private void ProcessAttributeCommand(SetAttributeCommand command, string s, ref int targetPoints) { var op = FindOperation(s); var numberString = Regex.Match(s, @"\d+").Value; if (string.IsNullOrWhiteSpace(numberString)) { WrmChargenCommon.SendErrorMessage(Session, "No valid number was found."); return; } int n; if (!int.TryParse(numberString, out n)) { WrmChargenCommon.SendErrorMessage(Session, "Could not process the number."); return; } if (string.IsNullOrWhiteSpace(op)) { // No operator? Try to set the value directly to the number provided. SetAttributeTarget(ref targetPoints, n); } else if (op == "+") { SetAttributeTarget(ref targetPoints, targetPoints + n); } else if (op == "-") { SetAttributeTarget(ref targetPoints, targetPoints - n); } }
private bool SetSkill(string skillName) { var selectedSkill = (from s in this.gameSkills where s.Name.Equals(skillName, StringComparison.OrdinalIgnoreCase) select s).FirstOrDefault(); if (selectedSkill == null) { WrmChargenCommon.SendErrorMessage(this.Session, "That skill does not exist."); return(false); } var alreadySelected = (from s in this.selectedSkills where s.Name.Equals(skillName, StringComparison.OrdinalIgnoreCase) select s).Any(); if (alreadySelected) { WrmChargenCommon.SendErrorMessage(this.Session, "You have already selected that skill."); return(false); } if (this.selectedSkills.Count() >= 3) { WrmChargenCommon.SendErrorMessage(this.Session, "You have already selected all 3 skills."); return(false); } this.selectedSkills.Add(selectedSkill); this.RefreshScreen(); this.Session.WritePrompt(); return(true); }
private void ViewRaceDescription(string race) { string raceToView = race.Replace("view ", string.Empty); CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; string properCaseRace = textInfo.ToTitleCase(raceToView); var foundRace = (from r in this.gameRaces where r.Name == properCaseRace select r).FirstOrDefault(); if (foundRace != null) { var sb = new StringBuilder(); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=" + Environment.NewLine); sb.AppendFormat("Description for {0}" + Environment.NewLine, foundRace.Name); sb.Append("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>" + Environment.NewLine); sb.Append("<%b%><%white%>" + foundRace.Description + Environment.NewLine); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>"); this.Session.Write(sb.ToString()); } else { WrmChargenCommon.SendErrorMessage(this.Session, "That race does not exist."); } }
/// <summary>ProcessInput is used to receive the user input during this state.</summary> /// <param name="command">The command text to be processed.</param> public override void ProcessInput(string command) { var currentCommand = command.ToLower().Trim(); switch (currentCommand) { case "view": ViewRaceDescription(currentCommand); break; case "list": RefreshScreen(); break; default: var race = GetRace(currentCommand); if (race != null) { var playerBehavior = Session.Thing.Behaviors.FindFirst <PlayerBehavior>(); playerBehavior.Race = race; StateMachine.HandleNextStep(this, StepStatus.Success); } else { WrmChargenCommon.SendErrorMessage(Session, "Invalid race. Try again, or use 'view [race]' or 'list'."); } break; } }
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."); } }
private bool SetSkill(string skillName) { var selectedSkill = GetSkill(skillName); if (selectedSkill == null) { WrmChargenCommon.SendErrorMessage(Session, "That skill does not exist."); return(false); } if (selectedSkills.Contains(selectedSkill)) { WrmChargenCommon.SendErrorMessage(Session, "You have already selected that skill."); return(false); } if (selectedSkills.Count() >= 3) { WrmChargenCommon.SendErrorMessage(Session, "You have already selected all 3 skills."); return(false); } selectedSkills.Add(selectedSkill); RefreshScreen(); return(true); }
/// <summary>Processes the text that the player sends while in this state.</summary> /// <param name="command">The command that the player just sent.</param> public override void ProcessInput(string command) { var commandParts = command.Split(' '); string currentCommand = commandParts[0].ToLower(); switch (currentCommand) { case "clear": this.ClearSkills(); break; case "view": if (commandParts.Length > 1) { this.ViewSkillDescription(commandParts[1]); } else { WrmChargenCommon.SendErrorMessage(this.Session, "Please select which skill you would like to view details for, like 'view axes'."); } break; case "list": this.RefreshScreen(); break; case "done": this.ProcessDone(); break; default: this.SetSkill(currentCommand); break; } }
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 } }
private string FormatSkillText() { var skillQueue = new Queue(); var text = new StringBuilder(); int rows = this.gameSkills.Count / 4; var longestSkillName = 0; foreach (var gameSkill in this.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); text.AppendFormat("{0} {1} {2} {3}" + Environment.NewLine, skill1, skill2, skill3, skill4); } if ((this.gameSkills.Count % 4) > 0) { int columns = this.gameSkills.Count - (rows * 4); switch (columns) { case 1: string skillcolumn1 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); text.AppendFormat("{0}" + Environment.NewLine, skillcolumn1); break; case 2: string sk1 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); string sk2 = WrmChargenCommon.FormatToColumn(longestSkillName, ((GameSkill)skillQueue.Dequeue()).Name); text.AppendFormat("{0} {1}" + Environment.NewLine, 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); text.AppendFormat("{0} {1} {2}" + Environment.NewLine, skl1, skl2, skl3); break; } } text.Append(Environment.NewLine); return(text.ToString()); }
/// <summary>ProcessInput is used to receive the user input during this state.</summary> /// <param name="command">The command text to be processed.</param> public override void ProcessInput(string command) { if (!string.IsNullOrEmpty(command) && this.SetGender(command)) { this.ProcessDone(); } else if (!this.HandleCommand(command)) { WrmChargenCommon.SendErrorMessage(this.Session, "Invalid command. Please select a gender."); } }
private void ProcessDone() { if (this.selectedTalent != string.Empty) { // Proceed to the next step. this.StateMachine.HandleNextStep(this, StepStatus.Success); } else { WrmChargenCommon.SendErrorMessage(this.Session, "Please select a talent before proceeding to the next step."); } }
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 ProcessDone() { if (this.selectedRace != null) { var playerBehavior = this.StateMachine.NewCharacter.Behaviors.FindFirst <PlayerBehavior>(); playerBehavior.Race = this.selectedRace; // Proceed to the next step. this.StateMachine.HandleNextStep(this, StepStatus.Success); } else { WrmChargenCommon.SendErrorMessage(this.Session, "You must select a valid race before continuing."); } }
private bool SetGender(string specifiedGender) { // Support strings of format "select m" and "m" by ignoring "select " from the input. string currentGender = specifiedGender.Replace("select ", string.Empty); this.selectedGender = (from g in GameSystemController.Instance.GameGenders where g.Name.Equals(currentGender, StringComparison.CurrentCultureIgnoreCase) || g.Abbreviation.Equals(currentGender, StringComparison.CurrentCultureIgnoreCase) select g).FirstOrDefault(); if (this.selectedGender == null) { WrmChargenCommon.SendErrorMessage(this.Session, string.Format("'{0}' is an invalid gender selection.", currentGender)); this.RefreshScreen(); } return(this.selectedGender != null); }
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); }
private void ProcessDone() { if (this.selectedSkills.Count() != 3) { WrmChargenCommon.SendErrorMessage(this.Session, "Please select all your starting skills before proceeding to the next step."); return; } // Assign the skills to the PlayerBehavior's parent, which should be a Thing object. var playerBehavior = this.Session.Thing.Behaviors.FindFirst <PlayerBehavior>(); foreach (var gameSkill in this.selectedSkills) { playerBehavior.Parent.Skills.Add(gameSkill.Name, gameSkill); } // Proceed to the next step. this.StateMachine.HandleNextStep(this, StepStatus.Success); }
private void ViewTalentDescription(string talent) { Talent foundTalent = GetTalent(talent); if (foundTalent != null) { var sb = new StringBuilder(); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=" + Environment.NewLine); sb.AppendFormat("Description for {0}" + Environment.NewLine, foundTalent.Name); sb.Append("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>" + Environment.NewLine); sb.Append("<%b%><%white%>" + foundTalent.Description + Environment.NewLine); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>"); Session.Write(sb.ToString()); } else { WrmChargenCommon.SendErrorMessage(Session, "That talent does not exist."); } }
private void ViewSkillDescription(string skillName) { GameSkill foundSkill = GetSkill(skillName); if (foundSkill == null) { WrmChargenCommon.SendErrorMessage(Session, "That skill does not exist."); return; } var sb = new StringBuilder(); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=" + Environment.NewLine); sb.AppendFormat("Description for {0}" + Environment.NewLine, foundSkill.Name); sb.Append("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>" + Environment.NewLine); sb.Append("<%b%><%white%>" + foundSkill.Description + Environment.NewLine); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>"); Session.Write(sb.ToString()); }
private void ViewTalentDescription(string talent) { var foundTalent = GetTalent(talent); if (foundTalent != null) { var output = new OutputBuilder(); output.AppendSeparator('=', "yellow", true); output.AppendLine($"Description for {foundTalent.Name}"); output.AppendSeparator('-', "yellow"); output.AppendLine($"<%b%><%white%>{foundTalent.Description}"); output.AppendSeparator('=', "yellow", true); Session.Write(output); } else { WrmChargenCommon.SendErrorMessage(Session, "That talent does not exist."); } }
private void SetTalent(string talentToSet) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; Talent currentSelection = (from r in this.talents where r.Name.ToLower() == talentToSet.ToLower() select r).FirstOrDefault(); if (currentSelection != null) { this.selectedTalent = textInfo.ToTitleCase(talentToSet); } else { WrmChargenCommon.SendErrorMessage(this.Session, "That talent does not exist."); } this.RefreshScreen(); }
private void SetAttributeTarget(ref int targetPoints, int newValue) { int netChange = newValue - targetPoints; if (newValue > 6) { WrmChargenCommon.SendErrorMessage(Session, "No attribute can be greater than 6."); } else if (newValue < 0) { WrmChargenCommon.SendErrorMessage(Session, "No attribute can be less than 0."); } else if (SpentPoints + netChange > MaxPoints) { WrmChargenCommon.SendErrorMessage(Session, "You do not have enough points to spend."); } else { targetPoints = newValue; } }
/// <summary>Processes the text that the player sends while in this state.</summary> /// <param name="s">The command that the player just sent.</param> public override void ProcessInput(string s) { var command = FindTargetCommand(s); switch (command) { case SetAttributeCommand.Warrior: ProcessAttributeCommand(command, s, ref warriorPoints); break; case SetAttributeCommand.Rogue: ProcessAttributeCommand(command, s, ref roguePoints); break; case SetAttributeCommand.Mage: ProcessAttributeCommand(command, s, ref magePoints); break; case SetAttributeCommand.Done: if (SpentPoints != MaxPoints) { WrmChargenCommon.SendErrorMessage(Session, "You have not spent all your points."); } else { // Proceed to the next step. SetPlayerBehaviorAttributes(); StateMachine.HandleNextStep(this, StepStatus.Success); return; } break; default: WrmChargenCommon.SendErrorMessage(Session, "Unknown command. Please use warrior, rogue, mage, or done."); break; } RefreshScreen(); }
private void ViewSkillDescription(string skillName) { GameSkill foundSkill = (from s in this.gameSkills where s.Name.Equals(skillName, StringComparison.OrdinalIgnoreCase) select s).FirstOrDefault(); if (foundSkill == null) { WrmChargenCommon.SendErrorMessage(this.Session, "That skill does not exist."); return; } var sb = new StringBuilder(); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=" + Environment.NewLine); sb.AppendFormat("Description for {0}" + Environment.NewLine, foundSkill.Name); sb.Append("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>" + Environment.NewLine); sb.Append("<%b%><%white%>" + foundSkill.Description + Environment.NewLine); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>"); this.Session.Write(sb.ToString()); }
private void ViewTalentDescription(string talent) { string talentToView = talent.Replace("view ", string.Empty); Talent foundTalent = this.talents.Find(s => s.Name.Equals(talentToView, StringComparison.CurrentCultureIgnoreCase)); if (foundTalent != null) { var sb = new StringBuilder(); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=" + Environment.NewLine); sb.AppendFormat("Description for {0}" + Environment.NewLine, foundTalent.Name); sb.Append("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>" + Environment.NewLine); sb.Append("<%b%><%white%>" + foundTalent.Description + Environment.NewLine); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>"); this.Session.Write(sb.ToString()); } else { WrmChargenCommon.SendErrorMessage(this.Session, "That talent does not exist."); } }
private void SetRace(string raceToSelect) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; string currentRace = textInfo.ToTitleCase(raceToSelect); GameRace currSelection = (from r in this.gameRaces where r.Name == currentRace select r).FirstOrDefault(); if (currSelection != null) { this.selectedRace = currSelection; } else { WrmChargenCommon.SendErrorMessage(this.Session, "That race does not exist."); } this.RefreshScreen(); }
private void SetSkill(string skillToSet) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; string currentSkill = textInfo.ToTitleCase(skillToSet); GameSkill currentSelection = (from r in this.gameSkills where r.Name == currentSkill select r).FirstOrDefault(); if (currentSelection != null) { if (string.IsNullOrEmpty(this.skillOne)) { this.skillOne = currentSkill; this.skillCount = 1; } else if (string.IsNullOrEmpty(this.skillTwo)) { this.skillTwo = currentSkill; this.skillCount = 2; } else if (string.IsNullOrEmpty(this.skillThree)) { this.skillThree = currentSkill; this.skillCount = 3; } } else { WrmChargenCommon.SendErrorMessage(this.Session, "That skill does not exist."); } this.RefreshScreen(); this.Session.WritePrompt(); }
/// <summary>ProcessInput is used to receive the user input during this state.</summary> /// <param name="command">The command text to be processed.</param> public override void ProcessInput(string command) { var commandParts = command.Split(' '); var currentCommand = commandParts[0]; switch (currentCommand) { case "view": if (commandParts.Length > 1) { string talentName = string.Join(" ", commandParts, 1, commandParts.Length - 1); ViewTalentDescription(talentName); } else { WrmChargenCommon.SendErrorMessage(Session, "Please select which talent you would like to view details for, like 'view sailor'."); } break; case "list": RefreshScreen(); break; default: var talent = GetTalent(currentCommand); if (talent != null) { // TODO: Save talent to a WRM-specific Behavior? StateMachine.HandleNextStep(this, StepStatus.Success); } else { WrmChargenCommon.SendErrorMessage(Session, "Invalid talent. Try again, or use 'view [talent]' or 'list'."); } break; } }
/// <summary>ProcessInput is used to receive the user input during this state.</summary> /// <param name="command">The command text to be processed.</param> public override void ProcessInput(string command) { string currentCommand = command.ToLower().Trim(); switch (currentCommand) { case "clear": this.ClearRace(); break; case "view": this.ViewRaceDescription(currentCommand); break; case "done": this.ProcessDone(); break; case "list": this.RefreshScreen(); break; default: string tentativeRaceName = this.GetCommardPart(currentCommand); if (tentativeRaceName == string.Empty) { this.SetRace(currentCommand); } else { WrmChargenCommon.SendErrorMessage(this.Session, "Invalid command. Please use clear, view, list, or done."); } break; } }
private void ViewSkillDescription(string skill) { string skillToView = skill.Replace("view ", string.Empty); var game = GameSystemController.Instance; GameSkill foundSkill = game.GameSkills.Find(s => s.Name.ToLower() == skillToView); if (foundSkill != null) { var sb = new StringBuilder(); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=" + Environment.NewLine); sb.AppendFormat("Description for {0}" + Environment.NewLine, foundSkill.Name); sb.Append("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>" + Environment.NewLine); sb.Append("<%b%><%white%>" + foundSkill.Description + Environment.NewLine); sb.Append("<%b%><%yellow%>=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=<%n%>"); this.Session.Write(sb.ToString()); } else { WrmChargenCommon.SendErrorMessage(this.Session, "That skill does not exist."); } }