Merge branch 'oracle'

This commit is contained in:
stryan 2021-07-25 13:43:41 -04:00
commit a6f5eb607c
6 changed files with 308 additions and 421 deletions

View File

@ -1,19 +1,18 @@
package game
import (
"encoding/json"
"fmt"
)
type Board struct {
Sentinal [4]Card `json:"sentinal"`
Scourge [4]Card `json:"scourge"`
Sentinal [4]*Card `json:"sentinal"`
Scourge [4]*Card `json:"scourge"`
}
func NewBoard() *Board {
return &Board{
Sentinal: [4]Card{CreateCard(-1), CreateCard(-1), CreateCard(-1), CreateCard(-1)},
Scourge: [4]Card{CreateCard(-1), CreateCard(-1), CreateCard(-1), CreateCard(-1)},
Sentinal: [4]*Card{NewEmpty(0), NewEmpty(1), NewEmpty(2), NewEmpty(3)},
Scourge: [4]*Card{NewEmpty(0), NewEmpty(1), NewEmpty(2), NewEmpty(3)},
}
}
@ -21,35 +20,60 @@ func (b *Board) String() string {
return fmt.Sprintf("---------\n|%v|%v|%v|%v|\n---------\n|%v|%v|%v|%v|\n---------\n", b.Sentinal[0], b.Sentinal[1], b.Sentinal[2], b.Sentinal[3], b.Scourge[0], b.Scourge[1], b.Scourge[2], b.Scourge[3])
}
func (b *Board) GetRow(id int) []Card {
if id == 1 {
func (b *Board) GetRow(id int) []*Card {
if id == SentinalID {
return b.Sentinal[:]
} else {
return b.Scourge[:]
}
}
func (b *Board) GetCard(id int, pos int) *Card {
return b.GetRow(id)[pos]
}
func (b *Board) Remove(c *Card) {
for k, v := range b.Sentinal {
if v.Id == c.Id {
b.Sentinal[k] = NewEmpty(k)
}
}
for k, v := range b.Scourge {
if v.Id == c.Id {
b.Scourge[k] = NewEmpty(k)
}
}
}
func (b *Board) Empty(id int) bool {
res := true
if id == SentinalID {
for _, v := range b.Sentinal {
row := b.GetRow(id)
for _, v := range row {
if !v.Empty() {
res = false
}
}
} else {
for _, v := range b.Scourge {
if !v.Empty() {
res = false
}
}
}
return res
}
func (b *Board) CanMove(id, src, dest int) bool {
brd := b.GetRow(id)
if brd[src].Empty() {
return false
}
if !brd[dest].Empty() {
return false
}
if brd[src].Sick {
return false
}
return true
}
func (b *Board) Move(id, src, dest int) bool {
var brd [4]Card
if id == 1 {
var brd [4]*Card
if id == SentinalID {
brd = b.Sentinal
} else {
brd = b.Scourge
@ -60,13 +84,12 @@ func (b *Board) Move(id, src, dest int) bool {
if !brd[dest].Empty() {
return false
}
if brd[src].Acted() {
if brd[src].Sick {
return false
}
brd[dest].Act()
brd[dest] = brd[src]
brd[src] = CreateCard(-1)
if id == 1 {
brd[src] = NewEmpty(src)
if id == SentinalID {
b.Sentinal = brd
} else {
b.Scourge = brd
@ -75,54 +98,45 @@ func (b *Board) Move(id, src, dest int) bool {
}
func (b *Board) CanPlay(id int, c *Card, dest int) bool {
var brd [4]Card
if id == 1 {
brd = b.Sentinal
} else {
brd = b.Scourge
}
if !brd[dest].Empty() {
brd := b.GetRow(id)
if !brd[dest].Empty() || !c.Spell {
return false
}
return true
}
func (b *Board) Play(id int, c *Card, dest int) bool {
var brd [4]Card
if id == 1 {
brd = b.Sentinal
func (b *Board) Play(id int, c *Card, dest int, should bool) bool {
brd := b.GetRow(id)
if should {
brd[dest] = c
c.Position = dest
} else {
brd = b.Scourge
}
if !brd[dest].Empty() {
return false
}
brd[dest] = *c
if id == 1 {
b.Sentinal = brd
} else {
b.Scourge = brd
return true
}
func (b *Board) CanAttack(id, atk, def int) bool {
aBrd := b.GetRow(id)
if aBrd[atk].Empty() || aBrd[atk].Sick || atk != def {
return false
}
return true
}
func (b *Board) Attack(id int, atk, def int) int {
var aBrd [4]Card
var dBrd [4]Card
if id == 1 {
var aBrd [4]*Card
var dBrd [4]*Card
if id == SentinalID {
aBrd = b.Sentinal
dBrd = b.Scourge
} else {
aBrd = b.Scourge
dBrd = b.Sentinal
}
if aBrd[atk].Empty() || !aBrd[atk].CanAttack(atk, def) {
return -1
}
aBrd[atk].Act()
if dBrd[def].Empty() {
//health damage
if id == 1 {
if id == SentinalID {
b.Sentinal = aBrd
b.Scourge = dBrd
} else {
@ -132,29 +146,11 @@ func (b *Board) Attack(id int, atk, def int) int {
return 1
}
//Do actual battle math
attacker := aBrd[atk].Value()
defender := dBrd[def].Value()
dBrd[def].Acted()
//check atk buffs
for i, v := range aBrd {
if v.Value() == Two {
attacker = attacker + 1
}
if v.Value() == Three && (i == atk-1 || i == atk+1) {
attacker = attacker + 1
}
}
for i, v := range dBrd {
if v.Value() == Two {
defender = defender + 1
}
if v.Value() == Three && (i == def-1 || i == def+1) {
defender = defender + 1
}
}
attacker := aBrd[atk].Power
defender := dBrd[def].Power
if attacker > defender {
dBrd[def] = CreateCard(-1)
if id == 1 {
dBrd[def] = NewEmpty(def)
if id == SentinalID {
b.Sentinal = aBrd
b.Scourge = dBrd
} else {
@ -164,8 +160,8 @@ func (b *Board) Attack(id int, atk, def int) int {
return 0
}
if attacker == defender {
aBrd[atk] = CreateCard(-1)
dBrd[def] = CreateCard(-1)
aBrd[atk] = NewEmpty(atk)
dBrd[def] = NewEmpty(def)
if id == 1 {
b.Sentinal = aBrd
b.Scourge = dBrd
@ -178,35 +174,3 @@ func (b *Board) Attack(id int, atk, def int) int {
return -1
}
func (b *Board) MarshalJSON() ([]byte, error) {
res := [][]*PortableCard{{b.Sentinal[0].Port(), b.Sentinal[1].Port(), b.Sentinal[2].Port(), b.Sentinal[3].Port()}, {b.Scourge[0].Port(), b.Scourge[1].Port(), b.Scourge[2].Port(), b.Scourge[3].Port()}}
return json.Marshal(res)
}
func (b *Board) UnmarshalJSON(data []byte) (err error) {
var ported [][]PortableCard
err = json.Unmarshal(data, &ported)
if err != nil {
return err
}
for i := 0; i < 4; i++ {
c := NewCard(ported[0][i].Type, ported[0][i].ID)
if ported[0][i].Sick {
c.Act()
} else {
c.Refresh()
}
b.Sentinal[i] = c
}
for i := 0; i < 4; i++ {
c := NewCard(ported[1][i].Type, ported[1][i].ID)
if ported[1][i].Sick {
c.Act()
} else {
c.Refresh()
}
b.Scourge[i] = c
}
return
}

View File

@ -6,85 +6,22 @@ import (
"github.com/google/uuid"
)
type Card interface {
Cast(g *Game) *Game
Upkeep(g *Game) *Game
Endstep(g *Game) *Game
Enters(g *Game) *Game
Value() CardValue
Act()
Refresh()
Acted() bool
Empty() bool
String() string
CanAttack(int, int) bool
Port() *PortableCard
}
type GenericCard struct {
Val CardValue `json:"value"`
type Card struct {
Type CardType `json:"type"`
BasePower int `json:"base_power"`
Power int `json:"power"`
Id uuid.UUID `json:"id"`
Sick bool `json:"sick"`
Counters int `json:"counters"`
Owner int `json:"owner"`
Position int `json:"position"`
Spell bool `json:"spell"`
}
func (g *GenericCard) Cast(game *Game) *Game {
return nil
}
func (g *GenericCard) Enters(game *Game) *Game {
return nil
}
func (g *GenericCard) Upkeep(game *Game) *Game {
g.Sick = false
return nil
}
func (g *GenericCard) Endstep(game *Game) *Game {
return nil
}
func (g *GenericCard) Value() CardValue {
return g.Val
}
func (g *GenericCard) Acted() bool {
return g.Sick
}
func (g *GenericCard) Act() {
g.Sick = true
}
func (g *GenericCard) Refresh() {
fmt.Println("refreshed")
g.Sick = false
}
func (g *GenericCard) Empty() bool {
return false
}
func (g *GenericCard) String() string {
return fmt.Sprintf("%v", g.Val)
}
func (g *GenericCard) Port() *PortableCard {
return &PortableCard{
Type: int(g.Val),
ID: g.Id,
Sick: g.Sick,
}
}
func (g *GenericCard) CanAttack(x, y int) bool {
if x == y && !g.Sick {
return true
}
fmt.Println("sick")
return false
}
type CardValue int
type CardType int
const (
Valk CardValue = iota
Valk CardType = iota
Ace
Two
Three
@ -95,131 +32,50 @@ const (
Eight
)
const (
EmptyValue CardValue = -1
EmptyValue CardType = -1
)
func (c CardValue) String() string {
func (c CardType) String() string {
if c == -1 {
return " "
}
return []string{"V", "A", "2", "3", "4", "5", "6", "7", "8"}[c]
}
func CreateCard(v int) Card {
return NewCard(v, uuid.New())
}
func NewCard(v int, id uuid.UUID) Card {
switch v {
case -1:
return &EmptyCard{
&GenericCard{
Val: EmptyValue,
Id: id,
Sick: true,
},
func NewCard(v, o, p int, id uuid.UUID) *Card {
if id == uuid.Nil {
id = uuid.New()
}
case 1:
return &AceCard{
&GenericCard{
Val: Ace,
return &Card{
Type: CardType(v),
BasePower: OraclePower(CardType(v), nil),
Power: OraclePower(CardType(v), nil),
Id: id,
Sick: false,
},
Counters: 0,
Owner: o,
Position: p,
Spell: OracleSpell(CardType(v), nil),
}
case 4:
return &FourCard{
&GenericCard{
Val: Four,
Id: id,
Sick: true,
},
}
case 8:
return &EightCard{
&GenericCard{
Val: Eight,
Id: id,
Sick: true,
},
0,
}
case 0:
return &Valkyrie{
&GenericCard{
Val: Valk,
Id: id,
}
func NewEmpty(p int) *Card {
return &Card{
Type: EmptyValue,
BasePower: -1,
Power: -1,
Id: uuid.New(),
Sick: false,
},
}
default:
return &GenericCard{
Val: CardValue(v),
Id: id,
Sick: true,
}
Counters: 0,
Owner: -1,
Position: p,
}
}
type EmptyCard struct {
*GenericCard
func (c *Card) Empty() bool {
return c.Type == EmptyValue
}
func (e *EmptyCard) Empty() bool {
return true
}
type AceCard struct {
*GenericCard
}
type FourCard struct {
*GenericCard
}
func (f *FourCard) Enters(g *Game) *Game {
g.CanDraw = true
return g
}
type EightCard struct {
*GenericCard
Counters int `json:"counters"`
}
func (e *EightCard) CanAttack(x, y int) bool {
return false
}
func (e *EightCard) Upkeep(g *Game) *Game {
if e.Counters > 2 {
e = nil
}
return g
}
func (e *EightCard) Endstep(g *Game) *Game {
e.Counters = e.Counters + 1
return g
}
type Valkyrie struct {
*GenericCard
}
func (v *Valkyrie) Cast(g *Game) *Game {
g.GameBoard.Sentinal = [4]Card{CreateCard(-1), CreateCard(-1), CreateCard(-1), CreateCard(-1)}
g.GameBoard.Scourge = [4]Card{CreateCard(-1), CreateCard(-1), CreateCard(-1), CreateCard(-1)}
return g
}
func (v *Valkyrie) Enters(g *Game) *Game {
v = nil
return g
}
type PortableCard struct {
Type int `json:"type"`
ID uuid.UUID `json:"ID"`
Sick bool `json:"sick"`
func (c *Card) String() string {
return fmt.Sprintf("|%v|", c.Type)
}

View File

@ -1,14 +1,15 @@
package game
import (
"encoding/json"
"fmt"
"math/rand"
"time"
"github.com/google/uuid"
)
type Deck struct {
Cards []Card `json:"cards"`
Cards []*Card `json:"cards"`
}
func (d *Deck) String() string {
@ -18,11 +19,11 @@ func (d *Deck) String() string {
return fmt.Sprintf("|%v|", d.Cards)
}
func NewDeck() *Deck {
cards := []Card{CreateCard(0)}
func NewDeck(owner int) *Deck {
cards := []*Card{NewCard(0, owner, -1, uuid.Nil)}
for i := 0; i < 3; i++ {
for j := 1; j < 9; j++ {
cards = append(cards, Card(CreateCard(j)))
cards = append(cards, NewCard(j, owner, -1, uuid.Nil))
}
}
return &Deck{
@ -30,7 +31,7 @@ func NewDeck() *Deck {
}
}
func DeckFromCards(c []Card) *Deck {
func DeckFromCards(c []*Card) *Deck {
return &Deck{
Cards: c,
}
@ -46,11 +47,11 @@ func (d *Deck) Shuffle() {
d.Cards = cards
}
func (d *Deck) Scry(s int) []Card {
seen := []Card{}
func (d *Deck) Scry(s int) []*Card {
seen := []*Card{}
if len(d.Cards) < s {
seen = d.Cards
d.Cards = []Card{}
d.Cards = []*Card{}
return seen
}
seen = d.Cards[(len(d.Cards) - s):len(d.Cards)]
@ -58,38 +59,10 @@ func (d *Deck) Scry(s int) []Card {
return seen
}
func (d *Deck) Bottom(result []Card) {
func (d *Deck) Bottom(result []*Card) {
d.Cards = append(result, d.Cards...) //Should shuffle result first?
}
func (d *Deck) Size() int {
return len(d.Cards)
}
func (d *Deck) MarshalJSON() ([]byte, error) {
var ported []*PortableCard
for i, _ := range d.Cards {
ported = append(ported, d.Cards[i].Port())
}
return json.Marshal(ported)
}
func (d *Deck) UnmarshalJSON(data []byte) (err error) {
var ported []PortableCard
err = json.Unmarshal(data, &ported)
if err != nil {
return err
}
cards := []Card{}
for _, v := range ported {
c := NewCard(v.Type, v.ID)
if v.Sick {
c.Act()
} else {
c.Refresh()
}
cards = append(cards, c)
}
d.Cards = cards
return
}

View File

@ -2,6 +2,7 @@ package game
import (
"fmt"
"log"
"strconv"
"strings"
)
@ -24,7 +25,7 @@ const (
)
func (g GameStatus) String() string {
return []string{"Lobby", "Ready", "Playing", "Stopped"}[g]
return []string{"Lobby", "Ready", "Playing", "Stopped", "SentinalWin", "ScougeWin", "Draw"}[g]
}
type Game struct {
@ -41,8 +42,8 @@ type Game struct {
}
func NewGame() *Game {
deckA := NewDeck()
deckB := NewDeck()
deckA := NewDeck(SentinalID)
deckB := NewDeck(ScourgeID)
deckA.Shuffle()
deckB.Shuffle()
return &Game{
@ -52,7 +53,7 @@ func NewGame() *Game {
SentinalDeck: deckA,
ScourgeDeck: deckB,
CurrentTurn: 0, //start with no turn
CardBuffer: DeckFromCards([]Card{}),
CardBuffer: DeckFromCards([]*Card{}),
CanDraw: false,
HasDrawn: false,
Status: StatusLobby,
@ -167,11 +168,11 @@ func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
}
if id == SentinalID {
for _, v := range g.GameBoard.Sentinal {
v.Upkeep(g)
OracleUpkeep(v, g)
}
} else {
for _, v := range g.GameBoard.Scourge {
v.Upkeep(g)
OracleUpkeep(v, g)
}
}
case "e":
@ -179,14 +180,14 @@ func (g *Game) PlayerStateAct(id int, cmd string) *GameView {
if id != g.CurrentTurn {
return nil
}
g.CardBuffer = DeckFromCards([]Card{})
g.CardBuffer = DeckFromCards([]*Card{})
if id == SentinalID {
for _, v := range g.GameBoard.Sentinal {
v.Endstep(g)
OracleEndstep(v, g)
}
} else {
for _, v := range g.GameBoard.Scourge {
v.Endstep(g)
OracleEndstep(v, g)
}
}
if g.CurrentTurn == SentinalID {
@ -261,11 +262,12 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
}
x_i, _ := strconv.Atoi(cmd_s[1])
y_i, _ := strconv.Atoi(cmd_s[2])
res := g.GameBoard.Move(g.CurrentTurn, x_i, y_i)
if res {
if g.GameBoard.CanMove(g.CurrentTurn, x_i, y_i) {
OracleMove(g.GameBoard.GetCard(g.CurrentTurn, x_i), x_i, y_i, g)
g.GameBoard.Move(g.CurrentTurn, x_i, y_i)
return DeckFromCards(g.GameBoard.GetRow(g.CurrentTurn))
} else {
return DeckFromCards([]Card{})
return DeckFromCards([]*Card{})
}
case "a":
//attack
@ -277,15 +279,18 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
}
x_i, _ := strconv.Atoi(cmd_s[1])
y_i, _ := strconv.Atoi(cmd_s[2])
if g.GameBoard.CanAttack(g.CurrentTurn, x_i, y_i) {
OracleAttack(g.GameBoard.GetCard(g.CurrentTurn, x_i), g)
res := g.GameBoard.Attack(g.CurrentTurn, x_i, y_i)
if res == 1 {
opp.Life = opp.Life - 1
return DeckFromCards(g.GameBoard.GetRow(g.CurrentTurn))
} else if res == 0 {
return DeckFromCards(g.GameBoard.GetRow(g.CurrentTurn))
} else {
fmt.Println("can't attack")
return DeckFromCards([]Card{})
return DeckFromCards(g.GameBoard.GetRow(g.CurrentTurn))
}
} else {
log.Println("can't attack")
return DeckFromCards([]*Card{})
}
case "p":
//play: return player boad or [] if invalid
@ -299,17 +304,18 @@ func (g *Game) PlayerAct(id int, cmd string) *Deck {
x_i, _ := strconv.Atoi(cmd_s[1])
y_i, _ := strconv.Atoi(cmd_s[2])
card := curr.Hand[x_i]
if g.GameBoard.CanPlay(g.CurrentTurn, &card, y_i) {
curr.Hand[x_i].Cast(g)
shouldPlace := true
if g.GameBoard.CanPlay(g.CurrentTurn, card, y_i) {
shouldPlace = OracleCast(curr.Hand[x_i], g)
placed := g.GameBoard.Play(g.CurrentTurn, card, y_i, shouldPlace)
if placed {
OracleEnters(curr.Hand[x_i], g)
}
res := g.GameBoard.Play(g.CurrentTurn, &card, y_i)
if res {
curr.Hand[x_i].Enters(g)
curr.Hand = append(curr.Hand[:x_i], curr.Hand[x_i+1:]...)
return DeckFromCards(g.GameBoard.GetRow(g.CurrentTurn))
} else {
fmt.Println("couldn't play")
return DeckFromCards([]Card{})
return DeckFromCards([]*Card{})
}
default:
fmt.Println("Invalid act command")

144
internal/game/oracle.go Normal file
View File

@ -0,0 +1,144 @@
package game
import "log"
func OracleUpkeep(c *Card, g *Game) {
switch c.Type {
case Eight:
c.Sick = true
if c.Counters > 3 {
g.GameBoard.Remove(c)
}
default:
c.Sick = false
}
return
}
func OracleSpell(c CardType, g *Game) bool {
switch c {
case Valk:
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 Ace:
c.Sick = false
case Two:
//+1 to all
if c.Owner == SentinalID {
for _, v := range g.GameBoard.Sentinal {
v.Power = v.Power + 1
}
} else if c.Owner == ScourgeID {
for _, v := range g.GameBoard.Scourge {
v.Power = v.Power + 1
}
} else {
log.Println("Trying to lookup an ETB when card not on field")
}
case Three:
//+1 around it
if c.Owner == SentinalID {
if c.Position-1 >= 0 {
g.GameBoard.Sentinal[c.Position-1].Power = g.GameBoard.Sentinal[c.Position-1].Power + 1
}
if c.Position+1 <= 3 {
g.GameBoard.Sentinal[c.Position+1].Power = g.GameBoard.Sentinal[c.Position+1].Power + 1
}
}
if c.Owner == ScourgeID {
if c.Position-1 >= 0 {
g.GameBoard.Scourge[c.Position-1].Power = g.GameBoard.Scourge[c.Position-1].Power + 1
}
if c.Position+1 <= 3 {
g.GameBoard.Scourge[c.Position+1].Power = g.GameBoard.Scourge[c.Position+1].Power + 1
}
}
}
return
}
func OracleLeaves(c *Card, g *Game) {
switch c.Type {
case Two:
//remove +1 to all
if c.Owner == SentinalID {
for _, v := range g.GameBoard.Sentinal {
v.Power = v.Power - 1
}
} else if c.Owner == ScourgeID {
for _, v := range g.GameBoard.Scourge {
v.Power = v.Power - 1
}
} else {
log.Println("Trying to lookup an LTB when card not on field")
}
case Three:
//+1 around it
if c.Owner == SentinalID {
if c.Position-1 >= 0 {
g.GameBoard.Sentinal[c.Position-1].Power = g.GameBoard.Sentinal[c.Position-1].Power - 1
}
if c.Position+1 <= 3 {
g.GameBoard.Sentinal[c.Position+1].Power = g.GameBoard.Sentinal[c.Position+1].Power - 1
}
}
if c.Owner == ScourgeID {
if c.Position-1 >= 0 {
g.GameBoard.Scourge[c.Position-1].Power = g.GameBoard.Scourge[c.Position-1].Power - 1
}
if c.Position+1 <= 3 {
g.GameBoard.Scourge[c.Position+1].Power = g.GameBoard.Scourge[c.Position+1].Power - 1
}
}
}
return
}
func OracleEndstep(c *Card, g *Game) {
switch c.Type {
case Eight:
c.Counters = c.Counters + 1
}
return
}
func OraclePower(c CardType, g *Game) int {
return int(c)
}
func OracleMove(c *Card, src, dest int, g *Game) {
c.Sick = true
switch c.Type {
case Three:
row := g.GameBoard.GetRow(c.Owner)
row[src-1].Power = row[src-1].Power - 1
row[src+1].Power = row[src+1].Power - 1
row[dest-1].Power = row[dest-1].Power + 1
row[dest+1].Power = row[dest+1].Power + 1
}
}
func OracleAttack(c *Card, g *Game) {
c.Sick = true
}

View File

@ -1,17 +1,9 @@
package game
import (
"encoding/json"
"fmt"
"log"
"github.com/google/uuid"
)
type Player struct {
Name string `json:"name"`
Id int `json:"id"`
Hand []Card `json:"hand"` //probably should be a Deck
Hand []*Card `json:"hand"`
Life int `json:"life"`
}
@ -19,55 +11,7 @@ func NewPlayer(name string, id int) *Player {
return &Player{
Name: name,
Id: id,
Hand: []Card{},
Hand: []*Card{},
Life: 3,
}
}
func (p *Player) MarshalJSON() ([]byte, error) {
var ported_hand []*PortableCard
for i, _ := range p.Hand {
ported_hand = append(ported_hand, p.Hand[i].Port())
}
res := []interface{}{p.Name, p.Id, ported_hand, p.Life}
return json.Marshal(res)
}
func (p *Player) UnmarshalJSON(data []byte) (err error) {
ported := []interface{}{}
err = json.Unmarshal(data, &ported)
if err != nil {
return err
}
fmt.Println(ported)
p.Name = ported[0].(string)
p.Id = int(ported[1].(float64))
var tmp []interface{}
if ported[2] != nil {
tmp = ported[2].([]interface{})
} else {
tmp = []interface{}{}
}
p.Life = int(ported[3].(float64))
hand := []Card{}
for _, v := range tmp {
m := v.(map[string]interface{})
t := int(m["type"].(float64))
i := m["ID"].(string)
b := m["sick"].(bool)
uid, err := uuid.Parse(i)
if err != nil {
log.Println("invalid card parse")
} else {
c := NewCard(t, uid)
if b {
c.Act()
} else {
c.Refresh()
}
hand = append(hand, c)
}
}
p.Hand = hand
return
}