more util methods

This commit is contained in:
stryan 2021-10-07 13:32:47 -04:00
parent 66fb3cc777
commit 1606a2953b
3 changed files with 23 additions and 31 deletions

10
game.go
View File

@ -398,7 +398,15 @@ func (g *Game) GetDeck(id int) *Deck {
return nil return nil
} }
} }
func (g *Game) GetOpponentDeck(id int) *Deck {
if id == SentinalID {
return g.ScourgeDeck
} else if id == ScourgeID {
return g.SentinalDeck
} else {
return nil
}
}
func (g *Game) GetBoard(id int) []*Card { func (g *Game) GetBoard(id int) []*Card {
return g.GameBoard.GetRow(id) return g.GameBoard.GetRow(id)
} }

View File

@ -5,32 +5,16 @@ import (
) )
func NewView(id int, g *Game) *GameView { func NewView(id int, g *Game) *GameView {
if id == SentinalID { return &GameView{
return &GameView{ Board: g.GameBoard,
Board: g.GameBoard, Player: g.GetPlayer(id),
Player: g.SentinalPlayer, DeckSize: g.GetDeck(id).Size(),
DeckSize: g.SentinalDeck.Size(), EnemyLife: g.GetOpponent(id).Life,
EnemyLife: g.ScourgePlayer.Life, EnemyDeckSize: g.GetOpponentDeck(id).Size(),
EnemyDeckSize: g.ScourgeDeck.Size(), EnemyHandSize: len(g.GetOpponent(id).Hand),
EnemyHandSize: len(g.ScourgePlayer.Hand), CurrentTurn: g.CurrentTurn,
CurrentTurn: g.CurrentTurn, CanDraw: g.CanDraw,
CanDraw: g.CanDraw, HasDrawn: g.HasDrawn,
HasDrawn: g.HasDrawn, Status: g.Status,
Status: g.Status,
}
} else {
return &GameView{
Board: g.GameBoard,
Player: g.ScourgePlayer,
DeckSize: g.ScourgeDeck.Size(),
EnemyLife: g.SentinalPlayer.Life,
EnemyDeckSize: g.SentinalDeck.Size(),
EnemyHandSize: len(g.SentinalPlayer.Hand),
CurrentTurn: g.CurrentTurn,
CanDraw: g.CanDraw,
HasDrawn: g.HasDrawn,
Status: g.Status,
}
} }
} }

View File

@ -55,7 +55,7 @@ func OracleTick(c *Card, g *Game) {
if c.Type == EmptyValue { if c.Type == EmptyValue {
return return
} }
row := g.GameBoard.GetRow(c.Owner) row := g.GetBoard(c.Owner)
switch c.Type { switch c.Type {
case Two: case Two:
@ -80,7 +80,7 @@ func OracleLeaves(c *Card, g *Game) {
if c.Empty() { if c.Empty() {
return return
} }
row := g.GameBoard.GetRow(c.Owner) row := g.GetBoard(c.Owner)
switch c.Type { switch c.Type {
case Two: case Two:
//remove +1 to all //remove +1 to all
@ -116,7 +116,7 @@ func OracleMove(c *Card, src, dest int, g *Game) {
c.Sick = true c.Sick = true
switch c.Type { switch c.Type {
case Three: case Three:
row := g.GameBoard.GetRow(c.Owner) row := g.GetBoard(c.Owner)
if src-1 >= 0 { if src-1 >= 0 {
RemoveEffect(c.Id, row[src-1]) RemoveEffect(c.Id, row[src-1])
} }