Skip to content

Commit

Permalink
spells that require quotes for conflicting names now work
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamKenneth committed Feb 11, 2018
1 parent 00f7c50 commit 8667bd5
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions MIMWebClient/Core/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using MIMWebClient.Core.Mob.Events;

namespace MIMWebClient.Core
Expand Down Expand Up @@ -227,7 +228,7 @@ public static void Commands(string commandOptions, string commandKey, PlayerSetu
case "cast cure light":
new CureLight().StartCureLight(context, playerData, room, commandOptions);
break;
case "cure blindness":
case "c cure blindness":
new CureBlindness().StartCureBlindness(context, playerData, room, commandOptions);
break;
case "c detect invis":
Expand Down Expand Up @@ -476,15 +477,36 @@ public static void ParseCommand(string input, PlayerSetup.Player playerData, Roo
if ((commands[1].Equals("in", StringComparison.InvariantCultureIgnoreCase) || commands[1].Equals("at", StringComparison.InvariantCultureIgnoreCase) || commands[1].Equals("up", StringComparison.InvariantCultureIgnoreCase)))
{
commandKey = commands[0] + " " + commands[1];
commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal)).Trim();
commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal)).Trim();
}
else if (commandKey.Equals("c", StringComparison.InvariantCultureIgnoreCase) || commandKey.Equals("cast", StringComparison.InvariantCultureIgnoreCase) && commands.Length > 1)
{// rework
commandKey = commands[1] + " " + commands[2];
{
commandKey = commands[0] + " " + commands[1] + " ";

var reg = new Regex("'.*?'");
var match = reg.Match(enteredCommand);

if (match.Success)
{
commandKey = commands[0] + " " + commands[1].Replace("'", "") + " " +
commands[2].Replace("'", "");

var hasTarget = commands.Length >= 4;

commandOptions =
enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal))
.Trim();
}
else
{
commandOptions =
enteredCommand.Substring(enteredCommand.IndexOf(commands[0], StringComparison.Ordinal))
.Trim();
}



commandOptions =
enteredCommand.Substring(enteredCommand.IndexOf(commands[3], StringComparison.Ordinal))
.Trim();


}
else
Expand All @@ -496,7 +518,7 @@ public static void ParseCommand(string input, PlayerSetup.Player playerData, Roo

}

var command = Startup.CommandKey.FirstOrDefault(x => x.Key.StartsWith(commandKey, StringComparison.InvariantCultureIgnoreCase));
var command = Startup.CommandKey.FirstOrDefault(x => x.Key.StartsWith(commandKey.Trim(), StringComparison.InvariantCultureIgnoreCase));

Command.Commands(commandOptions, command.Value, playerData, room);

Expand Down

0 comments on commit 8667bd5

Please sign in to comment.