Exemple #1
0
        public void Handle(Interpretation interpretation, Engine engine)
        {
            var output = engine.GetSystem <OutputSystem>();

            output.AddLog($"Command: {interpretation.Command}");

            if (interpretation.Specifier != null)
            {
                output.AddLog($"Specifier: {interpretation.Specifier}");
            }

            output.AddLog($"Primaries:");

            if (interpretation.Primary.Count > 0)
            {
                foreach (var currPrimary in interpretation.Primary)
                {
                    var line = currPrimary.UserInput + ": ";

                    foreach (var currCandidate in currPrimary.Candidates)
                    {
                        line += currCandidate + ", ";
                    }

                    output.AddLog(line);
                }
            }

            output.AddLog($"Secondaries:");

            if (interpretation.Secondary.Count > 0)
            {
                foreach (var currSecondary in interpretation.Secondary)
                {
                    var line = currSecondary.UserInput + ": ";

                    foreach (var currCandidate in currSecondary.Candidates)
                    {
                        line += currCandidate + ", ";
                    }

                    output.AddLog(line);
                }
            }

            output.AddLog("");

            if (interpretation.Primary.Count == 0)
            {
                return;
            }

            var target = interpretation.Primary[0];

            var targetingSystem = engine.GetSystem <TargetingSystem>();

            targetingSystem.Filter(target, _playerId, TargetingFilter.CurrentRoom | TargetingFilter.ContainerIsOpen | TargetingFilter.NotHeldByPlayer);
            targetingSystem.Validate(target);

            if (target.Error != null)
            {
                output.AddLog("Validation error: " + target.Error);
            }
            else
            {
                output.AddLog("Validation successful!");
            }
        }
Exemple #2
0
 public virtual void Handle(Interpretation interpretation, Engine engine)
 {
 }