package main import "git.sunturtle.xyz/zephyr/horse" type tables struct { skills map[horse.SkillID]*horse.Skill groups map[horse.SkillGroupID]map[int8]*horse.Skill sparks map[horse.SparkID]*horse.Spark umas map[horse.UmaID]*horse.Uma } func makeTables(skills []horse.Skill, sparks []horse.Spark, umas []horse.Uma) tables { tab := tables{ skills: make(map[horse.SkillID]*horse.Skill, len(skills)), groups: make(map[horse.SkillGroupID]map[int8]*horse.Skill, len(skills)/2), sparks: make(map[horse.SparkID]*horse.Spark, len(sparks)), umas: make(map[horse.UmaID]*horse.Uma, len(umas)), } for i, sk := range skills { tab.skills[sk.ID] = &skills[i] if tab.groups[sk.Group] == nil { tab.groups[sk.Group] = make(map[int8]*horse.Skill, 4) } // Only add the skill to the groups table if they're rare, the base // version of the common skill, or there isn't anything else there. if sk.Rarity == 2 || sk.GroupRate == 1 || tab.groups[sk.Group][sk.Rarity] == nil { tab.groups[sk.Group][sk.Rarity] = &skills[i] } } for i, sp := range sparks { tab.sparks[sp.ID] = &sparks[i] } for i, u := range umas { tab.umas[u.ID] = &umas[i] } return tab }