using System; using System.Text.RegularExpressions; public class CarpentryMessageParser { private Regex reStart = new Regex("You start (to improve|hammering|polishing|filing|carving) the"); private Regex reEnd4 = new Regex("You damage the .* a little|You (will want to polish|must use a file|must use a mallet|notice some notches)|The .* could be improved with (a|some more) log"); private Regex reEnd5 = new Regex("You improve the .* a bit"); private Regex reSkill = new Regex("Carpentry increased"); private bool hasEnded = false; public bool isActionStart(String message) { if (reStart.IsMatch(message)) { hasEnded = false; return true; } return false; } public bool isActionEnd(String message) { if (hasEnded) { return false; } if (reEnd4.IsMatch(message) || reEnd5.IsMatch(message)) { hasEnded = true; return true; } return false; } public bool isSkillGain(String message) { return reSkill.IsMatch(message); } public String getName() { return "Carpentry"; } }