Exemple #1
0
        /// <summary>Prepares the base character.</summary>
        /// <param name="session">The session.</param>
        /// <returns>Filled out base character.</returns>
        public static Thing PrepareBaseCharacter(Session session)
        {
            var movableBehavior        = new MovableBehavior();
            var livingBehavior         = new LivingBehavior();
            var sensesBehavior         = new SensesBehavior();
            var userControlledBehavior = new UserControlledBehavior()
            {
                Controller = session,
            };
            var playerBehavior = new PlayerBehavior(sensesBehavior, userControlledBehavior)
            {
                SessionId = session.ID,
            };

            var player = new Thing(livingBehavior, sensesBehavior, userControlledBehavior, playerBehavior, movableBehavior);

            var game = GameSystemController.Instance;

            // Load the default stats for the current gaming system
            foreach (var gameStat in game.GameStats)
            {
                var currStat = new GameStat(session, gameStat.Name, gameStat.Abbreviation, gameStat.Formula, gameStat.Value, gameStat.MinValue, gameStat.MaxValue, gameStat.Visible);
                player.Stats.Add(currStat.Abbreviation, currStat);
            }

            // Load the secondary stats\attributes for the current gaming system
            foreach (var attribute in game.GameAttributes)
            {
                var newAttribute = new GameAttribute(session, attribute.Name, attribute.Abbreviation, attribute.Formula, attribute.Value, attribute.MinValue, attribute.MaxValue, attribute.Visible);
                player.Attributes.Add(newAttribute.Abbreviation, newAttribute);
            }

            return(player);
        }
Exemple #2
0
        /// <summary>Prepares the base character.</summary>
        /// <param name="session">The session.</param>
        /// <returns>Filled out base character.</returns>
        public static Thing PrepareBaseCharacter(Session session)
        {
            var movableBehavior = new MovableBehavior();
            var livingBehavior  = new LivingBehavior();
            var sensesBehavior  = new SensesBehavior();
            // TODO: Most characters should start as just tutorialPlayer or player role, unless FirstCreatedCharacterIsAdmin
            //       is set and there is no character in the DB yet. See: https://github.com/DavidRieman/WheelMUD/issues/39
            var userControlledBehavior = new UserControlledBehavior()
            {
                Controller    = session,
                SecurityRoles = SecurityRole.player | SecurityRole.helper | SecurityRole.minorBuilder | SecurityRole.fullBuilder | SecurityRole.minorAdmin | SecurityRole.fullAdmin
            };
            var playerBehavior = new PlayerBehavior()
            {
                SessionId = session.ID
            };
            var player = new Thing(livingBehavior, sensesBehavior, userControlledBehavior, playerBehavior, movableBehavior);
            var game   = GameSystemController.Instance;

            // Load a fresh set of stats and attributes classes for the current gaming system.
            player.Attributes = game.CloneGameAttributes();
            player.Stats      = game.CloneGameStats();

            return(player);
        }
Exemple #3
0
        /// <summary>Tries to move a Thing from its current location into the specified location, if that thing is movable.</summary>
        /// <param name="thing">The Thing to move.</param>
        /// <param name="destinationThing">The new container to house the Thing.</param>
        /// <param name="goingVia">The going via.</param>
        /// <param name="leavingMessage">The leaving message.</param>
        /// <param name="arrivingMessage">The arriving message.</param>
        public void MoveThing(Thing thing, Thing destinationThing, Thing goingVia, SensoryMessage leavingMessage, SensoryMessage arrivingMessage)
        {
            MovableBehavior movableBehavior = thing.Behaviors.FindFirst <MovableBehavior>();

            if (movableBehavior != null)
            {
                movableBehavior.Move(destinationThing, goingVia, leavingMessage, arrivingMessage);
            }
        }
Exemple #4
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)
        {
            IController sender = actionInput.Controller;
            string 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.
            int itemParam = 0;
            int numberWords = actionInput.Params.Length;
            if (int.TryParse(actionInput.Params[0], out this.numberToGive))
            {
                itemParam = 1;

                // If the user specified a number, but it is less than 1, error!
                if (this.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).
            string itemName = actionInput.Params[itemParam];

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

            // The final argument should be the target name.
            string targetName = actionInput.Params[actionInput.Params.Length - 1];

            // Rule: Do we have a target?
            if (string.IsNullOrEmpty(targetName))
            {
                return "You must specify someone to give that to.";
            }

            // @@@ Shared targeting code should be used, and this rule should be implemented like:
            //     if (this.target == sender.Thing) ...
            // Rule: The giver cannot also be the receiver.
            if (targetName == "me")
            {
                return "You can't give something to yourself.";
            }

            // Rule: Is the target an entity?
            this.target = GameAction.GetPlayerOrMobile(targetName);
            if (this.target == null)
            {
                return "You cannot see " + targetName + ".";
            }

            // Rule: Is the target in the same room?
            if (sender.Thing.Parent.ID != this.target.Parent.ID)
            {
                return "You cannot see " + targetName + ".";
            }

            // Rule: The thing being given must be movable.
            this.movableBehavior = this.thing.Behaviors.FindFirst<MovableBehavior>();

            return null;
        }
Exemple #5
0
        /// <summary>Prepares the base character.</summary>
        /// <param name="session">The session.</param>
        /// <returns>Filled out base character.</returns>
        public static Thing PrepareBaseCharacter(Session session)
        {
            var movableBehavior = new MovableBehavior();
            var livingBehavior = new LivingBehavior();
            var sensesBehavior = new SensesBehavior();
            var userControlledBehavior = new UserControlledBehavior()
            {
                Controller = session,
            };
            var playerBehavior = new PlayerBehavior(sensesBehavior, userControlledBehavior)
            {
                SessionId = session.ID,
            };

            var player = new Thing(livingBehavior, sensesBehavior, userControlledBehavior, playerBehavior, movableBehavior);

            var game = GameSystemController.Instance;

            // Load the default stats for the current gaming system
            foreach (var gameStat in game.GameStats)
            {
                var currStat = new GameStat(session, gameStat.Name, gameStat.Abbreviation, gameStat.Formula, gameStat.Value, gameStat.MinValue, gameStat.MaxValue, gameStat.Visible);
                player.Stats.Add(currStat.Abbreviation, currStat);
            }

            // Load the secondary stats\attributes for the current gaming system
            foreach (var attribute in game.GameAttributes)
            {
                var newAttribute = new GameAttribute(session, attribute.Name, attribute.Abbreviation, attribute.Formula, attribute.Value, attribute.MinValue, attribute.MaxValue, attribute.Visible);
                player.Attributes.Add(newAttribute.Abbreviation, newAttribute);
            }

            return player;
        }