/// <summary>Shows who is currently following the player, and who the player is following.</summary> /// <remarks>TODO: Replace the sender.Write() calls with something more general, e.g. an event.</remarks> /// <param name="actionInput">The action input.</param> private void ShowStatus(ActionInput actionInput) { var senderBehaviors = actionInput.Actor.Behaviors; var followingBehavior = senderBehaviors.FindFirst <FollowingBehavior>(); var followedBehavior = senderBehaviors.FindFirst <FollowedBehavior>(); var output = new OutputBuilder().Append("You are following: "); output.AppendLine(followingBehavior == null ? "(nobody)" : followingBehavior.Target.Name); output.Append("You are being followed by: "); if (followedBehavior == null) { output.AppendLine("(nobody)"); } else { lock (followedBehavior.Followers) { var followers = followedBehavior.Followers.Select(f => f.Name).BuildPrettyList(); output.AppendLine(followers); } } actionInput.Session?.Write(output); }
private void ViewRaceDescription(string race) { var raceToView = race.Replace("view ", string.Empty); var cultureInfo = Thread.CurrentThread.CurrentCulture; var textInfo = cultureInfo.TextInfo; var properCaseRace = textInfo.ToTitleCase(raceToView); var foundRace = (from r in gameRaces where r.Name == properCaseRace select r).FirstOrDefault(); if (foundRace != null) { var output = new OutputBuilder(); output.AppendSeparator('=', "yellow", true); output.AppendLine($"Description for {foundRace.Name}"); output.AppendSeparator('-', "yellow"); output.AppendLine($"<%b%><%white%>{foundRace.Description}<%n%>"); output.AppendSeparator('=', "yellow", true); Session.Write(output); } else { WrmChargenCommon.SendErrorMessage(Session, "That race does not exist."); } }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { var session = actionInput.Session; if (session == null) { return; // This action only makes sense for player sessions. } var output = new OutputBuilder(); foreach (var kvp in actionInput.Actor.Stats) { output.Append(kvp.Value.Name.PadRight(20)); output.Append(kvp.Value.Value); output.AppendLine(); } foreach (var kvp in actionInput.Actor.Attributes) { output.Append(kvp.Value.Name.PadRight(20)); output.Append(kvp.Value.Value); output.AppendLine(); } session.Write(output); }
public override OutputBuilder Render() { var topics = HelpManager.Instance.GetHelpTopics().Where(topic => topic.Aliases.Count > 0); var output = new OutputBuilder(); if (!topics.Any()) { output.AppendLine("There are no help topics written yet."); return(output); } // Format the first column to the number of characters to fit the longest topic, then have the description to the right of that. var lineFormat = "{0," + -1 * HelpManager.Instance.MaxPrimaryAliasLength + "} {1}"; output.AppendLine("Available help topics:"); output.AppendSeparator(color: "yellow"); foreach (var topic in topics) { var primaryAlias = topic.Aliases.FirstOrDefault(); output.AppendLine(string.Format(lineFormat, primaryAlias, "TODO: Topic Short Description Support Here")); } output.AppendSeparator(color: "yellow"); output.AppendLine(); output.AppendLine("<%yellow%>NOTE:<%n%> You can also use the \"<%green%>commands<%n%>\" command to list out commands, and you can get help for a specific command with \"<%green%>help <command name><%n%>\"."); return(output); }
private void RefreshScreen() { var output = new OutputBuilder(); output.AppendLine(); output.AppendLine("You may pick three starting skills for your character."); int n = 1; foreach (var skill in selectedSkills) { output.AppendLine($"Skill #{n} : {skill.Name}"); n++; } output.AppendLine(); output.AppendLine("<%green%>Please select 3 from the list below:<%n%>"); FormatSkillText(output); output.AppendLine($"<%green%>You have {3 - selectedSkills.Count} skills left.<%n%>"); output.AppendSeparator('=', "yellow", true); output.AppendLine("To pick a skill, type the skill's name. Example: unarmed"); output.AppendLine("To view a skill's description use the view command. Example: view unarmed"); output.AppendLine("To see this screen again type list."); output.AppendLine("When you are done picking your three skills, type done."); output.AppendSeparator('=', "yellow", true); Session.Write(output); }
private void AddFriend(IController sender, Thing targetFriend) { var output = new OutputBuilder(); if (targetFriend == null) { output.AppendLine("Doesn't appear to be online at the moment."); sender.Write(output); return; } if (targetFriend == player) { output.AppendLine("You cannot add yourself as a friend."); sender.Write(output); return; } if (playerBehavior.Friends.Contains(targetFriend.Name)) { output.AppendLine($"{player.Name} is already on your friends list."); sender.Write(output); return; } playerBehavior.AddFriend(player.Name); output.AppendLine($"You have added {targetFriend.Name} to your friends list."); sender.Write(output); }
public override OutputBuilder Render(TerminalOptions terminalOptions, HelpTopic helpTopic) { var output = new OutputBuilder(); // TODO: What was this !element doing? Does it still work? Test with zMUD or something and re-read MXP specs? if (terminalOptions.UseMXP) { output.AppendLine($"{AnsiSequences.MxpSecureLine}<!element see '<send href=\"help &cref;\">' att='cref' open>"); } output.AppendSeparator(color: "yellow", design: '='); output.AppendLine($"HELP TOPIC: {helpTopic.Aliases.First()}"); output.AppendSeparator(color: "yellow"); if (terminalOptions.UseMXP) { var lines = helpTopic.Contents.Split(new string[] { AnsiSequences.NewLine }, StringSplitOptions.None); foreach (var line in lines) { output.AppendLine($"{AnsiSequences.MxpOpenLine}{line}<%n%>"); } } else { output.AppendLine($"{helpTopic.Contents}"); } output.AppendSeparator(color: "yellow", design: '='); return(output); }
private void FormatTalentText(OutputBuilder outputBuilder) { var talentQueue = new Queue <Talent>(); foreach (var gameTalent in talents) { // Find out what talent name is the longest if (gameTalent.Name.Length > longestTalentName) { longestTalentName = gameTalent.Name.Length; } talentQueue.Enqueue(gameTalent); } var rows = talents.Count / 4; try { for (var i = 0; i < rows; i++) { var talent1 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); var talent2 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); var talent3 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); var talent4 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); outputBuilder.AppendLine($"{talent1} {talent2} {talent3} {talent4}"); } if ((rows % 4) > 0) { var columns = rows - (rows * 4); switch (columns) { case 1: var talentcolumn1 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); outputBuilder.AppendLine($"{talentcolumn1}"); break; case 2: var tk1 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); var tk2 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); outputBuilder.AppendLine($"{tk1} {tk2}"); break; case 3: var tkl1 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); var tkl2 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); var tkl3 = WrmChargenCommon.FormatToColumn(longestTalentName, talentQueue.Dequeue().Name); outputBuilder.AppendLine($"{tkl1} {tkl2} {tkl3}"); break; } } } catch { // ignored } }
private void FormatRaceText(OutputBuilder outputBuilder) { var raceQueue = new Queue <GameRace>(); var rows = gameRaces.Count / 4; foreach (var gameRace in gameRaces) { // Find out what skill name is the longest if (gameRace.Name.Length > longestRaceName) { longestRaceName = gameRace.Name.Length; } raceQueue.Enqueue(gameRace); } try { for (var i = 0; i < rows; i++) { var race1 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); var race2 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); var race3 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); var race4 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); outputBuilder.AppendLine($"{race1} {race2} {race3} {race4}"); } if (gameRaces.Count % 4 > 0) { var columns = gameRaces.Count - (rows * 4); switch (columns) { case 1: var racecolumn1 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); outputBuilder.AppendLine($"{racecolumn1}"); break; case 2: var rc = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); var rcc1 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); outputBuilder.AppendLine($"{rc} {rcc1}"); break; case 3: var rc1 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); var rc2 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); var rc3 = WrmChargenCommon.FormatToColumn(longestRaceName, raceQueue.Dequeue().Name); outputBuilder.AppendLine($"{rc1} {rc2} {rc3}"); break; } } } catch (Exception) { // ignored } }
public override OutputBuilder Render() { var output = new OutputBuilder(); output.AppendLine("TODO: LIST OUT ALL HELP TOPICS FOUND VIA HelpManager."); output.AppendLine(); output.AppendLine("You can also use the \"commands\" command to list out commands, and you can get help"); output.AppendLine("for a specific command with \"help <command name>\""); return(output); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { // Contextual message text to be supplied based on the action below var response = new ContextualString(actionInput.Controller.Thing, room.Parent); if (command == "add") { // Add or update the description room.Visuals[visualName] = visualDescription; response.ToOriginator = $"Visual '{visualName}' added/updated on room {roomName} [{roomId}]."; //// TODO: Save change //room.Save(); } else if (command == "remove") { if (room.Visuals.ContainsKey(visualName)) { room.Visuals.Remove(visualName); response.ToOriginator = $"Visual '{visualName}' removed from room {roomName} [{roomId}]"; } //// TODO: Save change //room.Save(); } else if (command == "show") { var output = new OutputBuilder(); if (room.Visuals.Count > 0) { output.AppendLine($"Visuals for {roomName} [{roomId}]:"); foreach (var name in room.Visuals.Keys) { output.AppendLine($" {name}: {room.Visuals[name]}"); } } else { output.AppendLine($"No visuals found for {roomName} [{roomId}]."); } actionInput.Controller.Write(output); // No need to raise event. return; } var message = new SensoryMessage(SensoryType.Sight, 100, response); var evt = new GameEvent(actionInput.Controller.Thing, message); actionInput.Controller.Thing.Eventing.OnMiscellaneousEvent(evt, EventScope.SelfDown); }
public override OutputBuilder Render(IEnumerable <Command> commands, string categoryName) { var output = new OutputBuilder(); output.AppendLine($"<%yellow%>{categoryName} commands<%n%>:"); foreach (var command in commands) { output.AppendLine($"{AnsiSequences.MxpSecureLine}<send \"help {command.Name}\">{command.Name.PadRight(15)}</send> {command.Description}"); } return(output); }
static GetPasswordState() { var output = new OutputBuilder().AppendLine(); output.AppendLine(AppConfigInfo.Instance.UserAccountIsPlayerCharacter ? "Please carefully select a password for this character." : "Please carefully select a password for this user account."); output.AppendLine("Although the Telnet protocol provides an authentic retro experience, unfortunately it also sends password in plain-text. Do not use the same password as you use for any other account. Do not use this password on a network with machines do not fully trust (especially public networks)."); output.AppendLine("Your password can be changed while logged in."); InitialStateMessage = output; }
/// <summary>Called upon authentication of a session.</summary> /// <param name="session">The authenticated session.</param> public void OnSessionAuthenticated(Session session) { // If there was already a connected player for this new, authentic user session, kick the old // one (as it may have been a prior disconnect or whatnot or even a different player character // controlled by the same user account). // TODO: We can probably handle this more gracefully (without the extra logouts and messaging // the room about it and so on) by having the login process notice the target player is // already in the world sooner, and more directly taking fresh control of THAT Thing. PlayerBehavior previousPlayer = FindLoggedInPlayer(session.User.UserName); if (previousPlayer != null) { var msg = $"Duplicate player match, replacing session {previousPlayer.SessionId} with new session {session.ID}"; SystemHost.UpdateSystemHost(this, msg); var previousUser = previousPlayer.Parent.FindBehavior <UserControlledBehavior>(); Debug.Assert(previousUser != null, "Existing Player found must always also be a UserControlled Thing."); previousUser.Disconnect("Another connection has logged in as you; closing this connection."); previousUser.Session = session; previousPlayer.SessionId = session.ID; session.Thing = previousPlayer.Parent; } else { // Track this new player in the loaded players list. AddPlayer(session.Thing); } // A freshly (re)connected player is assumed not to be AFK anymore. PlayerBehavior playerBehavior = session.Thing.FindBehavior <PlayerBehavior>(); if (playerBehavior != null) { playerBehavior.IsAFK = false; playerBehavior.AFKReason = null; } // If this session doesn't have a player thing attached yet, load it up. Note that // for situations like character creation, we might already have our Thing, so we // don't want to load a duplicate version of the just-created player Thing. if (session.Thing == null) { var output = new OutputBuilder(); output.AppendLine("User was authenticated but the player character could not be loaded."); output.AppendLine("Please contact an administrator. Disconnecting."); session.Write(output); session.Connection.Disconnect(); } // TODO: Perhaps reset player command queue to have exactly one "look" command? }
private void FormatSkillText(OutputBuilder outputBuilder) { var skillQueue = new Queue(); int rows = gameSkills.Count / 4; var longestSkillName = 0; foreach (var gameSkill in gameSkills) { // Find out what skill name is the longest if (gameSkill.Name.Length > longestSkillName) { longestSkillName = gameSkill.Name.Length; } skillQueue.Enqueue(gameSkill); } // TODO: The columns calculations and such look wrong... for (int i = 0; i < rows; i++) { string skill1 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); string skill2 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); string skill3 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); string skill4 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); outputBuilder.AppendLine($"{skill1} {skill2} {skill3} {skill4}"); } if ((gameSkills.Count % 4) > 0) { int columns = gameSkills.Count - (rows * 4); switch (columns) { case 1: string skillcolumn1 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); outputBuilder.AppendLine($"{skillcolumn1}"); break; case 2: string sk1 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); string sk2 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); outputBuilder.AppendLine($"{sk1} {sk2}"); break; case 3: string skl1 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); string skl2 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); string skl3 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); outputBuilder.AppendLine($"{skl1} {skl2} {skl3}"); break; } } }
private void RefreshScreen() { var output = new OutputBuilder(); output.AppendLine(); output.AppendLine("<%green%>Please select 1 from the list below:<%n%>"); FormatRaceText(output); output.AppendSeparator('=', "yellow"); output.AppendLine("To pick a race, just type the race's name. Example: human"); output.AppendLine("To view a races' description use the view command. Example: view orc"); output.AppendLine("To see this screen again type 'list'."); output.AppendSeparator('=', "yellow"); Session.Write(output); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { var session = actionInput.Session; if (session == null) { return; // This action only makes sense for player sessions. } var output = new OutputBuilder(); //// TODO Reference to config file var appName = "WheelMUD.vshost.exe"; output.AppendSeparator('=', "red", true); output.AppendLine("System Status:"); output.AppendSeparator('-', "red"); ////ManagementObjectCollection queryCollection1 = query1.Get(); var query1 = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem"); var queryCollection1 = query1.Get(); foreach (ManagementObject mo in queryCollection1) { output.Append($"Manufacturer : {mo["manufacturer"]}"); output.AppendLine($"Model : {mo["model"]}"); output.AppendLine($"Physical Ram : {(ulong)mo["totalphysicalmemory"] / 1024}"); } output.AppendSeparator('-', "red"); query1 = new ManagementObjectSearcher("SELECT * FROM Win32_process where NAME = '" + appName + "'"); queryCollection1 = query1.Get(); foreach (ManagementObject mo in queryCollection1) { foreach (var item in mo.Properties) { output.AppendLine($"<%b%><%red%>{item.Name}<%b%><%yellow%>{item.Value}<%n%>"); } } output.AppendSeparator('-', "red"); query1 = new ManagementObjectSearcher("SELECT * FROM Win32_timezone"); queryCollection1 = query1.Get(); foreach (ManagementObject mo in queryCollection1) { output.AppendLine($"This Server lives in:{mo["caption"]}"); } session.Write(output); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { var session = actionInput.Session; if (session == null) { return; // This action only makes sense for player sessions. } var parameters = actionInput.Params; // Ensure two 'credits' commands at the same time do not race for shared cache, etc. lock (cacheLockObject) { if (cachedContents == null || parameters.Length > 0 && parameters[0].ToLower() == "reload") { using var reader = new StreamReader(Path.Combine(GameConfiguration.DataStoragePath, "Credits.txt")); var output = new OutputBuilder(); string s; while ((s = reader.ReadLine()) != null) { if (!s.StartsWith(";")) { output.AppendLine(s); } } cachedContents = output; } session.Write(cachedContents); } }
private void RefreshScreen() { var output = new OutputBuilder(); output.AppendLine(); output.AppendLine("You have the following gender choices:"); foreach (var gender in GameSystemController.Instance.GameGenders) { output.AppendLine(gender.Name); } output.AppendLine(); output.AppendSeparator('-', "yellow"); output.AppendLine("Type your gender selection."); output.AppendSeparator('-', "yellow"); Session.Write(output); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> /// <remarks>Verify that the Guards pass first.</remarks> public override void Execute(ActionInput actionInput) { if (actionInput.Params.Length == 1 && actionInput.Params[0].ToLower() == "list" || !actionInput.Params.Any()) { var output = new OutputBuilder(); if (playerBehavior.Friends.Count == 0) { output.AppendLine("You currently have no friends listed."); } else { output.AppendLine("Your Friends:"); foreach (var friendName in playerBehavior.Friends) { var status = PlayerManager.Instance. FindLoadedPlayerByName(friendName, false) == null ? "Offline" : "Online"; output.AppendLine($"{friendName} [{status}]"); } } actionInput.Controller.Write(output); return; } if (actionInput.Params.Length != 2 && actionInput.Params[0].ToLower() != "add" && actionInput.Params[0].ToLower() != "remove") { actionInput.Controller.Write(new OutputBuilder(). AppendLine("Please use the format friends add/remove player name.")); return; } var targetedFriendName = actionInput.Params[1].ToLower(); var targetFriend = PlayerManager.Instance.FindLoadedPlayerByName(targetedFriendName, false); if (actionInput.Params[0].ToLower() == "add") { AddFriend(actionInput.Controller, targetFriend); } else if (actionInput.Params[0].ToLower() == "remove") { RemoveFriend(actionInput.Controller, targetedFriendName); } }
public override void Begin() { var output = new OutputBuilder(); output.AppendLine("You will now pick your character's starting talent."); Session.Write(output, false); RefreshScreen(); }
public override OutputBuilder Render(TerminalOptions terminalOptions, Command command) { var output = new OutputBuilder().AppendLine($"<%yellow%>{command.Name.ToUpper()}<%n%>:"); if (!string.IsNullOrWhiteSpace(command.Description)) { output.AppendLine(command.Description); } // TODO: Add command.Usage? Rename Example to "Examples" as string[]? if (!string.IsNullOrWhiteSpace(command.Example)) { output.AppendLine("<%yellow%>USAGE<%n%>:"); output.AppendLine(command.Example); } // TODO: Add command.SeeAlso as string[]? return(output); }
public override OutputBuilder Render(TerminalOptions terminalOptions, Thing player) { var stats = player.Stats; var statEffects = player.Behaviors.OfType <StatEffect>(); var output = new OutputBuilder(); var health = stats["HP"]; var healthMod = statEffects.Where(e => e.Stat.Abbreviation == "HP").Sum(e => e.ValueMod); var mana = stats["MANA"]; var damage = stats["DAMAGE"]; var init = stats["INIT"]; var attack = stats["ATK"]; var defense = stats["DEF"]; var armorPenalty = stats["ARMORPENALTY"]; var wieldMax = stats["WEAPONWIELDMAX"]; var hunt = stats["HUNT"]; var familiar = stats["FAMILIAR"]; var fate = stats["FATE"]; var healthLine = $"{health.Name,-13} {health.Value,5:####0}/{health.MaxValue,-5:####0} ({healthMod})".PadRight(31); var manaLine = $"{mana.Name,-12} {mana.Value,5:####0}/{mana.MaxValue,-5:####0}".PadRight(31); var damageLine = $"{damage.Name,-13} {damage.Value,5:##0}/{damage.MaxValue,-5:##0}".PadRight(31); var initLine = $"{init.Name,-16} {init.Value,-6}".PadRight(31); var attackLine = $"{attack.Name,-15} {attack.Value,3:##0}/{attack.MaxValue,-3:##0}".PadRight(31); var defenseLine = $"{defense.Name,-14} {defense.Value,3:##0}/{defense.MaxValue,-3:##0}".PadRight(31); var armorPenaltyLine = $"{armorPenalty.Name,-16} {armorPenalty.Value,2}".PadRight(31); var wieldMaxLine = $"{wieldMax.Name,-16} {wieldMax.Value,1}/{wieldMax.MaxValue,-1}".PadRight(31); var huntLine = $"{hunt.Name,-16} {hunt.Value,2}({hunt.MaxValue,2})".PadRight(31); var familiarLine = $"{familiar.Name,-16} {familiar.Value,1:0}{familiar.MaxValue,-1:(0)}".PadRight(31); var fateLine = $"{fate.Name,-16} {fate.Value,2}({fate.MaxValue,2})".PadRight(31); var nameAndTitle = string.IsNullOrWhiteSpace(player.Title) ? player.Name : $"{player.Name}, {player.Title}"; var pipe = "<%green%>|<%n%>"; output.AppendLine("<%green%>+-------------------------------------------------------------------+"); output.AppendLine($"{pipe} {nameAndTitle,-19} Level {"?",-6} Reputation {"?",-6} Kudos {"?",-6} {pipe}"); output.AppendLine("<%green%>+----------------+----------------+----------------+----------------+"); output.AppendLine($"{pipe} {healthLine} {pipe} {manaLine} {pipe}"); output.AppendLine($"{pipe} {damageLine} {pipe} {initLine} {pipe}"); output.AppendLine($"{pipe} {attackLine} {pipe} {defenseLine} {pipe}"); output.AppendLine($"{pipe} {armorPenaltyLine} {pipe} {wieldMaxLine} {pipe}"); output.AppendLine($"{pipe} {huntLine} {pipe} {familiarLine} {pipe}"); output.AppendLine($"{pipe} {fateLine} {pipe} {string.Empty.PadRight(31)} {pipe}"); output.AppendLine("<%green%>+---------------------------------^---------------------------------+<%n%>"); return(output); }
/// <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(); }
public override OutputBuilder Render(TerminalOptions terminalOptions, Thing player) { var senses = player.FindBehavior <SensesBehavior>(); var output = new OutputBuilder(); var invThings = player.Children.Where(presentThing => senses.CanPerceiveThing(presentThing)).ToArray(); output.AppendLine(invThings.Length > 0 ? "<%yellow%>Searching your inventory, you find:<%n%>" : "<%yellow%>You found no inventory.<%n%>"); foreach (var presentThing in invThings) { output.AppendLine($" <%magenta%>{presentThing.FullName}<%n%>"); } return(output); }
/// <summary>Sends the error message to the player.</summary> /// <param name="session">The session.</param> /// <param name="message">The message.</param> public static void SendErrorMessage(Session session, string message) { var wrappedMessage = new OutputBuilder(); wrappedMessage.AppendSeparator('=', "red", true, message.Length); wrappedMessage.AppendLine(message); wrappedMessage.AppendSeparator('=', "red", true, message.Length); session.Write(wrappedMessage); }
private void ViewSkillDescription(string skillName) { GameSkill foundSkill = GetSkill(skillName); if (foundSkill == null) { WrmChargenCommon.SendErrorMessage(Session, "That skill does not exist."); return; } var output = new OutputBuilder(); output.AppendSeparator('=', "yellow", true); output.AppendLine($"Description for {foundSkill.Name}"); output.AppendSeparator('-', "yellow"); output.AppendLine($"<%b%><%white%>{foundSkill.Description}"); output.AppendSeparator('=', "yellow", true); Session.Write(output); }
/// <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); }
public override OutputBuilder Render(TerminalOptions terminalOptions, Thing activePlayer) { string mudNameLine = " "; // TODO: Dynamic centering instead, if we want centering! string plural = string.Empty; var output = new OutputBuilder(); string plural1 = "is"; // TODO: Should query for players who can be known about by this player (e.g. omit wiz-inviz players, if any?) if (PlayerManager.Instance.Players.Count > 1) { plural = "s"; plural1 = "are"; } // TODO: A game-system specific renderer could be used to includ race/class info and so on, if desired. // TODO: Dividing lines could be influenced by activePlayer connection Terminal.Width. mudNameLine += GameConfiguration.Name; output.AppendLine(); output.AppendSeparator(); output.AppendLine(mudNameLine); output.AppendSeparator(); output.AppendLine(); output.AppendLine($"The following player{plural} {plural1} currently online:"); foreach (PlayerBehavior player in PlayerManager.Instance.Players) { var playerName = player.Parent.Name; var playerState = GetPlayerState(player); if (terminalOptions.UseMXP) { // TODO: "tell {0}" is not a good menu command; possibly friend add/remove, invite to group, hailing, and so on. // TODO: #107: Fix handling of MXP Secure Lines... (This wasn't being built in a safe way, and does not render correctly now.) output.AppendLine($"<%mxpsecureline%><send \"finger {playerName}|tell {playerName}\" \"|finger|tell\">{playerName}</send> - {player.Parent.FullName} {playerState}"); } else { output.AppendLine($"{playerName} - {player.Parent.FullName} {playerState}"); } } output.AppendLine(); output.AppendSeparator(); output.AppendLine($"Counted {PlayerManager.Instance.Players.Count} player{plural} online."); output.AppendLine(); output.AppendSeparator(); return(output); }
/// <summary>Called upon authentication of a session.</summary> /// <param name="session">The authenticated session.</param> public void OnSessionAuthenticated(Session session) { // If there was already a connected player for this new, authentic user session, kick the old // one (as it may have been a prior disconnect or whatnot or even a different player character // controlled by the same user account). // TODO: We can probably handle this more gracefully (without the extra logouts and messaging // the room about it and so on) by having the login process notice the target player is // already in the world sooner, and more directly taking fresh control of THAT Thing. PlayerBehavior previousPlayer = FindLoggedInPlayer(session.User.UserName); if (previousPlayer != null) { var msg = $"Duplicate player match, kicking session id {previousPlayer.SessionId} and keeping {session.ID}"; SystemHost.UpdateSystemHost(this, msg); var existingUserControlledBehavior = previousPlayer.Parent.Behaviors.FindFirst <UserControlledBehavior>(); if (existingUserControlledBehavior != null) { existingUserControlledBehavior.Controller.Write(new OutputBuilder().AppendLine("Another connection has logged in as you; closing this connection.")); } previousPlayer.LogOut(); RemovePlayer(previousPlayer.Parent); } // Track this player in the loaded players list. AddPlayer(session.Thing); // If this session doesn't have a player thing attached yet, load it up. Note that // for situations like character creation, we might already have our Thing, so we // don't want to load a duplicate version of the just-created player Thing. if (session.Thing == null) { var output = new OutputBuilder(); output.AppendLine("User was authenticated but the player character could not be loaded."); output.AppendLine("Please contact an administrator. Disconnecting."); session.Write(output); session.Connection.Disconnect(); } // TODO: Perhaps reset player command queue to have exactly one "look" command? }