AllAround Patch

pull/113/head
Felix Stupp 8 years ago committed by GitHub
parent 3287759eff
commit 4f1279aae6

@ -37,15 +37,19 @@ public abstract class GeneralMap extends World implements ButtonEvent
VERSCHIEBEN VERSCHIEBEN
} }
protected Province[] provinces; protected Province[] provinces = new Province[] {null};
protected int[] continentBoni; protected int[] continentBoni;
protected Player[] players; protected Player[] players;
protected int currentPlayer = 0; protected int currentPlayer = 0;
private int statPlayer = -1;
protected GameStates status = GameStates.SETZEN; protected GameStates status = GameStates.SETZEN;
protected int provinceCount; protected int provinceCount;
protected int armyMinimum; protected int armyMinimum;
private Label statLabel1 = new Label("Lade Statistiken ...",20);
private Label statLabel2 = new Label("Lade Statistiken ...",20);
/** /**
Erstellt eine GeneralMap mit allen Eigenschaften und initialisiert die Arrays für Provinzen und Spieler. Erstellt eine GeneralMap mit allen Eigenschaften und initialisiert die Arrays für Provinzen und Spieler.
@ -60,11 +64,12 @@ public abstract class GeneralMap extends World implements ButtonEvent
modus.setSize(100,100); modus.setSize(100,100);
modus.setBackColor(Color.white); modus.setBackColor(Color.white);
modus.setForeColor(Color.black); modus.setForeColor(Color.black);
addObject(statLabel1, 270, 800);
addObject(statLabel2, 500, 800);
addObject( modus, 1500, 808); addObject( modus, 1500, 808);
for (int i = 0; i < playerList.length; i++) { for (int i = 0; i < playerList.length; i++) {
players[i] = new Player(i,playerList[i],colorList[i]); players[i] = new Player(i,playerList[i],colorList[i]);
addObject(players[i],0,0); addObject(players[i],0,0);
players[i].redrawPlayer();
} }
createPlayerObjects(playerList.length); createPlayerObjects(playerList.length);
@ -131,15 +136,15 @@ public abstract class GeneralMap extends World implements ButtonEvent
} }
switch (playerCount) { switch (playerCount) {
case 6: case 6:
players[5].setLocation(1512,350); players[5].setLocation(1512,450);
case 5: case 5:
players[4].setLocation(1512,230); players[4].setLocation(1512,280);
case 4: case 4:
players[3].setLocation(1512,110); players[3].setLocation(1512,110);
case 3: case 3:
players[2].setLocation(82,350); players[2].setLocation(82,450);
case 2: case 2:
players[1].setLocation(82,230); players[1].setLocation(82,280);
} }
players[0].setLocation(82,110); players[0].setLocation(82,110);
} }
@ -286,6 +291,28 @@ public abstract class GeneralMap extends World implements ButtonEvent
} }
} }
public void reloadPlayerStat() {
Player cP = players[(statPlayer == -1) ? currentPlayer : statPlayer];
cP.reloadMaxInfluence();
cP.reloadMaxEntities();
int[] stats = cP.getStatistics();
statLabel1.setText(
"Provinz-Statistik" +
"\nAktuell: " + cP.getProvinceCount() +
"\nErobert: " + stats[0] +
"\nVerloren: " + stats[1] +
"\nMaximum: " + stats[2]
);
statLabel2.setLocation(statLabel1.getX() + statLabel1.getWidth() + 20, statLabel2.getY());
statLabel2.setText(
"Einheiten-Statistik" +
"\nAktuell: " + cP.getEntitiesCount() +
"\nAusgebildet: " + stats[3] +
"\nGefallen: " + stats[4] +
"\nMaximum: " + stats[5]
);
}
public void buttonClicked(Button b) { public void buttonClicked(Button b) {
if ( modus == b ) { if ( modus == b ) {
if(status==GameStates.SETZEN && freeArmies == 0 ) { if(status==GameStates.SETZEN && freeArmies == 0 ) {
@ -317,6 +344,7 @@ public abstract class GeneralMap extends World implements ButtonEvent
} }
redrawProvinces(); redrawProvinces();
redrawPlayers(); redrawPlayers();
reloadPlayerStat();
} }
} }

@ -136,7 +136,6 @@ public class Player extends Actor
if (provinces[x] == id) if (provinces[x] == id)
{ {
p++; p++;
redrawPlayer();
} }
} }
return p; return p;
@ -213,7 +212,6 @@ public class Player extends Actor
public int[] getStatistics() public int[] getStatistics()
{ {
redrawPlayer();
return stats; return stats;
} }
@ -235,12 +233,17 @@ public class Player extends Actor
public void redrawPlayer() public void redrawPlayer()
{ {
getWorld().reloadPlayerStat();
int textSize = 20; int textSize = 20;
if(n == null) if(n == null)
{ {
n = "leererSpieler"; n = "leererSpieler";
} }
GreenfootImage statistics = new GreenfootImage(137,120); GreenfootImage statistics = new GreenfootImage(137,120);
if(getWorld().getCurrentPlayerID() == id) {
statistics.setColor(new Color(255,255,255));
statistics.fill();
}
GreenfootImage name = new GreenfootImage(n,textSize,getTextCol(),getTransBackCol()); GreenfootImage name = new GreenfootImage(n,textSize,getTextCol(),getTransBackCol());
statistics.drawImage(name,0,0); statistics.drawImage(name,0,0);
@ -279,7 +282,8 @@ public class Player extends Actor
{ {
flag.scale(137,83); flag.scale(137,83);
statistics.drawImage(flag,0,textSize); statistics.drawImage(flag,0,textSize);
GreenfootImage playerStatistics = new GreenfootImage(stats[0] + "||" + stats[1] + "||" + stats[2] + "||" +stats[3] + "||" + stats[4] + "||" + stats[5],textSize,getTextCol(),getTransBackCol()); String statTxt = (getWorld().getCurrentPlayerID() == id) ? "Du bist dran!" : stats[0] + " | " + stats[1] + " | " + stats[2] + " | " +stats[3] + " | " + stats[4] + " | " + stats[5];
GreenfootImage playerStatistics = new GreenfootImage(statTxt,textSize,getTextCol(),getTransBackCol());
statistics.drawImage(playerStatistics, 0, 103); statistics.drawImage(playerStatistics, 0, 103);
setImage(statistics); setImage(statistics);

Loading…
Cancel
Save