package tome_game import ( "log" . "git.saintnet.tech/tomecraft/tome_lib" "github.com/google/uuid" ) func OracleUpkeep(c *Card, g *Game) { switch c.Type { case ShieldWall: c.Sick = true if c.Counters >= 3 { g.GameBoard.Remove(c) g.Bury(c) } case Hologram: if c.Counters >= 3 { g.GameBoard.Remove(c) g.Bury(c) } case Clog: if c.Counters >= 1 { g.GameBoard.Remove(c) g.Bury(c) } 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 { case GoblinSpawn, Dud, Clog: 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 Speedster: c.Sick = false return case Scholar: AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 2, 1, true}) 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}) case ShieldWall, Tree: c.Counters = 0 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 } } } case Ally: g.QueuedEffect = &Effect{c.Id, uuid.Nil, 1, 1, true} g.TargetReq = TargetOwn case Enemy: 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} g.TargetReq = TargetOpp case Duelist: g.QueuedEffect = &Effect{c.Id, uuid.Nil, 6, 1, true} g.TargetReq = TargetOwn case Vanguard: 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} g.TargetReq = TargetOppEmpty 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}) } } func OracleTick(c *Card, g *Game) { if c.Type == EmptyValue { return } row := g.GetBoard(c.Owner) switch c.Type { case Commander: //+1 to all for _, v := range row { if v.Id != c.Id { AddEffect(v, &Effect{c.Id, v.Id, 1, 1, true}) } } case Paladin: //+1 around it if c.Position-1 >= 0 { AddEffect(row[c.Position-1], &Effect{c.Id, row[c.Position-1].Id, 1, 1, true}) } if c.Position+1 <= 3 { AddEffect(row[c.Position+1], &Effect{c.Id, row[c.Position+1].Id, 1, 1, true}) } case Tree: if c.Counters >= 5 { AddEffect(row[c.Position], &Effect{c.Id, row[c.Position].Id, 1, 8, true}) } } } func OracleLeaves(c *Card, g *Game) { if c.Empty() { return } row := g.GetBoard(c.Owner) switch c.Type { case Commander: //remove +1 to all for _, v := range row { RemoveEffect(c.Id, v) } case Paladin: //+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]) } case HealthPotion: g.SentinalPlayer.Life = g.SentinalPlayer.Life - 1 g.ScourgePlayer.Life = g.ScourgePlayer.Life - 1 } return } func OracleEndstep(c *Card, g *Game) { switch c.Type { case ShieldWall, Tree, Hologram, Clog: c.Counters = c.Counters + 1 } return } func OraclePower(c CardType, g *Game) int { //this is horrible switch c { case Dud, Clog, Valk: return 0 case Speedster, HealthPotion, Tree, Goblin, GoblinSpawn, Chupacabra: return 1 case Commander, Ally, Enemy: return 2 case Paladin, Duelist, Bureaucrat: return 3 case Scholar, Vanguard, Student, Librarian: return 4 case Warrior, Elephant: return 5 case Fighter, Mesmerist, Diviner: return 6 case Seven: return 7 case ShieldWall, Hologram: return 8 default: log.Printf("played card %v without power in oracle", c) return int(c) } } func OracleMove(c *Card, src, dest int, g *Game) { c.Sick = true switch c.Type { case Paladin: 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, src, dest int, g *Game) { c.Sick = true switch c.Type { case Hologram: row := g.GetOpponentBoard(c.Owner) if row[dest].Type == EmptyValue { c.Power = 0 } } } 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: c.Power = c.Power + e.Modifier 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) case 3: c.BasePower = e.Modifier case 4: 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) case 10: //create clog RemoveEffect(e.Owner, c) c = NewCard(int(Clog), c.Owner, c.Position, uuid.Nil) default: log.Println("wrong effect type") } } if c.Power < 0 { c.Power = 0 } } func OraclePlayerEffect(p *Player, g *Game) { if p == nil { return } for _, e := range p.Effects { switch e.ID { 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) case 4: g.ScryBuffer = e.Modifier g.CanDraw = true g.HasDrawn = false RemovePlayerEffect(e.Owner, p) } } }