tome_game/deck.go

48 lines
819 B
Go
Raw Normal View History

2021-10-01 13:40:46 -04:00
package tome_game
import (
. "git.saintnet.tech/tomecraft/tome_lib"
"github.com/google/uuid"
)
func NewDeck(owner int) *Deck {
cards := []*Card{}
for i := 0; i < 3; i++ {
for j := 1; j < 9; j++ {
cards = append(cards, NewCard(j, owner, -1, uuid.Nil))
}
}
cards = append(cards, NewCard(0, owner, -1, uuid.Nil))
return &Deck{
Cards: cards,
}
}
2021-11-08 15:00:41 -05:00
func LoadDeck(owner int, cards []int) *Deck {
if len(cards) == 0 {
return NewDeck(owner)
}
d := []*Card{}
for _, v := range cards {
d = append(d, NewCard(v, owner, -1, uuid.Nil))
2021-11-08 15:00:41 -05:00
}
return &Deck{
Cards: d,
}
}
func ValidateDeck(cards []int) bool {
2021-11-10 17:39:58 -05:00
if len(cards) < 15 {
return false
}
2021-11-08 15:00:41 -05:00
for _, v := range cards {
if !CardType(v).IsACardType() {
return false
}
if OracleToken(CardType(v), nil) {
2021-11-08 15:00:41 -05:00
return false
}
}
return true
}