//action roll back
 public ActionError RollBack(ActionInput input)
 {
     for (int i = 0; i < this.m_vecActions.Length; i++)
     {
         CAction action = ActionManager.sInstance.GetAction(this.m_vecActions[i]);
         if (action != null)
         {
             ActionError error = action.RollBack(input);
             if (error != null && error.code != ACTION_ERROR_CODE.NONE)
                 return error;
         }
     }
     return ActionError.NoError;
 }
Example #2
0
        /// <summary>Checks against the guards for the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            var commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            // Rule: The initiator must be currently immobilized.
            immobileEffect = actionInput.Actor.FindBehavior <ImmobileEffect>();
            if (immobileEffect == null)
            {
                return("You are not immobile, so what is the point of struggling?");
            }

            return(null);
        }
Example #3
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender     = actionInput.Controller;
            Thing       potionItem = new Thing(new PotionBehavior()
            {
                PotionType = "health",
                Modifier   = 30,
                MaxSips    = 50,
                SipsLeft   = 50,
                Duration   = new TimeSpan(0, 0, 15),
            });

            sender.Thing.Parent.Children.Add(potionItem);

            var userControlledBehavior = sender.Thing.Behaviors.FindFirst <UserControlledBehavior>();

            userControlledBehavior.Controller.Write("You create a colourful potion");
        }
Example #4
0
        /// <summary>Checks against the guards for the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            string commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            PreprocessInput(actionInput);

            if (!parseSucceeded || parsedBufferLength > 100 || parsedBufferLength < -1)
            {
                return("The screen buffer must be between 0 and 100 lines, or 'auto'.");
            }

            return(null);
        }
Example #5
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender  = actionInput.Controller;
            Session     session = sender as Session;

            if (session == null)
            {
                sender.Write("There is no valid session for this command.");
            }
            else if (session.Connection.OutputBuffer.HasMoreData)
            {
                session.Connection.ProcessBuffer(BufferDirection.Repeat);
            }
            else
            {
                sender.Write("There is no more data");
            }
        }
Example #6
0
        /// <summary>Checks against the guards for the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            string commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            // Rule: The initiator must be currently immobilized.
            this.immobileEffect = actionInput.Controller.Thing.Behaviors.FindFirst <ImmobileEffect>();
            if (this.immobileEffect == null)
            {
                return("You are not immobile, so what is the point of struggling?");
            }

            return(null);
        }
Example #7
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var userControlledBehavior = player.Behaviors.FindFirst <UserControlledBehavior>();

            userControlledBehavior.SecurityRoles |= role;

            var ob = new OutputBuilder();

            ob.AppendLine($"{player.Name} has been granted the {role.ToString()} role.");
            ob.AppendLine($"{player.Name} is now: {userControlledBehavior.SecurityRoles}.");
            actionInput.Controller.Write(ob);

            ob.Clear();
            ob.AppendLine($"You have been granted the {role.ToString()} role.");
            userControlledBehavior.Controller.Write(ob);

            player.FindBehavior <PlayerBehavior>()?.SavePlayer();
        }
Example #8
0
 void UpdateShieldInput()
 {
     //Shield Key pressed
     if (Input.GetButtonDown("Keyboard_Shield"))
     {
         shieldAction = true;
         if (!character.IsGrounded)
         {
             ActionInput actionInput = new ActionInput(InputType.Shield);
             character.ActionInput(actionInput);
         }
     }
     if (Input.GetButtonUp("Keyboard_Shield"))
     {
         shieldAction = false;
     }
     character.ShieldHold(Input.GetButton("Keyboard_Shield"));
 }
Example #9
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender = actionInput.Controller;

            if (sender != null && sender.Thing != null)
            {
                PlayerBehavior playerBehavior = sender.Thing.Behaviors.FindFirst <PlayerBehavior>();
                if (playerBehavior != null)
                {
                    playerBehavior.SetPassword(this.NewPassword);
                    sender.Write("Password successfully changed.");
                }
                else
                {
                    sender.Write("Unexpected error occurred changing password, please contact admin.");
                }
            }
        }
Example #10
0
        /// <summary>Checks against the guards for the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            string commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            // Rule: the sender must be capable of sensing/perceiving things.
            this.sensesBehavior = actionInput.Controller.Thing.Behaviors.FindFirst <SensesBehavior>();
            if (this.sensesBehavior == null)
            {
                return("You are incapable of perceiving anything.");
            }

            return(null);
        }
Example #11
0
        /// <summary>Prepare for, and determine if the command's prerequisites have been met.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            var commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            // Check to see if the first word is a number.
            // If so, shunt up the positions of our other params.
            var itemParam   = 0;
            var numberWords = actionInput.Params.Length;

            if (int.TryParse(actionInput.Params[0], out numberToGive))
            {
                itemParam = 1;

                // If the user specified a number, but it is less than 1, error!
                if (numberToGive < 1)
                {
                    return("You can't give less than 1 of something.");
                }

                // Rule: We should now have at least 3 items in our words array.
                // (IE "give 10 coins to Karak" or "give 10 coins Karak")
                if (numberWords < 3)
                {
                    return("You must specify something to give, and a target.");
                }
            }

            // The next parameter should be the item name (possibly pluralized).
            var itemName = actionInput.Params[itemParam];

            // Do we have an item matching the name in our inventory?
            thing = actionInput.Controller.Thing.FindChild(itemName.ToLower());
            if (thing == null)
            {
                return("You do not hold " + itemName + ".");
            }

            // The final argument should be the target name.
            var targetName = actionInput.Params[^ 1];
Example #12
0
        /// <summary>Checks against the guards for the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            IController sender        = actionInput.Controller;
            string      commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            string targetName = actionInput.Tail.Trim().ToLower();

            // Rule: if 2 params
            if (actionInput.Params.Length == 2)
            {
                int.TryParse(actionInput.Params[0], out this.numberToDrop);

                if (this.numberToDrop == 0)
                {
                    targetName = actionInput.Tail.ToLower();
                }
                else
                {
                    targetName = actionInput.Tail.Remove(0, actionInput.Params[0].Length).Trim().ToLower();
                }
            }

            // Rule: Did the initiator look to drop something?
            if (targetName == string.Empty)
            {
                return("What did you want to drop?");
            }

            this.parent = sender.Thing.Parent;

            // Rule: Is the target an item in the entity's inventory?
            this.thing = sender.Thing.Children.Find(t => t.Name.Equals(targetName, StringComparison.CurrentCultureIgnoreCase));
            if (this.thing == null)
            {
                return("You do not hold " + targetName + ".");
            }

            return(null);
        }
Example #13
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender = actionInput.Controller;

            string[] normalizedParams = this.NormalizeParameters(sender);
            string   role             = normalizedParams[0];
            string   playerName       = normalizedParams[1];

            Thing player = GameAction.GetPlayerOrMobile(playerName);

            if (player == null)
            {
                // If the player is not online, then load the player from the database
                //player = PlayerBehavior.Load(playerName);
            }

            // Rule: Does the player exist in our Universe?
            // @@@ TODO: Add code to make sure the player exists.

            /* @@@ FIX
             * if (Extensions.Contains(player.Roles, role))
             * {
             *  var roleRepository = new RoleRepository();
             *
             *  // @@@ TODO: The role.ToUpper is a hack. Need to create a case insensitive method for the RoleRepository.NoGen.cs class.
             *  RoleRecord record = roleRepository.GetByName(role.ToUpper());
             *  RoleRecord toDelete = null;
             *
             *  foreach (var currRole in player.RoleRecords)
             *  {
             *      if (currRole.Name == record.Name)
             *      {
             *          toDelete = currRole;
             *      }
             *  }
             *
             *  player.RoleRecords.Remove(toDelete);
             *  player.RoleRecords.TrimExcess();
             *  player.UpdateRoles();
             *  player.Save();
             *
             *  sender.Write(string.Format("{0} had the {1} role revoked.", player.Name, role), true);
             * }*/
        }
Example #14
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            if (!string.IsNullOrEmpty(actionInput.Tail))
            {
                // Save tail as player's new prompt
                try
                {
                    playerBehavior.Prompt = actionInput.Tail;
                }
                catch (Exception)
                {
                    actionInput.Controller.Write(new OutputBuilder().AppendLine("Error, prompt not saved."));
                }

                return;
            }

            // No new prompt supplied, so we display help and current values to the player
            var output = new OutputBuilder();

            // Create an array of values available to the player
            output.AppendLine($"{"Token".PadRight(15)}{"Current Value".PadRight(15)}{"Description".PadRight(40)}");
            output.AppendLine($"{"-----".PadRight(15)}{"-------------".PadRight(15)}{"-----------".PadRight(40)}");

            // Discover all methods with the promptable attribute in the adapter
            foreach (var m in playerBehavior.GetType().GetMethods())
            {
                var promptAttr = m.GetCustomAttributes(typeof(PlayerPromptableAttribute), false);
                if (promptAttr.Length > 0)
                {
                    var tokenInfo = (PlayerPromptableAttribute)promptAttr[0];

                    // Invoke the method to get current values
                    var currentValue = (string)m.Invoke(playerBehavior, new object[] { });

                    output.AppendLine($"{tokenInfo.Token.PadRight(15)}{currentValue.PadRight(15)}{tokenInfo.Description.PadRight(40)}");
                }
            }

            output.AppendLine($"Current prompt is '{playerBehavior.Prompt}'");
            output.AppendLine($"Parsed prompt is '{playerBehavior.BuildPrompt()}'");
            actionInput.Controller.Write(output);
        }
    protected override void Update()
    {
        float gyroZ = ActionInput.GetJoyconGyro().z *moveSpeed *Time.deltaTime * 60f;

        foreach (Transform child in transform)
        {
            // 子要素の歯車を回転させる
            child.transform.Rotate(0f, 0f, -gyroZ * 20f);
        }

        if (Mathf.Abs(moveDistance + gyroZ) > moveDistanceMax)
        {
            gyroZ = (gyroZ > 0) ? moveDistanceMax - moveDistance : -(moveDistanceMax + moveDistance);
        }

        moveDistance       += gyroZ;
        transform.position += new Vector3(gyroZ * Mathf.Cos(moveAngle), gyroZ * Mathf.Sin(moveAngle));

        base.Update();
        // 画面外にいるときは処理を行わないようにしたい 出来れば基底クラスで

        //画面内にいる時に音出す
        if (targetRenderer.isVisible && Mathf.Abs(ActionInput.GetJoyconGyro().z) > 0.1f)
        {
            if (!audioSource.isPlaying)
            {
                audioSource.Play();
            }
            //フェードイン
            audioSource.volume += (1 - audioSource.volume) * 0.2f;
            //Debug.Log("歯車音:" + gyroZ);
        }
        else
        {
            //audioSource.Stop();
            //フェードアウト
            audioSource.volume *= 0.9f;
            if (audioSource.volume < 0.01f)
            {
                audioSource.Stop();
            }
        }
    }
Example #16
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var myBehaviors = actionInput.Controller.Thing.Behaviors;

            var followingBehavior = myBehaviors.FindFirst <FollowingBehavior>();

            if (followingBehavior != null)
            {
                var target = followingBehavior.Target;
                if (target != null)
                {
                    var targetBehaviors  = target.Behaviors;
                    var followedBehavior = targetBehaviors.FindFirst <FollowedBehavior>();
                    if (followedBehavior != null)
                    {
                        lock (followedBehavior.Followers)
                        {
                            followedBehavior.Followers.Remove(actionInput.Controller.Thing);
                            if (followedBehavior.Followers.Count == 0)
                            {
                                targetBehaviors.Remove(followedBehavior);
                            }
                        }
                    }
                }

                myBehaviors.Remove(followingBehavior);
            }
            else
            {
                var message = new ContextualString(actionInput.Controller.Thing, null)
                {
                    ToOriginator = "You aren't following anybody."
                };

                var senseMessage = new SensoryMessage(SensoryType.All, 100, message);

                var followEvent = new FollowEvent(actionInput.Controller.Thing, senseMessage, actionInput.Controller.Thing, null);

                // Broadcast the event
                actionInput.Controller.Thing.Eventing.OnMiscellaneousEvent(followEvent, EventScope.ParentsDown);
            }
        }
Example #17
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            // No arguments were provided. Just show the current buffer setting and exit.
            if (string.IsNullOrEmpty(actionInput.Tail))
            {
                ShowCurrentBuffer();
                return;
            }

            // Set the value for the current session
            if (session.Connection != null)
            {
                session.Connection.PagingRowLimit = parsedBufferLength == -1 ? session.TerminalOptions.Height : parsedBufferLength;
            }

            userControlledBehavior.PagingRowLimit = parsedBufferLength;

            ShowCurrentBuffer();
        }
Example #18
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender      = actionInput.Controller;
            var         terminal    = (actionInput.Controller as Session).Terminal;
            var         commandTail = actionInput.Tail;

            // If no arguments were given, render the help topics list.
            if (string.IsNullOrWhiteSpace(commandTail))
            {
                sender.Write(Renderer.Instance.RenderHelpTopics(terminal));
                return;
            }

            // Check to see if the help topic is in the help manager.
            HelpTopic helpTopic = HelpManager.Instance.FindHelpTopic(commandTail);

            if (helpTopic != null)
            {
                sender.Write(Renderer.Instance.RenderHelpTopic(terminal, helpTopic));
                return;
            }

            // If not found we check commands.
            var commands = CommandManager.Instance.MasterCommandList;

            // First check for an exact match with a command name.
            var action = commands.Values.FirstOrDefault(c => c.Name.Equals(commandTail, StringComparison.OrdinalIgnoreCase));

            // If no exact match, check for a partial match.
            if (action == null)
            {
                action = commands.Values.FirstOrDefault(c => c.Name.ToLower().StartsWith(commandTail));
            }

            // Show result if a match was found
            if (action != null)
            {
                sender.Write(Renderer.Instance.RenderHelpCommand(terminal, action));
                return;
            }

            sender.Write("No such help topic or command was found.");
        }
Example #19
0
        /// <summary>Checks against the guards for the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            string commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            var session = actionInput.Controller as Session;

            if (session != null && session.Terminal != null)
            {
                this.useMXP = session.Terminal.UseMXP;
            }

            // There are currently no arguments nor situations where we expect failure.
            return(null);
        }
 OnSelected SetSE()
 {
     return(() =>
     {
         if (ActionInput.GetButton(ButtonCode.RightArrow))
         {
             seVol++;
             seVol = Mathf.Min(seVol, 20);
             audioMixer.SetFloat("SEVol", seVol);
         }
         if (ActionInput.GetButton(ButtonCode.LeftArrow))
         {
             seVol--;
             seVol = Math.Max(seVol, -80);
             audioMixer.SetFloat("SEVol", seVol);
         }
         titleUi.text = "おんりょうせってい … <sprite=7>でへんこう\n全体 < " + (masterVol + 80) + " >\nBGM < " + (bgmVol + 80) + " >\nこうかおん < " + (seVol + 80) + " >\n元にもどす";
     });
 }
 OnSelected SetScreenSize()
 {
     return(() =>
     {
         if (ActionInput.GetButtonDown(ButtonCode.RightArrow))
         {
             ScreenSizeNum++;
             ScreenSizeNum = (ScreenSizeNum + 4) % 4;
             ScreenSizeChange();
         }
         if (ActionInput.GetButtonDown(ButtonCode.LeftArrow))
         {
             ScreenSizeNum--;
             ScreenSizeNum = (ScreenSizeNum + 4) % 4;
             ScreenSizeChange();
         }
         titleUi.text = "がめんせってい\nフルスクリーン\u3000< " + ScreenIsFull() + " >\nかいぞうど < " + ScreenSizeString() + " >";
     });
 }
Example #22
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            // Create a portal targeting the specified room.
            var portalItem = new Thing();

            portalItem.Behaviors.Add(new PortalBehavior
            {
                DestinationThingID = targetPlace.Id,
            });

            // TODO: Should not be needed after OLC and instant-spawn commands which should work
            // for any type of Thing; not just portals.  Spawning (either way) should use the Request
            // and Event pattern.
            actionInput.Controller.Thing.Parent.Add(portalItem);
            var userControlledBehavior = actionInput.Controller.Thing.Behaviors.FindFirst <UserControlledBehavior>();

            userControlledBehavior.Controller.Write(new OutputBuilder().
                                                    AppendLine("A magical portal opens up in front of you."));
        }
Example #23
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            if (actionInput.Controller.Thing == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(actionInput.Tail))
            {
                actionInput.Controller.Write(new OutputBuilder().
                                             AppendLine($"Your current title is '{actionInput.Controller.Thing.Title}'."));
            }
            else
            {
                actionInput.Controller.Thing.Title = actionInput.Tail;
                actionInput.Controller.Write(new OutputBuilder().
                                             AppendLine($"Your title is now '{actionInput.Controller.Thing.Title}'"));
            }
        }
Example #24
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var contextMessage = new ContextualString(actionInput.Actor, thingToDrop.Parent)
            {
                ToOriginator = $"You drop up {thingToDrop.Name}.",
                ToReceiver   = $"{actionInput.Actor.Name} drops {thingToDrop.Name} in you.",
                ToOthers     = $"{actionInput.Actor.Name} drops {thingToDrop.Name}."
            };
            var dropMessage = new SensoryMessage(SensoryType.Sight, 100, contextMessage);

            var actor = actionInput.Actor;

            if (movableBehavior.Move(dropLocation, actor, null, dropMessage))
            {
                // TODO: Transactionally save actors if applicable.
                //actor.Save();
                //dropLocation.Save();
            }
        }
Example #25
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender         = actionInput.Controller;
            var         contextMessage = new ContextualString(sender.Thing, sender.Thing.Parent)
            {
                ToOriginator = $"You say: {this.sayText}",
                ToReceiver   = $"{sender.Thing.Name} says: {this.sayText}",
                ToOthers     = $"{sender.Thing.Name} says: {this.sayText}",
            };
            var sm = new SensoryMessage(SensoryType.Hearing, 100, contextMessage);

            var sayEvent = new VerbalCommunicationEvent(sender.Thing, sm, VerbalCommunicationType.Say);

            sender.Thing.Eventing.OnCommunicationRequest(sayEvent, EventScope.ParentsDown);
            if (!sayEvent.IsCancelled)
            {
                sender.Thing.Eventing.OnCommunicationEvent(sayEvent, EventScope.ParentsDown);
            }
        }
Example #26
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var emoteString = $"<*{actionInput.Actor.Name} {actionInput.Tail}>";

            var contextualString = new ContextualString(actionInput.Actor, actionInput.Actor.Parent)
            {
                ToOriginator = emoteString,
                ToOthers     = emoteString
            };

            var msg        = new SensoryMessage(SensoryType.Sight, 100, contextualString);
            var emoteEvent = new VerbalCommunicationEvent(actionInput.Actor, msg, VerbalCommunicationType.Emote);

            actionInput.Actor.Eventing.OnCommunicationRequest(emoteEvent, EventScope.ParentsDown);
            if (!emoteEvent.IsCancelled)
            {
                actionInput.Actor.Eventing.OnCommunicationEvent(emoteEvent, EventScope.ParentsDown);
            }
        }
Example #27
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            // @@@ TODO: Allow admins to check effects on target?

            /* @@@ FIX?
             * var sb = new StringBuilder();
             *
             * string line = "+" + string.Empty.PadRight(70, '-') + "+";
             *
             * // Header
             * sb.AppendFormat("{0,72}\r\n", "Effects on " + sender.Thing.Name);
             * sb.AppendFormat("{0,72}\r\n", line);
             *
             * // Iterate through Effects
             * bool hasEffect = false;
             * foreach (Behavior behavior in sender.Thing.BehaviorManager.ManagedBehaviors)
             * {
             *  var effect = behavior as Effect;
             *  if (effect != null)
             *  {
             *      hasEffect = true;
             *      sb.AppendFormat(
             *          "| {0, -10}{1, 16}{2, 16}{3, 12}{4, -14} |\r\n",
             *          "Effect [",
             *          effect.Name + " ]",
             *          "Duration [",
             *          effect.RemainingTime.TotalSeconds,
             *          " ] seconds");
             *  }
             * }
             *
             * if (!hasEffect)
             * {
             *  sb.AppendFormat("There are no effects effecting " + sender.Thing.Name);
             * }
             *
             * // Footer
             * sb.AppendFormat("{0,72}\r\n", line);
             *
             * // Send to Parser
             * sender.Write(sb.ToString().Trim());
             */
        }
Example #28
0
        /// <summary>Creates a scripting command from action input.</summary>
        /// <param name="actionInput">The action input to transform into a ScriptingCommand instance.</param>
        /// <returns>A new ScriptingCommand instance for the specified input, if found, else null.</returns>
        public ScriptingCommand Create(ActionInput actionInput)
        {
            // TODO: Build targeting into command selection when there are multiple valid targets; IE if multiple
            //     openable things registered an "open" context command, then if the user said "open door" then we
            //     want to select the context command attached to the closest match for "door" as our command; if
            //     there are still multiple targets, we can start a conflict resolution prompt, etc.  Individual non-
            //     context commands may also wish to use such targeting code, so it should be built to be reusable.
            ScriptingCommand command = this.TryCreateMasterCommand(actionInput, 0) ??
                                       this.TryCreateMasterCommand(actionInput, 1) ??
                                       this.TryCreateContextCommand(actionInput, 0) ??
                                       this.TryCreateContextCommand(actionInput, 1);

            if (command == null)
            {
                actionInput.Controller.Write(unknownCommandResponse);
            }

            return(command);
        }
Example #29
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            // Build our knock messages for this room and the next.  Only send message to the door-type thing once.
            IController sender          = actionInput.Controller;
            var         thisRoomMessage = new ContextualString(sender.Thing, this.target)
            {
                ToOriginator = @"You knock on $ActiveThing.Name.",
                ToOthers     = @"$Knocker.Name knocks on $ActiveThing.Name.",
                ToReceiver   = @"$Knocker.Name knocks on you.",
            };
            var nextRoomMessage = new ContextualString(sender.Thing, this.target)
            {
                ToOriginator = null,
                ToOthers     = @"Someone knocks on $ActiveThing.Name.",
                ToReceiver   = null,
            };

            // Create sensory messages.
            var thisRoomSM = new SensoryMessage(SensoryType.Sight | SensoryType.Hearing, 100, thisRoomMessage, new Hashtable {
                { "Knocker", sender.Thing }
            });
            var nextRoomSM = new SensoryMessage(SensoryType.Hearing, 100, nextRoomMessage);

            // Generate our knock events.
            var thisRoomKnockEvent = new KnockEvent(this.target, thisRoomSM);
            var nextRoomKnockEvent = new KnockEvent(this.target, nextRoomSM);

            // Broadcast the requests/events; the events handle sending the sensory messages.
            sender.Thing.Eventing.OnCommunicationRequest(thisRoomKnockEvent, EventScope.ParentsDown);
            if (!thisRoomKnockEvent.IsCancelled)
            {
                // The knocking here happens regardless of whether it's cancelled on the inside.
                sender.Thing.Eventing.OnCommunicationEvent(thisRoomKnockEvent, EventScope.ParentsDown);

                // Next try to send a knock event into the adjacent place too.
                this.nextRoom.Eventing.OnCommunicationRequest(nextRoomKnockEvent, EventScope.SelfDown);
                if (!nextRoomKnockEvent.IsCancelled)
                {
                    this.nextRoom.Eventing.OnCommunicationEvent(nextRoomKnockEvent, EventScope.SelfDown);
                }
            }
        }
Example #30
0
        /// <summary>Prepare for, and determine if the command's prerequisites have been met.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            string commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;
            ////string targetName = command.Action.Tail.Trim().ToLower();
            string targetName = textInfo.ToTitleCase(actionInput.Tail.Trim().ToLower());

            // Rule: Is the target an entity?
            this.target = GameAction.GetPlayerOrMobile(targetName);
            if (this.target == null)
            {
                // Now we need to look for the user in the database.
                // @@@ What if the player is offline? Player.Load probably adds them to the world, etc...
                //     This seems quite bad.  TEST!  Ideally we should be able to get the info of an off-
                //     line player BUT if the player logs in between say, our Guards and Execute getting
                //     run, we still want nothing strange to result, we don't want this to generate any
                //     'player logged in' events (as monitored by Friends system), etc...  Probably need
                //     some sort of ghosting system for info-gathering, should be generic for all things?
                //     Maybe the players all have a 'template' that can be loaded independently and gets
                //     saved with the player instance saving.
                //this.target = PlayerBehavior.Load(targetName);
                if (this.target == null)
                {
                    return(targetName + " has never visited " + MudEngineAttributes.Instance.MudName + ".");
                }
            }

            // Rule: If there is less than 1 parameter, show help.
            if (actionInput.Params.Length != 1)
            {
                return("Syntax:\n<finger [entity]>\n\nRemarking line 31 in this file will help crash test the mud :)\n\nSee also who");
            }

            return(null);
        }
Example #31
0
        /// <summary>Prepare for, and determine if the command's prerequisites have been met.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <returns>A string with the error message for the user upon guard failure, else null.</returns>
        public override string Guards(ActionInput actionInput)
        {
            var commonFailure = VerifyCommonGuards(actionInput, ActionGuards);

            if (commonFailure != null)
            {
                return(commonFailure);
            }

            // Changing strings here seem to cause casting error?
            // string targetName = command.Action.Tail.Trim().ToLower();
            var targetName = actionInput.Params[0].Trim().ToLower();

            // TODO: InterMUD support? string mudName = GameConfiguration.GameName;

            // Rule: Target must be an entity. TODO: REMOVE CHECK?
            target = GetPlayerOrMobile(targetName);
            if (target == null)
            {
                // Make first char Upper?  IE textInfo.ToTitleCase.
                return(targetName + " is not part of reality.");
            }

            //// TODO what if player offline ?

            // Rule: Prevent talking to yourself.
            if (actionInput.Controller.Thing.Name.ToLower() == target.Name.ToLower())
            {
                return("Talking to yourself is the first sign of madness!");
            }

            // Rule: Give help if too few Params, having problems with the causing casting errors ?
            if (actionInput.Params.Length <= 1)
            {
                return("Syntax:\n<tell [player] [message]>\n\nSee also say, yell, shout, emote.");
            }

            // The sentence to be relayed consists of all input beyond the first parameter,
            // which was used to identify entity already.
            var firstCommandLength = actionInput.Params[0].Length;

            sentence = actionInput.Tail[firstCommandLength..].Trim();
Example #32
0
 public CLICommandRegex(string commands, Action<string> action)
     : this(commands)
 {
     InputType = ActionInput.Text;
     TextAction = action;
 }
Example #33
0
 public abstract ActionError Excute(ActionInput input);
Example #34
0
 //roll back action
 public virtual ActionError RollBack(ActionInput input)
 {
     return ActionError.NoError;
 }
Example #35
0
 public CLICommandRegex(string commands, Action action)
     : this(commands)
 {
     InputType = ActionInput.None;
     DefaultAction = action;
 }
Example #36
0
 public CLICommandRegex(string commands, Action<int> action)
     : this(commands)
 {
     InputType = ActionInput.Number;
     NumberAction = action;
 }