public static CardList ProduceDeck(CardPool CP, DeckSpec DS) { CardList resultList = new CardList(); foreach (KeyValuePair <string, int> cardEntry in DS.Cards) { for (int i = 0; i < cardEntry.Value; i++) { resultList.AddCard(CardLoading.ProduceCard(cardEntry.Key, CP)); } } return(resultList); }
public static void LoadDeckSpec(DeckSpec DS) { TextAsset DeckSpecXML = Resources.Load("DeckSpec") as TextAsset; System.IO.StringReader DeckSpecReader = new System.IO.StringReader(DeckSpecXML.text); XmlReader xmlReader = XmlReader.Create(DeckSpecReader); while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "card") { int number = 0; if (int.TryParse(xmlReader["number"], out number) == true) { DS.SetEntry(xmlReader["name"], number); } else { Debug.Log("Non integer number in Deck spec"); } } } }