more util methods
This commit is contained in:
parent
66fb3cc777
commit
1606a2953b
10
game.go
10
game.go
@ -398,7 +398,15 @@ func (g *Game) GetDeck(id int) *Deck {
|
||||
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 {
|
||||
return g.GameBoard.GetRow(id)
|
||||
}
|
||||
|
26
game_view.go
26
game_view.go
@ -5,32 +5,16 @@ import (
|
||||
)
|
||||
|
||||
func NewView(id int, g *Game) *GameView {
|
||||
if id == SentinalID {
|
||||
return &GameView{
|
||||
Board: g.GameBoard,
|
||||
Player: g.SentinalPlayer,
|
||||
DeckSize: g.SentinalDeck.Size(),
|
||||
EnemyLife: g.ScourgePlayer.Life,
|
||||
EnemyDeckSize: g.ScourgeDeck.Size(),
|
||||
EnemyHandSize: len(g.ScourgePlayer.Hand),
|
||||
Player: g.GetPlayer(id),
|
||||
DeckSize: g.GetDeck(id).Size(),
|
||||
EnemyLife: g.GetOpponent(id).Life,
|
||||
EnemyDeckSize: g.GetOpponentDeck(id).Size(),
|
||||
EnemyHandSize: len(g.GetOpponent(id).Hand),
|
||||
CurrentTurn: g.CurrentTurn,
|
||||
CanDraw: g.CanDraw,
|
||||
HasDrawn: g.HasDrawn,
|
||||
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,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ func OracleTick(c *Card, g *Game) {
|
||||
if c.Type == EmptyValue {
|
||||
return
|
||||
}
|
||||
row := g.GameBoard.GetRow(c.Owner)
|
||||
row := g.GetBoard(c.Owner)
|
||||
|
||||
switch c.Type {
|
||||
case Two:
|
||||
@ -80,7 +80,7 @@ func OracleLeaves(c *Card, g *Game) {
|
||||
if c.Empty() {
|
||||
return
|
||||
}
|
||||
row := g.GameBoard.GetRow(c.Owner)
|
||||
row := g.GetBoard(c.Owner)
|
||||
switch c.Type {
|
||||
case Two:
|
||||
//remove +1 to all
|
||||
@ -116,7 +116,7 @@ func OracleMove(c *Card, src, dest int, g *Game) {
|
||||
c.Sick = true
|
||||
switch c.Type {
|
||||
case Three:
|
||||
row := g.GameBoard.GetRow(c.Owner)
|
||||
row := g.GetBoard(c.Owner)
|
||||
if src-1 >= 0 {
|
||||
RemoveEffect(c.Id, row[src-1])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user