Пример #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);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="blockHeight"></param>
        public bool Evolve(out GameLog history)
        {
            // any shift left?
            if (!Shifts.ContainsKey(Pointer + 1))
            {
                history = null;
                return(false);
            }

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

            // set current shift to the actual shift we process
            currentShift = Shifts[Pointer];

            // assign game log for this shift
            history = currentShift.History;

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

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

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

            Adventure = null;


            if (!currentShift.IsSmallShift)
            {
                switch (currentShift.Interaction.InteractionType)
                {
                case InteractionType.ADVENTURE:
                    Adventure = AdventureGenerator.Create(currentShift, (AdventureAction)currentShift.Interaction);
                    break;

                case InteractionType.LEVELING:
                    Console.WriteLine("Received a leveling action!");
                    break;

                default:
                    break;
                }
            }

            // lazy health regeneration
            if (MogwaiState == MogwaiState.NONE)
            {
                Heal(currentShift.IsSmallShift ? 2 * CurrentLevel : CurrentLevel, HealType.REST);
            }

            History.Add(LogType.INFO, $"Evolved {Name} shift ¬G{Pointer}§!¬");

            // no more shifts to proccess, no more logging possible to the game log
            currentShift = null;

            return(true);
        }