more custom deck and new cards, better deck validation
This commit is contained in:
parent
02f5028301
commit
b07d824804
1
card.go
1
card.go
@ -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
12
deck.go
@ -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
|
||||
}
|
||||
}
|
||||
|
4
game.go
4
game.go
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user