snengame/internal/game/oracle.go

155 lines
2.6 KiB
Go
Raw Normal View History

2021-07-23 18:33:17 -04:00
package game
2021-07-26 11:17:45 -04:00
import "log"
2021-07-23 18:33:17 -04:00
func OracleUpkeep(c *Card, g *Game) {
switch c.Type {
2021-07-23 18:57:39 -04:00
case Eight:
c.Sick = true
2021-07-26 11:52:43 -04:00
if c.Counters >= 3 {
2021-07-23 18:57:39 -04:00
g.GameBoard.Remove(c)
}
2021-07-23 18:33:17 -04:00
default:
c.Sick = false
}
return
}
func OracleSpell(c CardType, g *Game) bool {
switch c {
case Valk:
return true
default:
return false
}
}
2021-07-23 18:33:17 -04:00
func OracleCast(c *Card, g *Game) bool {
2021-07-23 18:57:39 -04:00
switch c.Type {
case Valk:
g.GameBoard = NewBoard()
return false
default:
return true
}
2021-07-23 18:33:17 -04:00
}
func OracleEnters(c *Card, g *Game) {
c.Sick = true
2021-07-23 18:57:39 -04:00
switch c.Type {
case Ace:
c.Sick = false
2021-07-25 15:33:47 -04:00
return
case Four:
2021-07-26 11:17:45 -04:00
AddEffect(c, &Effect{c.Id, c.Id, 2})
2021-07-25 15:33:47 -04:00
case Eight:
c.Counters = 0
}
}
func OracleTick(c *Card, g *Game) {
2021-07-26 11:17:45 -04:00
if c.Type == EmptyValue {
return
}
2021-07-25 15:33:47 -04:00
row := g.GameBoard.GetRow(c.Owner)
switch c.Type {
2021-07-23 18:57:39 -04:00
case Two:
//+1 to all
2021-07-25 15:33:47 -04:00
for _, v := range row {
if v.Id != c.Id {
2021-07-26 11:17:45 -04:00
AddEffect(v, &Effect{c.Id, v.Id, 1})
2021-07-23 18:57:39 -04:00
}
}
case Three:
//+1 around it
2021-07-25 15:33:47 -04:00
if c.Position-1 >= 0 {
2021-07-26 11:17:45 -04:00
AddEffect(row[c.Position-1], &Effect{c.Id, row[c.Position-1].Id, 1})
}
2021-07-25 15:33:47 -04:00
if c.Position+1 <= 3 {
2021-07-26 11:17:45 -04:00
AddEffect(row[c.Position+1], &Effect{c.Id, row[c.Position+1].Id, 1})
}
2021-07-23 18:57:39 -04:00
}
2021-07-23 18:33:17 -04:00
}
func OracleLeaves(c *Card, g *Game) {
2021-07-26 11:17:45 -04:00
if c.Empty() {
return
}
2021-07-25 15:33:47 -04:00
row := g.GameBoard.GetRow(c.Owner)
switch c.Type {
case Two:
//remove +1 to all
2021-07-25 15:33:47 -04:00
for _, v := range row {
RemoveEffect(c.Id, v)
}
case Three:
//+1 around it
2021-07-25 15:33:47 -04:00
if c.Position-1 >= 0 {
RemoveEffect(c.Id, row[c.Position-1])
}
2021-07-25 15:33:47 -04:00
if c.Position+1 <= 3 {
RemoveEffect(c.Id, row[c.Position+1])
}
2021-07-25 15:33:47 -04:00
}
2021-07-23 18:33:17 -04:00
return
}
func OracleEndstep(c *Card, g *Game) {
2021-07-23 18:57:39 -04:00
switch c.Type {
case Eight:
c.Counters = c.Counters + 1
}
2021-07-23 18:33:17 -04:00
return
}
func OraclePower(c CardType, g *Game) int {
return int(c)
}
func OracleMove(c *Card, src, dest int, g *Game) {
2021-07-23 18:33:17 -04:00
c.Sick = true
switch c.Type {
case Three:
row := g.GameBoard.GetRow(c.Owner)
2021-07-25 15:33:47 -04:00
if src-1 >= 0 {
RemoveEffect(c.Id, row[src-1])
}
if src+1 <= 3 {
RemoveEffect(c.Id, row[src-1])
}
}
2021-07-23 18:33:17 -04:00
}
func OracleAttack(c *Card, g *Game) {
c.Sick = true
}
2021-07-25 15:33:47 -04:00
func OracleEffect(c *Card, g *Game) {
2021-07-26 11:17:45 -04:00
if c.Empty() {
return
}
2021-07-25 15:33:47 -04:00
for _, e := range c.Effects {
switch e.ID {
2021-07-26 11:17:45 -04:00
case 0:
log.Println("dummy effect applied. probably a bug")
2021-07-25 15:33:47 -04:00
case 1:
c.Power = c.Power + 1
case 2:
if c.Owner == SentinalID {
g.CardBuffer = DeckFromCards(g.SentinalDeck.Scry(1))
2021-07-26 11:44:16 -04:00
} else if c.Owner == ScourgeID {
2021-07-25 15:33:47 -04:00
g.CardBuffer = DeckFromCards(g.SentinalDeck.Scry(1))
2021-07-26 11:44:16 -04:00
} else {
log.Println("card draw effect was played but with no owner?")
2021-07-25 15:33:47 -04:00
}
g.CanDraw = true
g.HasDrawn = false
RemoveEffect(e.Owner, c)
2021-07-26 11:17:45 -04:00
default:
log.Println("wrong effect type")
2021-07-25 15:33:47 -04:00
}
}
}