Exemplo n.º 1
0
        public InspectionResult Inspect(Character character)
        {
            var result = new InspectionResult
            {
                GuessedStats = RandomsHelper.GuessStats(character.Stats, Stats.Perception)
            };

            result.Response =
                $"You see a {LexicalHelper.GetStregthEpithet(result.GuessedStats.Strength)} " +
                $"{LexicalHelper.GetDescriptionString(result.GuessedStats.Race, result.GuessedStats.Gender)}.";

            if (Stats.Perception > 3)
            {
                if (character.Stats.IsDead)
                {
                    result.Response += $"\n{LexicalHelper.GenderPronoun(character.Stats.Gender)} seems to be dead.";
                }
                else
                {
                    result.Response += $"\n{LexicalHelper.GenderPronoun(character.Stats.Gender)} seems to be {character.CurrentAction}.";
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public ScreenInputProcessResult ProcessInput(ConsoleKey key)
        {
            var result = new ScreenInputProcessResult
            {
                RerenderFlag = true
            };

            var prevChar = _activeCharacter;

            _activeCharacter = Fight.Queue.First().Character;

            if (prevChar != _activeCharacter)
            {
                _gameLog.WriteLine($"{_activeCharacter.Name}'s turn.");

                Fight.BeginTurn(_activeCharacter);

                return(result);
            }

            var fightResult = _activeCharacter.FightComponent.Process(key);

            var fightUpdateResult = Fight.UpdateFight();

            fightUpdateResult.DeadChars.ForEach(c =>
            {
                _gameLog.WriteLine($"{c.Character.Name} ({c.Faction}) died.");
            });

            switch (fightUpdateResult.FightOutcome)
            {
            case FightOutcome.PlayerWin:
                _gameLog.WriteLine("");
                _gameLog.WriteLine(LexicalHelper.GetVictoryString());
                _gameLog.WriteLine("");

                result.SwitchState = GameState.World;
                Fight.PostFight();
                break;

            case FightOutcome.PlayerLose:
                _gameLog.WriteLine("");
                _gameLog.WriteLine(LexicalHelper.GetDefeatString());
                _gameLog.WriteLine("");

                result.SwitchState = GameState.GameOver;
                break;
            }

            if (fightResult.TurnEnd || _activeCharacter?.Stats.ActionPoints == 0)
            {
                Fight.EndCurrentTurn();
                _activeCharacter    = null;
                result.RerenderFlag = true;
                return(result);
            }

            return(result);
        }
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var user = this._userService.Get(workEvent.Data);

            if (!workEvent.ObjectId.HasValue)
            {
                throw new PmsException("Error in event model");
            }
            var item = this._workItemService.GetWithNoTracking(workEvent.ObjectId.Value);
            var text = GetStartText(forUser);

            text += IsUserAuthor ? $" {NotificationResources.HaveDisappointed} " : $" {NotificationResources.Disappointed} ";
            text += $"{LexicalHelper.GetWorkItemTypeInCase(item.Type, "a")} {item.GetWorkItemIdentityText()} c пользователя {user.GetUserIdentityText()}.";
            return(text);
        }
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var stateChangedModel = JsonConvert.DeserializeObject <StateChangedModel>(workEvent.Data);

            if (!workEvent.ObjectId.HasValue)
            {
                throw new PmsException("Error in event model");
            }
            var item = _workItemService.GetWithNoTracking(workEvent.ObjectId.Value);

            _isUserExecutor = workEvent.UserId == item.ExecutorId;
            var  user         = _userService.Get(workEvent.UserId);
            var  text         = GetStartText(user);
            bool needAddition = true;

            text += GetTextForStateChanging(stateChangedModel, item, ref needAddition);
            if (needAddition)
            {
                text += LexicalHelper.GetWorkItemTypeInCase(item.Type, "a") + " ";
            }
            text += item.GetWorkItemIdentityText() + ".";
            return(text);
        }
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var appointedUser = _userService.Get(workEvent.Data);

            if (appointedUser == null)
            {
                throw new PmsException("Invalid event data. Must be Id.");
            }
            var appointedUserText = appointedUser.Id == forUser.Id
                ? (IsUserAuthor ? " себе " : " вам ")
                : " пользователю " + appointedUser.GetUserIdentityText();

            if (!workEvent.ObjectId.HasValue)
            {
                throw new PmsException("Error in event model");
            }
            var user = _userService.Get(workEvent.UserId);
            var item = _workItemService.GetWithNoTracking(workEvent.ObjectId.Value);
            var text = GetStartText(user);

            text += IsUserAuthor ? $" {NotificationResources.HaveAppointed} " : $" {NotificationResources.Appointed} ";
            text += appointedUserText + $"{LexicalHelper.GetWorkItemTypeInCase(item.Type, "a")} {item.GetWorkItemIdentityText()}.";
            return(text);
        }
Exemplo n.º 6
0
        private string GetItemName(WorkItemType type, int i, WorkItem parent)
        {
            var name = (parent?.Name ?? "") + " " + LexicalHelper.GetWorkItemTypeInCase(type, "n") + i;

            return(name);
        }
Exemplo n.º 7
0
        public void UpdateCharacterSelectList(Character character)
        {
            IEnumerable <Character> applicableCharacters = character.CurrentScene.Characters;

            if (GameObject is Skill skill)
            {
                switch (skill.SkillType)
                {
                case SkillType.Melee:
                    applicableCharacters = applicableCharacters.Except(new[] { character });
                    break;

                case SkillType.Heal:
                    break;

                case SkillType.Projectile:
                    applicableCharacters = applicableCharacters.Except(new[] { character });
                    break;

                case SkillType.AreaOfEffect:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            var labels = applicableCharacters
                         .Select((c, i) =>
            {
                var text = c.Name;

                var verbosity = LexicalVerbosity.Poor;

                if (character.Stats.Perception >= 4)
                {
                    verbosity = LexicalVerbosity.Normal;
                }
                else if (character.Stats.Perception >= 6)
                {
                    verbosity = LexicalVerbosity.High;
                }
                else if (character.Stats.Perception >= 8)
                {
                    verbosity = LexicalVerbosity.VeryHigh;
                }

                if (character.Stats.Perception >= 2)
                {
                    text += $" ({LexicalHelper.GetHealthString(c.Stats.Health, c.Stats.MaxHealth, verbosity)})";
                }

                return(new UiLabel
                {
                    Text = text,
                    Row = i,
                    OnPress = (_, __) =>
                    {
                        if (GameObject is Skill appliedSkill)
                        {
                            var skillResult = character.ApplySkill(appliedSkill, c);
                            if (!skillResult.IsSuccess)
                            {
                                _gameLog.WriteLine(skillResult.Comment);
                            }
                            else
                            {
                                if (skillResult.Damage >= 0)
                                {
                                    _gameLog.WriteLine(
                                        $"You deal {skillResult.Damage} damage to {c.Name}."
                                        );
                                }
                                else
                                {
                                    _gameLog.WriteLine(
                                        $"You heal {c.Name} for {-skillResult.Damage} health points."
                                        );
                                }
                            }
                        }
                    }
                });
            })
        /// <summary>
        /// Внутренний метод получения описания события
        /// </summary>
        /// <param name="workEvent">Событие</param>
        /// <param name="forUser">Пользователь, для которого создается описание</param>
        /// <returns></returns>
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var item = this._workItemService.GetWithNoTracking(workEvent.ObjectId.Value);

            return($"{GetStartText(forUser)} {GetActionString()} {LexicalHelper.GetWorkItemTypeInCase(item.Type, "a")} {item.GetWorkItemIdentityText()}.");
        }
        private string GetTextForStateChanging(StateChangedModel stateChangedModel, WorkItem item, ref bool needAddition)
        {
            var oldState = stateChangedModel.Old;
            var newState = stateChangedModel.New;
            var text     = "";

            switch (newState)
            {
            case WorkItemState.New:
            case WorkItemState.Planned:
                text += IsUserAuthor ? $" {NotificationResources.HaveMovedToPlanned} " : $" {NotificationResources.MovedToPlanned} ";
                break;

            case WorkItemState.Done:
                if (oldState == WorkItemState.Reviewing)
                {
                    text        += IsUserAuthor ? $" {NotificationResources.HaveConfirmed} " : $" {NotificationResources.Confirmed} ";
                    text        += LexicalHelper.GetWorkItemTypeInCase(item.Type, "g") + " ";
                    needAddition = false;
                }
                else
                {
                    text += IsUserAuthor ? $" {NotificationResources.HaveFinished} " : $" {NotificationResources.Finished} ";
                }
                break;

            case WorkItemState.Deleted:
                text += IsUserAuthor ? $" {NotificationResources.HaveDeleted} " : $" {NotificationResources.Deleted} ";
                break;

            case WorkItemState.Archive:
                text += IsUserAuthor ? $" {NotificationResources.HaveMovedToArchive} " : $" {NotificationResources.MovedToArchive} ";
                break;

            case WorkItemState.Reviewing:
                if (_isUserExecutor)
                {
                    text += IsUserAuthor ? $" {NotificationResources.HaveMovedToChecking} " : $" {NotificationResources.MovedToChecking} ";
                }
                else
                {
                    text += IsUserAuthor ? $" {NotificationResources.HaveMoved} " : $" {NotificationResources.Moved} ";
                    text += NotificationResources.ToChecking + " ";
                }
                break;

            case WorkItemState.AtWork:
                if (oldState == WorkItemState.Planned)
                {
                    if (_isUserExecutor)
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveTook} " : $" {NotificationResources.Took} ";
                    }
                    else
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveMoved} " : $" {NotificationResources.Moved} ";
                        text += NotificationResources.ToWork + " ";
                    }
                }
                else
                {
                    if (_isUserExecutor)
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveMovedToRebuild} " : $" {NotificationResources.MovedToRebuild} ";
                    }
                    else
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveMoved} " : $" {NotificationResources.Moved} ";
                        text += NotificationResources.ToRebuild + " ";
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(newState), newState, null);
            }
            return(text);
        }