maybe don't give sentinal scourges deck huh

This commit is contained in:
stryan 2021-07-26 14:19:05 -04:00
parent 6eb24636e5
commit d8777b0dda
3 changed files with 22 additions and 12 deletions

View File

@ -20,12 +20,13 @@ func (d *Deck) String() string {
}
func NewDeck(owner int) *Deck {
cards := []*Card{NewCard(0, owner, -1, uuid.Nil)}
cards := []*Card{}
for i := 0; i < 3; i++ {
for j := 1; j < 9; j++ {
cards = append(cards, NewCard(j, owner, -1, uuid.Nil))
}
}
cards = append(cards, NewCard(0, owner, -1, uuid.Nil))
return &Deck{
Cards: cards,
}
@ -38,13 +39,11 @@ func DeckFromCards(c []*Card) *Deck {
}
func (d *Deck) Shuffle() {
cards := d.Cards
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := range cards {
for i := range d.Cards {
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 {

View File

@ -28,6 +28,9 @@ func AddEffect(c *Card, e *Effect) {
log.Println("Can't add effect to empty card")
return
}
if c.Position < 0 {
log.Println("trying to apply effect to card not on the board")
}
for _, v := range c.Effects {
if v.Owner == e.Owner && v.ID == e.ID && v.Target == e.Target {
log.Println("can't stack effects")

View File

@ -151,6 +151,8 @@ func (g *Game) StateChanges() {
func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
switch cmd {
case "d":
Debug(g)
case "g":
//game state
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
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.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":
//start turn
if g.Status == StatusReady { //first turn
@ -255,13 +258,11 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
return nil
}
x := g.CardBuffer.Cards[x_i]
buf := g.CardBuffer
for i, v := range buf.Cards {
if v == x {
buf.Cards = append(buf.Cards[:i], buf.Cards[i+1:]...)
}
if x.Owner != g.CurrentTurn {
log.Println("drew a card from our deck that isn't our own")
}
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)
g.CanDraw = false
g.HasDrawn = true
@ -363,6 +364,9 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
log.Println(err)
return nil
}
if x_i < 0 || x_i > len(curr.Hand) {
return nil
}
card := curr.Hand[x_i]
shouldPlace := true
if g.GameBoard.CanPlay(g.CurrentTurn, card, y_i) {
@ -383,3 +387,7 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
}
return nil
}
func Debug(g *Game) {
return
}