tome_game/oracle.go

315 lines
6.5 KiB
Go
Raw Normal View History

2021-10-01 13:40:46 -04:00
package tome_game
import (
"log"
. "git.saintnet.tech/tomecraft/tome_lib"
2021-11-08 15:46:11 -05:00
"github.com/google/uuid"
2021-10-01 13:40:46 -04:00
)
func OracleUpkeep(c *Card, g *Game) {
switch c.Type {
2021-11-08 15:46:11 -05:00
case ShieldWall:
2021-10-01 13:40:46 -04:00
c.Sick = true
if c.Counters >= 3 {
g.GameBoard.Remove(c)
2021-10-07 13:59:47 -04:00
g.Bury(c)
2021-10-01 13:40:46 -04:00
}
case Hologram:
if c.Counters >= 3 {
g.GameBoard.Remove(c)
g.Bury(c)
}
2021-11-16 15:50:53 -05:00
case Clog:
if c.Counters >= 1 {
g.GameBoard.Remove(c)
g.Bury(c)
}
2021-10-01 13:40:46 -04:00
default:
c.Sick = false
}
return
}
func OracleSpell(c CardType, g *Game) bool {
switch c {
case Valk:
return true
default:
return false
}
}
func OracleToken(c CardType, g *Game) bool {
switch c {
2021-11-16 15:50:53 -05:00
case GoblinSpawn, Dud, Clog:
return true
default:
return false
}
}
2021-10-01 13:40:46 -04:00
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 {
2021-11-08 15:46:11 -05:00
case Speedster:
2021-10-01 13:40:46 -04:00
c.Sick = false
return
2021-11-08 15:46:11 -05:00
case Scholar:
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 2, 1, true})
2021-11-14 14:59:53 -05:00
case Student:
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 4, 2, true})
case Librarian:
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 1, 1, true})
2021-11-08 15:46:11 -05:00
case ShieldWall, Tree:
2021-10-01 13:40:46 -04:00
c.Counters = 0
2021-11-08 15:46:11 -05:00
case HealthPotion:
g.SentinalPlayer.Life = g.SentinalPlayer.Life + 1
g.ScourgePlayer.Life = g.ScourgePlayer.Life + 1
case Goblin:
for i := 0; i < 2; i++ {
for k, v := range g.GetBoard(c.Owner) {
if v.Empty() {
g.GetBoard(c.Owner)[k] = NewCard(int(GoblinSpawn), c.Owner, k, uuid.Nil)
break
}
}
}
2021-11-10 17:46:19 -05:00
case Ally:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 1, 1, true}
2021-11-10 17:46:19 -05:00
g.TargetReq = TargetOwn
2021-11-10 17:53:08 -05:00
case Enemy:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 1, -1, true}
2021-11-10 17:53:08 -05:00
g.TargetReq = TargetOpp
2021-11-11 12:21:18 -05:00
case Chupacabra:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 4, 0, true}
2021-11-11 12:21:18 -05:00
g.TargetReq = TargetOpp
case Duelist:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 6, 1, true}
2021-11-11 12:21:18 -05:00
g.TargetReq = TargetOwn
case Vanguard:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 5, 1, true}
2021-11-11 12:21:18 -05:00
g.TargetReq = TargetOwn
case Elephant:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 9, 0, false}
g.TargetReq = TargetOppEmpty
2021-11-16 15:50:53 -05:00
case Bureaucrat:
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 10, 0, false}
g.TargetReq = TargetAny
case Clog:
c.Phased = true
c.Counters = 0
case Mesmerist:
g.GetOpponentDeck(c.Owner).Shuffle()
case Diviner:
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 3, 2, true})
2021-10-01 13:40:46 -04:00
}
}
func OracleTick(c *Card, g *Game) {
if c.Type == EmptyValue {
return
}
2021-10-07 13:32:47 -04:00
row := g.GetBoard(c.Owner)
2021-10-01 13:40:46 -04:00
switch c.Type {
2021-11-08 15:46:11 -05:00
case Commander:
2021-10-01 13:40:46 -04:00
//+1 to all
for _, v := range row {
if v.Id != c.Id {
AddEffect(v, &Effect{c.Id, v.Id, 1, 1, true})
2021-10-01 13:40:46 -04:00
}
}
2021-11-08 15:46:11 -05:00
case Paladin:
2021-10-01 13:40:46 -04:00
//+1 around it
if c.Position-1 >= 0 {
AddEffect(row[c.Position-1], &Effect{c.Id, row[c.Position-1].Id, 1, 1, true})
2021-10-01 13:40:46 -04:00
}
if c.Position+1 <= 3 {
AddEffect(row[c.Position+1], &Effect{c.Id, row[c.Position+1].Id, 1, 1, true})
2021-11-08 15:46:11 -05:00
}
case Tree:
if c.Counters >= 5 {
AddEffect(row[c.Position], &Effect{c.Id, row[c.Position].Id, 1, 8, true})
2021-10-01 13:40:46 -04:00
}
}
2021-11-08 15:46:11 -05:00
2021-10-01 13:40:46 -04:00
}
func OracleLeaves(c *Card, g *Game) {
if c.Empty() {
return
}
2021-10-07 13:32:47 -04:00
row := g.GetBoard(c.Owner)
2021-10-01 13:40:46 -04:00
switch c.Type {
2021-11-08 15:46:11 -05:00
case Commander:
2021-10-01 13:40:46 -04:00
//remove +1 to all
for _, v := range row {
RemoveEffect(c.Id, v)
}
2021-11-08 15:46:11 -05:00
case Paladin:
2021-10-01 13:40:46 -04:00
//+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])
}
2021-11-08 15:46:11 -05:00
case HealthPotion:
g.SentinalPlayer.Life = g.SentinalPlayer.Life - 1
g.ScourgePlayer.Life = g.ScourgePlayer.Life - 1
2021-10-01 13:40:46 -04:00
}
return
}
func OracleEndstep(c *Card, g *Game) {
switch c.Type {
2021-11-16 15:50:53 -05:00
case ShieldWall, Tree, Hologram, Clog:
2021-10-01 13:40:46 -04:00
c.Counters = c.Counters + 1
}
return
}
func OraclePower(c CardType, g *Game) int {
2021-11-08 15:46:11 -05:00
//this is horrible
switch c {
case Dud, Clog, Valk:
return 0
case Speedster, HealthPotion, Tree, Goblin, GoblinSpawn, Chupacabra:
2021-11-08 15:46:11 -05:00
return 1
case Commander, Ally, Enemy:
2021-11-08 15:46:11 -05:00
return 2
case Paladin, Duelist, Bureaucrat:
2021-11-08 15:46:11 -05:00
return 3
case Scholar, Vanguard, Student, Librarian:
2021-11-08 15:46:11 -05:00
return 4
case Warrior, Elephant:
2021-11-08 15:46:11 -05:00
return 5
case Fighter, Mesmerist, Diviner:
2021-11-08 15:46:11 -05:00
return 6
case Seven:
return 7
case ShieldWall, Hologram:
return 8
2021-11-08 15:46:11 -05:00
default:
log.Printf("played card %v without power in oracle", c)
2021-11-08 15:46:11 -05:00
return int(c)
}
2021-10-01 13:40:46 -04:00
}
func OracleMove(c *Card, src, dest int, g *Game) {
c.Sick = true
switch c.Type {
2021-11-08 15:46:11 -05:00
case Paladin:
2021-10-07 13:32:47 -04:00
row := g.GetBoard(c.Owner)
2021-10-01 13:40:46 -04:00
if src-1 >= 0 {
RemoveEffect(c.Id, row[src-1])
}
if src+1 <= 3 {
RemoveEffect(c.Id, row[src-1])
}
}
}
func OracleAttack(c *Card, src, dest int, g *Game) {
2021-10-01 13:40:46 -04:00
c.Sick = true
switch c.Type {
case Hologram:
row := g.GetOpponentBoard(c.Owner)
if row[dest].Type == EmptyValue {
c.Power = 0
}
}
2021-10-01 13:40:46 -04:00
}
func OracleEffect(c *Card, g *Game) {
for _, e := range c.Effects {
switch e.ID {
case 0:
log.Println("dummy effect applied. probably a bug")
case 1:
2021-11-08 15:46:11 -05:00
c.Power = c.Power + e.Modifier
2021-10-01 13:40:46 -04:00
case 2:
2021-10-07 13:47:55 -04:00
if c.Owner != SentinalID && c.Owner != ScourgeID {
2021-10-01 13:40:46 -04:00
log.Println("card draw effect was played but with no owner?")
2021-10-07 13:37:12 -04:00
} else {
g.CardBuffer = DeckFromCards(g.GetDeck(c.Owner).Scry(1))
2021-10-01 13:40:46 -04:00
}
g.CanDraw = true
g.HasDrawn = false
RemoveEffect(e.Owner, c)
2021-11-08 15:46:11 -05:00
case 3:
c.BasePower = e.Modifier
2021-11-10 17:53:08 -05:00
case 4:
2021-11-11 12:21:18 -05:00
g.Bury(c)
case 5: //+x/+0
if g.CurrentTurn == c.Owner {
c.Power = c.Power + e.Modifier
}
case 6: //+0/+x
if g.CurrentTurn != c.Owner {
c.Power = c.Power + e.Modifier
}
case 7: //+x/-x
if g.CurrentTurn == c.Owner {
c.Power = c.Power + e.Modifier
} else {
c.Power = c.Power - e.Modifier
}
case 8: //-x/+x
if g.CurrentTurn == c.Owner {
c.Power = c.Power + e.Modifier
} else {
c.Power = c.Power + e.Modifier
}
case 9: //create dud
RemoveEffect(e.Owner, c)
c = NewCard(int(Dud), c.Owner, c.Position, uuid.Nil)
2021-11-16 15:50:53 -05:00
case 10: //create clog
RemoveEffect(e.Owner, c)
c = NewCard(int(Clog), c.Owner, c.Position, uuid.Nil)
2021-10-01 13:40:46 -04:00
default:
log.Println("wrong effect type")
}
}
2021-11-11 12:21:18 -05:00
if c.Power < 0 {
c.Power = 0
}
2021-10-01 13:40:46 -04:00
}
func OraclePlayerEffect(p *Player, g *Game) {
if p == nil {
return
}
for _, e := range p.Effects {
switch e.ID {
2021-11-14 14:59:53 -05:00
case 1:
g.CanDraw = true
g.HasDrawn = false
RemovePlayerEffect(e.Owner, p)
case 2:
g.CardBuffer = DeckFromCards(g.GetDeck(p.Id).Scry(1))
g.CanDraw = true
g.HasDrawn = false
RemovePlayerEffect(e.Owner, p)
case 3:
g.ScryBuffer = e.Modifier
g.BottomBuffer = e.Modifier - 1
RemovePlayerEffect(e.Owner, p)
2021-11-14 14:59:53 -05:00
case 4:
g.ScryBuffer = e.Modifier
g.CanDraw = true
g.HasDrawn = false
RemovePlayerEffect(e.Owner, p)
}
}
}