/// <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); }
/// <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); }
/// <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; } this.sensesBehavior = actionInput.Controller.Thing.Behaviors.FindFirst<SensesBehavior>(); if (this.sensesBehavior == null) { return "You do not have any senses to perceive with."; } return null; }
/// <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); }
/// <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); }
/// <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; }
/// <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; }
/// <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; }
/// <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); }
/// <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); }