-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHumanPlayer.java
55 lines (50 loc) · 1.51 KB
/
HumanPlayer.java
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
import java.util.Scanner;
import java.util.ArrayList;
public class HumanPlayer extends Player
{
public HumanPlayer(Card[] tops, Card[] bottoms, Card[] privates, Card[] enemyTops, Card[] enemyBottoms, Card[] enemyPrivates)
{
super(tops, bottoms, privates, enemyTops, enemyBottoms, enemyPrivates);
}
//MOVE: <code><index>
//code: T for top, B for bottom, P for private
//index: 0 start
//Postcondition: move is valid
public String getMove(Card placedCard)
{
boolean isValid = true;
String move = "";
Scanner reader = new Scanner(System.in);
ArrayList legalMoves = getAllLegalMoves(placedCard)[0];
do {
System.out.print("What move should we do? Input: ");
move = reader.nextLine();
// String moveLoc = moveLine.substring(0, 1);
// int index = Character.getNumericValue(moveLine.charAt(1));
// Object[] move = [moveLoc, index];
} while (!legalMoves.contains(move));
return move;
}
public int getSurCall()
{
Scanner reader = new Scanner(System.in);
boolean valid = true;
do {
System.out.print("What sur should we call? Input: ");
String surString = reader.nextLine().substring(0, 1);
if (surString.equalsIgnoreCase("s")) {
return Card.SPADES;
} else if (surString.equalsIgnoreCase("c")) {
return Card.CLUBS;
} else if (surString.equalsIgnoreCase("d")) {
return Card.DIAMONDS;
} else if (surString.equalsIgnoreCase("h")) {
return Card.HEARTS;
} else {
System.out.println("Invalid sur!");
valid = false;
}
} while (!valid);
return -2;
}
}