The Cardobject describes a crowd-control card. A Card is represented by a nested go-struct which contains all necessary data including effects and abilities. Addidtional functions provided allow to retrieve a build-instruction, an unmarshaling-method and the validation of a card. It also provides a shortened Version, the KeywordedCard which can be resolved to a full Card.
- An instruction on how to build a card is provided in form of a json-schema.
- A card-json can be unmarshaled and validated to a Card.
- The schema that describes to a frontend how to build a card is provided by the CardSchema()-function.
- The schema that describes to a frontend how to build a keyworded card is provided by the KeywordedSchema()-function.
- The UnmarshalRaw()-method takes a Card in form of a json and returns a Card or an error.
- This process involves validating the Card.
- Example:
import "github.com/DecentralCardGame/cardobject"
data, _ := ioutil.ReadFile("card.json")
card, err := cardobject.UnmarshalRaw(data)
- The UnmarshalKeyworded()-method takes a KeywordedCard in form of a json and returns a Card or an error.
- This process involves resolving and validating the KeywordedCard and validating the resulting Card.
- Example:
import "github.com/DecentralCardGame/cardobject"
data, _ := ioutil.ReadFile("KeywordedCard.json")
card, err := cardobject.UnmarshalKeyworded(data)
- Cards can be marshaled using the go-json package.
- Example:
import "encoding/json"
cardJSON, error := json.Marshal(card)