-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsolePlayer.cs
More file actions
29 lines (28 loc) · 805 Bytes
/
ConsolePlayer.cs
File metadata and controls
29 lines (28 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
namespace GameOf2048
{
public class ConsolePlayer : IPlayer
{
public Moves MakeMove(int[][] board)
{
while(true)
{
var ch = Console.ReadKey(false).Key;
switch(ch)
{
case ConsoleKey.LeftArrow:
return Moves.LEFT;
case ConsoleKey.RightArrow:
return Moves.RIGHT;
case ConsoleKey.UpArrow:
return Moves.UP;
case ConsoleKey.DownArrow:
return Moves.DOWN;
case ConsoleKey.Escape:
Environment.Exit(0);
break;
}
}
}
}
}