public void RandomDeck(CardCollection cards, int cardNumber=15) { Random random = new Random(); deckOriginal = new List<Card>(); for (int i = 0; i < cardNumber; i++) { deckOriginal.Add(cards.Cards[random.Next(0, cards.Cards.Count - 1)].Clone()); } this.Init(); }
public void LoadFromFiles(String cardPath = null, String playersPath = null) { if (cardPath == null) cardPath = @"Cartas.csv"; if (playersPath == null) playersPath = @"Players.csv"; cards = new CardCollection(); cards.ReadFromFile(cardPath); HelperCsv fichero = new HelperCsv(playersPath); Player player; oponentes = new List<Player>(); for (int i = 0; i < fichero.Count; i++) { player = new Player(); player.LoadFromCsv(fichero, i, this.cards); oponentes.Add(player); } }
public void LoadFromCsv(HelperCsv csv, int line, CardCollection cards) { this.deckOriginal = new List<Card>(); this.Id = line; this.Name = csv[line, "Name"]; //this.HitPoints = Convert.ToInt32(csv[line, "Hitpoints"]); Card card = null; string[] carta; for(int i = 1; i < 16; i++) { carta = csv[line, "Card" + i.ToString()].Split(';'); int level = 0; if (carta.Length > 1) level = Convert.ToInt32(carta[1]); card = cards.GetCard(carta[0], level); if (card != null) this.deckOriginal.Add(card); } this.deckOriginal = deckOriginal.OrderBy(x => x.Id).ToList(); string hero = csv[line, "Hero"]; SetHero(hero); }