snengame/internal/game/game_view.go
2021-07-22 15:37:25 -04:00

52 lines
1.6 KiB
Go

package game
import "fmt"
type GameView struct {
Board *Board `json:"board"`
Player *Player `json:"player"`
Deck *Deck `json:"deck"`
EnemyLife int `json:"enemy_life"`
EnemyDeckSize int `json:"enemy_deck_size"`
EnemyHandSize int `json:"enemy_hand_size"`
CurrentTurn int `json:"current_turn"`
CanDraw bool `json:"can_draw"`
HasDrawn bool `json:"has_drawn"`
Status GameStatus `json:"game_status"`
}
func NewView(id int, g *Game) *GameView {
if id == SentinalID {
return &GameView{
Board: g.GameBoard,
Player: g.SentinalPlayer,
Deck: g.SentinalDeck,
EnemyLife: g.ScourgePlayer.Life,
EnemyDeckSize: g.ScourgeDeck.Size(),
EnemyHandSize: len(g.ScourgePlayer.Hand),
CurrentTurn: g.CurrentTurn,
CanDraw: g.CanDraw,
HasDrawn: g.HasDrawn,
Status: g.Status,
}
} else {
return &GameView{
Board: g.GameBoard,
Player: g.ScourgePlayer,
Deck: g.ScourgeDeck,
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,
}
}
}
func (v *GameView) String() string {
return fmt.Sprintf("Enemy Life: %v Enemy Hand Size: %v Enemy DeckSize: %v\n\n%v\n\n%v\nYou Life: %v\nCT:%v CD: %v, HD %v, Status: %v\n", v.EnemyLife, v.EnemyHandSize, v.EnemyDeckSize, v.Board, v.Player.Hand, v.Player.Life, v.CurrentTurn, v.CanDraw, v.HasDrawn, v.Status)
}