-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
68 lines (47 loc) · 1.39 KB
/
Player.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
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Text;
namespace Scrabble.Game_Logic {
class Player {
private int Score { get; set; }
private Tile[] Hand { get; set; }
public Player() {
Score = 0;
Hand = new Tile[7];
}
public bool draw(Tile tile) {
for(int x=0; x<Hand.Length; x++) {
if(Hand[x] == null) {
Hand[x] = tile;
return true;
}
}
return false;
}
// this is what was called after player ended turn to re draw all tiles
public void refillHand(TileSet set) {
if (draw(set.grab())) {
refillHand(set);
}
}
// finds spot in hand of selected tile
// removes from hand
public void play(int index) {
Hand[index] = null;
}
// console testing purposes
public Tile getTile(int index) {
return Hand[index];
}
public override string ToString() {
return printHand();
}
public string printHand() {
string s = "";
for(int x=0; x< Hand.Length; x++){
s += $"{Hand[x]}, ";
}
return s;
}
}
}