diff --git a/.vscode/koboldsimsnippets.code-snippets b/.vscode/koboldsimsnippets.code-snippets index 1265a88..e9a54e3 100644 --- a/.vscode/koboldsimsnippets.code-snippets +++ b/.vscode/koboldsimsnippets.code-snippets @@ -21,7 +21,7 @@ "body": [ "case ${1:field}:", "\tk.${1:field} += amount", - "\treturn k.${1:field}", + "\treturn nil", ], } } \ No newline at end of file diff --git a/koboldsim/cards.go b/koboldsim/cards.go index 074be61..1d45315 100644 --- a/koboldsim/cards.go +++ b/koboldsim/cards.go @@ -27,70 +27,45 @@ var cards = []Card{ EnactionDesc: cardsim.MsgStr("Kobolds are known to be born warriors."), CanDo: YesWeAlsoCan, }, - &BasicPolicy{ + &TablePolicy{ UnenactedDesc: cardsim.MsgStr(`Your head miner considers the matter worriedly. "Creches under military control? No. That would invite chaos. We need to dig deeper; we can have a peaceful, orderly society if we just get far enough away from surfacers."`), EnactedDesc: cardsim.MsgStr("[current policy] Your head miner is presently leading a project to dig as far away from the surface as possible."), - Do: func(p *Player) (cardsim.Message, error) { - p.Stats.BasePopulation += 40 - p.Stats.Mining += 2 - p.Stats.Construction += 1 - p.Stats.Manufacturing += 1 - p.Stats.Bureaucracy += 1 - p.Stats.FoodSupply -= 1 - p.Stats.Secrecy += 3 - return cardsim.MsgStr("Kobolds are known to be cowards hiding in the dark."), nil + EffectsTable: map[FieldLabel]float64{ + BasePopulation: 40, + Mining: 2, + Construction: 1, + Manufacturing: 1, + Bureaucracy: 1, + FoodSupply: -1, + Secrecy: 3, }, - Undo: func(p *Player) error { - p.Stats.BasePopulation -= 40 - p.Stats.Mining -= 2 - p.Stats.Manufacturing -= 1 - p.Stats.Construction -= 1 - p.Stats.Bureaucracy -= 1 - p.Stats.FoodSupply += 1 - p.Stats.Secrecy -= 3 - return nil - }, - CanDo: YesWeCan, + EnactionDesc: cardsim.MsgStr("Kobolds are known to be cowards hiding in the dark."), + CanDo: YesWeAlsoCan, }, - &BasicPolicy{ + &TablePolicy{ UnenactedDesc: cardsim.MsgStr(`Your nursery director is incensed. "Creches under military control? Never! Let young kobolds play! In fact, cut the military just for suggesting this. The threats facing us are completely overstated."`), EnactedDesc: cardsim.MsgStr("[current policy] Military funding has been diverted into early childhood education."), - Do: func(p *Player) (cardsim.Message, error) { - p.Stats.BasePopulation -= 40 - p.Stats.Scavenging -= 1 - p.Stats.Militarism -= 2 - p.Stats.Education += 1 - p.Stats.FoodSupply -= 1 - p.Stats.ForeignRelations += 2 - p.Stats.Madness -= 1 - p.Stats.Cruelty -= 1 - return cardsim.MsgStr("An undefended hunting outpost near the surface was recently wiped out by a raid."), nil + EffectsTable: map[FieldLabel]float64{ + BasePopulation: -40, + Scavenging: -1, + Militarism: -2, + Education: 1, + FoodSupply: -2, + ForeignRelations: 2, + Madness: -1, + Cruelty: -1, }, - Undo: func(p *Player) error { - p.Stats.BasePopulation += 40 - p.Stats.Scavenging += 1 - p.Stats.Militarism += 2 - p.Stats.Education -= 1 - p.Stats.FoodSupply += 1 - p.Stats.ForeignRelations -= 2 - p.Stats.Madness += 1 - p.Stats.Cruelty += 1 - return nil - }, - CanDo: YesWeCan, + EnactionDesc: cardsim.MsgStr("An undefended hunting outpost near the surface was recently wiped out by a raid."), + CanDo: YesWeAlsoCan, }, &VerbosePolicy{ - Default: &BasicPolicy{ + Default: &TablePolicy{ UnenactedDesc: cardsim.MsgStr("This isn't about a disaster and can probably be safely dismissed."), - Do: func(p *Player) (cardsim.Message, error) { - p.Stats.BasePopulation += 20 - return cardsim.MsgStr("Creche control doesn't shift that easily."), nil + EffectsTable: map[FieldLabel]float64{ + BasePopulation: 20, }, - Undo: func(p *Player) error { - p.Stats.BasePopulation -= 20 - return nil - }, - CanDo: YesWeCan, + EnactionDesc: cardsim.MsgStr("Creche control doesn't shift that easily."), + CanDo: YesWeAlsoCan, }, Variants: []Policy{ &BasicPolicy{ @@ -118,47 +93,32 @@ var cards = []Card{ Desc: cardsim.MsgStr(" Good times are upon us! A great festival has been declared between many kobold tribes, celebrating the orderly nature of the kobold soul! That's right, it's the Pan-Tribal Festival of Bureaucracy!"), After: ShuffleIntoBottomHalf, Policies: []Policy{ - &BasicPolicy{ + &TablePolicy{ UnenactedDesc: cardsim.MsgStr(`Your Minister of Administration is practically jumping for joy. "This is our opportunity to prove that we're a prosperous society and attract some fresh blood! We need to raise salaries in the bureaucracy, grant some time off to our bureaucrats to make sure they can attend, and try to hire talent away from other tribes. We'll forge productive trade relations by this, you'll see!`), EnactedDesc: cardsim.MsgStr("[current policy] Your bureaucrats are really looking forward to attending, where they can boast about how the festival boosted their salaries."), - Do: func(p *Player) (cardsim.Message, error) { - p.Stats.BasePopulation += 60 - p.Stats.Scavenging += 1 - p.Stats.Bureaucracy += 3 - p.Stats.FoodSupply += 2 - p.Stats.Gullibility -= 1 - return cardsim.MsgStr("Bureaucrats are considered pillars of society."), nil + EffectsTable: map[FieldLabel]float64{ + BasePopulation: 60, + Scavenging: 1, + Bureaucracy: 3, + FoodSupply: 1, + Gullibility: -1, }, - Undo: func(p *Player) error { - p.Stats.BasePopulation -= 80 - p.Stats.Scavenging -= 1 - p.Stats.Bureaucracy -= 3 - p.Stats.FoodSupply -= 2 - p.Stats.Gullibility += 1 - return nil - }, - CanDo: YesWeCan, + EnactionDesc: cardsim.MsgStr("Bureaucrats are considered pillars of society."), + CanDo: YesWeAlsoCan, }, - &BasicPolicy{ + &TablePolicy{ UnenactedDesc: cardsim.MsgStr(`Your Minister of Finance pulls you aside. "This is a good opportunity to head-hunt. Bureaucrats from many tribes will be attending. There's got to be some who'll work for less than the ones we've got. There are some terribly threatened or impoverished communities among kobolds.`), EnactedDesc: cardsim.MsgStr("[current policy] Your tribe's policy is clear: the festival of bureaucracy is a chance to trade workers with other kobold tribes in your attempts to build a more efficient government."), - Do: func(p *Player) (cardsim.Message, error) { - p.Stats.BasePopulation += 20 - p.Stats.Bureaucracy -= 1 - p.Stats.Gullibility -= 1 - return cardsim.MsgStr("Immigrant bureaucrats complain about being under-appreciated."), nil + EffectsTable: map[FieldLabel]float64{ + BasePopulation: 20, + Bureaucracy: -1, }, - Undo: func(p *Player) error { - p.Stats.BasePopulation -= 20 - p.Stats.Bureaucracy += 1 - p.Stats.Gullibility += 1 - return nil - }, - CanDo: func(b *BasicPolicy, p *Player) bool { - return p.Stats.Bureaucracy >= 2 && b.LastEnactedIdx != 3 + EnactionDesc: cardsim.MsgStr("Immigrant bureaucrats complain about being under-appreciated."), + CanDo: func(t *TablePolicy, p *Player) bool { + return p.Stats.Bureaucracy >= 2 && t.LastEnactedIdx != 3 }, }, - &BasicPolicy{ + &TablePolicy{ UnenactedDesc: cardsim.MsgStr(`Your Minister of Finance greets you exuberantly. "We've trimmed the wages of the bureaucracy beautifully, but maybe we can scout some outright volunteers. Some tribes are absolute disasters, after all.`), EnactedDesc: cardsim.MsgStr(`[current policy] It's hard to find volunteer workers at the festival, but your tribe is doing its best.`), Do: func(p *Player) (cardsim.Message, error) { @@ -173,8 +133,8 @@ var cards = []Card{ p.Stats.Rebellion -= 1 return nil }, - CanDo: func(b *BasicPolicy, p *Player) bool { - return p.Stats.Bureaucracy < 2 && b.LastEnactedIdx != 3 + CanDo: func(t *TablePolicy, p *Player) bool { + return p.Stats.Bureaucracy < 2 && t.LastEnactedIdx != 3 }, }, &BasicPolicy{ diff --git a/koboldsim/stats.go b/koboldsim/stats.go index a069b99..1f76e73 100644 --- a/koboldsim/stats.go +++ b/koboldsim/stats.go @@ -170,27 +170,43 @@ func NewKoboldMine() *KoboldMine { type FieldLabel string const ( + Authoritarianism FieldLabel = "Authoritarianism" BasePopulation FieldLabel = "BasePopulation" - Scavenging FieldLabel = "Scavenging" - Militarism FieldLabel = "Militarism" + Bureaucracy FieldLabel = "Bureaucracy" + Construction FieldLabel = "Construction" + Cruelty FieldLabel = "Cruelty" + Education FieldLabel = "Education" FoodSupply FieldLabel = "FoodSupply" ForeignRelations FieldLabel = "ForeignRelations" - Rebellion FieldLabel = "Rebellion" + Gullibility FieldLabel = "Gullibility" Madness FieldLabel = "Madness" - Cruelty FieldLabel = "Cruelty" - Authoritarianism FieldLabel = "Authoritarianism" + Manufacturing FieldLabel = "Manufacturing" + Mining FieldLabel = "Mining" + Militarism FieldLabel = "Militarism" + Rebellion FieldLabel = "Rebellion" + Scavenging FieldLabel = "Scavenging" + Secrecy FieldLabel = "Secrecy" ) func (k *KoboldMine) Add(which FieldLabel, amount float64) error { switch which { + case Authoritarianism: + k.Authoritarianism += amount + return nil case BasePopulation: k.BasePopulation += amount return nil - case Scavenging: - k.Scavenging += amount + case Bureaucracy: + k.Bureaucracy += amount return nil - case Militarism: - k.Militarism += amount + case Construction: + k.Construction += amount + return nil + case Cruelty: + k.Cruelty += amount + return nil + case Education: + k.Education += amount return nil case FoodSupply: k.FoodSupply += amount @@ -198,17 +214,29 @@ func (k *KoboldMine) Add(which FieldLabel, amount float64) error { case ForeignRelations: k.ForeignRelations += amount return nil - case Rebellion: - k.Rebellion += amount + case Gullibility: + k.Gullibility += amount return nil case Madness: k.Madness += amount return nil - case Cruelty: - k.Cruelty += amount + case Manufacturing: + k.Manufacturing += amount return nil - case Authoritarianism: - k.Authoritarianism += amount + case Mining: + k.Mining += amount + return nil + case Militarism: + k.Militarism += amount + return nil + case Rebellion: + k.Rebellion += amount + return nil + case Scavenging: + k.Scavenging += amount + return nil + case Secrecy: + k.Secrecy += amount return nil } return fmt.Errorf("cannot add %f to %q: %w", amount, which, ErrNoFieldLabel)