public void Initialize(String json) { card = new CardJSON(json); }
public void Initialize(CardJSON card) { this.card = card; }
/// <summary> /// Add card to collection from JSON (string) parameters. /// Adds or updates a card in your collection, based on data passed as parameters. /// It is intended to be used to load data from JSON files and store it as cards/locales in your collection. /// </summary> /// <param name="card">JSON card data for card (mainly strings)</param> /// <param name="set">Set which card is related to</param> /// <param name="locale">Locale of the texts from the card</param> /// <param name="filename">File name of the picture used as background for card</param> /// <param name="race">Localized text for card race, if necessary</param> /// <param name="useDefault">Use default image if no filename is given</param> public void Add(CardJSON card, CardSet set, Locales locale, string filename, string race = "", bool useDefault = true) { // If card already stored, add new texts only if necessary CardItem item; if (Cards.TryGetValue(card.Id, out item)) { // If locale is not included, add it if (!item.hasLocale(locale)) { item.addLocale(locale, card.Name, card.Text, race); } } else // Add new card { // Take JSON values var _type = General.getCustomCardType(card.Type); var _class = General.getCardClass(card.PlayerClass); var _race = General.getCardRace(card.Race); var _rarity = General.getCardRarity(card.Rarity); // Create card from them item = new CardItem(card.Id, card.Cost, card.Attack, card.Health, card.Durability, _type, _class, _race, set, _rarity, filename, useDefault); // Add localized texts item.addLocale(locale, card.Name, card.Text, race); // Add it to collection Cards.Add(card.Id, item); } // If locale not included in locales, include it if (!Languages.ContainsKey(locale)) { Languages.Add(locale, General.getShortLocale(locale)); } }