-
Notifications
You must be signed in to change notification settings - Fork 0
/
TurnManager.cs
57 lines (49 loc) · 1.37 KB
/
TurnManager.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
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Text;
namespace Slick
{
class TurnManager
{
// 1. Buy land plot
// 2. Drill
// 3. Nothing
// 4. End Turn
List<Player> Players;
int currentPlayerIndex = 0;
public Player CurrentPlayer
{
get { return Players[currentPlayerIndex]; }
}
Board board;
public TurnManager(Board board, List<Player> players)
{
this.board = board;
this.Players = players;
}
public void BuyLand(int x, int y)
{
CurrentPlayer.Money -= board.PurchaseCost(x, y);
board.PurchaseCell(x, y, CurrentPlayer);
NextTurn();
}
/// <summary>
/// Drills for oil at given location.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="depth">How deep to drill(1-3)</param>
/// <returns>True, if oil was found.</returns>
public bool DrillLand(int x, int y, int depth)
{
CurrentPlayer.Money -= board.DrillCost(x, y, depth);
NextTurn();
return board.DrillCell(x, y, depth);
}
private void NextTurn()
{
currentPlayerIndex++;
currentPlayerIndex %= Players.Count;
}
}
}