allow custom decks

This commit is contained in:
stryan 2021-11-08 15:00:41 -05:00
parent 2ecf1dbc70
commit a10110d4a5
4 changed files with 36 additions and 3 deletions

22
deck.go
View File

@ -17,3 +17,25 @@ func NewDeck(owner int) *Deck {
Cards: cards, Cards: cards,
} }
} }
func LoadDeck(owner int, cards []int) *Deck {
if len(cards) == 0 {
return NewDeck(owner)
}
d := []*Card{}
for k, v := range cards {
d[k] = NewCard(v, owner, -1, uuid.Nil)
}
return &Deck{
Cards: d,
}
}
func ValidateDeck(cards []int) bool {
for _, v := range cards {
if CardType(v).IsACardType() {
return false
}
}
return true
}

View File

@ -24,9 +24,9 @@ type Game struct {
Status GameStatus Status GameStatus
} }
func NewGame() *Game { func NewGame(sentDeck []int, scoDeck []int) *Game {
deckA := NewDeck(SentinalID) deckA := LoadDeck(SentinalID, sentDeck)
deckB := NewDeck(ScourgeID) deckB := LoadDeck(ScourgeID, scoDeck)
deckA.Shuffle() deckA.Shuffle()
deckB.Shuffle() deckB.Shuffle()
return &Game{ return &Game{

2
go.mod
View File

@ -6,3 +6,5 @@ require (
git.saintnet.tech/tomecraft/tome_lib v0.1.3 // indirect git.saintnet.tech/tomecraft/tome_lib v0.1.3 // indirect
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect
) )
replace git.saintnet.tech/tomecraft/tome_lib => ../tome_lib

9
go.sum
View File

@ -6,5 +6,14 @@ git.saintnet.tech/tomecraft/tome_lib v0.1.2 h1:S2BHgsWBGFv9fy+qBHuKXv0kcjT7VP/7g
git.saintnet.tech/tomecraft/tome_lib v0.1.2/go.mod h1:Jekqa9ojNDOrcO1aL0IWKuhCQSE5+MNHVcYtTWA6uko= git.saintnet.tech/tomecraft/tome_lib v0.1.2/go.mod h1:Jekqa9ojNDOrcO1aL0IWKuhCQSE5+MNHVcYtTWA6uko=
git.saintnet.tech/tomecraft/tome_lib v0.1.3 h1:JHW5ozFDfikLcRakAUSX+xxXlwNb4nmlcl8/ja7dKAo= git.saintnet.tech/tomecraft/tome_lib v0.1.3 h1:JHW5ozFDfikLcRakAUSX+xxXlwNb4nmlcl8/ja7dKAo=
git.saintnet.tech/tomecraft/tome_lib v0.1.3/go.mod h1:Jekqa9ojNDOrcO1aL0IWKuhCQSE5+MNHVcYtTWA6uko= git.saintnet.tech/tomecraft/tome_lib v0.1.3/go.mod h1:Jekqa9ojNDOrcO1aL0IWKuhCQSE5+MNHVcYtTWA6uko=
github.com/alvaroloes/enumer v1.1.2 h1:5khqHB33TZy1GWCO/lZwcroBFh7u+0j40T83VUbfAMY=
github.com/alvaroloes/enumer v1.1.2/go.mod h1:FxrjvuXoDAx9isTJrv4c+T410zFi0DtXIT0m65DJ+Wo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pascaldekloe/name v0.0.0-20180628100202-0fd16699aae1/go.mod h1:eD5JxqMiuNYyFNmyY9rkJ/slN8y59oEu4Ei7F8OoKWQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190524210228-3d17549cdc6b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=