1717import javafx .scene .paint .ImagePattern ;
1818import javafx .scene .shape .Rectangle ;
1919import sample .controller .menuController .DeckController ;
20+ import sample .controller .menuController .MainMenuController ;
2021import sample .controller .menuController .MenuController ;
2122import sample .controller .responses .DeckMenuResponses ;
2223import sample .model .Deck ;
@@ -73,7 +74,11 @@ public void start(){
7374 readyUpMainDeck ();
7475 readyUpSideDeck ();
7576 }
76-
77+ public void update (){
78+ MainMenuController .getUserByToken ();
79+ userCards = MenuController .getUser ().getAllCardsOfUser ();
80+ deck = MenuController .getUser ().getDeckByName (deck .getName ());
81+ }
7782 public void readyUpTrunk (){
7883 GridPane pane = new GridPane ();
7984 pane .setPadding (new Insets (10 ,10 ,10 ,20 ));
@@ -210,6 +215,7 @@ else if(selectedCard.getDeckViewLocation()== Card.DeckViewLocation.TRUNK)
210215 deckController .removeCardFromDeck (selectedCard ,deck .getName (),type );
211216 selectedCard .setDeckViewLocation (Card .DeckViewLocation .TRUNK );
212217 new Alert (Alert .AlertType .INFORMATION ,"card removed successfully" ).show ();
218+ update ();
213219 if (type == Deck .DeckType .MAIN ) readyUpMainDeck ();
214220 else readyUpSideDeck ();
215221 readyUpTrunk ();
@@ -228,6 +234,7 @@ else if(deckMenuResponses.equals(MAX_SIZE_IDENTICAL_CARDS_ALREADY_IN_DECK))
228234 new Alert (Alert .AlertType .ERROR ,"there are already three cards of this type" ).show ();
229235 else if (deckMenuResponses .equals (CARD_ADD_TO_DECK_SUCCESSFUL )) {
230236 selectedCard .setDeckViewLocation (Card .DeckViewLocation .MAIN_DECK );
237+ update ();
231238 readyUpMainDeck ();
232239 readyUpTrunk ();
233240 new Alert (Alert .AlertType .INFORMATION , "card added to main deck successfully" ).show ();
@@ -247,6 +254,7 @@ else if(deckMenuResponses.equals(MAX_SIZE_IDENTICAL_CARDS_ALREADY_IN_DECK))
247254 new Alert (Alert .AlertType .ERROR ,"there are already three cards of this type" ).show ();
248255 else if (deckMenuResponses .equals (CARD_ADD_TO_DECK_SUCCESSFUL )) {
249256 selectedCard .setDeckViewLocation (Card .DeckViewLocation .SIDE_DECK );
257+ update ();
250258 readyUpSideDeck ();
251259 readyUpTrunk ();
252260 new Alert (Alert .AlertType .INFORMATION , "card added to side deck successfully" ).show ();
0 commit comments