Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beau extra #7

Open
wants to merge 167 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
ae0085e
lobbySettings
LarsPB Jun 18, 2019
81b9091
lobbySettings
LarsPB Jun 18, 2019
35394b7
Merge branch 'master' of https://github.com/realDragonium/SmallWorld …
YoranFox Jun 18, 2019
716ceac
Merge branch 'lobby-branch' of https://github.com/realDragonium/Small…
realDragonium Jun 18, 2019
3c0065b
Lobby is connectbaar met firebase.
realDragonium Jun 18, 2019
6c32a54
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 18, 2019
3cbf6ff
Unused import deleted
realDragonium Jun 18, 2019
12e669f
java doc
LarsPB Jun 18, 2019
88b971e
Merge branch 'master' of https://github.com/realDragonium/SmallWorld …
YoranFox Jun 19, 2019
e0598ae
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
47d5cde
ff snel van yoran met lobby 196 1130
Jun 19, 2019
bb07d14
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 19, 2019
7446e8e
wanneer 1 speler start, start de rest ook
realDragonium Jun 19, 2019
513adf2
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 19, 2019
d53f8a9
merged firebase with beauextra
realDragonium Jun 19, 2019
3e4839a
lobby fixed?
realDragonium Jun 19, 2019
67310e1
player id fixed
realDragonium Jun 19, 2019
1a159af
player id fixed
realDragonium Jun 19, 2019
6da0dfb
@overriding helemaal naar de getver
Jun 19, 2019
5c409ce
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 19, 2019
773b4bd
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
033478c
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
99f1696
Lobby algemene start gefixed
realDragonium Jun 19, 2019
d565f0f
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
175cc8f
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
bc08b82
JUNIT test proberen 1330
Jun 19, 2019
1c06fd2
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 19, 2019
6042e4b
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
343188c
commit before merge
realDragonium Jun 19, 2019
636de01
mogelijk om met firebase te werken
winosabelis Jun 19, 2019
6e27757
fiches en punten via firebase
realDragonium Jun 19, 2019
29b4b39
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
8097150
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
5e0363a
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
f1fad25
met namen erin
winosabelis Jun 19, 2019
93747dd
inlobby players
LarsPB Jun 19, 2019
f9417e9
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
a267008
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
a20f4ee
areas loaded within firebase
realDragonium Jun 19, 2019
065f832
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 19, 2019
b813a4b
areas loaded within firebase
realDragonium Jun 19, 2019
0475f55
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
5746fa0
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
14e5c91
autolobby delete wanneer game is gestart, werkt.
realDragonium Jun 19, 2019
1287dad
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
7071691
timer firebase, not tested.
realDragonium Jun 19, 2019
3fad92c
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 19, 2019
7814bad
fxml lobby scenes
LarsPB Jun 19, 2019
b472f78
timer firebase error fixed
realDragonium Jun 19, 2019
e7ae678
Merge remote-tracking branch 'origin/lobby-branch' into lobby-branch
LarsPB Jun 19, 2019
fd1bdb9
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
408f4fb
firebase werkt weer
realDragonium Jun 19, 2019
2c2b25d
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
0c70111
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
3360fc5
begin aan top3, commit before pull
realDragonium Jun 19, 2019
69310fb
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 19, 2019
4029963
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
dff2b60
commit before pull
realDragonium Jun 19, 2019
8eb6a4a
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 19, 2019
820f9c0
Geen idee meer......................
realDragonium Jun 19, 2019
71dd458
timer werkt weer
realDragonium Jun 19, 2019
824ab4e
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 19, 2019
229cef3
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 20, 2019
25202ea
fxml lobby scenes
LarsPB Jun 20, 2019
c1ab84d
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
4f864e7
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
6387132
commit before pull
realDragonium Jun 20, 2019
3f003da
Merge branch 'Test' of https://github.com/realDragonium/SmallWorld in…
realDragonium Jun 20, 2019
1f18c0e
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
ff52cc8
Dice werkt samen met nieuwste versie
winosabelis Jun 20, 2019
10c0908
Java doc to lobbies
LarsPB Jun 20, 2019
3c2a28d
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
a635368
Java doc to lobbies
LarsPB Jun 20, 2019
96ab0b1
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 20, 2019
c829b3d
Merge branch 'Test' of https://github.com/realDragonium/SmallWorld in…
realDragonium Jun 20, 2019
5ca06df
JUNIT test proberen 206 1145
Jun 20, 2019
b61f0a5
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 20, 2019
83528f8
De leaderboard haalt de naam en de waarde van de spelers op
winosabelis Jun 20, 2019
f488442
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 20, 2019
eeb97d9
verandering gamescreen
YoranFox Jun 20, 2019
a1e7b14
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
8fff928
verandering gamescreen
YoranFox Jun 20, 2019
00500ee
Merge branches 'BeauExtra' and 'Test' of https://github.com/realDrago…
realDragonium Jun 20, 2019
067d500
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 20, 2019
039ecdc
firebased aanvallen werkt?
realDragonium Jun 20, 2019
62157ae
Java doc to lobbies
LarsPB Jun 20, 2019
6cf3200
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 20, 2019
cf35e64
Java doc to lobbies
LarsPB Jun 20, 2019
59b8ad8
Java doc to lobbies
LarsPB Jun 20, 2019
488d41f
Dice logic toegevoegd en phaseEnder gemaakt
YoranFox Jun 20, 2019
153750e
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
64a2bf4
cijfers werken weer
realDragonium Jun 20, 2019
d1e09f3
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 20, 2019
58bb54d
Dice logic toegevoegd en phaseEnder gemaakt
YoranFox Jun 20, 2019
f142a71
commit before pull
realDragonium Jun 20, 2019
8a1db52
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 20, 2019
508040e
firebase area info wordt nu nog maar een keer geladen
realDragonium Jun 20, 2019
a32426b
area attack bug fixed
realDragonium Jun 20, 2019
d812d08
Info scherm toegevoegd in game
YoranFox Jun 20, 2019
276ca4a
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
76f4aa3
Java doc to lobbies
LarsPB Jun 20, 2019
a07c354
JUNIT test proberen 206 1530
Jun 20, 2019
8986f17
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 20, 2019
3c4bd0b
shop via firebase en kan items buiten bereik niet meer kopen
realDragonium Jun 20, 2019
3b040b9
Java doc to lobbies
LarsPB Jun 20, 2019
9182232
Timer fixed
YoranFox Jun 20, 2019
925f7f6
Dice gefixt
YoranFox Jun 20, 2019
1b5b2a3
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 20, 2019
4695ce7
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 20, 2019
af8d7de
shop werkt weer
realDragonium Jun 20, 2019
411cf6b
fixed some attack dingen
realDragonium Jun 20, 2019
c0f1b4a
je kan alleen nog maar buren aanvallen
realDragonium Jun 20, 2019
df243d1
gonna solve some warnings
realDragonium Jun 20, 2019
65630a1
Failed login attempt message
realDragonium Jun 20, 2019
e8b6228
Failed register message
realDragonium Jun 20, 2019
ae41532
register account set fixed
realDragonium Jun 20, 2019
ff3579f
Java doc to lobbies
LarsPB Jun 21, 2019
84d6094
redeploy firebase test
realDragonium Jun 21, 2019
0f2e582
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
3ba8766
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
847fd10
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
f2de1fd
login fixed
realDragonium Jun 21, 2019
494114c
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
3b7cbaf
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
f39a998
miauwwie 2161030
Jun 21, 2019
333d145
Dice gefixt
YoranFox Jun 21, 2019
f2fbb35
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 21, 2019
b97093e
redeploy fb fixed?
realDragonium Jun 21, 2019
41e44df
fb punten
realDragonium Jun 21, 2019
4ec4a95
Niet
YoranFox Jun 21, 2019
321102f
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
454f6b2
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
004e9b2
Krachten gefixt
YoranFox Jun 21, 2019
5ced4a6
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
5eb590e
jdocs
YoranFox Jun 21, 2019
4cd3131
216 1420
Jun 21, 2019
0bb5a7b
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 21, 2019
236ae42
Javadoc of all observers
LarsPB Jun 21, 2019
2aa7041
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
3b01637
nu doen de turns en rondes het wel
Jun 21, 2019
a089170
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 21, 2019
d525391
commit before pull
realDragonium Jun 21, 2019
34c1a26
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 21, 2019
09a065e
nu doen de turns en rondes het wel 216 1515
Jun 21, 2019
0cdd13f
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 21, 2019
f41bee5
aanvallen fixed?
realDragonium Jun 21, 2019
95507f1
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 21, 2019
7fb9b82
Javadoc of all observables
LarsPB Jun 21, 2019
af3e686
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
6445cf0
Javadoc of all observables
LarsPB Jun 21, 2019
77c6cd0
Javadoc of all observables
LarsPB Jun 21, 2019
0573e71
Javadoc of all observables
LarsPB Jun 21, 2019
70d0a9e
Javadoc of all observables
LarsPB Jun 21, 2019
61b22c9
aanvallen verbeterd
realDragonium Jun 21, 2019
3064362
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 21, 2019
4df2d9c
nu doen de turns en rondes het wel 216 1615
Jun 21, 2019
2f3b83a
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 21, 2019
691a6a4
Javadoc created
LarsPB Jun 21, 2019
25a9280
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
LarsPB Jun 21, 2019
c6a1283
Javadoc created
LarsPB Jun 21, 2019
48fd650
javadoc pulled
realDragonium Jun 21, 2019
6e8271d
1715 nu ben ik er helemaal klaar mee
Jun 21, 2019
2bcae03
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
Jun 21, 2019
c2ecbda
Player info toegevoegd
YoranFox Jun 23, 2019
6053f04
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
YoranFox Jun 23, 2019
60b5341
Merge branch 'BeauExtra' of https://github.com/realDragonium/SmallWor…
realDragonium Jun 23, 2019
512194c
fixed farm color
realDragonium Jun 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,60 @@
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13-beta-3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13-beta-3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -38,7 +92,7 @@
<archive>
<index>true</index>
<manifest>
<mainClass>src.main.java.Init</mainClass>
<mainClass>src.main.java.Main</mainClass>
</manifest>
</archive>
</configuration>
Expand Down
34 changes: 22 additions & 12 deletions src/main/java/Applicatie/Applicatie.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package Applicatie;

import Controller.AccountController;
import Controller.LobbyController;
import Controller.LoginController;
import Firebase.FirebaseServiceOwn;
import Managers.SceneManager;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Applicatie {
Expand All @@ -14,39 +16,47 @@ public class Applicatie {
private double windowAnchorX = 50;
private double windowAnchorY= 50;
private Stage primaryStage;
private Group root = new Group();
private Pane root = new Pane();
private static FirebaseServiceOwn fb;
private AccountController accountCon;

public Applicatie(Stage primaryStage) {
SceneManager.getInstance().registerApp(this);
this.primaryStage = primaryStage;
loadPrimaryStage();
}

public static FirebaseServiceOwn getFirebaseService(){
public void setAccount(AccountController accountCon){
this.accountCon = accountCon;
}

public FirebaseServiceOwn getFirebaseService(){
if(fb == null) fb = new FirebaseServiceOwn();
return fb;
}

public AccountController getAccountCon(){
return accountCon;
}

private void loadPrimaryStage() {
Scene scene = new Scene(root, width,height);
SceneManager.getInstance().setPane(root);
primaryStage.setScene(scene);
primaryStage.setMaximized(true);
primaryStage.setFullScreen(true);
primaryStage.setTitle("Small World");
// primaryStage.setX(windowAnchorX);
// primaryStage.setY(windowAnchorY);
// primaryStage.setFullScreen(true);
primaryStage.show();

//new LoginController();
new LobbyController();
/// new LobbyController();
new LoginController();
}



public void changeScene(Scene scene) {
public void loadScene(Scene scene) {
System.out.println("switched!");
primaryStage.setFullScreen(true);
primaryStage.setScene(scene);
//primaryStage.setFullScreen(true);

SceneManager.getInstance().setPane(root);
}
}

24 changes: 24 additions & 0 deletions src/main/java/Controller/AccountController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Controller;

import Model.AccountModel;

public class AccountController {

AccountModel model;

public AccountController(String username) {
model = new AccountModel(username);
}

public String getAccountName(){
return model.getAccountName();
}

public void setPlayerId(String id){
model.setPlayerId(id);
}

public String getPlayerId(){
return model.getPlayerId();
}
}
203 changes: 135 additions & 68 deletions src/main/java/Controller/AreaController.java
Original file line number Diff line number Diff line change
@@ -1,84 +1,151 @@
package Controller;

import Enum.AreaProperty;
import Enum.AreaType;
import Firebase.FirebaseControllerObserver;
import Firebase.FirebaseServiceOwn;
import Managers.SceneManager;
import Model.AreaModel;
import Objects.RaceFiche;
import Observer.AreaObserver;
import com.google.cloud.firestore.DocumentSnapshot;
import javafx.application.Platform;
import javafx.scene.Group;
import Applicatie.Applicatie;

import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.Stack;

/**
* This Controller-class handles the logic for all the functions that can be called for areas
*
* @author beau
* @version June 2019
*/

public class AreaController implements FirebaseControllerObserver {
private Map2DController map2DCon;
private AreaModel model;
private GameController gameCon;
private FirebaseServiceOwn fb = SceneManager.getInstance().getApp().getFirebaseService();

public AreaController(Group area, Map2DController mapCon, GameController gameCon) {
model = new AreaModel(area.getChildren().get(0).getId());
map2DCon = mapCon;
this.gameCon = gameCon;
getAreaInfo();
SceneManager.getInstance().createAreaView(this, area);
fb.AreaListener(model.getId(), this);
}

String getId() {
return model.getId();
}

int numbersNeeded() {
return model.numbersNeeded();
}

void attackArea(Stack<RaceFiche> fiches) {
model.setFiches(fiches);
fb.areaUpdateFiches(model.getId(), model.getNumberOfFiches());
}

void setPlayerOwner(PlayerController player) {
model.player = player;
}

PlayerController getOwnerPlayer() {
return model.player;
}

Stack<RaceFiche> removeFiches() {
// fb.areaUpdateFiches(model.getId(), 0);
return model.getAllFiches();
}

RaceFiche getOneFiche() {
return model.getOneFiche();
}

void changeActive() {
model.changeActive();
}

public void register(AreaObserver ao) {
model.register(ao);
}

public void selectActive() {
map2DCon.selectSingleArea(this);
}

public void destroyAllButOne() {
model.getAllButOne();
fb.areaUpdateFiches("fiches", model.getNumberOfFiches());
}

void returnAllButOne(RaceController raceController) {
raceController.pushFiches(model.getAllButOne());
fb.areaUpdateFiches("fiches", model.getNumberOfFiches());
}

private void getAreaInfo() {
DocumentSnapshot ds = fb.getAreaInfo(model.getId());
Platform.runLater(() -> {
model.setFiches((int) Math.round(ds.getDouble("fiches")));
model.setAreaType(ds.getString("type"));
model.setBorderArea(ds.getBoolean("borderArea"));
model.setNeighbours((List<String>) ds.get("neighbours"));
model.setAttackAble(ds.getBoolean("attackAble"));
model.notifyObserver();
});
}

@Override
public void update(DocumentSnapshot ds) {
if (gameCon.getCurrentPlayer() == gameCon.getMyPlayer()) return;
Platform.runLater(() -> {
if (model.getPlayer() == gameCon.getMyPlayer()) {
model.getPlayer().getActiveCombination().getRace().pushFiches(removeFiches());
model.player = null;
model.setFiches((int) Math.round(ds.getDouble("fiches")));
}
model.setFiches((int) Math.round(ds.getDouble("fiches")));
System.out.println(ds.getDouble("fiches"));
});
}

public AreaProperty getSpecialProp() {
return model.getSpecialProp();
}

private Map2DController map2DCon;
private AreaModel model;
private GameController gameCon;
private FirebaseServiceOwn fb = Applicatie.getFirebaseService();

public AreaController(Group area, Map2DController mapCon, GameController gameCon) {
model = new AreaModel(area.getChildren().get(0).getId());
map2DCon = mapCon;
this.gameCon = gameCon;
SceneManager.getInstance().createAreaView(this, area);
setAreaInFirebase();
fb.AreaListener(model.getId(), this);
}

String getId(){return model.getId();}

public void setAreaInFirebase(){
Map<String, Object> area = new HashMap<>();
area.put("fiches", model.getNumberOfFiches());
area.put("owner", null);
area.put("oldOwner", null);
area.put("oldFiches", null);
fb.setAreas(model.getId(), area);
}

int numbersNeeded(){
return model.numbersNeeded();
}

void attackArea(Stack<RaceFiche> fiches){
model.setFiches(fiches);
fb.areaUpdateFiches(model.getId(), model.getNumberOfFiches());
}

void setPlayerOwner(PlayerController player){
model.player = player;
}

PlayerController getOwnerPlayer(){
return model.player;
}

Stack<RaceFiche> removeFiches(){
fb.areaUpdateFiches(model.getId(), 0);
return model.getAllFiches();
}

void changeActive(){model.changeActive();}

public void register(AreaObserver ao){model.register(ao);}

public void selectActive(){ map2DCon.selectSingleArea(this);}

public void returnAllButOne(RaceController raceController) {
raceController.pushFiches(model.getAllButOne());
}

@Override
public void update(DocumentSnapshot ds) {
if(ds.get("oldowner") == null) return;

AttackController attCon = gameCon.getAttCon();
attCon.getTargetArea();
attCon.attackAreaLocal();
}
public boolean isNextToWater() {
return model.isNextToWater();
}

public int getFichesAmount() {
return model.getNumberOfFiches();
}

public void addFiche(RaceFiche fiche) {
model.addFiche(fiche);
}

public AreaType getAreaType() {
return model.getAreaType();
}

public boolean firstAttackArea() {
return model.firstAttackArea();
}

public boolean isAttackAble() {
return model.isAttackAble();
}

public List<String> getNeighbours() { return model.getNeigbours();}

public void highLightArea() {
model.highLight();
}
}
Loading