40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using GameModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace GameHandler.Parser
|
|
{
|
|
public static class ThrowCommandParser
|
|
{
|
|
public static ThrowCommandData Parse(string data, bool withFreePlayerSelection, int playerId = 0)
|
|
{
|
|
if (string.IsNullOrEmpty(data))
|
|
throw new ArgumentNullException("data");
|
|
|
|
if (!withFreePlayerSelection && playerId != 0)
|
|
{
|
|
throw new ArgumentNullException("playerid not selectable");
|
|
}
|
|
|
|
string pindata;
|
|
if (withFreePlayerSelection)
|
|
{
|
|
var player = data.Substring(0, 1);
|
|
playerId = int.Parse(player);
|
|
pindata = data.Substring(2, data.Length - 2);
|
|
}
|
|
else
|
|
{
|
|
pindata = data;
|
|
}
|
|
|
|
return new ThrowCommandData(playerId, Regex.Match(pindata, @"\d+").Value, data.Contains("b"), data.Contains("s"), data.Contains("e"), data.Contains("u"), data.Contains("r"));
|
|
}
|
|
}
|
|
}
|