Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Evolve()
        {
            // any shift left?
            if (!CanEvolve)
            {
                return(false);
            }

            // increase pointer to next block height
            Pointer++;

            // set current shift to the actual shift we process
            //_currentShift = Shifts[Pointer];
            if (!Shifts.TryGetValue(Pointer, out _currentShift))
            {
                return(false);
            }

            if (Pointer % 180 == 0)
            {
                HomeTown.Shop.Resupply(_currentShift);
            }

            // we go for the adventure if there is one up
            if (Adventure != null && Adventure.CanEnter)
            {
                Adventure.Enter(this, _currentShift);
                return(true);
            }

            if (Adventure != null && Adventure.AdventureState == AdventureState.Completed && Adventure.Reward != null)
            {
                AddExp(Adventure.Reward.Exp);
                AddGold(Adventure.Reward.Gold);
            }

            Adventure   = null;
            MogwaiState = MogwaiState.HomeTown;

            // first we always calculated current lazy experience
            var lazyExp = Experience.GetExp(CurrentLevel, _currentShift);

            if (lazyExp > 0)
            {
                AddExp(Experience.GetExp(CurrentLevel, _currentShift));
            }

            if (!_currentShift.IsSmallShift)
            {
                // TODO remove this is only for debug
                Log.Info(_currentShift.ToString());

                switch (_currentShift.Interaction.InteractionType)
                {
                case InteractionType.Adventure:
                    // only alive mogwais can go to an adventure, finish adventure before starting a new one ...
                    if (CanAct && (Adventure == null || !Adventure.CanEnter))
                    {
                        Adventure = AdventureGenerator.Create(_currentShift,
                                                              (AdventureAction)_currentShift.Interaction);
                        Adventure.Enter(this, _currentShift);
                        MogwaiState = MogwaiState.Adventure;
                        return(true);
                    }

                    break;

                case InteractionType.Leveling:
                    var levelingAction = (LevelingAction)_currentShift.Interaction;
                    switch (levelingAction.LevelingType)
                    {
                    case LevelingType.Class:
                        LevelClass(levelingAction.ClassType);
                        break;

                    case LevelingType.Ability:
                        break;

                    case LevelingType.None:
                        break;
                    }

                    break;

                case InteractionType.Special:
                    var specialAction = (SpecialAction)_currentShift.Interaction;

                    if (SpecialAction(specialAction.SpecialType))
                    {
                        return(true);
                    }

                    break;
                }
            }

            // lazy health regeneration, only rest healing if he is not dieing and not dead
            // TODO check MogwaiState?
            if (MogwaiState == MogwaiState.HomeTown && !IsDying && !IsDead)
            {
                Heal(_currentShift.IsSmallShift ? 2 * CurrentLevel : CurrentLevel, HealType.Rest);
            }

            var activity = ActivityLog.Create(ActivityLog.ActivityType.Evolve, ActivityLog.ActivityState.None, new int[] { Pointer }, null);

            History.Add(LogType.Info, activity);

            // no more shifts to process, no more logging possible to the game log
            _currentShift = null;

            return(true);
        }