-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.java
138 lines (124 loc) · 6.03 KB
/
Game.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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import java.io.IOException;
import java.util.List;
import java.util.Scanner;
public class Game {
public void start(Scanner sc) {
System.out.println("");
System.out.println(".----------------. .----------------. .----------------. .----------------. ");
System.out.println("| .--------------. || .--------------. || .--------------. || .--------------. |");
System.out.println("| | ____ ____ | || | _____ | || | _____ | || | _____ | |");
System.out.println("| | |_ || _| | || | |_ _| | || | |_ _| | || | |_ _| | |");
System.out.println("| | | |__| | | || | | | | || | | | | || | | | | |");
System.out.println("| | | __ | | || | | | | || | _ | | | || | | | | |");
System.out.println("| | _| | | |_ | || | _| |_ | || | | |_' | | || | _| |_ | |");
System.out.println("| | |____||____| | || | |_____| | || | `.___.' | || | |_____| | |");
System.out.println("| | | || | | || | | || | | |");
System.out.println("| '--------------' || '--------------' || '--------------' || '--------------' |");
System.out.println(" '----------------' '----------------' '----------------' '----------------' ");
System.out.println(" Kelompok 21 | IF2212 Pemrograman Berorientasi Objek | OperaVanJava");
System.out.println(" Ketik 1 untuk memulai");
System.out.println("");
String start = sc.next();
while (!start.equals("1")) {
System.out.println("Ketik 1 untuk memulai!");
start = sc.next();
}
System.out.println("");
}
public void listCommand() {
System.out.println("Command yang dapat kamu jalankan:");
System.out.println("[1] Lihat list kartu");
System.out.println("[2] Pilih Kartu");
System.out.println("[3] List Pemain");
System.out.println("[4] Urutan Pemain");
System.out.println("[5] Ambil Kartu Dari Deck");
System.out.println("[6] Declare Hiji");
System.out.println("[7] Bantuan");
}
public void space() {
System.out.println("");
System.out.println("--------------------------------------");
System.out.println("");
}
public void tableCardInfo(Card tableCard) {
System.out.println("Table Card: ");
System.out.println(tableCard.printCard());
System.out.println("");
}
public void listCard(List<Card> playerCardList) {
if (playerCardList.size() != 0) {
System.out.println("Berikut adalah list kartumu:");
for (int j = 0; j < playerCardList.size(); j++) {
System.out.println((j + 1) + ". " + playerCardList.get(j).printCard());
}
System.out.println(" ");
} else {
System.out.println("Kamu tidak memiliki kartu lagi!");
}
}
public void getColorOption() {
new Print<String>("Kamu mengeluarkan sebuah wildcard").enterPrint();
new Print<String>("1. Red").enterPrint();
new Print<String>("2. Blue").enterPrint();
new Print<String>("3. Yellow").enterPrint();
new Print<String>("4. Green").enterPrint();
new Print<String>("Warna apa yang kamu inginkan?").noEnterPrint();
}
public void getTableCard(Card card) {
new Print<Character>(' ').enterPrint();;
System.out.println("Table Card: ");
System.out.println(card.printCard());
new Print<Character>(' ').enterPrint();;
}
public void currentPlayerInfo(Player currentPlayer) {
System.out.println("Pemain Saat Ini: ");
System.out.println(currentPlayer.getName());
System.out.println("");
}
public void viewPlayer(Player[] playerList, int currTurn) {
for (int j = 0; j < playerList.length; j++) {
if (playerList[j] == playerList[currTurn]) {
System.out.println(playerList[j].getName() + " sedang giliran");
j += 1;
System.out.println(playerList[j % playerList.length].getName() + " giliran berikutnya");
System.out.println("");
}
}
}
public void listPlayer(Player[] playerList, int currTurn) {
for (int j = 0; j < playerList.length; j++) {
System.out.println("Pemain " + (j + 1) + ": " + playerList[j].getName());
System.out.println("Jumlah Kartu: " + (j + 1) + ": " + playerList[j].getCardLeft());
if (playerList[j] == playerList[currTurn]) {
System.out.println("Sedang giliran");
} else {
System.out.println("Tidak sedang giliran");
}
System.out.println("");
}
}
public void help() {
System.out.println("Bagaimana cara memainkan game ini?");
System.out.println("Pertama, pemain harus memasukkan banyaknya dan nama pemain");
System.out.println("Setelahnya kartu yang ada akan diacak dan dibagikan kepada pemain dengan setiap pemain mendapat 7 kartu");
System.out.println("Lalu dipilih kartu pertama untuk acuan dan pemain pertama");
System.out.println("Terdapat beberapa command penting. Diantaranya:");
System.out.println("[1] Lihat list kartu");
System.out.println("[2] Pilih Kartu");
System.out.println("[3] List Pemain");
System.out.println("[4] Urutan Pemain");
System.out.println("[5] Ambil Kartu Dari Deck");
System.out.println("[6] Declare Hiji");
System.out.println("[7] Bantuan");
}
public static void clearScreen(){
try {
if (System.getProperty("os.name").contains("Windows"))
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
else
Runtime.getRuntime().exec("clear");
} catch (IOException | InterruptedException ex) {
System.out.println(ex);
}
}
}