public static string GetResultString(Move user, Move cpu, MoveResult result) { if (result.Result == MoveResultType.Tie) return "Tie!"; const string Format = "{0} {1} {2}"; bool win = result.Result == MoveResultType.Win; return string.Format(Format, win ? user : cpu, result.Action, win ? cpu : user); }
public MoveResult Play(Move move) { var result = new MoveResult(); if (this == move) { result.Result = MoveResultType.Tie; return result; } var dict = BeatMatrix[Type]; if (dict.ContainsKey(move.Type)) { result.Result = MoveResultType.Win; result.Action = dict[move.Type]; } else // User lost { result.Result = MoveResultType.Loss; result.Action = move.Play(this).Action; // Dirty dirty } return result; }
protected bool Equals(Move other) { return Type == other.Type; }
public static bool TryParse(string input, out Move move) { try { move = Parse(input); return true; } catch (ArgumentException) { move = null; } return false; }