Converting cards to TablePolicy
This commit is contained in:
parent
219ff33d66
commit
c4427885ca
2
.vscode/koboldsimsnippets.code-snippets
vendored
2
.vscode/koboldsimsnippets.code-snippets
vendored
@ -21,7 +21,7 @@
|
|||||||
"body": [
|
"body": [
|
||||||
"case ${1:field}:",
|
"case ${1:field}:",
|
||||||
"\tk.${1:field} += amount",
|
"\tk.${1:field} += amount",
|
||||||
"\treturn k.${1:field}",
|
"\treturn nil",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,70 +27,45 @@ var cards = []Card{
|
|||||||
EnactionDesc: cardsim.MsgStr("Kobolds are known to be born warriors."),
|
EnactionDesc: cardsim.MsgStr("Kobolds are known to be born warriors."),
|
||||||
CanDo: YesWeAlsoCan,
|
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."`),
|
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."),
|
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) {
|
EffectsTable: map[FieldLabel]float64{
|
||||||
p.Stats.BasePopulation += 40
|
BasePopulation: 40,
|
||||||
p.Stats.Mining += 2
|
Mining: 2,
|
||||||
p.Stats.Construction += 1
|
Construction: 1,
|
||||||
p.Stats.Manufacturing += 1
|
Manufacturing: 1,
|
||||||
p.Stats.Bureaucracy += 1
|
Bureaucracy: 1,
|
||||||
p.Stats.FoodSupply -= 1
|
FoodSupply: -1,
|
||||||
p.Stats.Secrecy += 3
|
Secrecy: 3,
|
||||||
return cardsim.MsgStr("Kobolds are known to be cowards hiding in the dark."), nil
|
|
||||||
},
|
},
|
||||||
Undo: func(p *Player) error {
|
EnactionDesc: cardsim.MsgStr("Kobolds are known to be cowards hiding in the dark."),
|
||||||
p.Stats.BasePopulation -= 40
|
CanDo: YesWeAlsoCan,
|
||||||
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,
|
&TablePolicy{
|
||||||
},
|
|
||||||
&BasicPolicy{
|
|
||||||
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."`),
|
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."),
|
EnactedDesc: cardsim.MsgStr("[current policy] Military funding has been diverted into early childhood education."),
|
||||||
Do: func(p *Player) (cardsim.Message, error) {
|
EffectsTable: map[FieldLabel]float64{
|
||||||
p.Stats.BasePopulation -= 40
|
BasePopulation: -40,
|
||||||
p.Stats.Scavenging -= 1
|
Scavenging: -1,
|
||||||
p.Stats.Militarism -= 2
|
Militarism: -2,
|
||||||
p.Stats.Education += 1
|
Education: 1,
|
||||||
p.Stats.FoodSupply -= 1
|
FoodSupply: -2,
|
||||||
p.Stats.ForeignRelations += 2
|
ForeignRelations: 2,
|
||||||
p.Stats.Madness -= 1
|
Madness: -1,
|
||||||
p.Stats.Cruelty -= 1
|
Cruelty: -1,
|
||||||
return cardsim.MsgStr("An undefended hunting outpost near the surface was recently wiped out by a raid."), nil
|
|
||||||
},
|
},
|
||||||
Undo: func(p *Player) error {
|
EnactionDesc: cardsim.MsgStr("An undefended hunting outpost near the surface was recently wiped out by a raid."),
|
||||||
p.Stats.BasePopulation += 40
|
CanDo: YesWeAlsoCan,
|
||||||
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,
|
|
||||||
},
|
},
|
||||||
&VerbosePolicy{
|
&VerbosePolicy{
|
||||||
Default: &BasicPolicy{
|
Default: &TablePolicy{
|
||||||
UnenactedDesc: cardsim.MsgStr("This isn't about a disaster and can probably be safely dismissed."),
|
UnenactedDesc: cardsim.MsgStr("This isn't about a disaster and can probably be safely dismissed."),
|
||||||
Do: func(p *Player) (cardsim.Message, error) {
|
EffectsTable: map[FieldLabel]float64{
|
||||||
p.Stats.BasePopulation += 20
|
BasePopulation: 20,
|
||||||
return cardsim.MsgStr("Creche control doesn't shift that easily."), nil
|
|
||||||
},
|
},
|
||||||
Undo: func(p *Player) error {
|
EnactionDesc: cardsim.MsgStr("Creche control doesn't shift that easily."),
|
||||||
p.Stats.BasePopulation -= 20
|
CanDo: YesWeAlsoCan,
|
||||||
return nil
|
|
||||||
},
|
|
||||||
CanDo: YesWeCan,
|
|
||||||
},
|
},
|
||||||
Variants: []Policy{
|
Variants: []Policy{
|
||||||
&BasicPolicy{
|
&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!"),
|
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,
|
After: ShuffleIntoBottomHalf,
|
||||||
Policies: []Policy{
|
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!`),
|
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."),
|
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) {
|
EffectsTable: map[FieldLabel]float64{
|
||||||
p.Stats.BasePopulation += 60
|
BasePopulation: 60,
|
||||||
p.Stats.Scavenging += 1
|
Scavenging: 1,
|
||||||
p.Stats.Bureaucracy += 3
|
Bureaucracy: 3,
|
||||||
p.Stats.FoodSupply += 2
|
FoodSupply: 1,
|
||||||
p.Stats.Gullibility -= 1
|
Gullibility: -1,
|
||||||
return cardsim.MsgStr("Bureaucrats are considered pillars of society."), nil
|
|
||||||
},
|
},
|
||||||
Undo: func(p *Player) error {
|
EnactionDesc: cardsim.MsgStr("Bureaucrats are considered pillars of society."),
|
||||||
p.Stats.BasePopulation -= 80
|
CanDo: YesWeAlsoCan,
|
||||||
p.Stats.Scavenging -= 1
|
|
||||||
p.Stats.Bureaucracy -= 3
|
|
||||||
p.Stats.FoodSupply -= 2
|
|
||||||
p.Stats.Gullibility += 1
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
CanDo: YesWeCan,
|
&TablePolicy{
|
||||||
},
|
|
||||||
&BasicPolicy{
|
|
||||||
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.`),
|
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."),
|
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) {
|
EffectsTable: map[FieldLabel]float64{
|
||||||
p.Stats.BasePopulation += 20
|
BasePopulation: 20,
|
||||||
p.Stats.Bureaucracy -= 1
|
Bureaucracy: -1,
|
||||||
p.Stats.Gullibility -= 1
|
|
||||||
return cardsim.MsgStr("Immigrant bureaucrats complain about being under-appreciated."), nil
|
|
||||||
},
|
},
|
||||||
Undo: func(p *Player) error {
|
EnactionDesc: cardsim.MsgStr("Immigrant bureaucrats complain about being under-appreciated."),
|
||||||
p.Stats.BasePopulation -= 20
|
CanDo: func(t *TablePolicy, p *Player) bool {
|
||||||
p.Stats.Bureaucracy += 1
|
return p.Stats.Bureaucracy >= 2 && t.LastEnactedIdx != 3
|
||||||
p.Stats.Gullibility += 1
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
CanDo: func(b *BasicPolicy, p *Player) bool {
|
|
||||||
return p.Stats.Bureaucracy >= 2 && b.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.`),
|
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.`),
|
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) {
|
Do: func(p *Player) (cardsim.Message, error) {
|
||||||
@ -173,8 +133,8 @@ var cards = []Card{
|
|||||||
p.Stats.Rebellion -= 1
|
p.Stats.Rebellion -= 1
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
CanDo: func(b *BasicPolicy, p *Player) bool {
|
CanDo: func(t *TablePolicy, p *Player) bool {
|
||||||
return p.Stats.Bureaucracy < 2 && b.LastEnactedIdx != 3
|
return p.Stats.Bureaucracy < 2 && t.LastEnactedIdx != 3
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&BasicPolicy{
|
&BasicPolicy{
|
||||||
|
@ -170,27 +170,43 @@ func NewKoboldMine() *KoboldMine {
|
|||||||
type FieldLabel string
|
type FieldLabel string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Authoritarianism FieldLabel = "Authoritarianism"
|
||||||
BasePopulation FieldLabel = "BasePopulation"
|
BasePopulation FieldLabel = "BasePopulation"
|
||||||
Scavenging FieldLabel = "Scavenging"
|
Bureaucracy FieldLabel = "Bureaucracy"
|
||||||
Militarism FieldLabel = "Militarism"
|
Construction FieldLabel = "Construction"
|
||||||
|
Cruelty FieldLabel = "Cruelty"
|
||||||
|
Education FieldLabel = "Education"
|
||||||
FoodSupply FieldLabel = "FoodSupply"
|
FoodSupply FieldLabel = "FoodSupply"
|
||||||
ForeignRelations FieldLabel = "ForeignRelations"
|
ForeignRelations FieldLabel = "ForeignRelations"
|
||||||
Rebellion FieldLabel = "Rebellion"
|
Gullibility FieldLabel = "Gullibility"
|
||||||
Madness FieldLabel = "Madness"
|
Madness FieldLabel = "Madness"
|
||||||
Cruelty FieldLabel = "Cruelty"
|
Manufacturing FieldLabel = "Manufacturing"
|
||||||
Authoritarianism FieldLabel = "Authoritarianism"
|
Mining FieldLabel = "Mining"
|
||||||
|
Militarism FieldLabel = "Militarism"
|
||||||
|
Rebellion FieldLabel = "Rebellion"
|
||||||
|
Scavenging FieldLabel = "Scavenging"
|
||||||
|
Secrecy FieldLabel = "Secrecy"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (k *KoboldMine) Add(which FieldLabel, amount float64) error {
|
func (k *KoboldMine) Add(which FieldLabel, amount float64) error {
|
||||||
switch which {
|
switch which {
|
||||||
|
case Authoritarianism:
|
||||||
|
k.Authoritarianism += amount
|
||||||
|
return nil
|
||||||
case BasePopulation:
|
case BasePopulation:
|
||||||
k.BasePopulation += amount
|
k.BasePopulation += amount
|
||||||
return nil
|
return nil
|
||||||
case Scavenging:
|
case Bureaucracy:
|
||||||
k.Scavenging += amount
|
k.Bureaucracy += amount
|
||||||
return nil
|
return nil
|
||||||
case Militarism:
|
case Construction:
|
||||||
k.Militarism += amount
|
k.Construction += amount
|
||||||
|
return nil
|
||||||
|
case Cruelty:
|
||||||
|
k.Cruelty += amount
|
||||||
|
return nil
|
||||||
|
case Education:
|
||||||
|
k.Education += amount
|
||||||
return nil
|
return nil
|
||||||
case FoodSupply:
|
case FoodSupply:
|
||||||
k.FoodSupply += amount
|
k.FoodSupply += amount
|
||||||
@ -198,17 +214,29 @@ func (k *KoboldMine) Add(which FieldLabel, amount float64) error {
|
|||||||
case ForeignRelations:
|
case ForeignRelations:
|
||||||
k.ForeignRelations += amount
|
k.ForeignRelations += amount
|
||||||
return nil
|
return nil
|
||||||
case Rebellion:
|
case Gullibility:
|
||||||
k.Rebellion += amount
|
k.Gullibility += amount
|
||||||
return nil
|
return nil
|
||||||
case Madness:
|
case Madness:
|
||||||
k.Madness += amount
|
k.Madness += amount
|
||||||
return nil
|
return nil
|
||||||
case Cruelty:
|
case Manufacturing:
|
||||||
k.Cruelty += amount
|
k.Manufacturing += amount
|
||||||
return nil
|
return nil
|
||||||
case Authoritarianism:
|
case Mining:
|
||||||
k.Authoritarianism += amount
|
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 nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("cannot add %f to %q: %w", amount, which, ErrNoFieldLabel)
|
return fmt.Errorf("cannot add %f to %q: %w", amount, which, ErrNoFieldLabel)
|
||||||
|
Loading…
Reference in New Issue
Block a user