private void OnAddCount(SpousesSelectTroopsItemVM troopItem) { if (troopItem.CurrentAmount < troopItem.MaxAmount && this._currentTotalSelectedTroopCount < this._maxSelectableTroopCount) { int num = 1; if (this.IsEntireStackModifierActive) { num = Math.Min(troopItem.MaxAmount - troopItem.CurrentAmount, this._maxSelectableTroopCount - this._currentTotalSelectedTroopCount); } else if (this.IsFiveStackModifierActive) { num = Math.Min(Math.Min(troopItem.MaxAmount - troopItem.CurrentAmount, this._maxSelectableTroopCount - this._currentTotalSelectedTroopCount), 5); } troopItem.CurrentAmount += num; this._currentTotalSelectedTroopCount += num; } this.OnCurrentSelectedAmountChange(); }
private void InitList() { this.Troops = new MBBindingList <SpousesSelectTroopsItemVM>(); this._currentTotalSelectedTroopCount = 0; foreach (TroopRosterElement current in MobileParty.MainParty.MemberRoster) { if (current.Number - current.WoundedNumber > 0) { SpousesSelectTroopsItemVM manageHideoutTroopItemVM = new SpousesSelectTroopsItemVM(current, new Action <SpousesSelectTroopsItemVM>(this.OnAddCount), new Action <SpousesSelectTroopsItemVM>(this.OnRemoveCount)); manageHideoutTroopItemVM.IsLocked = !this._canChangeChangeStatusOfTroop(current.Character); this.Troops.Add(manageHideoutTroopItemVM); int troopCount = this._initialRoster.GetTroopCount(current.Character); if (troopCount > 0) { manageHideoutTroopItemVM.CurrentAmount = troopCount; this._currentTotalSelectedTroopCount += troopCount; } } } }