public static UpgradeResults UpgradeTroops(PartyVM partyVm, PartyScreenLogic partyScreenLogic)
        {
            UpgradeResults results = new UpgradeResults();

            List <PartyCharacterVM> upgradableTroops = GetUpgradeableTroops(partyVm);

            if (upgradableTroops.IsEmpty())
            {
                Global.Helpers.Message("No troops available to upgrade");
                return(results);
            }

            List <Tuple <PartyCharacterVM, PartyScreenLogic.PartyCommand> > commands = PrepareUpgradeCommands(upgradableTroops, partyScreenLogic, ref results);

            if (results.UpgradedTotal == 0)
            {
                Global.Helpers.Message(results.MultiPathSkipped > 0
                                           ? $"No troops upgraded. {results.MultiPathSkipped} troop types with multi-path upgrades were skipped. To prevent any skipping enable split upgrades and disable player decision in the settings"
                                           : "No troops upgraded");
            }
            else
            {
                ExecuteCommands(commands, partyVm, partyScreenLogic);
            }

            return(results);
        }
        // Something wrong with upgrade
        private static List <Tuple <PartyCharacterVM, PartyScreenLogic.PartyCommand> > PrepareUpgradeCommands(IEnumerable <PartyCharacterVM> upgradableTroops, PartyScreenLogic partyScreenLogic, ref UpgradeResults upgradeResults)
        {
            List <Tuple <PartyCharacterVM, PartyScreenLogic.PartyCommand> > commands = new List <Tuple <PartyCharacterVM, PartyScreenLogic.PartyCommand> >();

            AvailableResources availableResources = new AvailableResources();

            foreach (PartyCharacterVM troops in upgradableTroops)
            {
                List <(int, PartyScreenLogic.PartyCommand.UpgradeTargetType)> upgradesPerTypes =
                    new List <(int maxUpgradableTroops, PartyScreenLogic.PartyCommand.UpgradeTargetType upgradeTargetType)> {
                    (int.MaxValue, PartyScreenLogic.PartyCommand.UpgradeTargetType.UpgradeTarget1)
                };

                if (HasTwoUpgradePaths(troops) && !YapoSettings.Instance.PlayerDecision && !MultipathUpgradeLogic.TryGetUpgradePaths(troops, out upgradesPerTypes))
                {
                    upgradeResults.MultiPathSkipped++;
                    continue;
                }

                foreach ((int maxUpgradableTroops, PartyScreenLogic.PartyCommand.UpgradeTargetType upgradeTargetType)upgradesPerType in upgradesPerTypes)
                {
                    int troopsToUpgrade = CalculateCountOfTroopsThatCanBeUpgraded(availableResources, troops, partyScreenLogic, upgradesPerType);
                    if (troopsToUpgrade == 0)
                    {
                        continue;
                    }

                    upgradeResults.UpgradedTypes++;
                    upgradeResults.UpgradedTotal += troopsToUpgrade;

                    PartyScreenLogic.PartyCommand upgradeCommand = new PartyScreenLogic.PartyCommand();
                    upgradeCommand.FillForUpgradeTroop(troops.Side, troops.Type, troops.Character, troopsToUpgrade, upgradesPerType.upgradeTargetType);
                    commands.Add(new Tuple <PartyCharacterVM, PartyScreenLogic.PartyCommand>(troops, upgradeCommand));

                    availableResources.UpdateAvailableResources(troops, troopsToUpgrade, (int)upgradesPerType.upgradeTargetType);
                }
            }

            return(commands);
        }