From 783174f99e4e553f402a1012fb617ad05aff14eb Mon Sep 17 00:00:00 2001 From: erfanfaravani Date: Mon, 24 Jun 2019 12:50:44 +0430 Subject: [PATCH] deckMenu fixed --- src/controller/BattleMenuController.java | 26 ++++++++++++++++++++++-- src/models/Deck.java | 6 +++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/controller/BattleMenuController.java b/src/controller/BattleMenuController.java index cd79e05..59b1df4 100644 --- a/src/controller/BattleMenuController.java +++ b/src/controller/BattleMenuController.java @@ -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; @@ -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 @@ -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()) diff --git a/src/models/Deck.java b/src/models/Deck.java index 219234d..7379b9b 100644 --- a/src/models/Deck.java +++ b/src/models/Deck.java @@ -23,7 +23,7 @@ public ArrayList 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: @@ -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; }