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,
|
Owner: o,
|
||||||
Position: p,
|
Position: p,
|
||||||
Spell: OracleSpell(CardType(v), nil),
|
Spell: OracleSpell(CardType(v), nil),
|
||||||
|
Token: OracleToken(CardType(v), nil),
|
||||||
Effects: []*Effect{},
|
Effects: []*Effect{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
deck.go
12
deck.go
@ -23,8 +23,8 @@ func LoadDeck(owner int, cards []int) *Deck {
|
|||||||
return NewDeck(owner)
|
return NewDeck(owner)
|
||||||
}
|
}
|
||||||
d := []*Card{}
|
d := []*Card{}
|
||||||
for k, v := range cards {
|
for _, v := range cards {
|
||||||
d[k] = NewCard(v, owner, -1, uuid.Nil)
|
d = append(d, NewCard(v, owner, -1, uuid.Nil))
|
||||||
}
|
}
|
||||||
return &Deck{
|
return &Deck{
|
||||||
Cards: d,
|
Cards: d,
|
||||||
@ -32,8 +32,14 @@ func LoadDeck(owner int, cards []int) *Deck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ValidateDeck(cards []int) bool {
|
func ValidateDeck(cards []int) bool {
|
||||||
|
if len(cards) < 7 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
for _, v := range cards {
|
for _, v := range cards {
|
||||||
if CardType(v).IsACardType() {
|
if !CardType(v).IsACardType() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if OracleToken(CardType(v), nil) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
game.go
4
game.go
@ -27,8 +27,6 @@ type Game struct {
|
|||||||
func NewGame(sentDeck []int, scoDeck []int) *Game {
|
func NewGame(sentDeck []int, scoDeck []int) *Game {
|
||||||
deckA := LoadDeck(SentinalID, sentDeck)
|
deckA := LoadDeck(SentinalID, sentDeck)
|
||||||
deckB := LoadDeck(ScourgeID, scoDeck)
|
deckB := LoadDeck(ScourgeID, scoDeck)
|
||||||
deckA.Shuffle()
|
|
||||||
deckB.Shuffle()
|
|
||||||
return &Game{
|
return &Game{
|
||||||
GameBoard: NewBoard(),
|
GameBoard: NewBoard(),
|
||||||
SentinalPlayer: NewPlayer("Sentinal", SentinalID),
|
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 {
|
if g.SentinalPlayer.Ready && g.ScourgePlayer.Ready && g.Status == StatusLobby {
|
||||||
g.Status = StatusReady
|
g.Status = StatusReady
|
||||||
|
g.SentinalDeck.Shuffle()
|
||||||
|
g.ScourgeDeck.Shuffle()
|
||||||
if id == SentinalID {
|
if id == SentinalID {
|
||||||
g.SentinalPlayer.Hand = g.SentinalDeck.Cards[len(g.SentinalDeck.Cards)-5 : len(g.SentinalDeck.Cards)]
|
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]
|
g.SentinalDeck.Cards = g.SentinalDeck.Cards[0 : len(g.SentinalDeck.Cards)-5]
|
||||||
|
@ -29,7 +29,14 @@ func OracleSpell(c CardType, g *Game) bool {
|
|||||||
return false
|
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 {
|
func OracleCast(c *Card, g *Game) bool {
|
||||||
switch c.Type {
|
switch c.Type {
|
||||||
case Valk:
|
case Valk:
|
||||||
|
Loading…
Reference in New Issue
Block a user