Esempio n. 1
0
        public void HandleInput(string input)
        {
            input = input.Trim();
            if (status != InterpreterState.Standard)
            {
                Initialize(input);
                return;
            }
            input = input.ToLower();
            string[] inputArgs   = input.Split(' ');
            string   command     = inputArgs[0].ToLower();
            string   commandargs = input.Substring(command.Length).Trim();;

            if (inputArgs.Length >= 1)
            {
                ActionArgs a   = null;
                string     arg = input.Remove(0, command.Length);
                try
                {
                    ActionBuilder builder = Player.GetAction(command);
                    if (builder != null)
                    {
                        a = builder.TranslateArgs(Player, input);
                    }

                    if (builder != null && a != null)
                    {
                        CharacterAction act = builder.BuildAction(a);
                        if (act != null)
                        {
                            if (act is TargetedAction && ((TargetedAction)act).Target == null)
                            {
                                Player.NotifyPlayer("Targeted actions must have a valid target");
                                return;
                            }
                            Player.Room.AddActionToQueue(builder.BuildAction(a));
                        }
                    }
                }catch (ArgumentException ex) {
                    Player.NotifyPlayer(ex.Message);
                }
            }
            if (Commands.ContainsKey(command))
            {
                Commands[command](commandargs);
            }
        }