diff --git a/GeneralMap.java b/GeneralMap.java index 6d2d2b4..1c2e187 100644 --- a/GeneralMap.java +++ b/GeneralMap.java @@ -37,15 +37,19 @@ public abstract class GeneralMap extends World implements ButtonEvent VERSCHIEBEN } - protected Province[] provinces; + protected Province[] provinces = new Province[] {null}; protected int[] continentBoni; protected Player[] players; protected int currentPlayer = 0; + private int statPlayer = -1; protected GameStates status = GameStates.SETZEN; protected int provinceCount; 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. @@ -60,10 +64,12 @@ public abstract class GeneralMap extends World implements ButtonEvent modus.setSize(100,100); modus.setBackColor(Color.white); modus.setForeColor(Color.black); + addObject(statLabel1, 270, 800); + addObject(statLabel2, 500, 800); addObject( modus, 1500, 808); for (int i = 0; i < playerList.length; i++) { players[i] = new Player(i,playerList[i],colorList[i]); - players[i].redrawPlayer(); + addObject(players[i],0,0); } createPlayerObjects(playerList.length); @@ -118,17 +124,17 @@ public abstract class GeneralMap extends World implements ButtonEvent } switch (playerCount) { case 6: - addObject(players[5],1512,350); + players[5].setLocation(1512,450); case 5: - addObject(players[4],1512,230); + players[4].setLocation(1512,280); case 4: - addObject(players[3],1512,110); + players[3].setLocation(1512,110); case 3: - addObject(players[2],82,350); + players[2].setLocation(82,450); case 2: - addObject(players[1],82,230); + players[1].setLocation(82,280); } - addObject(players[0],82,110); + players[0].setLocation(82,110); } /** @@ -251,6 +257,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(Bildbutton b) { if ( modus == b ) { if(status==GameStates.SETZEN && freeArmies == 0 ) { @@ -279,6 +307,9 @@ public abstract class GeneralMap extends World implements ButtonEvent status=GameStates.SETZEN; modus.setText("Kampf\nbeginnen"); } + redrawProvinces(); + redrawPlayers(); + reloadPlayerStat(); } } diff --git a/Player.java b/Player.java index 9843844..cc6a0de 100644 --- a/Player.java +++ b/Player.java @@ -135,7 +135,6 @@ public class Player extends Actor if (provinces[x] == id) { p++; - redrawPlayer(); } } return p; @@ -184,7 +183,6 @@ public class Player extends Actor public int[] getStatistics() { - redrawPlayer(); return stats; } @@ -198,6 +196,7 @@ public class Player extends Actor public void redrawPlayer() { + getWorld().reloadPlayerStat(); int textSize = 20; if(n == null) { @@ -206,6 +205,13 @@ public class Player extends Actor GreenfootImage statistics = new GreenfootImage(137,120); GreenfootImage Name = new GreenfootImage(n,textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f)); statistics.drawImage(Name,0,0); + 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()); + statistics.drawImage(name,0,0); setImage(statistics); oDecide(statistics,textSize); @@ -260,7 +266,8 @@ public class Player extends Actor { flag.scale(137,83); statistics.drawImage(flag,0,textSize); - GreenfootImage playerStatistics = new GreenfootImage(stats[0] + "||" + stats[1] + "||" + stats[2] + "||" +stats[3] + "||" + stats[4] + "||" + stats[5],textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f)); + 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); setImage(statistics);