public bool InSelectedCell(EncounterCard card) { if (fSelectedCell == Point.Empty) return false; int diff_index = fSelectedCell.X - 1; Difficulty diff = fColumns[diff_index]; int cat_index = fSelectedCell.Y - 1; CardCategory cat = fRows[cat_index]; return ((card.Category == cat) && (card.GetDifficulty(fDeck.Level) == diff)); }
public bool InSelectedCell(EncounterCard card) { if (this.fSelectedCell == Point.Empty) { return(false); } int x = this.fSelectedCell.X - 1; Difficulty item = this.fColumns[x]; int y = this.fSelectedCell.Y - 1; CardCategory cardCategory = this.fRows[y]; if (card.Category != cardCategory) { return(false); } return(card.GetDifficulty(this.fDeck.Level) == item); }
public static EncounterDeck BuildDeck(int level, List <string> categories, List <string> keywords) { build_creature_list(level - 2, level + 5, categories, keywords, false); if (fCreatures.Count == 0) { return(null); } Dictionary <CardCategory, Pair <int, int> > role_breakdown = new Dictionary <CardCategory, Pair <int, int> >(); role_breakdown[CardCategory.SoldierBrute] = new Pair <int, int>(0, 18); role_breakdown[CardCategory.Skirmisher] = new Pair <int, int>(0, 14); role_breakdown[CardCategory.Minion] = new Pair <int, int>(0, 5); role_breakdown[CardCategory.Artillery] = new Pair <int, int>(0, 5); role_breakdown[CardCategory.Controller] = new Pair <int, int>(0, 5); role_breakdown[CardCategory.Lurker] = new Pair <int, int>(0, 2); role_breakdown[CardCategory.Solo] = new Pair <int, int>(0, 1); Dictionary <Difficulty, Pair <int, int> > diff_breakdown = new Dictionary <Difficulty, Pair <int, int> >(); if (level >= 3) { diff_breakdown[Difficulty.Trivial] = new Pair <int, int>(0, 7); diff_breakdown[Difficulty.Easy] = new Pair <int, int>(0, 30); } else { diff_breakdown[Difficulty.Easy] = new Pair <int, int>(0, 37); } diff_breakdown[Difficulty.Moderate] = new Pair <int, int>(0, 8); diff_breakdown[Difficulty.Hard] = new Pair <int, int>(0, 5); diff_breakdown[Difficulty.Extreme] = new Pair <int, int>(0, 0); EncounterDeck deck = new EncounterDeck(); deck.Level = level; int attempts = 0; while (attempts < TRIES) { attempts += 1; // Pick a card int card_index = Session.Random.Next() % fCreatures.Count; EncounterCard card = fCreatures[card_index]; // Do we need a card of this type? CardCategory cat = card.Category; Pair <int, int> role_counts = role_breakdown[cat]; bool role_ok = (role_counts.First < role_counts.Second); if (!role_ok) { continue; } // Do we need a card of this level? Difficulty diff = card.GetDifficulty(level); Pair <int, int> diff_counts = diff_breakdown[diff]; bool level_ok = (diff_counts.First < diff_counts.Second); if (!level_ok) { continue; } // Add this card to the deck deck.Cards.Add(card); role_breakdown[cat].First += 1; diff_breakdown[diff].First += 1; if (deck.Cards.Count == 50) { break; } } FillDeck(deck); return(deck); }
public static EncounterDeck BuildDeck(int level, List <string> categories, List <string> keywords) { EncounterBuilder.build_creature_list(level - 2, level + 5, categories, keywords, false); if (EncounterBuilder.fCreatures.Count == 0) { return(null); } Dictionary <CardCategory, Pair <int, int> > cardCategories = new Dictionary <CardCategory, Pair <int, int> >(); cardCategories[CardCategory.SoldierBrute] = new Pair <int, int>(0, 18); cardCategories[CardCategory.Skirmisher] = new Pair <int, int>(0, 14); cardCategories[CardCategory.Minion] = new Pair <int, int>(0, 5); cardCategories[CardCategory.Artillery] = new Pair <int, int>(0, 5); cardCategories[CardCategory.Controller] = new Pair <int, int>(0, 5); cardCategories[CardCategory.Lurker] = new Pair <int, int>(0, 2); cardCategories[CardCategory.Solo] = new Pair <int, int>(0, 1); Dictionary <Difficulty, Pair <int, int> > difficulties = new Dictionary <Difficulty, Pair <int, int> >(); if (level < 3) { difficulties[Difficulty.Easy] = new Pair <int, int>(0, 37); } else { difficulties[Difficulty.Trivial] = new Pair <int, int>(0, 7); difficulties[Difficulty.Easy] = new Pair <int, int>(0, 30); } difficulties[Difficulty.Moderate] = new Pair <int, int>(0, 8); difficulties[Difficulty.Hard] = new Pair <int, int>(0, 5); difficulties[Difficulty.Extreme] = new Pair <int, int>(0, 0); EncounterDeck encounterDeck = new EncounterDeck() { Level = level }; int num = 0; do { Label0: if (num >= 100) { break; } num++; int num1 = Session.Random.Next() % EncounterBuilder.fCreatures.Count; EncounterCard item = EncounterBuilder.fCreatures[num1]; CardCategory category = item.Category; Pair <int, int> pair = cardCategories[category]; if (pair.First < pair.Second) { Difficulty difficulty = item.GetDifficulty(level); Pair <int, int> item1 = difficulties[difficulty]; if (item1.First < item1.Second) { encounterDeck.Cards.Add(item); Pair <int, int> first = cardCategories[category]; first.First = first.First + 1; Pair <int, int> first1 = difficulties[difficulty]; first1.First = first1.First + 1; } else { goto Label0; } } else { goto Label0; } }while (encounterDeck.Cards.Count != 50); EncounterBuilder.FillDeck(encounterDeck); return(encounterDeck); }