Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/com/Resources/JSONs/AccountRelated/Admin.json
#	src/com/Resources/JSONs/AccountRelated/Gamer.json
#	src/com/plato/Controller/AccountRelated/AccountController.java
#	src/com/plato/Controller/Menus/LoginMenuController.java
  • Loading branch information
dorrin-sot committed Feb 5, 2021
2 parents 7343939 + 6f1e335 commit a4cf1f1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
5 changes: 1 addition & 4 deletions src/com/Resources/JSONs/IDGenerator.json
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
[
"944106",
"565519"
]
["944106","565519"]
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public void login (String username, String password, boolean rememberMe) throws
if (!username.matches("[!-~]+"))
throw new MainController.InvalidFormatException("Username");

if (!Account.accountExists(username))
else if (!Account.accountExists(username))
throw new NoAccountExistsWithUsernameException();

if (!Account.getAccount(username).isPasswordCorrect(password))
else if (!Account.getAccount(username).isPasswordCorrect(password))
throw new PaswordIncorrectException();

throw new MainController.SuccessfulOperationException();
Expand Down
13 changes: 9 additions & 4 deletions src/com/plato/Controller/Menus/FriendsTabController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Model.AccountRelated.Account;
import Model.AccountRelated.Gamer;
import Controller.Client;
import com.google.gson.Gson;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
Expand All @@ -30,6 +31,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.LinkedList;
import java.util.ResourceBundle;

public class FriendsTabController implements Initializable {
Expand All @@ -50,10 +52,13 @@ public void updateFrndsList (ActionEvent actionEvent) throws IOException {
dataInputStream = Client.getClient().getDataInputStream();
dataOutputStream = Client.getClient().getDataOutputStream();
frndsList.getItems().clear();
// dataOutputStream.writeUTF("getCurrentAccLoggedIn");
// dataOutputStream.flush();
Gamer currentAccLoggedIn = (Gamer) AccountController.getInstance().getCurrentAccLoggedIn();
for (String frndUN : currentAccLoggedIn.getFrnds()) {
dataOutputStream.writeUTF("getCurrentAccLoggedIn");
dataOutputStream.flush();
Gamer currentAccLoggedIn = MainController.getInstance().getGson().fromJson(dataInputStream.readUTF() , Gamer.class);
// TODO: 2/5/2021
dataOutputStream.writeUTF("getFrnds_" + MainController.getInstance().getGson().toJson(currentAccLoggedIn.getFrnds()));
dataOutputStream.flush();
for (String frndUN :currentAccLoggedIn.getFrnds()) {
Gamer frndAcc = (Gamer) Account.getAccount(frndUN);

Circle circle = new Circle(40);
Expand Down
7 changes: 4 additions & 3 deletions src/com/plato/Controller/Menus/LoginMenuController.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package Controller.Menus;

import Controller.AccountRelated.AccountController;
import Controller.Client;
import Controller.MainController;
import Model.AccountRelated.Account;
import Model.AccountRelated.Gamer;
import Controller.Client;
import com.google.gson.Gson;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
Expand All @@ -27,15 +28,15 @@

public class LoginMenuController implements Initializable {
private static Stage stage;
private static DataOutputStream dataOutputStream;
private static DataInputStream dataInputStream;
public StackPane pwStackPane;
public ImageView showPwOrNot;
public PasswordField pwFieldpwHidden;
public TextField pwFieldpwShown;
public Label delAccLbl, sgnUpLbl, usernameError, passwordError;
public CheckBox rememberMe;
public TextField username;
private static DataOutputStream dataOutputStream;
private static DataInputStream dataInputStream;

public static void setStage (Stage stage) {
LoginMenuController.stage = stage;
Expand Down
2 changes: 1 addition & 1 deletion src/com/plato/Controller/Menus/RegisterFormController.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void signUp (ActionEvent actionEvent) {
// (Class accType, String pfp, String firstName, String lastName, String username, String password, String email, String phoneNum, double money)
try {
dataOutputStream.writeUTF(
"register" + (Admin.adminHasBeenCreated() ? Gamer.class : Admin.class).getSimpleName() + "_" +
"register_" + (Admin.adminHasBeenCreated() ? Gamer.class : Admin.class).getSimpleName() + "_" +
pfp.getImage().getUrl() + "_" +
firstName.getText() + "_" +
lastName.getText() + "_" +
Expand Down
16 changes: 13 additions & 3 deletions src/com/plato/Controller/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,17 @@ public void run () {
// ShipController.getClient().moveShip(BattleSeaEditBoardPageController.getClient().getCurrentBoard(),ship,x,y);
// break;
case "getCurrentAccLoggedIn":
Account account = AccountController.getInstance().getCurrentAccLoggedIn();
//Account account = AccountController.getInstance().getCurrentAccLoggedIn();
dataOutputStream.writeUTF(MainController.getInstance().getGson().toJson(account));
dataOutputStream.flush();
break;

case "getCurrentAccLoggedInAsGamer":
Gamer gamer = (Gamer) AccountController.getInstance().getCurrentAccLoggedIn();
dataOutputStream.writeUTF(MainController.getInstance().getGson().toJson(gamer));
dataOutputStream.flush();
break;

case "logOut":
AccountController.getInstance().logout();
break;
Expand All @@ -162,8 +168,7 @@ public void run () {
ReversiController.getInstance().placeDisk(x, y);
break;

case "moveShip":

//case "moveShip":
case "ReversinextTurn":
ReversiController.getInstance().nextTurn();
break;
Expand Down Expand Up @@ -249,6 +254,11 @@ public void run () {
case "acceptFriendReq":
FriendRequestController.getInstance().acceptFriendReq(receivedInfo[1]);
break;
case "getFrnds" :
gamer = (Gamer) AccountController.getInstance().getCurrentAccLoggedIn();
dataOutputStream.writeUTF( MainController.getInstance().getGson().toJson(gamer.getFrnds()));
dataOutputStream.flush();
break;
}
} catch (IOException e) {
try {
Expand Down

0 comments on commit a4cf1f1

Please sign in to comment.