Skip to content

Commit

Permalink
deckMenu fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
erfanfi79 committed Jun 24, 2019
1 parent 6346c32 commit 783174f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
26 changes: 24 additions & 2 deletions src/controller/BattleMenuController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
Expand All @@ -13,11 +16,13 @@
import models.GamePlay.Match;
import request.battleMenuRequest.battleMenuRequestChilds.MultiPlayerMenuRequest;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;

public class BattleMenuController implements Initializable {
double x,y;
private Account account;
private MatchType matchType;
@FXML
Expand Down Expand Up @@ -51,10 +56,27 @@ public class BattleMenuController implements Initializable {
private Button btnMode2;

@FXML
void gotoStartMenu(ActionEvent event) {

void gotoStartMenu() {
try {
Parent root = FXMLLoader.load(getClass().getResource("../view/StartMenuView.fxml"));
Scene scene = new Scene(root);
scene.setOnMousePressed(event -> {
x = event.getSceneX();
y = event.getSceneY();
});

scene.setOnMouseDragged(event -> {

Controller.stage.setX(event.getScreenX() - x);
Controller.stage.setY(event.getScreenY() - y);

});
Controller.stage.setScene(scene);
} catch (IOException e) {
}
}


@FXML
void playSinglePlayer(ActionEvent event) {
if (!checkValidateDeck())
Expand Down
6 changes: 3 additions & 3 deletions src/models/Deck.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ArrayList<Card> getCards() {
}

public boolean isDeckValidate() {
int numOfCards = 0, numOfHero = 0, numOfItem = 0;
int numOfCards = 0, numOfHero = 0;
for (Card card : cards)
switch (card.getType()) {
case SPELL:
Expand All @@ -36,9 +36,9 @@ public boolean isDeckValidate() {
numOfCards++;
break;
case USABLE_ITEM:
numOfItem++;
numOfCards++;
}
return numOfCards == 20 && numOfHero == 1 && numOfItem == 1;
return numOfCards == 20 && numOfHero == 1;

}

Expand Down

0 comments on commit 783174f

Please sign in to comment.