update game string, fix ally,enemy.other effects

This commit is contained in:
stryan 2021-11-16 16:42:37 -05:00
parent d5bc5ba8a4
commit 99938e1447
2 changed files with 18 additions and 9 deletions

13
game.go
View File

@ -52,7 +52,7 @@ func NewGame(sentDeck []int, scoDeck []int) *Game {
}
func (g *Game) String() string {
return fmt.Sprintf("Sen(%v): %v\n\n%v\n\nSco(%v): %v\nStatus:%v Draw:%v Turn:%v\n%v\n", g.SentinalPlayer.Life, g.SentinalPlayer.Hand, g.GameBoard, g.ScourgePlayer.Life, g.ScourgePlayer.Hand, g.Status, g.CanDraw, g.CurrentTurn, g.CardBuffer)
return fmt.Sprintf("Sen(%v): %v\n\n%v\n\nSco(%v): %v\nStatus:%v Draw:%v Turn:%v\nBuffers\nCardBuffer:%v\nSB:%v BB:%v\nEffectTarget:%v\nQueuedEffect:%v", g.SentinalPlayer.Life, g.SentinalPlayer.Hand, g.GameBoard, g.ScourgePlayer.Life, g.ScourgePlayer.Hand, g.Status, g.CanDraw, g.CurrentTurn, g.CardBuffer, g.ScryBuffer, g.CardBuffer, g.TargetReq, g.QueuedEffect)
}
func (g *Game) Parse(cmd *Command) *CommandResult {
@ -93,7 +93,9 @@ func (g *Game) Parse(cmd *Command) *CommandResult {
debug_res = nil
res_type = InvalidCmd
}
g.StateChanges()
if g.Status == StatusPlaying {
g.StateChanges()
}
return &CommandResult{
PlayerID: cmd.PlayerID,
ResultType: res_type,
@ -202,6 +204,10 @@ func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
if id != g.CurrentTurn {
return nil
}
if g.CanDraw == true || g.QueuedEffect != nil {
log.Println("player tried to end turn while still actions available")
return nil
}
g.CardBuffer = DeckFromCards([]*Card{})
for _, v := range g.GetBoard(id) {
OracleEndstep(v, g)
@ -216,6 +222,9 @@ func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
}
func (g *Game) PlayerAct(id int, cmd string) *Deck {
if g.Status != StatusLobby {
return nil
}
if id != g.CurrentTurn {
return nil
}

View File

@ -84,10 +84,10 @@ func OracleEnters(c *Card, g *Game) {
}
}
case Ally:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 2, 1, true}
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 1, 1, true}
g.TargetReq = TargetOwn
case Enemy:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 2, -1, true}
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 1, -1, true}
g.TargetReq = TargetOpp
case Chupacabra:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 4, 0, true}
@ -96,7 +96,7 @@ func OracleEnters(c *Card, g *Game) {
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 6, 1, true}
g.TargetReq = TargetOwn
case Vanguard:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 7, 1, true}
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 5, 1, true}
g.TargetReq = TargetOwn
case Elephant:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 9, 0, false}
@ -181,15 +181,15 @@ func OracleEndstep(c *Card, g *Game) {
func OraclePower(c CardType, g *Game) int {
//this is horrible
switch c {
case Dud, Clog:
case Dud, Clog, Valk:
return 0
case Speedster, HealthPotion, Tree, Goblin, GoblinSpawn, Chupacabra:
return 1
case Commander, Ally:
case Commander, Ally, Enemy:
return 2
case Paladin, Duelist:
case Paladin, Duelist, Bureaucrat:
return 3
case Scholar, Vanguard:
case Scholar, Vanguard, Student, Librarian:
return 4
case Warrior, Elephant:
return 5