add diviner,mesmer,hologram,elephant,uuuh probably more things
This commit is contained in:
parent
8230a94357
commit
960d4cc806
50
game.go
50
game.go
@ -20,6 +20,7 @@ type Game struct {
|
|||||||
CurrentTurn int
|
CurrentTurn int
|
||||||
CardBuffer *Deck
|
CardBuffer *Deck
|
||||||
ScryBuffer int
|
ScryBuffer int
|
||||||
|
BottomBuffer int
|
||||||
CanDraw bool
|
CanDraw bool
|
||||||
HasDrawn bool
|
HasDrawn bool
|
||||||
QueuedEffect *Effect
|
QueuedEffect *Effect
|
||||||
@ -41,6 +42,7 @@ func NewGame(sentDeck []int, scoDeck []int) *Game {
|
|||||||
CurrentTurn: 0, //start with no turn
|
CurrentTurn: 0, //start with no turn
|
||||||
CardBuffer: DeckFromCards([]*Card{}),
|
CardBuffer: DeckFromCards([]*Card{}),
|
||||||
ScryBuffer: 0,
|
ScryBuffer: 0,
|
||||||
|
BottomBuffer: 0,
|
||||||
CanDraw: false,
|
CanDraw: false,
|
||||||
HasDrawn: false,
|
HasDrawn: false,
|
||||||
QueuedEffect: nil,
|
QueuedEffect: nil,
|
||||||
@ -254,9 +256,10 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
}
|
}
|
||||||
x_i, err := strconv.Atoi(cmd_s[1])
|
x_i, err := strconv.Atoi(cmd_s[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Printf("error converting draw target %v", err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if x_i > 2 || x_i < 0 {
|
if x_i > g.CardBuffer.Size() || x_i < 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
x := g.CardBuffer.Cards[x_i]
|
x := g.CardBuffer.Cards[x_i]
|
||||||
@ -269,7 +272,31 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
g.CanDraw = false
|
g.CanDraw = false
|
||||||
g.HasDrawn = true
|
g.HasDrawn = true
|
||||||
return DeckFromCards(curr.Hand)
|
return DeckFromCards(curr.Hand)
|
||||||
|
case "b":
|
||||||
|
if g.BottomBuffer == 0 || g.ScryBuffer == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if len(cmd_s) != 2 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
x_i, err := strconv.Atoi(cmd_s[1])
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error converting bottom target %v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if x_i > g.CardBuffer.Size() || x_i < 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
bottomTarget := g.CardBuffer.Cards[x_i]
|
||||||
|
g.CardBuffer.Cards = append(g.CardBuffer.Cards[:x_i], g.CardBuffer.Cards[x_i+1:]...)
|
||||||
|
currD.Bottom([]*Card{bottomTarget})
|
||||||
|
g.BottomBuffer = g.BottomBuffer - 1
|
||||||
|
if g.BottomBuffer > 0 {
|
||||||
|
return g.CardBuffer
|
||||||
|
} else {
|
||||||
|
g.BottomBuffer = 0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
case "m":
|
case "m":
|
||||||
//move: return player board or [] if invalid
|
//move: return player board or [] if invalid
|
||||||
if len(cmd_s) != 3 {
|
if len(cmd_s) != 3 {
|
||||||
@ -313,7 +340,7 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if g.GameBoard.CanAttack(g.CurrentTurn, x_i, y_i) {
|
if g.GameBoard.CanAttack(g.CurrentTurn, x_i, y_i) {
|
||||||
OracleAttack(g.GameBoard.GetCard(g.CurrentTurn, x_i), g)
|
OracleAttack(g.GameBoard.GetCard(g.CurrentTurn, x_i), x_i, y_i, g)
|
||||||
res := g.GameBoard.Attack(g.CurrentTurn, x_i, y_i)
|
res := g.GameBoard.Attack(g.CurrentTurn, x_i, y_i)
|
||||||
var aid, did int
|
var aid, did int
|
||||||
aid = g.GetPlayer(id).Id
|
aid = g.GetPlayer(id).Id
|
||||||
@ -401,6 +428,12 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if pos == -1 {
|
||||||
|
fmt.Println("no target requested, fizzling effect")
|
||||||
|
g.QueuedEffect = nil
|
||||||
|
g.TargetReq = TargetNone
|
||||||
|
return DeckFromCards(g.GetBoard(board))
|
||||||
|
}
|
||||||
if pos < 0 || pos >= 3 {
|
if pos < 0 || pos >= 3 {
|
||||||
fmt.Println("board position out of bounds")
|
fmt.Println("board position out of bounds")
|
||||||
return nil
|
return nil
|
||||||
@ -482,6 +515,15 @@ func (g *Game) GetOpponentDeck(id int) *Deck {
|
|||||||
func (g *Game) GetBoard(id int) []*Card {
|
func (g *Game) GetBoard(id int) []*Card {
|
||||||
return g.GameBoard.GetRow(id)
|
return g.GameBoard.GetRow(id)
|
||||||
}
|
}
|
||||||
|
func (g *Game) GetOpponentBoard(id int) []*Card {
|
||||||
|
if id == SentinalID {
|
||||||
|
return g.GameBoard.GetRow(ScourgeID)
|
||||||
|
} else if id == ScourgeID {
|
||||||
|
return g.GameBoard.GetRow(SentinalID)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Game) GetGrave(id int) *Deck {
|
func (g *Game) GetGrave(id int) *Deck {
|
||||||
if id == SentinalID {
|
if id == SentinalID {
|
||||||
|
63
oracle.go
63
oracle.go
@ -15,6 +15,11 @@ func OracleUpkeep(c *Card, g *Game) {
|
|||||||
g.GameBoard.Remove(c)
|
g.GameBoard.Remove(c)
|
||||||
g.Bury(c)
|
g.Bury(c)
|
||||||
}
|
}
|
||||||
|
case Hologram:
|
||||||
|
if c.Counters >= 3 {
|
||||||
|
g.GameBoard.Remove(c)
|
||||||
|
g.Bury(c)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
c.Sick = false
|
c.Sick = false
|
||||||
}
|
}
|
||||||
@ -31,7 +36,7 @@ func OracleSpell(c CardType, g *Game) bool {
|
|||||||
}
|
}
|
||||||
func OracleToken(c CardType, g *Game) bool {
|
func OracleToken(c CardType, g *Game) bool {
|
||||||
switch c {
|
switch c {
|
||||||
case GoblinSpawn:
|
case GoblinSpawn, Dud:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
@ -54,7 +59,7 @@ func OracleEnters(c *Card, g *Game) {
|
|||||||
c.Sick = false
|
c.Sick = false
|
||||||
return
|
return
|
||||||
case Scholar:
|
case Scholar:
|
||||||
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 2, 1})
|
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 2, 1, true})
|
||||||
case ShieldWall, Tree:
|
case ShieldWall, Tree:
|
||||||
c.Counters = 0
|
c.Counters = 0
|
||||||
case HealthPotion:
|
case HealthPotion:
|
||||||
@ -70,20 +75,27 @@ func OracleEnters(c *Card, g *Game) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case Ally:
|
case Ally:
|
||||||
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 2, 1}
|
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 2, 1, true}
|
||||||
g.TargetReq = TargetOwn
|
g.TargetReq = TargetOwn
|
||||||
case Enemy:
|
case Enemy:
|
||||||
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 2, -1}
|
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 2, -1, true}
|
||||||
g.TargetReq = TargetOpp
|
g.TargetReq = TargetOpp
|
||||||
case Chupacabra:
|
case Chupacabra:
|
||||||
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 4, 0}
|
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 4, 0, true}
|
||||||
g.TargetReq = TargetOpp
|
g.TargetReq = TargetOpp
|
||||||
case Duelist:
|
case Duelist:
|
||||||
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 6, 1}
|
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 6, 1, true}
|
||||||
g.TargetReq = TargetOwn
|
g.TargetReq = TargetOwn
|
||||||
case Vanguard:
|
case Vanguard:
|
||||||
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 7, 1}
|
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 7, 1, true}
|
||||||
g.TargetReq = TargetOwn
|
g.TargetReq = TargetOwn
|
||||||
|
case Elephant:
|
||||||
|
g.QueuedEffect = &Effect{c.Id, uuid.Nil, 9, 0, false}
|
||||||
|
g.TargetReq = TargetOppEmpty
|
||||||
|
case Mesmerist:
|
||||||
|
g.GetOpponentDeck(c.Owner).Shuffle()
|
||||||
|
case Diviner:
|
||||||
|
AddPlayerEffect(g.GetPlayer(c.Owner), &Effect{c.Id, uuid.Nil, 3, 2, true})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,20 +110,20 @@ func OracleTick(c *Card, g *Game) {
|
|||||||
//+1 to all
|
//+1 to all
|
||||||
for _, v := range row {
|
for _, v := range row {
|
||||||
if v.Id != c.Id {
|
if v.Id != c.Id {
|
||||||
AddEffect(v, &Effect{c.Id, v.Id, 1, 1})
|
AddEffect(v, &Effect{c.Id, v.Id, 1, 1, true})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case Paladin:
|
case Paladin:
|
||||||
//+1 around it
|
//+1 around it
|
||||||
if c.Position-1 >= 0 {
|
if c.Position-1 >= 0 {
|
||||||
AddEffect(row[c.Position-1], &Effect{c.Id, row[c.Position-1].Id, 1, 1})
|
AddEffect(row[c.Position-1], &Effect{c.Id, row[c.Position-1].Id, 1, 1, true})
|
||||||
}
|
}
|
||||||
if c.Position+1 <= 3 {
|
if c.Position+1 <= 3 {
|
||||||
AddEffect(row[c.Position+1], &Effect{c.Id, row[c.Position+1].Id, 1, 1})
|
AddEffect(row[c.Position+1], &Effect{c.Id, row[c.Position+1].Id, 1, 1, true})
|
||||||
}
|
}
|
||||||
case Tree:
|
case Tree:
|
||||||
if c.Counters >= 5 {
|
if c.Counters >= 5 {
|
||||||
AddEffect(row[c.Position], &Effect{c.Id, row[c.Position].Id, 1, 8})
|
AddEffect(row[c.Position], &Effect{c.Id, row[c.Position].Id, 1, 8, true})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +166,8 @@ func OracleEndstep(c *Card, g *Game) {
|
|||||||
func OraclePower(c CardType, g *Game) int {
|
func OraclePower(c CardType, g *Game) int {
|
||||||
//this is horrible
|
//this is horrible
|
||||||
switch c {
|
switch c {
|
||||||
|
case Dud:
|
||||||
|
return 0
|
||||||
case Speedster, HealthPotion, Tree, Goblin, GoblinSpawn, Chupacabra:
|
case Speedster, HealthPotion, Tree, Goblin, GoblinSpawn, Chupacabra:
|
||||||
return 1
|
return 1
|
||||||
case Commander, Ally:
|
case Commander, Ally:
|
||||||
@ -162,13 +176,16 @@ func OraclePower(c CardType, g *Game) int {
|
|||||||
return 3
|
return 3
|
||||||
case Scholar, Vanguard:
|
case Scholar, Vanguard:
|
||||||
return 4
|
return 4
|
||||||
case Warrior:
|
case Warrior, Elephant:
|
||||||
return 5
|
return 5
|
||||||
case Fighter:
|
case Fighter, Mesmerist, Diviner:
|
||||||
return 6
|
return 6
|
||||||
case Seven:
|
case Seven:
|
||||||
return 7
|
return 7
|
||||||
|
case ShieldWall, Hologram:
|
||||||
|
return 8
|
||||||
default:
|
default:
|
||||||
|
log.Printf("played card %v without power in oracle", c)
|
||||||
return int(c)
|
return int(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,14 +204,18 @@ func OracleMove(c *Card, src, dest int, g *Game) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func OracleAttack(c *Card, g *Game) {
|
func OracleAttack(c *Card, src, dest int, g *Game) {
|
||||||
c.Sick = true
|
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) {
|
func OracleEffect(c *Card, g *Game) {
|
||||||
if c.Empty() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, e := range c.Effects {
|
for _, e := range c.Effects {
|
||||||
switch e.ID {
|
switch e.ID {
|
||||||
case 0:
|
case 0:
|
||||||
@ -234,7 +255,9 @@ func OracleEffect(c *Card, g *Game) {
|
|||||||
} else {
|
} else {
|
||||||
c.Power = c.Power + e.Modifier
|
c.Power = c.Power + e.Modifier
|
||||||
}
|
}
|
||||||
|
case 9: //create dud
|
||||||
|
RemoveEffect(e.Owner, c)
|
||||||
|
c = NewCard(int(Dud), c.Owner, c.Position, uuid.Nil)
|
||||||
default:
|
default:
|
||||||
log.Println("wrong effect type")
|
log.Println("wrong effect type")
|
||||||
}
|
}
|
||||||
@ -255,6 +278,10 @@ func OraclePlayerEffect(p *Player, g *Game) {
|
|||||||
g.CanDraw = true
|
g.CanDraw = true
|
||||||
g.HasDrawn = false
|
g.HasDrawn = false
|
||||||
RemovePlayerEffect(e.Owner, p)
|
RemovePlayerEffect(e.Owner, p)
|
||||||
|
case 3:
|
||||||
|
g.ScryBuffer = e.Modifier
|
||||||
|
g.BottomBuffer = e.Modifier - 1
|
||||||
|
RemovePlayerEffect(e.Owner, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user