private int GetActivationPoints(Deck.DeckType type) { if (IsSingleCountryDeckType(type)) { return(database.GetActivationPoints(typeToCountry[type])); } else { return(database.GetDefaultActivationPoints()); } }
public List <WargameUnit> FilterByDeckType(List <WargameUnit> units, Deck.DeckType type) { if (IsSingleCountryDeckType(type)) { return(units.Where(unit => unit.Category == Categories.NAVAL || unit.Country == typeToCountry[type].ToString()).ToList()); } else { return(units.Where(unit => !unit.IsPrototype).ToList()); } }
public List <WargameUnit> LoadUnits(Deck.DeckType type) { List <WargameUnit> units; if (bluforDecks.Contains(type)) { units = database.GetOtanUnits(); } else { units = database.GetPactUnits(); } return(FilterOutTransports(units)); }
private void InitCardCountChecker(Deck.DeckType type) { unitsAndTransports = LoadUnits(type); unitsAndTransports = FilterInvalidUnits(unitsAndTransports); unitsAndTransports = FilterByDeckType(unitsAndTransports, type); HashSet <WargameUnit> transports = new HashSet <WargameUnit>(); foreach (var unit in unitsAndTransports) { foreach (var transport in unit.Transports) { transports.Add(transport); } } unitsAndTransports.AddRange(transports); }
public CardView(Card card, Deck currentDeck) { InitializeComponent(); this.card = card; FillCardView(); // fill deck picker with deck names DeckPicker.Items.Add("Add New Deck"); foreach (Deck deck in App.Decks) { DeckPicker.Items.Add(deck.Name); } DeckPicker.SelectedIndexChanged += Deck_Changed; // set deck picker's selected index if (currentDeck == null) { DeckPicker.SelectedIndex = 0; } else { int currentDeckIndex = DeckPicker.Items.IndexOf(currentDeck.Name); DeckPicker.SelectedIndex = currentDeckIndex; } // determine deck limit and type through card type if (card.Type.Contains("G Unit")) { deckLimit = 16; deckType = Deck.DeckType.G; } else if (card.Type.Contains("Other")) { deckLimit = 0; deckType = Deck.DeckType.OTHER; } else { deckLimit = 50; deckType = Deck.DeckType.DECK; } }
private bool IsSingleCountryDeckType(Deck.DeckType type) { return(type != Deck.DeckType.Blufor && type != Deck.DeckType.Redfor); }
public Deck GenerateDeck(Deck.DeckType type) { deck = new Deck(type); List <WargameUnit> units = LoadUnits(type); units = FilterInvalidUnits(units); units = FilterByDeckType(units, type); foreach (var unit in units) { RemoveNavalTransports(unit); } CategorizeUnitsAndApplyRestrictions(units); InitAddedUnits(units); InitCardCountChecker(type); foreach (var unitPoolCategory in unitPool) { InitUnitWeights(unitPoolCategory.Value.AvailableUnits); } int activationPoints = GetActivationPoints(type); costMatrix = database.GetCostMatrix(); UsedActivationPoints = 0; AddCommander(); AddCommander(); unitPool[Categories.LOGISTICS].AvailableUnits.RemoveAll(unit => unit.IsCommander); AddFob(); while (CanDrawAnotherCard()) { Categories category = ChooseCategory(); if (unitPool[category].AvailableUnits.Count == 0 || costMatrix[category].Count == 0 || costMatrix[category].First() + UsedActivationPoints > activationPoints) { unitPool.Remove(category); } else { WargameUnit selectedUnit = DrawCard(unitPool[category].AvailableUnits); AddUnitToDeck(selectedUnit, deck); UpdateDeckCost(category, costMatrix); } } List <WargameUnit> navalUnits = LoadUnits(type); navalUnits = FilterByDeckType(navalUnits, type); navalUnits = navalUnits.Where(unit => unit.Cards > 0 && unit.AvailableVeterancy.Count > 0 && unit.Specializations.Count > 0 && unit.Year > 1900 && (unit.Category == Categories.NAVAL || HasNavalTransport(unit))).ToList(); InitUnitWeights(navalUnits); foreach (var unit in navalUnits) { unit.Transports.RemoveAll(t => t.Category != Categories.NAVAL && !HasNavalTransport(t)); } while (navalUnits.Count > 0 && costMatrix[Categories.NAVAL].Count > 0) { WargameUnit navalUnit = DrawCard(navalUnits); AddUnitToDeck(navalUnit, deck); UpdateDeckCost(Categories.NAVAL, costMatrix); } return(deck); }