Example #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);
 }
Example #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;
        }