-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.cs
50 lines (43 loc) · 1.08 KB
/
Game.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Linq;
namespace VoracityMac
{
public class Game
{
private readonly IBoard _board;
private int _score;
public Game(IBoard board)
{
_board = board;
}
public IBoard Board
{
get { return _board; }
}
public int TilesRemaining()
{
return _board.Tiles().Count(t => t.IsActive);
}
public void NewGame()
{
_score = 0;
_board.ResetTiles();
}
public int Score()
{
return _score;
}
public void Chomp(Directions direction)
{
if (_board.CanMove(direction))
{
Board.Move(direction);
var tileWithNumberToMove = Board.CurrentTile;
for (int i = 1; i < tileWithNumberToMove.Number; i++)
{
_board.Move(direction);
}
_score += tileWithNumberToMove.Number;
}
}
}
}