mirror of
https://github.com/HexCardGames/HexDeck.git
synced 2025-09-05 11:18:38 +02:00
🎉 🚧 Start working on backend
This commit is contained in:
31
backend/decks/decks.go
Normal file
31
backend/decks/decks.go
Normal file
@ -0,0 +1,31 @@
|
||||
package decks
|
||||
|
||||
import (
|
||||
"github.com/HexCardGames/HexDeck/types"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
func DeckFromInterface(cardDeckId int, cardDeck bson.D) types.CardDeck {
|
||||
bsonBytes, _ := bson.Marshal(cardDeck)
|
||||
|
||||
switch cardDeckId {
|
||||
case 0:
|
||||
deck := Classic{}
|
||||
bson.Unmarshal(bsonBytes, &deck)
|
||||
return &deck
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CardFromInterface(cardDeckId int, card bson.D) types.Card {
|
||||
bsonBytes, _ := bson.Marshal(card)
|
||||
|
||||
switch cardDeckId {
|
||||
case 0:
|
||||
deck := ClassicCard{}
|
||||
bson.Unmarshal(bsonBytes, &deck)
|
||||
return &deck
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user