This commit is contained in:
joachimschmidt557 2019-03-26 18:19:15 +01:00
commit efa26657ba
3 changed files with 24 additions and 1 deletions

View file

@ -2,6 +2,8 @@ package game;
import game.map.Castle;
import gui.components.JokerPanel.JokerTypes;
import java.awt.Color;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@ -14,14 +16,27 @@ public abstract class Player {
private Color color;
private int points;
private int remainingTroops;
private JokerTypes[] jokers;
protected Player(String name, Color color) {
this.name = name;
this.points = 0;
this.color = color;
this.remainingTroops = 0;
jokers = new JokerTypes[]{JokerTypes.ADD_TROOPS, JokerTypes.SCARE_TROOPS};
}
public JokerTypes[] getJokers() {
return jokers;
}
public void setJoker(int index, JokerTypes joker) {
jokers[index] = joker;
}
/**
* Creates a player
* @param playerType The type of player (human, AI, etc.)

View file

@ -21,7 +21,7 @@ public class JokerPanel extends JPanel implements MouseListener{
private GameView gv;
private enum JokerTypes {
public enum JokerTypes {
ADD_TROOPS,
ADD_TROOPS_USED,
SCARE_TROOPS,
@ -65,6 +65,11 @@ public class JokerPanel extends JPanel implements MouseListener{
this.game = game;
}
public void setJokers(JokerTypes[] jokers) {
this.jokers = jokers;
}
/**
* Associates with a map panel
* @param map The map panel
@ -80,6 +85,7 @@ public class JokerPanel extends JPanel implements MouseListener{
*/
private void setJoker(int index, JokerTypes j) {
jokers[index] = j;
game.getCurrentPlayer().setJoker(index, j);
}
/**

View file

@ -251,6 +251,8 @@ public class GameView extends View implements GameInterface {
@Override
public void onNewRound(int round) {
jokers.setJokers(game.getCurrentPlayer().getJokers());
this.onResize();
this.logLine(String.format("Runde %d.", round));
}