コード例 #1
0
        public ViewModelWindowFactionLearningPointsDonation([NotNull] Action callbackCloseWindow)
        {
            this.callbackCloseWindow = callbackCloseWindow;

            var faction             = FactionSystem.ClientCurrentFaction;
            var factionPublicState  = Faction.GetPublicState(faction);
            var factionPrivateState = Faction.GetPrivateState(faction);

            this.toLevel = (byte)(factionPublicState.Level + 1);
            this.UpdateCostLearningPoints = FactionConstants.SharedGetFactionUpgradeCost(
                toLevel: this.toLevel);

            this.FactionAccumulatedLearningPointsForUpgrade = factionPrivateState.AccumulatedLearningPointsForUpgrade;

            this.LearningPointsToDonateMax
                = (ushort)Math.Max(0,
                                   this.UpdateCostLearningPoints
                                   - factionPrivateState.AccumulatedLearningPointsForUpgrade);

            this.PlayerAvailableLearningPoints = ClientComponentTechnologiesWatcher.CurrentTechnologies.LearningPoints;
            this.LearningPointsToDonateMax     = (ushort)Math.Min(this.LearningPointsToDonateMax,
                                                                  this.PlayerAvailableLearningPoints);

            this.LearningPointsToDonateSelected = Math.Min(this.LearningPointsToDonateMax, (ushort)10);

            if (this.LearningPointsToDonateMax == 0)
            {
                // no need to donate anything as the required amount of LP is already present
                FactionSystem.ClientUpgradeFactionLevel(learningPointsDonation: 0,
                                                        this.toLevel);
                callbackCloseWindow();
            }
        }
コード例 #2
0
 private void ExecuteCommandDonate()
 {
     this.callbackCloseWindow.Invoke();
     FactionSystem.ClientUpgradeFactionLevel(this.LearningPointsToDonateSelected, this.toLevel);
 }