Initial stats, etc.
This commit is contained in:
parent
bdc095e2b2
commit
825ee8d053
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
||||
module git.chromaticdragon.app/kistaro/KoboldSim
|
||||
|
||||
go 1.20
|
||||
|
||||
require git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1
|
4
go.sum
Normal file
4
go.sum
Normal file
@ -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=
|
10
koboldsim/aliases.go
Normal file
10
koboldsim/aliases.go
Normal file
@ -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]
|
3
koboldsim/doc.go
Normal file
3
koboldsim/doc.go
Normal file
@ -0,0 +1,3 @@
|
||||
// Package koboldsim implements the rules and model for a kobold mine
|
||||
// simulation game, based on CardSimEngine.
|
||||
package koboldsim
|
7
koboldsim/flavor.go
Normal file
7
koboldsim/flavor.go
Normal file
@ -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"
|
||||
}
|
37
koboldsim/setup.go
Normal file
37
koboldsim/setup.go
Normal file
@ -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
|
||||
}
|
88
koboldsim/stats.go
Normal file
88
koboldsim/stats.go
Normal file
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
17
main/main.go
Normal file
17
main/main.go
Normal file
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user