2021-07-22 12:44:25 -04:00
|
|
|
package main
|
|
|
|
|
2021-07-22 13:09:56 -04:00
|
|
|
import "fmt"
|
|
|
|
|
2021-07-22 12:44:25 -04:00
|
|
|
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"`
|
2021-07-22 12:44:25 -04:00
|
|
|
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,
|
2021-07-22 12:44:25 -04:00
|
|
|
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,
|
2021-07-22 12:44:25 -04:00
|
|
|
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)
|
|
|
|
}
|