more custom deck and new cards, better deck validation

This commit is contained in:
stryan 2021-11-08 16:57:38 -05:00
parent 02f5028301
commit b07d824804
4 changed files with 20 additions and 6 deletions

View File

@ -19,6 +19,7 @@ func NewCard(v, o, p int, id uuid.UUID) *Card {
Owner: o,
Position: p,
Spell: OracleSpell(CardType(v), nil),
Token: OracleToken(CardType(v), nil),
Effects: []*Effect{},
}
}

12
deck.go
View File

@ -23,8 +23,8 @@ func LoadDeck(owner int, cards []int) *Deck {
return NewDeck(owner)
}
d := []*Card{}
for k, v := range cards {
d[k] = NewCard(v, owner, -1, uuid.Nil)
for _, v := range cards {
d = append(d, NewCard(v, owner, -1, uuid.Nil))
}
return &Deck{
Cards: d,
@ -32,8 +32,14 @@ func LoadDeck(owner int, cards []int) *Deck {
}
func ValidateDeck(cards []int) bool {
if len(cards) < 7 {
return false
}
for _, v := range cards {
if CardType(v).IsACardType() {
if !CardType(v).IsACardType() {
return false
}
if OracleToken(CardType(v), nil) {
return false
}
}

View File

@ -27,8 +27,6 @@ type Game struct {
func NewGame(sentDeck []int, scoDeck []int) *Game {
deckA := LoadDeck(SentinalID, sentDeck)
deckB := LoadDeck(ScourgeID, scoDeck)
deckA.Shuffle()
deckB.Shuffle()
return &Game{
GameBoard: NewBoard(),
SentinalPlayer: NewPlayer("Sentinal", SentinalID),
@ -150,6 +148,8 @@ func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
}
if g.SentinalPlayer.Ready && g.ScourgePlayer.Ready && g.Status == StatusLobby {
g.Status = StatusReady
g.SentinalDeck.Shuffle()
g.ScourgeDeck.Shuffle()
if id == SentinalID {
g.SentinalPlayer.Hand = g.SentinalDeck.Cards[len(g.SentinalDeck.Cards)-5 : len(g.SentinalDeck.Cards)]
g.SentinalDeck.Cards = g.SentinalDeck.Cards[0 : len(g.SentinalDeck.Cards)-5]

View File

@ -29,7 +29,14 @@ func OracleSpell(c CardType, g *Game) bool {
return false
}
}
func OracleToken(c CardType, g *Game) bool {
switch c {
case GoblinSpawn:
return true
default:
return false
}
}
func OracleCast(c *Card, g *Game) bool {
switch c.Type {
case Valk: