maybe don't give sentinal scourges deck huh
This commit is contained in:
parent
6eb24636e5
commit
d8777b0dda
@ -20,12 +20,13 @@ func (d *Deck) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewDeck(owner int) *Deck {
|
func NewDeck(owner int) *Deck {
|
||||||
cards := []*Card{NewCard(0, owner, -1, uuid.Nil)}
|
cards := []*Card{}
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
for j := 1; j < 9; j++ {
|
for j := 1; j < 9; j++ {
|
||||||
cards = append(cards, NewCard(j, owner, -1, uuid.Nil))
|
cards = append(cards, NewCard(j, owner, -1, uuid.Nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cards = append(cards, NewCard(0, owner, -1, uuid.Nil))
|
||||||
return &Deck{
|
return &Deck{
|
||||||
Cards: cards,
|
Cards: cards,
|
||||||
}
|
}
|
||||||
@ -38,13 +39,11 @@ func DeckFromCards(c []*Card) *Deck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Deck) Shuffle() {
|
func (d *Deck) Shuffle() {
|
||||||
cards := d.Cards
|
|
||||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
for i := range cards {
|
for i := range d.Cards {
|
||||||
j := r.Intn(i + 1)
|
j := r.Intn(i + 1)
|
||||||
cards[i], cards[j] = cards[j], cards[i]
|
d.Cards[i], d.Cards[j] = d.Cards[j], d.Cards[i]
|
||||||
}
|
}
|
||||||
d.Cards = cards
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Deck) Scry(s int) []*Card {
|
func (d *Deck) Scry(s int) []*Card {
|
||||||
|
@ -28,6 +28,9 @@ func AddEffect(c *Card, e *Effect) {
|
|||||||
log.Println("Can't add effect to empty card")
|
log.Println("Can't add effect to empty card")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if c.Position < 0 {
|
||||||
|
log.Println("trying to apply effect to card not on the board")
|
||||||
|
}
|
||||||
for _, v := range c.Effects {
|
for _, v := range c.Effects {
|
||||||
if v.Owner == e.Owner && v.ID == e.ID && v.Target == e.Target {
|
if v.Owner == e.Owner && v.ID == e.ID && v.Target == e.Target {
|
||||||
log.Println("can't stack effects")
|
log.Println("can't stack effects")
|
||||||
|
@ -151,6 +151,8 @@ func (g *Game) StateChanges() {
|
|||||||
|
|
||||||
func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
|
func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
|
||||||
switch cmd {
|
switch cmd {
|
||||||
|
case "d":
|
||||||
|
Debug(g)
|
||||||
case "g":
|
case "g":
|
||||||
//game state
|
//game state
|
||||||
return NewView(id, g)
|
return NewView(id, g)
|
||||||
@ -160,8 +162,9 @@ func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
|
|||||||
//TODO check for ready on both accounts first
|
//TODO check for ready on both accounts first
|
||||||
g.SentinalPlayer.Hand = g.SentinalDeck.Cards[len(g.SentinalDeck.Cards)-5 : len(g.SentinalDeck.Cards)]
|
g.SentinalPlayer.Hand = g.SentinalDeck.Cards[len(g.SentinalDeck.Cards)-5 : len(g.SentinalDeck.Cards)]
|
||||||
g.SentinalDeck.Cards = g.SentinalDeck.Cards[0 : len(g.SentinalDeck.Cards)-5]
|
g.SentinalDeck.Cards = g.SentinalDeck.Cards[0 : len(g.SentinalDeck.Cards)-5]
|
||||||
|
|
||||||
g.ScourgePlayer.Hand = g.ScourgeDeck.Cards[len(g.ScourgeDeck.Cards)-5 : len(g.ScourgeDeck.Cards)]
|
g.ScourgePlayer.Hand = g.ScourgeDeck.Cards[len(g.ScourgeDeck.Cards)-5 : len(g.ScourgeDeck.Cards)]
|
||||||
g.SentinalDeck.Cards = g.ScourgeDeck.Cards[0 : len(g.ScourgeDeck.Cards)-5]
|
g.ScourgeDeck.Cards = g.ScourgeDeck.Cards[0 : len(g.ScourgeDeck.Cards)-5]
|
||||||
case "s":
|
case "s":
|
||||||
//start turn
|
//start turn
|
||||||
if g.Status == StatusReady { //first turn
|
if g.Status == StatusReady { //first turn
|
||||||
@ -255,13 +258,11 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
x := g.CardBuffer.Cards[x_i]
|
x := g.CardBuffer.Cards[x_i]
|
||||||
buf := g.CardBuffer
|
if x.Owner != g.CurrentTurn {
|
||||||
for i, v := range buf.Cards {
|
log.Println("drew a card from our deck that isn't our own")
|
||||||
if v == x {
|
|
||||||
buf.Cards = append(buf.Cards[:i], buf.Cards[i+1:]...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
currD.Bottom(buf.Cards)
|
g.CardBuffer.Cards = append(g.CardBuffer.Cards[:x_i], g.CardBuffer.Cards[x_i+1:]...)
|
||||||
|
currD.Bottom(g.CardBuffer.Cards)
|
||||||
curr.Hand = append(curr.Hand, x)
|
curr.Hand = append(curr.Hand, x)
|
||||||
g.CanDraw = false
|
g.CanDraw = false
|
||||||
g.HasDrawn = true
|
g.HasDrawn = true
|
||||||
@ -363,6 +364,9 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if x_i < 0 || x_i > len(curr.Hand) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
card := curr.Hand[x_i]
|
card := curr.Hand[x_i]
|
||||||
shouldPlace := true
|
shouldPlace := true
|
||||||
if g.GameBoard.CanPlay(g.CurrentTurn, card, y_i) {
|
if g.GameBoard.CanPlay(g.CurrentTurn, card, y_i) {
|
||||||
@ -383,3 +387,7 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Debug(g *Game) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user