1package gen 2 3import ( 4 "fmt" 5 "math/rand/v2" 6 7 "tinyadventure/internal/model" 8 "tinyadventure/internal/rng" 9 "tinyadventure/internal/sim" 10) 11 12type look struct{ name, race, class string } 13 14type factionDef struct { 15 name string 16 theme string 17 minions []look 18 boss look 19 titles []string 20} 21 22type nature struct { 23 typ string 24 traits, weak, resist []string 25} 26 27var natures = map[string]nature{ 28 "Vampires": {sim.Shadow, []string{"lifesteal"}, []string{"holy", "fire"}, []string{"frost", "shadow"}}, 29 "Lizardfolk": {sim.Poison, []string{"thorns"}, []string{"frost", "lightning"}, []string{"fire", "poison"}}, 30 "Bandits": {sim.Physical, []string{"first"}, []string{"poison"}, nil}, 31 "Undead": {sim.Frost, []string{"armored"}, []string{"holy", "fire"}, []string{"frost", "shadow", "poison"}}, 32 "Cultists": {sim.Fire, nil, []string{"frost", "lightning"}, []string{"fire", "shadow"}}, 33 "Goblins": {sim.Poison, []string{"swarm", "first"}, []string{"fire"}, []string{"poison"}}, 34 "Beastkin": {sim.Physical, []string{"swarm", "thorns"}, []string{"fire"}, []string{"frost"}}, 35 "Witches": {sim.Shadow, nil, []string{"holy"}, []string{"shadow", "frost"}}, 36 "Wildlings": {sim.Physical, []string{"swarm"}, []string{"fire"}, nil}, 37} 38 39var factionPool = []factionDef{ 40 {"Vampires", "blood", []look{{"Thrall", "human", "thrall"}, {"Bloodbat", "beast", "bat"}, {"Vampire Spawn", "vampire", "rogue"}}, look{"", "vampire", "lord"}, []string{"Count", "Countess", "Lord"}}, 41 {"Lizardfolk", "reptile", []look{{"Scaleguard", "lizard", "fighter"}, {"Lizard Skirmisher", "lizard", "rogue"}, {"Marsh Spitter", "lizard", "shaman"}}, look{"", "lizard", "chief"}, []string{"Warlord", "High Shaman", "Scale-King"}}, 42 {"Bandits", "outlaw", []look{{"Cutpurse", "bandit", "rogue"}, {"Brigand", "bandit", "fighter"}, {"Bandit Archer", "bandit", "archer"}}, look{"", "bandit", "captain"}, []string{"Captain", "Highwayman", "Boss"}}, 43 {"Undead", "grave", []look{{"Skeleton", "skeleton", "fighter"}, {"Zombie", "zombie", "brute"}, {"Wight", "skeleton", "knight"}}, look{"", "skeleton", "lich"}, []string{"Lich", "Death Knight", "Revenant"}}, 44 {"Cultists", "occult", []look{{"Acolyte", "human", "cultist"}, {"Zealot", "human", "zealot"}, {"Hollow Priest", "hollow", "priest"}}, look{"", "hollow", "prophet"}, []string{"Prophet", "Archon", "Hierophant"}}, 45 {"Goblins", "greenskin", []look{{"Goblin", "goblin", "rogue"}, {"Hobgoblin", "orc", "fighter"}, {"Goblin Sneak", "goblin", "sneak"}}, look{"", "orc", "warboss"}, []string{"Chieftain", "Warboss", "King"}}, 46 {"Beastkin", "wild", []look{{"Dire Wolf", "beast", "wolf"}, {"Gnoll", "gnoll", "fighter"}, {"Boar Raider", "beast", "boar"}}, look{"", "beast", "owlbear"}, []string{"Packlord", "Alpha", "Horned King"}}, 47 {"Witches", "hex", []look{{"Hedge Witch", "human", "witch"}, {"Crow Familiar", "beast", "crow"}, {"Bog Hag", "hag", "witch"}}, look{"", "hag", "coven"}, []string{"Coven Mother", "Grand Hag", "Queen"}}, 48} 49 50var wildFaction = factionDef{"Wildlings", "wild", []look{{"Wolf", "beast", "wolf"}, {"Giant Spider", "beast", "spider"}, {"Wild Boar", "beast", "boar"}}, look{"", "beast", "troll"}, []string{"Alpha", "Elder", "Terror"}} 51 52func rollFactions(r *rand.Rand, on bool) []model.Faction { 53 if !on { 54 return []model.Faction{factionOf(wildFaction, 0, 3)} 55 } 56 chosen := rng.Shuffled(r, factionPool)[:rng.Between(r, 2, 4)] 57 out := make([]model.Faction, len(chosen)) 58 for i, d := range chosen { 59 out[i] = factionOf(d, i, 1+i*2+r.IntN(2)) 60 } 61 return out 62} 63 64func factionOf(d factionDef, i, power int) model.Faction { 65 id := fmt.Sprintf("f%d", i+1) 66 return model.Faction{ID: id, Name: d.name, Theme: d.theme, Power: power} 67} 68 69func defOf(f model.Faction) factionDef { 70 for _, d := range factionPool { 71 if d.name == f.Name { 72 return d 73 } 74 } 75 return wildFaction 76}