add player effects, initial support for arbitrary scrying
This commit is contained in:
parent
059a0acd3b
commit
8230a94357
10
game.go
10
game.go
@ -19,6 +19,7 @@ type Game struct {
|
||||
ScourgeGrave *Deck
|
||||
CurrentTurn int
|
||||
CardBuffer *Deck
|
||||
ScryBuffer int
|
||||
CanDraw bool
|
||||
HasDrawn bool
|
||||
QueuedEffect *Effect
|
||||
@ -39,6 +40,7 @@ func NewGame(sentDeck []int, scoDeck []int) *Game {
|
||||
ScourgeGrave: DeckFromCards([]*Card{}),
|
||||
CurrentTurn: 0, //start with no turn
|
||||
CardBuffer: DeckFromCards([]*Card{}),
|
||||
ScryBuffer: 0,
|
||||
CanDraw: false,
|
||||
HasDrawn: false,
|
||||
QueuedEffect: nil,
|
||||
@ -112,6 +114,10 @@ func (g *Game) StateChanges() {
|
||||
g.Status = StatusSentinalWin
|
||||
}
|
||||
}
|
||||
//apply CurrentTurn player effects
|
||||
for i := 0; i < len(g.GetPlayer(g.CurrentTurn).Effects); i++ {
|
||||
OraclePlayerEffect(g.GetPlayer(g.CurrentTurn), g)
|
||||
}
|
||||
//reapply card effects
|
||||
g.GameBoard.ResetCards()
|
||||
for i := 0; i < len(g.GameBoard.Sentinal); i++ {
|
||||
@ -227,9 +233,13 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
||||
if !g.CanDraw || g.QueuedEffect != nil {
|
||||
return nil
|
||||
}
|
||||
if g.ScryBuffer == 0 {
|
||||
g.ScryBuffer = curr.Life
|
||||
}
|
||||
if g.CardBuffer.Size() <= 0 {
|
||||
g.CardBuffer = DeckFromCards(currD.Scry(curr.Life))
|
||||
}
|
||||
g.ScryBuffer = 0
|
||||
return g.CardBuffer
|
||||
case "d":
|
||||
//draw: return player hand
|
||||
|
23
oracle.go
23
oracle.go
@ -54,7 +54,7 @@ func OracleEnters(c *Card, g *Game) {
|
||||
c.Sick = false
|
||||
return
|
||||
case Scholar:
|
||||
AddEffect(c, &Effect{c.Id, c.Id, 2, 1})
|
||||
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 2, 1})
|
||||
case ShieldWall, Tree:
|
||||
c.Counters = 0
|
||||
case HealthPotion:
|
||||
@ -154,13 +154,13 @@ func OracleEndstep(c *Card, g *Game) {
|
||||
func OraclePower(c CardType, g *Game) int {
|
||||
//this is horrible
|
||||
switch c {
|
||||
case Speedster, HealthPotion, Tree, Goblin:
|
||||
case Speedster, HealthPotion, Tree, Goblin, GoblinSpawn, Chupacabra:
|
||||
return 1
|
||||
case Commander, Ally:
|
||||
return 2
|
||||
case Paladin:
|
||||
case Paladin, Duelist:
|
||||
return 3
|
||||
case Scholar:
|
||||
case Scholar, Vanguard:
|
||||
return 4
|
||||
case Warrior:
|
||||
return 5
|
||||
@ -243,3 +243,18 @@ func OracleEffect(c *Card, g *Game) {
|
||||
c.Power = 0
|
||||
}
|
||||
}
|
||||
|
||||
func OraclePlayerEffect(p *Player, g *Game) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
for _, e := range p.Effects {
|
||||
switch e.ID {
|
||||
case 2:
|
||||
g.CardBuffer = DeckFromCards(g.GetDeck(p.Id).Scry(1))
|
||||
g.CanDraw = true
|
||||
g.HasDrawn = false
|
||||
RemovePlayerEffect(e.Owner, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user