Fehlerkorrektur 3

Beheben des GetProvinceCount, den Achim erwähnt hat, beheben von
Anzeigeproblemen bei redrawPlayer
master
SariusRu 8 years ago
parent b3c21d9ada
commit bddc7d07cf

@ -2,7 +2,7 @@ public class Debug3 extends Map_World {
public Debug3() { public Debug3() {
super( super(
new String[] {"Spieler Nr. 1", "Player No. 2", "Spieler Nr. 3"}, new String[] {"Spieler Nr. 1", "Player No. 2", "Spieler Nr. 3"},
new int[] {0,1,2} new int[] {1,2,3}
); );
} }
} }

@ -24,6 +24,7 @@ public class Player extends Actor
String n; String n;
int color; int color;
int textsize; int textsize;
int c;
//definiert die ID und Namens Variable //definiert die ID und Namens Variable
public Player(int identity,String name, int c) public Player(int identity,String name, int c)
@ -79,7 +80,7 @@ public class Player extends Actor
System.out.println("Deine aktuelle Sternenanzahl beträgt " + stars + "."); System.out.println("Deine aktuelle Sternenanzahl beträgt " + stars + ".");
redrawPlayer(); redrawPlayer();
} }
} }
//eine Methode um addToStars zu testen //eine Methode um addToStars zu testen
public void add () public void add ()
@ -93,7 +94,7 @@ public class Player extends Actor
stars = set; stars = set;
redrawPlayer(); redrawPlayer();
return stars; return stars;
} }
//eine Methode, die das Abziehen von Sternen testet und, wenn das Ergebnis >= 0 ist, die Sternenanzahl um eine gewählte Anzahl verringert //eine Methode, die das Abziehen von Sternen testet und, wenn das Ergebnis >= 0 ist, die Sternenanzahl um eine gewählte Anzahl verringert
public int removeFromStars(int sub) public int removeFromStars(int sub)
@ -111,37 +112,37 @@ public class Player extends Actor
} }
redrawPlayer(); redrawPlayer();
return stars; return stars;
} }
public int getProvinceCount () public int getProvinceCount ()
{ {
GeneralMap w= getWorld(); GeneralMap w= getWorld();
int[] provinces = w.getProvinceOwners(); // int[] provinces = w.getProvinceOwners();
for (int x=0; x<=42; x++ ) for (int x=1; x<=42; x++ )
{ {
if ( provinces [x] ==id) c = w.provinces[x].getOwner();
if (c ==id+1)
{ {
provZahl++; provZahl++;
stats[2] = provZahl;
redrawPlayer();
} }
} }
if(stats[2] < provZahl)
{
stats[2]=provZahl;
}
return provZahl; return provZahl;
} }
public void gotEntities(int gotEnt) public void gotEntities(int gotEnt)
{ {
stats[3]+= gotEnt; stats[3]+= gotEnt;
redrawPlayer();
} }
public void lostEntity() public void lostEntity()
{ {
stats[4]+=1; stats[4]+=1;
redrawPlayer();
} }
private void maxEntities(int entNumber) private void maxEntities(int entNumber)
@ -149,6 +150,7 @@ public class Player extends Actor
if (stats[5]< entNumber) if (stats[5]< entNumber)
{ {
stats[5]=entNumber; stats[5]=entNumber;
redrawPlayer();
} }
} }
@ -168,6 +170,7 @@ public class Player extends Actor
} }
} }
redrawPlayer();
return pBesitzer; return pBesitzer;
} }
@ -191,31 +194,36 @@ public class Player extends Actor
lostProv = true; lostProv = true;
stats[1]+=1; stats[1]+=1;
} }
redrawPlayer();
provVgl = provZahl; provVgl = provZahl;
} }
public boolean getGotProvince () public boolean getGotProvince ()
{ {
redrawPlayer();
return gotProv; return gotProv;
} }
public boolean getLostProvince() public boolean getLostProvince()
{ {
redrawPlayer();
return lostProv; return lostProv;
} }
public int[] getStatistics() public int[] getStatistics()
{ {
redrawPlayer();
return stats; return stats;
} }
public int setColor(int c) public int setColor(int c)
{ {
color = c; color = c;
redrawPlayer(); redrawPlayer();
return color; return color;
} }
public void redrawPlayer() public void redrawPlayer()
{ {
int textSize = 20; int textSize = 20;
@ -226,7 +234,7 @@ public class Player extends Actor
GreenfootImage statistics = new GreenfootImage(137,120); 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)); 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); statistics.drawImage(Name,0,0);
setImage(statistics); setImage(statistics);
oDecide(statistics,textSize); oDecide(statistics,textSize);
} }
@ -239,32 +247,32 @@ public class Player extends Actor
{ {
case 2: case 2:
flag = new GreenfootImage("images\\BlaueArmee.jpg"); flag = new GreenfootImage("images\\BlaueArmee.jpg");
redraw(statistics,flag,textSize); redraw(statistics,flag,textSize);
break; break;
case 5: case 5:
flag = new GreenfootImage("images\\GelbeArmee.jpg"); flag = new GreenfootImage("images\\GelbeArmee.jpg");
redraw(statistics,flag,textSize); redraw(statistics,flag,textSize);
break; break;
case 6: case 6:
flag = new GreenfootImage("images\\LilaArmee.jpg"); flag = new GreenfootImage("images\\LilaArmee.jpg");
redraw(statistics,flag,textSize); redraw(statistics,flag,textSize);
break; break;
case 4: case 4:
flag = new GreenfootImage("images\\RoteArmee.jpg"); flag = new GreenfootImage("images\\RoteArmee.jpg");
redraw(statistics,flag,textSize); redraw(statistics,flag,textSize);
break; break;
case 1: case 1:
flag = new GreenfootImage("images\\SchwarzeArmee.jpg"); flag = new GreenfootImage("images\\SchwarzeArmee.jpg");
redraw(statistics,flag,textSize); redraw(statistics,flag,textSize);
break; break;
case 3: case 3:
flag = new GreenfootImage("images\\GrueneArmee.jpg"); flag = new GreenfootImage("images\\GrueneArmee.jpg");
redraw(statistics,flag,textSize); redraw(statistics,flag,textSize);
break; break;
} }
@ -273,14 +281,12 @@ public class Player extends Actor
private void redraw(GreenfootImage statistics,GreenfootImage flag, int textSize) private void redraw(GreenfootImage statistics,GreenfootImage flag, int textSize)
{ {
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],textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f)); 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));
GreenfootImage playerStatistics2 = new GreenfootImage(stats[3] + "||" + stats[4] + "||" + stats[5],textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f)); statistics.drawImage(playerStatistics, 0, 103);
statistics.drawImage(playerStatistics, 0, 123);
statistics.drawImage(playerStatistics2, 0, 123 + textSize);
setImage(statistics); setImage(statistics);
} }
} }

Loading…
Cancel
Save