示例#1
0
 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);
 }
示例#2
0
        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;
        }
示例#3
0
 protected bool Equals(Move other)
 {
     return Type == other.Type;
 }
示例#4
0
        public static bool TryParse(string input, out Move move)
        {
            try
            {
                move = Parse(input);
                return true;
            }
            catch (ArgumentException)
            {
                move = null;
            }

            return false;
        }