diff --git a/go.mod b/go.mod index 7935b9c..4714552 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module git.chromaticdragon.app/kistaro/KoboldSim go 1.20 + +require git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1 \ No newline at end of file diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..2a7a9df --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.0 h1:ZBByQW64MwyOloLGgQHMHgp4Vug6fj9ERdg8c+OEqBk= +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.0/go.mod h1:y511g1vH+CXntY0FauKYU7Y4gQy+jlkNzEFOws9Yxvg= +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1 h1:nPp8ymzfnwzrzfzjkuvDAb4X73BUgUNBGKHhDp6Iz3c= +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1/go.mod h1:VFaOagdbtM6gH87ioHent8v76nDh9PddpymMqWdrLfI= diff --git a/koboldsim/aliases.go b/koboldsim/aliases.go new file mode 100644 index 0000000..b71a085 --- /dev/null +++ b/koboldsim/aliases.go @@ -0,0 +1,10 @@ +// This file contains type aliases to abbreviate otherwise-verbose fully +// quallified type names from cardsim, as used by koboldsim. + +package koboldsim + +import "git.chromaticdragon.app/kistaro/CardSimEngine/cardsim" + +type Player = cardsim.Player[*KoboldMine] +type Card = cardsim.Card[*KoboldMine] +type InfoPanel = cardsim.InfoPanel[*KoboldMine] diff --git a/koboldsim/doc.go b/koboldsim/doc.go new file mode 100644 index 0000000..098ca2a --- /dev/null +++ b/koboldsim/doc.go @@ -0,0 +1,3 @@ +// Package koboldsim implements the rules and model for a kobold mine +// simulation game, based on CardSimEngine. +package koboldsim diff --git a/koboldsim/flavor.go b/koboldsim/flavor.go new file mode 100644 index 0000000..5aa2f3f --- /dev/null +++ b/koboldsim/flavor.go @@ -0,0 +1,7 @@ +package koboldsim + +func RandomKoboldName() string { + // TODO: implement random two-part name generator. + // Rakeela, where's that list of kobold name-halves we had? + return "Kobold" +} diff --git a/koboldsim/setup.go b/koboldsim/setup.go new file mode 100644 index 0000000..8640b4c --- /dev/null +++ b/koboldsim/setup.go @@ -0,0 +1,37 @@ +package koboldsim + +import "git.chromaticdragon.app/kistaro/CardSimEngine/cardsim" + +func InitPlayer() *Player { + p := cardsim.InitPlayer(NewKoboldMine()) + p.Name = RandomKoboldName() + initDeck(p.Deck) + initRules(p.Rules) + p.HandLimit = 3 + p.InfoPanels = []InfoPanel{ + &cardsim.BasicStatsPanel[*KoboldMine]{ + Name: cardsim.MsgStr("All Stats"), + Intro: cardsim.MsgStr("All available statistics."), + }, + } + p.Prompt = &cardsim.BasicStatsPanel[*KoboldMine]{ + Name: cardsim.MsgStr("The Kobold Mine"), + Intro: cardsim.MsgStr("We await your command, Overlord."), + Filter: cardsim.VisibleOrDebugStatsNamed[*KoboldMine]( + "Kobolds", + "Total Sector Productivity", + "Total Government Productivity", + ), + } + p.State = cardsim.GameActive + p.DebugLevel = 5 + return p +} + +func initDeck(*cardsim.Deck[*KoboldMine]) { + // TODO: move to cards.go, add cards +} + +func initRules(*cardsim.RuleCollection[*KoboldMine]) { + // TODO: move to rules.go, add rules +} diff --git a/koboldsim/stats.go b/koboldsim/stats.go new file mode 100644 index 0000000..cb354ef --- /dev/null +++ b/koboldsim/stats.go @@ -0,0 +1,88 @@ +package koboldsim + +import ( + "git.chromaticdragon.app/kistaro/CardSimEngine/cardsim" +) + +// KoboldMine is the state of a kobold mine. +type KoboldMine struct { + Kobolds cardsim.Stored[int64] + + SectorMiningProductivity cardsim.Stored[float64] + SectorScavengingProductivity cardsim.Stored[float64] + + GovBureaucracyProductivity cardsim.Stored[float64] + GovWarProductivity cardsim.Stored[float64] +} + +func (k *KoboldMine) ProductivityFunc(s *cardsim.Stored[float64]) func() float64 { + return func() float64 { + return s.Value * float64(k.Kobolds.Value) + } +} + +func (k *KoboldMine) TotalSectorProductivity() float64 { + return float64(k.Kobolds.Value) * (k.SectorMiningProductivity.Value + k.SectorScavengingProductivity.Value) +} + +func (k *KoboldMine) TotalGovProductivity() float64 { + return float64(k.Kobolds.Value) * (k.GovBureaucracyProductivity.Value + k.GovWarProductivity.Value) +} + +func (k *KoboldMine) Stats() []cardsim.Stat { + stats := cardsim.ExtractStats(k) + funcs := []cardsim.Stat{ + cardsim.StatFunc( + "Total Sector Mining Productivity", + k.ProductivityFunc(&k.SectorMiningProductivity), + ), + cardsim.StatFunc( + "Total Sector Scavenging Productivity", + k.ProductivityFunc(&k.SectorScavengingProductivity), + ), + cardsim.StatFunc( + "Total Government Bureaucracy Productivity", + k.ProductivityFunc(&k.GovBureaucracyProductivity), + ), + cardsim.StatFunc( + "Total Government War Productivity", + k.ProductivityFunc(&k.GovBureaucracyProductivity), + ), + cardsim.StatFunc( + "Total Sector Productivity", + k.TotalSectorProductivity, + ), + cardsim.StatFunc( + "Total Government Productivity", + k.TotalGovProductivity, + ), + } + stats = append(stats, funcs...) + cardsim.SortStats(stats) + return stats +} + +func NewKoboldMine() *KoboldMine { + return &KoboldMine{ + Kobolds: cardsim.Stored[int64]{ + Name: "Kobolds", + Value: 1000, + }, + SectorMiningProductivity: cardsim.Stored[float64]{ + Name: "Sector Mining Productivity", + Value: 0.15, + }, + SectorScavengingProductivity: cardsim.Stored[float64]{ + Name: "Sector Scavening Productivity", + Value: 0.1, + }, + GovBureaucracyProductivity: cardsim.Stored[float64]{ + Name: "Government Bureaucracy Productivity", + Value: 0.05, + }, + GovWarProductivity: cardsim.Stored[float64]{ + Name: "Government War Productivity", + Value: 0.1, + }, + } +} diff --git a/main/main.go b/main/main.go new file mode 100644 index 0000000..2c02640 --- /dev/null +++ b/main/main.go @@ -0,0 +1,17 @@ +// Binary koboldsim is an economic simulation game of a kobold mine. +package main + +import ( + "fmt" + + "git.chromaticdragon.app/kistaro/CardSimEngine/cardsim" + "git.chromaticdragon.app/kistaro/KoboldSim/koboldsim" +) + +func main() { + p := koboldsim.InitPlayer() + err := cardsim.RunSimpleTerminalUI(p) + if err != nil { + fmt.Println("Terminated with error:", err) + } +}