/** deck remove wrapper */ public void delete(int num) { try { Deck.deleteDeck(num); } catch (IOException e) { // System.out.println("error trying to delete a deck"); } decksUI.remove(num); }
public void update(GameContainer gc, StateBasedGame sbg, int arg2) throws SlickException { input = gc.getInput(); // asks if it needs to load the decks if (load) { decks = Deck.loadDecks(); if (decks != null) { int counter = 0; for (Deck each : decks) { DeckUI aux = new DeckUI(each); aux.generateCardsImg(gc); // sets the position of the deck, with it's first card aux.setFirstCard(counter * gc.getWidth() * 1 / 5, gc.getHeight() * 1 / 4); decksUI.add(aux); counter++; } } load = false; } // enter in this if when some deck has been right clicked if (askForDeck) { if (setp1.mouseLClicked(input)) { Match.getMatch().setPlayer1(new Player(new Deck(ref.getDeck()))); askForDeck = false; } else if (setp2.mouseLClicked(input)) { Match.getMatch().setPlayer2(new Player(new Deck(ref.getDeck()))); askForDeck = false; } else if (edit.mouseLClicked(input)) { NewDeckState.setEditingDeck(ref); delete(deckNum); decks = new LinkedList<Deck>(); decksUI = new LinkedList<DeckUI>(); NewDeckState.setNotBack(); sbg.enterState(3); askForDeck = false; } else if (delete.mouseLClicked(input)) { delete(deckNum); askForDeck = false; } else if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) { askForDeck = false; } } if (back.mouseLClicked(input)) { decks = new LinkedList<Deck>(); decksUI = new LinkedList<DeckUI>(); if (backToConfig) { backToConfig = false; sbg.enterState(2); } else { sbg.enterState(1); } } if (wheelMoved) { for (DeckUI each : decksUI) { each.setFirstCard(each.getX() + mouseWheel, each.getY()); } wheelMoved = false; } for (DeckUI each : decksUI) { if (each.mouseRClicked(input)) { this.askForDeck = true; ref = new DeckUI(each); deckNum = decksUI.indexOf(each); return; } } if (gc.getInput().isKeyPressed(Input.KEY_ESCAPE)) { gc.exit(); } }