/// <summary> Cretes a new preset from the given list of vehicles. </summary> /// <param name="nation"> The preset's nation. </param> /// <param name="mainBranch"> The preset's main branch. </param> /// <param name="battleRating"> The preset's battle rating. </param> /// <param name="vehicleList"> The vehicle list to use for initialization. </param> public Preset(ENation nation, EBranch mainBranch, string battleRating, IList <IVehicle> vehicleList) : base(vehicleList) { Nation = nation; MainBranch = mainBranch; BattleRating = battleRating; }
/// <summary> Maintains branch selection when switching between nations, unless the branch is not implemented in which case selection is reset to the first available branch. </summary> /// <param name="sender"> Not used. </param> /// <param name="routedEventArguments"> Event arguments. <see cref="SelectionChangedEventArgs"/> are expected. </param> private void OnTabChange(object sender, RoutedEventArgs routedEventArguments) { if (routedEventArguments.OriginalSource is TabControl && routedEventArguments is SelectionChangedEventArgs selectionChangedEventArguments && selectionChangedEventArguments.AddedItems.OfType <TabItem>().First() is TabItem newTabItem) { if (newTabItem.Tag is ENation selectedNation) { _currentNation = selectedNation; if (_currentBranch.IsValid()) { var nationControl = _nationControls[_currentNation]; var branchTab = nationControl.BranchTabs[_currentBranch]; if (branchTab.IsEnabled) { nationControl.TabControl.SelectedItem = branchTab; } else { nationControl.TabControl.SelectedItem = nationControl.BranchTabs.Values.First(branch => branch.IsEnabled); } } } if (newTabItem.Tag is EBranch selectedBranch) { _currentBranch = selectedBranch; } } }
/// <summary> Creates a new filter specification with the given parameters. </summary> /// <param name="nation"> The nation. </param> /// <param name="nation"> Countries that have vehicles in service with the nation. </param> /// <param name="branches"> Branches of the nation. </param> /// <param name="crewSlots"> Available crew slots for the nation. </param> public NationSpecification(ENation nation, IEnumerable <ECountry> countries, IEnumerable <EBranch> branches, int crewSlots) { Nation = nation; Countries = countries; Branches = branches; CrewSlots = crewSlots; }
/// <summary> Cretes a new preset from the given list of vehicles. </summary> /// <param name="nation"> The preset's nation. </param> /// <param name="gameMode"> The preset's game mode. </param> /// <param name="mainBranch"> The preset's main branch. </param> /// <param name="economicRank"> The preset's <see cref="IVehicle.EconomicRank"/>. </param> /// <param name="battleRating"> The preset's battle rating. </param> /// <param name="vehicleList"> The vehicle list to use for initialisation. </param> public Preset(EGameMode gameMode, ENation nation, EBranch mainBranch, int economicRank, string battleRating, IList <IVehicle> vehicleList) : base(vehicleList) { GameMode = gameMode; Nation = nation; MainBranch = mainBranch; EconomicRank = economicRank; BattleRating = battleRating; Branches = this.Select(vehicle => vehicle.Branch).Distinct(); }
/// <summary> Returns the base country of the given playable <paramref name="nation"/>. </summary> /// <param name="nation"> The playable nation whose base country to return. </param> /// <returns></returns> public static ECountry GetBaseCountry(this ENation nation) { var presetCountry = nation switch { ENation.Usa => ECountry.Usa, ENation.Germany => ECountry.NaziGermany, ENation.Ussr => ECountry.Ussr, ENation.GreatBritain => ECountry.GreatBritain, ENation.Japan => ECountry.EmpireOfJapan, ENation.China => ECountry.China, ENation.Italy => ECountry.Italy, ENation.France => ECountry.France, ENation.Sweden => ECountry.Sweden, _ => ECountry.None, }; if (presetCountry == ECountry.None && nation.ToString().TryParseEnumeration <ECountry>(out var parsedCountry)) { return(parsedCountry); } return(presetCountry); }
/// <summary> Selects valid economic ranks from <paramref name="enabledEconomicRanks"/> based on <paramref name="economicRanksWithVehicles"/></summary> /// <param name="enabledEconomicRanks"> Economic ranks enabled via GUI (as battle ratings). </param> /// <param name="economicRanksWithVehicles"> Economic ranks that have vehicles after application of previous filters. </param> /// <param name="getFormattedBattleRating"> A function to get a formatted battle rating from an economic rank. </param> /// <param name="nation"> The nation. </param> /// <param name="mainBranch"> The main branch. </param> /// <returns></returns> private IEnumerable <int> GetEconomicRanks(IEnumerable <int> enabledEconomicRanks, IEnumerable <int> economicRanksWithVehicles, Func <int, string> getFormattedBattleRating, ENation nation, EBranch mainBranch) { var validEconomicRanks = enabledEconomicRanks.Intersect(economicRanksWithVehicles); if (validEconomicRanks.IsEmpty()) { var minimumBattleRating = getFormattedBattleRating(enabledEconomicRanks.Min()); var maximumBattleRating = getFormattedBattleRating(enabledEconomicRanks.Max()); LogWarn(EOrganizationLogMessage.NoVehiclesAvailableForSelectedBattleRatings.Format(minimumBattleRating, maximumBattleRating, mainBranch, nation)); return(null); } return(validEconomicRanks); }
public NationTagPair(ENation nation, EVehicleBranchTag tag) { Nation = nation; Tag = tag; }
public FlagControl(ENation nation, Thickness margin, MouseButtonEventHandler mouseDownHandler, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center, double?panelWidth = null, bool setTag = true) { InitializeComponent(); Initialise(nation, margin, mouseDownHandler, horizontalAlignment, panelWidth, setTag); }
public NationAvailablityPair(ENation nation, EVehicleAvailability availability) { Nation = nation; Availability = availability; }
/// <summary> Returns the enumeration item representing selection of all countries serving with the given nation. </summary> /// <param name="nation"> The nation whose item to get. </param> /// <returns></returns> public static ECountry GetAllCountriesItem(this ENation nation) => nation switch {
public NationSubclassPair(ENation nation, EVehicleSubclass subclass) { Nation = nation; Subclass = subclass; }
public static Image CreateFlag(this ENation nation, Style flagStyle, Thickness margin, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left) { return(new NationCountryPair(nation, ECountry.None).CreateFlag(flagStyle, margin, true, horizontalAlignment: horizontalAlignment)); }
/// <summary> Checks whether the given <paramref name="nation"/> has any <see cref="ECountry"/> items enabled or not. </summary> /// <param name="nation"> The nation to check. </param> /// <returns></returns> public bool NationHasCountriesEnabled(ENation nation) => EnabledCountriesByNations.TryGetValue(nation, out var countries) && countries.Any();
/// <summary> Checks whether the nation is valid. </summary> /// <param name="nation"> The nation to check. </param> /// <returns></returns> public static bool IsValid(this ENation nation) => nation.EnumerationItemValueIsPositive();
/// <summary> Initializes the class with the given values. </summary> /// <param name="nation"> The nation. </param> /// <param name="country"> The country. </param> private void Initialise(ENation nation, ECountry country) { Nation = nation; Country = country; }
/// <summary> Focuses on a research tree by given parameters. </summary> /// <param name="nation"> The nation whose <paramref name="branch"/> to put into focus. </param> /// <param name="branch"> The branch to put into focus. </param> public void FocusResearchTree(ENation nation, EBranch branch) => Owner.FocusResearchTree(nation, branch);
/// <summary> Disables all nation and branch tabs of the research tree not specified in the parameters. </summary> /// <param name="nation"> The nation tab to keep enabled. </param> /// <param name="branches"> Branch tabs to keep enabled. </param> public void EnableOnly(ENation nation, IEnumerable <EBranch> branches) => Owner.EnableOnly(nation, branches);
/// <summary> Displays a message that no vehicles suit the criteria with additional information. </summary> /// <param name="nation"> The nation. </param> /// <param name="mainBranch"> The branch. </param> public void ShowNoVehicles(ENation nation, EBranch mainBranch) => Owner.ShowNoVehicles(nation, mainBranch);
/// <summary> Checks whether a research tree for the given <paramref name="nation"/> exists. </summary> /// <param name="dictionary"> The dictionary of research trees indexed by nations. </param> /// <param name="nation"> The nation to check. </param> /// <returns></returns> public static bool Has(this IDictionary <ENation, ResearchTree> dictionary, ENation nation) => dictionary.TryGetValue(nation, out var researchTree) && researchTree is ResearchTree && researchTree.Any();
public static IEnumerable <NationCountryPair> GetNationCountryPairs(this ENation nation) => EReference.CountriesByNation.TryGetValue(nation, out var countries) ? countries.Select(country => new NationCountryPair(nation, country)) : new List <NationCountryPair>();
/// <summary> Creates a new nation-country pair. </summary> /// <param name="nation"> The nation. </param> /// <param name="country"> The country. </param> public NationCountryPair(ENation nation, ECountry country) { Initialise(nation, country); }
/// <summary> Creates a new nation-branch pair. </summary> /// <param name="nation"> The nation. </param> /// <param name="branch"> The branch. </param> public NationBranchPair(ENation nation, EBranch branch) { Nation = nation; Branch = branch; }
public NationClassPair(ENation nation, EVehicleClass vehicleClass) { Nation = nation; Class = vehicleClass; }
/// <summary> Returns all countries that have vehicles serving with the given nation. </summary> /// <param name="nation"> The nation to search by. </param> /// <returns></returns> public static IEnumerable <ECountry> GetCountries(this ENation nation) => EReference.CountriesByNation.TryGetValue(nation, out var countries) ? countries : new List <ECountry>();