Javadoc for JokerPanel

This commit is contained in:
joachimschmidt557 2019-03-26 17:48:35 +01:00
parent d0aa8fda5d
commit c348da2de2

View file

@ -30,6 +30,11 @@ public class JokerPanel extends JPanel implements MouseListener{
private JokerTypes[] jokers; private JokerTypes[] jokers;
/**
* Constructs a new joker panel
* @param resources The resources
* @param game The corresponding game
*/
public JokerPanel(Resources resources, Game game) { public JokerPanel(Resources resources, Game game) {
this.game = game; this.game = game;
this.resources = resources; this.resources = resources;
@ -37,26 +42,50 @@ public class JokerPanel extends JPanel implements MouseListener{
initJokers(); initJokers();
} }
/**
* Initializes the jokers
*/
private void initJokers() { private void initJokers() {
jokers = new JokerTypes[]{JokerTypes.ADD_TROOPS, JokerTypes.SCARE_TROOPS }; jokers = new JokerTypes[]{JokerTypes.ADD_TROOPS, JokerTypes.SCARE_TROOPS };
} }
/**
* Associates with a game view
* @param gv The game view
*/
public void setGameView(GameView gv) { public void setGameView(GameView gv) {
this.gv = gv; this.gv = gv;
} }
/**
* Associates with a game
* @param game The game
*/
public void setGame(Game game) { public void setGame(Game game) {
this.game = game; this.game = game;
} }
/**
* Associates with a map panel
* @param map The map panel
*/
public void setMapPanel(MapPanel map) { public void setMapPanel(MapPanel map) {
this.map = map; this.map = map;
} }
/**
* Modifies the joker at this index
* @param index The index
* @param j The new joker
*/
private void setJoker(int index, JokerTypes j) { private void setJoker(int index, JokerTypes j) {
jokers[index] = j; jokers[index] = j;
} }
/**
* Plays the joker at this index
* @param index The index
*/
public void playJoker(int index) { public void playJoker(int index) {
if(game.getRound() < 2) if(game.getRound() < 2)
return; return;
@ -99,6 +128,10 @@ public class JokerPanel extends JPanel implements MouseListener{
paintJokers(g); paintJokers(g);
} }
/**
* Paints the jokers
* @param g The graphics to paint on
*/
public void paintJokers(Graphics g) { public void paintJokers(Graphics g) {
if(jokers == null) if(jokers == null)
return; return;