snengame/internal/game/game_view.go

52 lines
1.6 KiB
Go
Raw Normal View History

2021-07-22 15:37:25 -04:00
package game
2021-07-22 13:09:56 -04:00
import "fmt"
type GameView struct {
Board *Board `json:"board"`
Player *Player `json:"player"`
Deck *Deck `json:"deck"`
2021-07-22 13:09:56 -04:00
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,
2021-07-22 13:09:56 -04:00
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,
2021-07-22 13:09:56 -04:00
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,
}
}
}
2021-07-22 13:09:56 -04:00
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)
}