public void RemoveUnwantedTargets(ref Dictionary <String, HoningNode <String> > comboByTargets, ref Dictionary <String, CardObject> cardTable, ref List <String> targets, String abilityKey) { List <String> keys = new List <string>(); foreach (String sKey in comboByTargets.Keys) { CardObject card = cardTable[sKey]; CardAbility ability = ExtractAbilityObject(ref card, abilityKey); if (!ListCheck(ref targets, ref ability.target)) { keys.Add(sKey); } } foreach (String key in keys) { comboByTargets.Remove(key); } }
public CardAbility ExtractAbilityObject(ref CardObject card, String ability) { if (card == null) { return(null); } CardAbility toExtract = null; foreach (CardAbility ab in card.abilities) { if (ab.ability == ability) { toExtract = ab; break; } } return(toExtract); }
public HSCardsParser(String path) { objects = new Dictionary <string, List <CardObject> >(); // Le arquivo json e retorna string inteira da rede String json = System.IO.File.ReadAllText(path); // Ler json com dados da rede dynamic stuff = JObject.Parse(json); foreach (dynamic cardSet in stuff) { foreach (dynamic card in cardSet) { // bool collectible = false; dynamic abValue = null; try { // collectible = card.collectible; abValue = card.abilities; // do stuff with x } catch (RuntimeBinderException) { // MyProperty doesn't exist } //if (collectible == false) // continue; List <CardAbility> abilities = new List <CardAbility>(); if (abValue != null) { foreach (dynamic ability in card.abilities) { CardAbility cardAb = new CardAbility(); cardAb.ability = ability.ability; cardAb.value = ability.value; foreach (String t in ability.target) { cardAb.target.Add(t); } abilities.Add(cardAb); } } String race = card.race; String type = card.type; String id = card.id; String name = card.name; String text = card.text; String cost = card.cost; String attack = card.attack; String health = card.health; String hero = card.playerClass; if (hero == null) { hero = "Neutral"; } if (!objects.ContainsKey(hero)) { objects.Add(hero, new List <CardObject>()); } List <CardObject> l = objects[hero]; CardObject newobj = new CardObject(); newobj.type = type; newobj.race = race; newobj.id = id; newobj.name = name; newobj.text = text; newobj.cost = cost; newobj.attack = attack; newobj.health = health; newobj.hero = hero; newobj.abilities = abilities; //---------------- To Lowernormalization if (newobj.type != null) { newobj.type = newobj.type.ToLower(); } if (newobj.race != null) { newobj.race = newobj.race.ToLower(); } if (newobj.id != null) { newobj.id = newobj.id.ToLower(); } if (newobj.name != null) { newobj.name = newobj.name.ToLower(); } if (newobj.text != null) { newobj.text = newobj.text.ToLower(); } if (newobj.cost != null) { newobj.cost = newobj.cost.ToLower(); } if (newobj.attack != null) { newobj.attack = newobj.attack.ToLower(); } if (newobj.health != null) { newobj.health = newobj.health.ToLower(); } if (newobj.hero != null) { newobj.hero = newobj.hero.ToLower(); } foreach (CardAbility c in newobj.abilities) { c.ability = c.ability.ToLower(); c.value = c.value.ToLower(); for (int i = 0; i < c.target.Count; i++) { c.target[i] = c.target[i].ToLower(); } } //----------------- To Lowernormalization l.Add(newobj); } // end card } //end card set }// end constructor