argument safety, reset card effect stacks on tick
This commit is contained in:
parent
8a20d97ad6
commit
08a3559c99
@ -78,6 +78,7 @@ func (b *Board) CanMove(id, src, dest int) bool {
|
|||||||
func (b *Board) Move(id, src, dest int) bool {
|
func (b *Board) Move(id, src, dest int) bool {
|
||||||
brd := b.GetRow(id)
|
brd := b.GetRow(id)
|
||||||
brd[dest] = brd[src]
|
brd[dest] = brd[src]
|
||||||
|
brd[dest].Position = dest
|
||||||
brd[src] = NewEmpty(src)
|
brd[src] = NewEmpty(src)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -96,8 +97,8 @@ func (b *Board) CanPlay(id int, c *Card, dest int) bool {
|
|||||||
func (b *Board) Play(id int, c *Card, dest int, should bool) bool {
|
func (b *Board) Play(id int, c *Card, dest int, should bool) bool {
|
||||||
brd := b.GetRow(id)
|
brd := b.GetRow(id)
|
||||||
if should {
|
if should {
|
||||||
brd[dest] = c
|
|
||||||
c.Position = dest
|
c.Position = dest
|
||||||
|
brd[dest] = c
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -150,8 +151,10 @@ func (b *Board) Attack(id, atk, def int) int {
|
|||||||
func (b *Board) ResetCards() {
|
func (b *Board) ResetCards() {
|
||||||
for _, v := range b.Sentinal {
|
for _, v := range b.Sentinal {
|
||||||
v.Power = v.BasePower
|
v.Power = v.BasePower
|
||||||
|
v.Effects = []Effect{}
|
||||||
}
|
}
|
||||||
for _, v := range b.Scourge {
|
for _, v := range b.Scourge {
|
||||||
v.Power = v.BasePower
|
v.Power = v.BasePower
|
||||||
|
v.Effects = []Effect{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,12 +248,12 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
return DeckFromCards(curr.Hand)
|
return DeckFromCards(curr.Hand)
|
||||||
}
|
}
|
||||||
x_i, err := strconv.Atoi(cmd_s[1])
|
x_i, err := strconv.Atoi(cmd_s[1])
|
||||||
if x_i > 2 || x_i < 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if x_i > 2 || x_i < 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
x := g.CardBuffer.Cards[x_i]
|
x := g.CardBuffer.Cards[x_i]
|
||||||
buf := g.CardBuffer
|
buf := g.CardBuffer
|
||||||
for i, v := range buf.Cards {
|
for i, v := range buf.Cards {
|
||||||
@ -275,8 +275,15 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
if !g.HasDrawn {
|
if !g.HasDrawn {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
x_i, _ := strconv.Atoi(cmd_s[1])
|
x_i, err := strconv.Atoi(cmd_s[1])
|
||||||
y_i, _ := strconv.Atoi(cmd_s[2])
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
y_i, err := strconv.Atoi(cmd_s[2])
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
if g.GameBoard.CanMove(g.CurrentTurn, x_i, y_i) {
|
if g.GameBoard.CanMove(g.CurrentTurn, x_i, y_i) {
|
||||||
OracleMove(g.GameBoard.GetCard(g.CurrentTurn, x_i), x_i, y_i, g)
|
OracleMove(g.GameBoard.GetCard(g.CurrentTurn, x_i), x_i, y_i, g)
|
||||||
g.GameBoard.Move(g.CurrentTurn, x_i, y_i)
|
g.GameBoard.Move(g.CurrentTurn, x_i, y_i)
|
||||||
@ -292,8 +299,16 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
if !g.HasDrawn {
|
if !g.HasDrawn {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
x_i, _ := strconv.Atoi(cmd_s[1])
|
x_i, err := strconv.Atoi(cmd_s[1])
|
||||||
y_i, _ := strconv.Atoi(cmd_s[2])
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
y_i, err := strconv.Atoi(cmd_s[2])
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if g.GameBoard.CanAttack(g.CurrentTurn, x_i, y_i) {
|
if g.GameBoard.CanAttack(g.CurrentTurn, x_i, y_i) {
|
||||||
OracleAttack(g.GameBoard.GetCard(g.CurrentTurn, x_i), g)
|
OracleAttack(g.GameBoard.GetCard(g.CurrentTurn, x_i), g)
|
||||||
res := g.GameBoard.Attack(g.CurrentTurn, x_i, y_i)
|
res := g.GameBoard.Attack(g.CurrentTurn, x_i, y_i)
|
||||||
@ -338,8 +353,16 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
if !g.HasDrawn {
|
if !g.HasDrawn {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
x_i, _ := strconv.Atoi(cmd_s[1])
|
x_i, err := strconv.Atoi(cmd_s[1])
|
||||||
y_i, _ := strconv.Atoi(cmd_s[2])
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
y_i, err := strconv.Atoi(cmd_s[2])
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
card := curr.Hand[x_i]
|
card := curr.Hand[x_i]
|
||||||
shouldPlace := true
|
shouldPlace := true
|
||||||
if g.GameBoard.CanPlay(g.CurrentTurn, card, y_i) {
|
if g.GameBoard.CanPlay(g.CurrentTurn, card, y_i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user