Skip to content

Commit 0afbf5e

Browse files
committed
network
1 parent df28f4e commit 0afbf5e

24 files changed

+114
-95
lines changed

src/main/java/clientcontroller/Controller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public String showAll() {
268268

269269
public boolean admin() {
270270
try {
271-
dataOutputStream.writeUTF("admin " + token);
271+
dataOutputStream.writeUTF("admin enter " + token);
272272
dataOutputStream.flush();
273273
String result = dataInputStream.readUTF();
274274
return result.equals("true");

src/main/java/clientview/Admin.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package clientview;
22

33
import clientcontroller.Controller;
4-
import model.CheatSheet;
54

6-
import java.io.IOException;
75
import java.util.regex.Matcher;
86
import java.util.regex.Pattern;
97

@@ -24,12 +22,12 @@ public static Admin getInstance() {
2422
public void run() {
2523
System.out.println("welcome abp");
2624
while (true) {
27-
String input = Main.scanner.nextLine();
28-
Matcher matcher1 = getCommand(input, "^set ([a-zA-Z\\s]+) forbidden$");
29-
Matcher matcher2 = getCommand(input, "^set ([a-zA-Z\\s]+) allowed$");
30-
Matcher matcher3 = getCommand(input, "exit");
31-
Matcher matcher4 = getCommand(input, "^increase ([a-zA-Z\\s]+)$");
32-
Matcher matcher5 = getCommand(input, "^decrease ([a-zA-Z\\s]+)$");
25+
String input = MainClient.scanner.nextLine();
26+
Matcher matcher1 = getCommand(input, "^set ([a-zA-Z]+) forbidden$");
27+
Matcher matcher2 = getCommand(input, "^set ([a-zA-Z]+) allowed$");
28+
Matcher matcher3 = getCommand(input, "^exit");
29+
Matcher matcher4 = getCommand(input, "^increase ([a-zA-Z]+)$");
30+
Matcher matcher5 = getCommand(input, "^decrease ([a-zA-Z]+)$");
3331
if(matcher1.find()){
3432
System.out.println(controller.setForbidden(matcher1.group(1)));
3533
}

src/main/java/clientview/DeckView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static clientview.DeckView getInstance()
2626
public void run() {
2727
System.out.println("welcome to deck menu");
2828
while (true) {
29-
String input= Main.scanner.nextLine();
29+
String input= MainClient.scanner.nextLine();
3030
Matcher matcher = getCommand(input, "deck create (\\w+)");
3131
Matcher matcher1 = getCommand(input, "deck delete (\\w+)");
3232
Matcher matcher2 = getCommand(input, "^deck set-activate (\\w+)");

src/main/java/clientview/Duel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.regex.Pattern;
55

66
import clientcontroller.*;
7-
import servercontroller.GlobalVariable;
87

98
public class Duel {
109
Controller controller = Controller.getInstance();
@@ -27,7 +26,7 @@ public static Duel getInstance() {
2726
public void run() {
2827
System.out.println("welcome to duel menu");
2928
while (true) {
30-
String input = Main.scanner.nextLine();
29+
String input = MainClient.scanner.nextLine();
3130
Matcher matcherPlayer0 = getCommand(input, "duel new second-player (\\w+) rounds (\\d)");
3231
Matcher matcherPlayer1 = getCommand(input, "duel new rounds (\\d) second-player (\\w+)");
3332
Matcher matcherSelect4 = getCommand(input, "select spell (\\d)");

src/main/java/clientview/GraveView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static GraveView getInstance() {
1414
}
1515
public void run(){
1616
while(true){
17-
String input=Main.scanner.nextLine();
17+
String input= MainClient.scanner.nextLine();
1818
if(input.equals("back")){
1919
MenuHandler.runBack(Menu.GRAVEYARD);
2020
break;

src/main/java/clientview/Lobby.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package clientview;
22

33
import clientcontroller.Controller;
4-
import clientview.MainView;
54

65
import java.time.LocalDateTime;
76
import java.time.temporal.ChronoUnit;
@@ -23,7 +22,7 @@ public static Lobby getInstance()
2322
public void run(){
2423
System.out.println("welcome to main menu");
2524
while(true){
26-
String input=Main.scanner.nextLine();
25+
String input= MainClient.scanner.nextLine();
2726
Matcher matcher = getCommand(input, "^request game round (\\d)$");
2827
//Matcher matcher1 = getCommand(input, "^request game round (\\d) username");
2928
Matcher matcher2 = getCommand(input, "exit");
@@ -38,7 +37,7 @@ public void requestView(String round){
3837
LocalDateTime l=LocalDateTime.now();
3938
System.out.println("you cancel your request by typing 'cancel request' or wait to connect ...");
4039
while(ChronoUnit.SECONDS.between(l,LocalDateTime.now())<6) {
41-
s = Main.scanner.nextLine();
40+
s = MainClient.scanner.nextLine();
4241
if(s!=null&&s.startsWith("cancel")) {
4342
System.out.println("you canceled");
4443
return;

src/main/java/clientview/Login.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static Login getInstance() {
2222
public void run() {
2323
System.out.println("welcome to login menu");
2424
while (true) {
25-
String input=Main.scanner.nextLine();
25+
String input= MainClient.scanner.nextLine();
2626
Matcher matcher1 = getCommand(input, "user create username (\\w+) nickname (\\w+) password (\\w+)");
2727
Matcher matcher1_1 = getCommand(input, "user create nickname (\\w+) username (\\w+) password (\\w+)");
2828
Matcher matcher1_2 = getCommand(input, "user create username (\\w+) password (\\w+) nickname (\\w+)");
@@ -78,13 +78,13 @@ else if(matcher6.find())
7878
public void loginUser(Matcher matcher, int flag) {
7979
if (flag == 0) {
8080
System.out.println(controller.loginUser(matcher.group(1), matcher.group(2)));
81-
if(controller.loginUser(matcher.group(1), matcher.group(2)).equals("user logged in successfully!")){
81+
if(controller.loginUser(matcher.group(1), matcher.group(2)).startsWith("user logged in")){
8282
MenuHandler.runNextLogin();
8383
}
8484
b = 8;
8585
} else {
8686
System.out.println(Controller.getInstance().loginUser(matcher.group(2), matcher.group(1)));
87-
if(controller.loginUser(matcher.group(2), matcher.group(1)).equals("user logged in successfully!")){
87+
if(controller.loginUser(matcher.group(2), matcher.group(1)).equals("user logged in!")){
8888
MenuHandler.runNextLogin();
8989
}
9090
}

src/main/java/clientview/Main.java renamed to src/main/java/clientview/MainClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.util.Scanner;
1111

1212

13-
public class Main {
13+
public class MainClient {
1414

1515
public static Scanner scanner=new Scanner(System.in);
1616

src/main/java/clientview/MainView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.regex.Matcher;
44
import java.util.regex.Pattern;
55
import clientcontroller.*;
6-
import model.*;
6+
77
public class MainView {
88
private static MainView mainView=null;
99
private MainView(){
@@ -21,7 +21,7 @@ public static MainView getInstance()
2121
public void run(){
2222
System.out.println("welcome to main menu");
2323
while(true){
24-
String input=Main.scanner.nextLine();
24+
String input= MainClient.scanner.nextLine();
2525
Matcher matcher = getCommand(input, "scoreboard show");
2626
Matcher matcher1 = getCommand(input, "user logout");
2727
Matcher matcher2 = getCommand(input, "exit");

src/main/java/clientview/Profile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static Profile getInstance() {
2323
public void run() {
2424
System.out.println("welcome to profile menu");
2525
while (true) {
26-
String input = Main.scanner.nextLine();
26+
String input = MainClient.scanner.nextLine();
2727
Matcher matcher1 = getCommand(input, "profile change nickname (\\w+)");
2828
Matcher matcher2 = getCommand(input, "profile change password current (\\w+) new (\\w+)|profile change current password(\\w+) new(\\w+)|profile change current(\\w+) new(\\w+) password");
2929
Matcher matcher2_1 = getCommand(input, "profile change password new (\\w+) current (\\w+)|profile change new(\\w+) password current(\\w+)|profile change new(\\w+) current(\\w+) password");

0 commit comments

Comments
 (0)