Skip to content

Commit

Permalink
database
Browse files Browse the repository at this point in the history
  • Loading branch information
alrz1999 committed Jul 13, 2019
1 parent d9d7681 commit ff9d69d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/controller/logicController/GameController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package controller.logicController;

import javafx.scene.chart.PieChart;
import models.Account;
import models.Game;
import server.*;

Expand All @@ -18,6 +20,7 @@ public static GameController getInstance() {
public void signIn(String username, String password, ResponseSender responseSender) {
Game game = Game.getInstance();
Response response = new Response(Environment.LOGIN_PAGE);
Account account = (Account) Database.getValue("Accounts",username,Account.class);
if (!game.isUsedUsername(username))
response.setResponseType(ResponseType.INVALID_USERNAME);
else {
Expand Down
6 changes: 5 additions & 1 deletion src/models/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.stream.JsonReader;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import server.Database;
import server.Request;

import java.io.FileReader;
Expand Down Expand Up @@ -39,7 +40,10 @@ public static Account getAccount(String userName) {
}

public void createAccount(String username, String password) {
accounts.add(new Account(username, password));
Account account = new Account(username, password);
accounts.add(account);
Database.putElement("Accounts", username, account);

}

public ArrayList<Account> getSortedAccounts() {
Expand Down
2 changes: 2 additions & 0 deletions src/server/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public void start(Stage primaryStage) throws Exception {

});
thread.start();
Database.makeNewDataBase("Accounts");
Database.makeNewDataBase("OnlineAccounts");

Thread updater = new Thread(() -> Platform.runLater(() -> controller.updateTable()));
updater.start();
Expand Down

0 comments on commit ff9d69d

Please sign in to comment.