Esempio n. 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();
            // 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);
        }
Esempio n. 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();
            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);
        }
Esempio n. 3
0
 /// <summary>Initializes a PlayerEventProcessor for this player.</summary>
 /// <param name="sensesBehavior">A valid SensesBehavior which has already been created for this player.</param>
 /// <param name="userControlledBehavior">A valid UserControlledBehavior which has already been created for this player.</param>
 internal void InitEventProcessor(SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
 {
     this.EventProcessor = new PlayerEventProcessor(this, sensesBehavior, userControlledBehavior);
 }
Esempio n. 4
0
 /// <summary>Initializes a new instance of the PlayerBehavior class.</summary>
 /// <param name="sensesBehavior">The senses Behavior.</param>
 /// <param name="userControlledBehavior">The user Controlled Behavior.</param>
 public PlayerBehavior(SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
     : this()
 {
     this.EventProcessor = new PlayerEventProcessor(this, sensesBehavior, userControlledBehavior);
 }
Esempio n. 5
0
        /// <summary>
        /// Pre-process the important bits of input and store in private fields, so they
        /// will be available for validation and the main execute method.
        /// </summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        private void PreprocessInput(ActionInput actionInput)
        {
            // Make sure there is a sender.
            this.sender = actionInput.Controller;
            this.session = this.sender as Session;
            if (this.sender == null || this.sender.Thing == null)
            {
                return;
            }

            // Make sure the sender is an actual connected user.
            this.userControlledBehavior = this.sender.Thing.Behaviors.FindFirst<UserControlledBehavior>();
            if (this.userControlledBehavior == null)
            {
                return;
            }

            // Parse and store the desired buffer length, if one was provided.
            string lengthText = actionInput.Tail.ToLower().Trim();
            if (string.IsNullOrEmpty(lengthText))
            {
                this.parseSucceeded = true;
            }
            else if (lengthText == "auto")
            {
                this.parsedBufferLength = -1;
                this.parseSucceeded = true;
            }
            else
            {
                this.parseSucceeded = this.TryParse(lengthText, out this.parsedBufferLength);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerEventProcessor"/> class.
 /// </summary>
 /// <param name="playerBehavior">The player behavior.</param>
 /// <param name="sensesBehavior">The senses behavior.</param>
 /// <param name="userControlledBehavior">The user controlled behavior.</param>
 public PlayerEventProcessor(PlayerBehavior playerBehavior, SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
 {
     this.playerBehavior         = playerBehavior;
     this.sensesBehavior         = sensesBehavior;
     this.userControlledBehavior = userControlledBehavior;
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerEventProcessor"/> class.
 /// </summary>
 /// <param name="playerBehavior">The player behavior.</param>
 /// <param name="sensesBehavior">The senses behavior.</param>
 /// <param name="userControlledBehavior">The user controlled behavior.</param>
 public PlayerEventProcessor(PlayerBehavior playerBehavior, SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
 {
     this.playerBehavior = playerBehavior;
     this.sensesBehavior = sensesBehavior;
     this.userControlledBehavior = userControlledBehavior;
 }
Esempio n. 8
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;
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the PlayerBehavior class.
 /// </summary>
 /// <param name="sensesBehavior">
 /// The senses Behavior.
 /// </param>
 /// <param name="userControlledBehavior">
 /// The user Controlled Behavior.
 /// </param>
 public PlayerBehavior(SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
     : this()
 {
     this.EventProcessor = new PlayerEventProcessor(this, sensesBehavior, userControlledBehavior);
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a PlayerEventProcessor for this player.
 /// </summary>
 /// <param name="sensesBehavior">A valid SensesBehavior which has already been created for this player.</param>
 /// <param name="userControlledBehavior">A valid UserControlledBehavior which has already been created for this player.</param>
 internal void InitEventProcessor(SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
 {
     this.EventProcessor = new PlayerEventProcessor(this, sensesBehavior, userControlledBehavior);
 }