public static void assertWinner(Moves playerMove, Moves opponantMove) { var possibleMoves = new MoveHierachy().MoveList(); foreach (var move in possibleMoves) { if (move.moveName == playerMove && move.moveBeats.Contains(opponantMove)) { Console.WriteLine("You won the round!"); GameState.playerScore += 1; GameState.gamesPlayed++; break; } else if (move.moveName == opponantMove && move.moveBeats.Contains(playerMove)) { Console.WriteLine("You lost the round. Bad Luck"); GameState.opponantScore += 1; GameState.gamesPlayed++; break; } else if (move.moveName == opponantMove && move.moveName == playerMove) { Console.WriteLine("Draw! Rematch!"); break; } } }
public static Moves PlayerMove() { try { var possibleMoves = new MoveHierachy().MoveList(); // get the players move var choice = Console.ReadLine().ToLower(); Moves move = (Moves)Enum.Parse(typeof(Moves), choice); return(move); } catch { var possibleMove = ""; foreach (Moves x in Enum.GetValues(typeof(Moves))) { possibleMove += x + " "; } Console.WriteLine("Did not recognise the move, please try again"); Console.WriteLine(String.Format("Here is the list of possible moves: {0}", possibleMove)); Moves move = PlayerMove(); return(move); } }