public void StartExplorer(int stage)
        {
            var stageData  = _explorer.GetStage(stage);
            var staticData = _explorer.Stages[stage];

            //UpdateExplorerSlots();
            foreach (var temp in _units.State.LastTeam)
            {
                var data = _units.GetUnit(temp.Key).data;
                data.ExplorerPosition = temp.Value;
                data.Reserve          = false;
            }

            if (_units.ExplorerUnits.Length == 0)
            {
                throw new Exception("The number of selected units in exploration should be: 0 < count < 3");
            }
            if (!stageData.IsUnlock)
            {
                throw new Exception($"Stage is locked. stage_id = {stage}");
            }
            if (stageData.DailyNumber <= 0)
            {
                throw new Exception($"Ended up trying for today. stage_id = {stage}.");
            }
            if (!staticData.NoExit)
            {
                stageData.DailyNumber--;
            }
            _scorers.Spend(staticData.Price, _formula);
            _explorerLogic.StartExplorer(stage);
            LogicLog.SetExplorer(stage, LogExplorerType.Start);
        }
        public ILogicDictionary <int, long> GetScrorerMap(int id, int stageId)
        {
            var staticData = _scorers.Static.Scorers[id];

            if (staticData == null)
            {
                Logger.Error($"No scorer for id = {id}", this);
                return(null);
            }
            id = staticData.Id;
            ILogicDictionary <int, long> values;

            switch (staticData.Domain)
            {
            case ScorerType.Common:
                values = _scorers.State.Values;
                break;

            case ScorerType.Impact:
                values = _scorers.State.ImpactValues;
                break;

            case ScorerType.Battle:
                values = _scorers.State.BattleValues;
                break;

            case ScorerType.Level:
                if (stageId == 0)
                {
                    stageId = _explorer.CurrentStage;
                }
                if (stageId == -1)
                {
                    Logger.Error($"Trying to read counter for stage outside explorer. id = {id}", this);
                    return(null);
                }
                var stage = _explorer.GetStage(stageId);
                values = stage.Values;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (!values.ContainsKey(staticData.Id))
            {
                values[staticData.Id] = 0;
            }
            return(values);
        }
        public override void Execute(IImpactChangeMana data)
        {
            //if (_battle.State.Data == null)
            //{
            //    throw new Exception("ImpactManaExecutor Битва не запущена");
            //}
            var manaId = _scorers.ManaId;
            var value  = (int)_logic.Calculate(data.Value);

            if (!_explorer.State.IsRun)
            {
                Logger.Error("Attempting to record mana for stage outside of explorer", this);
                return;
            }
            var stage = _explorer.GetStage(_explorer.CurrentStage);

            stage.Values.TryGetValue(manaId, out var scorer);

            if (data.Oversize)
            {
                value = (int)scorer + value;
            }
            else
            {
                value = Mathf.Min((int)scorer + value, _settings.Settings.PlayerSettings.ManaMax);
                value = Mathf.Max(value, 0);
            }
            stage.Values[manaId] = value;
        }
        public void SpendManaAction(int value)
        {
            var stage = _explorer.GetStage(_explorer.CurrentStage);

            stage.Values.TryGetValue(_scorers.ManaId, out var scorer);
            value = Mathf.Min((int)scorer + value, _settings.Settings.PlayerSettings.ManaMax);
            if (value < 0)
            {
                throw new Exception($"Unable to summon the ability. Not enough mana. present value = {scorer} value for calling an ability = {value}");
            }
            stage.Values[_scorers.ManaId] = value;
        }
Exemple #5
0
        public void StageAutowin(int selectedStageId, int tryCount)
        {
            var stage     = _explorer.Stages[selectedStageId];
            var stageData = _explorer.GetStage(stage.Id);

            for (var i = 0; i < tryCount; i++)
            {
                _explorer.SetCurrentStage(selectedStageId);
                Impact.ExecuteImpact(stage.ImpactAutowin);
                Scorers.Spend(stage.Price, Formula);
                _explorer.ClearCurrentStage();
                LogicLog.SetExplorer(selectedStageId, LogExplorerType.AutoWin);
            }

            stageData.DailyNumber = Mathf.Clamp(stageData.DailyNumber - tryCount, 0, int.MaxValue);
        }
Exemple #6
0
        public void StartExplorer(int stageId)
        {
            var stageData = _explorer.GetStage(stageId);

            _explorer.SetCurrentStage(stageId);
            _explorer.State.PlayerBuffs.Clear();

            foreach (var id in stageData.ObjectAvailibility.Select(x => x.Key).ToList())
            {
                var staticData = _explorer.Static.Objects[id];
                if (staticData.Revert)
                {
                    stageData.ObjectAvailibility.Remove(id);
                }
            }


            _scorersLogic.ClearTemporaryScorers();
            var maxStamina = 0;

            foreach (var unitId in _units.ExplorerUnits)
            {
                var(data, def) = _units.GetUnit(unitId);
                maxStamina    += _units.CalculateMaxStamina(unitId);
                foreach (var perk in data.PerkStars)
                {
                    var charges = _units.CalculatePerkCharges(unitId, perk.Key);
                    data.PerkCharges[perk.Key] = charges;
                }
                //_context.SetContextFormula(unitId);
                //data.CurrentHp = (float)_units.CalculateMaxHp(data, _formula).Value;
            }
            foreach (var data in _units.State.Units)
            {
                if (data.Stars > 0)
                {
                    _context.SetContextFormula(data.Id);
                    data.CurrentHp = (float)_units.CalculateMaxHp(data, _formula).Value;
                }
            }

            _context.SetContextFormula(null);
            stageData.Values[_scorers.StaminaId] = maxStamina;
        }
Exemple #7
0
        public override void Execute(IImpactStageAccess data)
        {
            var stage = _explorer.GetStage(data.StageId);

            switch (data.Access)
            {
            case AccessType.Lock:
                stage.IsUnlock = false;
                break;

            case AccessType.Unlock:
                stage.IsUnlock    = true;
                stage.DailyNumber = _settings.Settings.PlayerSettings.StageDailyNumber;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            LogicLog.StageAccess(data.StageId, data.Access);
        }