public void AddAction(ActionRaw action) { Action a = new Action(); a.ActionRaw = action; AddAction(a); }
public Multiattack ParseMultiattack(ActionRaw raw, List <string> errors, List <Action> actions) { var action = new Multiattack { Name = raw.Name, Text = new Regex("[ ]{2,}", RegexOptions.None).Replace(raw.Text.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " "), " "), Actions = new Dictionary <string, int>() }; var textSplit = action.Text.ToLower().Split(new[] { ":", ",", "and", "or", "." }, StringSplitOptions.RemoveEmptyEntries); foreach (var t in textSplit) { FindActionInText(t, actions, action); } return(action); }
public Action ParseAction(ActionRaw raw, List <string> errors, DynamicEnumProvider dep) { var action = new Action { Name = raw.Name, Text = new Regex("[ ]{2,}", RegexOptions.None).Replace(raw.Text.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " "), " "), }; GetAttackTypeFromText(action, errors); if (action.Attack != null) { GetHitBonusFromText(action, errors); GetReachFromText(action, errors, out var reachEnd); GetTargetFromText(action, errors, reachEnd); } var pos = 0; FindHitEffects(action, errors, ref pos, dep); return(action); }
private void TestInternal(string text, string[] actions, Dictionary <string, int> result) { var ap = new ActionParser(); var raw = new ActionRaw() { Name = "Multiattack", Text = text }; var errors = new List <string>(); var res = ap.ParseMultiattack(raw, errors, actions.Select(a => a == "Claw" ? new Action() { Name = a, Attack = new Models.CoreData.Attack() { Type = Models.CoreData.Enums.AttackType.Melee_Weapon_Attack } } : new Action() { Name = a }).ToList()); Assert.True(res.Actions.All(ra => result[ra.Key] == ra.Value)); Assert.True(result.All(ra => res.Actions[ra.Key] == ra.Value)); }