-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.java
More file actions
99 lines (78 loc) · 1.84 KB
/
Copy pathPlayer.java
File metadata and controls
99 lines (78 loc) · 1.84 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
Nick Soetaert
Player.java
Parent: N/A
Children: N/A
*/
import java.util.*;
public class Player{
ArrayList<Card> hand = new ArrayList<Card>();
ArrayList<PropertySet> properties = new ArrayList<PropertySet>();
int bank;
private int _movesLeft;
public Player(Deck deck){
for(int i = 0; i < 5; i++){
deck.drawCard();
}
}
//Helper function while game is text-based
void displayCards(){
System.out.println("YOUR HAND:");
int i = 0;
for(Card c : hand){
i++;
System.out.println(i + ") " + c.getName());
}
System.out.println("YOUR PROPERTIES:");
for(PropertySet p : properties){
p.displayCards();
}
}
void startTurn(){
_movesLeft = 3;
}
//get rid of while loop? (what if you win mid turn?)
void useMove(){
Scanner s = new Scanner(System.in);
while(_movesLeft > 0){
System.out.println(" ");
System.out.println("Would you like to...");
System.out.println("a) Play a card from your hand");
System.out.println("b) Move a card already played on the table");
System.out.println("c) End your turn");
String input = s.nextLine();
switch(input){
case "a":
playCard();
break;
case "b":
endTurn();
break;
case "c":
moveCard();
break;
default:
System.out.println("Please only enter lower case letters a, b, or c.");
}
}
while(hand.size() > 7){
System.out.println("You have " + hand.size()
+ " cards left at the end of your turn.");
System.out.println("Select a card from your hand by index to discard:");
displayCards();
int input = s.nextInt();
}
}
void playCard(){
_movesLeft--;
}
void moveCard(){
_movesLeft--;
}
void endTurn(){
_movesLeft = 0;
}
void discard(int cardIndex){
hand.remove(cardIndex);
};
}