First round of substantial bug fixes

This commit is contained in:
Kistaro Windrider 2023-04-02 19:25:53 -07:00
parent 0f21020647
commit 9796c2e970
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8
4 changed files with 38 additions and 7 deletions

View File

@ -8,13 +8,14 @@ import (
) )
func RunSimpleTerminalUI[C StatsCollection](p *Player[C]) error { func RunSimpleTerminalUI[C StatsCollection](p *Player[C]) error {
for {
err := p.StartNextTurn() err := p.StartNextTurn()
if p.DebugLevel < 1 && IsSeriousError(err) { if p.DebugLevel < 1 && IsSeriousError(err) {
return err return err
} }
p.ReportError(err) p.ReportError(err)
for {
for p.CanAct() { for p.CanAct() {
isCard, cardIdx, choiceIdx, err := pickNextAction(p) isCard, cardIdx, choiceIdx, err := pickNextAction(p)
p.ReportError(err) p.ReportError(err)

6
go.mod
View File

@ -1,3 +1,9 @@
module cardSimEngine module cardSimEngine
go 1.20 go 1.20
require (
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
)

8
go.sum Normal file
View File

@ -0,0 +1,8 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=

View File

@ -4,6 +4,8 @@ package main
import ( import (
"cardSimEngine/cardsim" "cardSimEngine/cardsim"
"fmt" "fmt"
"github.com/kr/pretty"
) )
func main() { func main() {
@ -38,6 +40,7 @@ func main() {
Name: cardsim.MsgStr("Stats"), Name: cardsim.MsgStr("Stats"),
Intro: cardsim.MsgStr("Hi! These are the smoke test stats."), Intro: cardsim.MsgStr("Hi! These are the smoke test stats."),
}, },
ruledumper{},
} }
p.Prompt = prompt{} p.Prompt = prompt{}
p.DebugLevel = 5 p.DebugLevel = 5
@ -58,5 +61,18 @@ func (prompt) Title(p *cardsim.Player[*SmokeTestCollection]) cardsim.Message {
} }
func (prompt) Info(p *cardsim.Player[*SmokeTestCollection]) ([]cardsim.Message, error) { func (prompt) Info(p *cardsim.Player[*SmokeTestCollection]) ([]cardsim.Message, error) {
return []cardsim.Message{cardsim.MsgStr("Here, have some stuff.")}, nil return []cardsim.Message{
cardsim.MsgStr("Here, have some stuff."),
cardsim.Msgf("It's turn %d according to the player and turn %d according to me.", p.TurnNumber, p.Stats.Turns.Value),
}, nil
}
type ruledumper struct{}
func (ruledumper) Title(p *player) cardsim.Message {
return cardsim.MsgStr("Rule Dumper")
}
func (ruledumper) Info(p *player) ([]cardsim.Message, error) {
return []cardsim.Message{cardsim.Msgf("%# v", pretty.Formatter(p.Rules))}, nil
} }