tome_game/oracle.go
2021-10-07 13:37:12 -04:00

157 lines
2.5 KiB
Go

package tome_game
import (
"log"
. "git.saintnet.tech/tomecraft/tome_lib"
)
func OracleUpkeep(c *Card, g *Game) {
switch c.Type {
case Eight:
c.Sick = true
if c.Counters >= 3 {
g.GameBoard.Remove(c)
}
default:
c.Sick = false
}
return
}
func OracleSpell(c CardType, g *Game) bool {
switch c {
case Valk:
return true
default:
return false
}
}
func OracleCast(c *Card, g *Game) bool {
switch c.Type {
case Valk:
g.GameBoard = NewBoard()
return false
default:
return true
}
}
func OracleEnters(c *Card, g *Game) {
c.Sick = true
switch c.Type {
case Ace:
c.Sick = false
return
case Four:
AddEffect(c, &Effect{c.Id, c.Id, 2})
case Eight:
c.Counters = 0
}
}
func OracleTick(c *Card, g *Game) {
if c.Type == EmptyValue {
return
}
row := g.GetBoard(c.Owner)
switch c.Type {
case Two:
//+1 to all
for _, v := range row {
if v.Id != c.Id {
AddEffect(v, &Effect{c.Id, v.Id, 1})
}
}
case Three:
//+1 around it
if c.Position-1 >= 0 {
AddEffect(row[c.Position-1], &Effect{c.Id, row[c.Position-1].Id, 1})
}
if c.Position+1 <= 3 {
AddEffect(row[c.Position+1], &Effect{c.Id, row[c.Position+1].Id, 1})
}
}
}
func OracleLeaves(c *Card, g *Game) {
if c.Empty() {
return
}
row := g.GetBoard(c.Owner)
switch c.Type {
case Two:
//remove +1 to all
for _, v := range row {
RemoveEffect(c.Id, v)
}
case Three:
//+1 around it
if c.Position-1 >= 0 {
RemoveEffect(c.Id, row[c.Position-1])
}
if c.Position+1 <= 3 {
RemoveEffect(c.Id, row[c.Position+1])
}
}
return
}
func OracleEndstep(c *Card, g *Game) {
switch c.Type {
case Eight:
c.Counters = c.Counters + 1
}
return
}
func OraclePower(c CardType, g *Game) int {
return int(c)
}
func OracleMove(c *Card, src, dest int, g *Game) {
c.Sick = true
switch c.Type {
case Three:
row := g.GetBoard(c.Owner)
if src-1 >= 0 {
RemoveEffect(c.Id, row[src-1])
}
if src+1 <= 3 {
RemoveEffect(c.Id, row[src-1])
}
}
}
func OracleAttack(c *Card, g *Game) {
c.Sick = true
}
func OracleEffect(c *Card, g *Game) {
if c.Empty() {
return
}
for _, e := range c.Effects {
switch e.ID {
case 0:
log.Println("dummy effect applied. probably a bug")
case 1:
c.Power = c.Power + 1
case 2:
if c.Owner != SentinalID || c.Owner != ScourgeID {
log.Println("card draw effect was played but with no owner?")
} else {
g.CardBuffer = DeckFromCards(g.GetDeck(c.Owner).Scry(1))
}
g.CanDraw = true
g.HasDrawn = false
RemoveEffect(e.Owner, c)
default:
log.Println("wrong effect type")
}
}
}