This commit is contained in:
stryan 2021-10-07 14:03:16 -04:00
parent 739f10c51e
commit 2ecf1dbc70

22
game.go
View File

@ -15,6 +15,8 @@ type Game struct {
ScourgePlayer *Player ScourgePlayer *Player
SentinalDeck *Deck SentinalDeck *Deck
ScourgeDeck *Deck ScourgeDeck *Deck
SentinalGrave *Deck
ScourgeGrave *Deck
CurrentTurn int CurrentTurn int
CardBuffer *Deck CardBuffer *Deck
CanDraw bool CanDraw bool
@ -33,6 +35,8 @@ func NewGame() *Game {
ScourgePlayer: NewPlayer("Scourge", ScourgeID), ScourgePlayer: NewPlayer("Scourge", ScourgeID),
SentinalDeck: deckA, SentinalDeck: deckA,
ScourgeDeck: deckB, ScourgeDeck: deckB,
SentinalGrave: DeckFromCards([]*Card{}),
ScourgeGrave: DeckFromCards([]*Card{}),
CurrentTurn: 0, //start with no turn CurrentTurn: 0, //start with no turn
CardBuffer: DeckFromCards([]*Card{}), CardBuffer: DeckFromCards([]*Card{}),
CanDraw: false, CanDraw: false,
@ -308,14 +312,18 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
case 2: case 2:
OracleLeaves(defender, g) OracleLeaves(defender, g)
g.GameBoard.Remove(defender) g.GameBoard.Remove(defender)
g.Bury(defender)
case 3: case 3:
OracleLeaves(attacker, g) OracleLeaves(attacker, g)
g.GameBoard.Remove(attacker) g.GameBoard.Remove(attacker)
g.Bury(attacker)
case 4: case 4:
OracleLeaves(attacker, g) OracleLeaves(attacker, g)
OracleLeaves(defender, g) OracleLeaves(defender, g)
g.GameBoard.Remove(attacker) g.GameBoard.Remove(attacker)
g.GameBoard.Remove(defender) g.GameBoard.Remove(defender)
g.Bury(attacker)
g.Bury(defender)
} }
return DeckFromCards(g.GameBoard.GetRow(g.CurrentTurn)) return DeckFromCards(g.GameBoard.GetRow(g.CurrentTurn))
@ -410,3 +418,17 @@ func (g *Game) GetOpponentDeck(id int) *Deck {
func (g *Game) GetBoard(id int) []*Card { func (g *Game) GetBoard(id int) []*Card {
return g.GameBoard.GetRow(id) return g.GameBoard.GetRow(id)
} }
func (g *Game) GetGrave(id int) *Deck {
if id == SentinalID {
return g.SentinalGrave
} else if id == ScourgeID {
return g.ScourgeGrave
} else {
return nil
}
}
func (g *Game) Bury(c *Card) {
grave := g.GetGrave(c.Owner)
grave.Cards = append(grave.Cards, c)
}