-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtension.cs
58 lines (43 loc) · 1.53 KB
/
Extension.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
58
#nullable disable
namespace SnakesAndLadders;
class Extension{
private static readonly int _numNodes = 100;
public static void generateNodes(Board board){
for(int i = _numNodes; i > 1; i--){
Node node = new(i);
node.nodeState = Node.NodeState.unoccupied;
board.allNodes.Add(node);
}
Node startingNode = new(1);
startingNode.nodeState = Node.NodeState.occupied;
board.allNodes.Add(startingNode);
Console.WriteLine(board.allNodes.Count);
Console.WriteLine("----Completed Generating Nodes----\n");
}
public static void generatePawns(Board board){
string strNumPlayers;
int numPlayers;
Node startingNode = board.allNodes[0];
do{
Console.Clear();
Console.WriteLine("Enter Number of Players: ");
strNumPlayers = Console.ReadLine();
if(string.IsNullOrEmpty(strNumPlayers)){
Console.WriteLine("Number of Players Cannot be Null!");
Thread.Sleep(2000);
}
} while(string.IsNullOrEmpty(strNumPlayers));
numPlayers = Convert.ToInt32(strNumPlayers);
for (int i = 0; i < numPlayers; i++){
Pawn pawn = new(i);
pawn.nodeAt = startingNode;
board.allPawns.Add(pawn);
}
Console.WriteLine("----Completed Generating Pawns----\n");
}
public static int rollDie(){
Random r = new Random();
int die = r.Next(1,7);
return die;
}
}