Merge branch 'master' of https://gitlab.com/joachimschmidt557/fop-projekt
This commit is contained in:
commit
efa26657ba
3 changed files with 24 additions and 1 deletions
|
|
@ -2,6 +2,8 @@ package game;
|
||||||
|
|
||||||
import game.map.Castle;
|
import game.map.Castle;
|
||||||
|
|
||||||
|
import gui.components.JokerPanel.JokerTypes;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
@ -14,14 +16,27 @@ public abstract class Player {
|
||||||
private Color color;
|
private Color color;
|
||||||
private int points;
|
private int points;
|
||||||
private int remainingTroops;
|
private int remainingTroops;
|
||||||
|
|
||||||
|
private JokerTypes[] jokers;
|
||||||
|
|
||||||
protected Player(String name, Color color) {
|
protected Player(String name, Color color) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.points = 0;
|
this.points = 0;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.remainingTroops = 0;
|
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
|
* Creates a player
|
||||||
* @param playerType The type of player (human, AI, etc.)
|
* @param playerType The type of player (human, AI, etc.)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class JokerPanel extends JPanel implements MouseListener{
|
||||||
|
|
||||||
private GameView gv;
|
private GameView gv;
|
||||||
|
|
||||||
private enum JokerTypes {
|
public enum JokerTypes {
|
||||||
ADD_TROOPS,
|
ADD_TROOPS,
|
||||||
ADD_TROOPS_USED,
|
ADD_TROOPS_USED,
|
||||||
SCARE_TROOPS,
|
SCARE_TROOPS,
|
||||||
|
|
@ -65,6 +65,11 @@ public class JokerPanel extends JPanel implements MouseListener{
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setJokers(JokerTypes[] jokers) {
|
||||||
|
this.jokers = jokers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates with a map panel
|
* Associates with a map panel
|
||||||
* @param map The 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) {
|
private void setJoker(int index, JokerTypes j) {
|
||||||
jokers[index] = j;
|
jokers[index] = j;
|
||||||
|
game.getCurrentPlayer().setJoker(index, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,8 @@ public class GameView extends View implements GameInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNewRound(int round) {
|
public void onNewRound(int round) {
|
||||||
|
jokers.setJokers(game.getCurrentPlayer().getJokers());
|
||||||
|
this.onResize();
|
||||||
this.logLine(String.format("Runde %d.", round));
|
this.logLine(String.format("Runde %d.", round));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue