From bddc7d07cfd2bad9ebf6e9e9b57be90ecd059ea2 Mon Sep 17 00:00:00 2001 From: SariusRu Date: Sat, 2 Jul 2016 19:36:42 +0200 Subject: [PATCH] Fehlerkorrektur 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Beheben des GetProvinceCount, den Achim erwähnt hat, beheben von Anzeigeproblemen bei redrawPlayer --- Debug3.java | 2 +- Player.java | 66 +++++++++++++++++++++++++++++------------------------ 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Debug3.java b/Debug3.java index f9e70c0..8f5d774 100644 --- a/Debug3.java +++ b/Debug3.java @@ -2,7 +2,7 @@ public class Debug3 extends Map_World { public Debug3() { super( new String[] {"Spieler Nr. 1", "Player No. 2", "Spieler Nr. 3"}, - new int[] {0,1,2} + new int[] {1,2,3} ); } } \ No newline at end of file diff --git a/Player.java b/Player.java index 6547183..ea9c1f6 100644 --- a/Player.java +++ b/Player.java @@ -24,6 +24,7 @@ public class Player extends Actor String n; int color; int textsize; + int c; //definiert die ID und Namens Variable 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 + "."); redrawPlayer(); } - + } //eine Methode um addToStars zu testen public void add () @@ -93,7 +94,7 @@ public class Player extends Actor stars = set; redrawPlayer(); return stars; - + } //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) @@ -111,37 +112,37 @@ public class Player extends Actor } redrawPlayer(); return stars; - + } public int getProvinceCount () { GeneralMap w= getWorld(); - int[] provinces = w.getProvinceOwners(); - for (int x=0; x<=42; x++ ) + // int[] provinces = w.getProvinceOwners(); + for (int x=1; x<=42; x++ ) { - if ( provinces [x] ==id) + c = w.provinces[x].getOwner(); + if (c ==id+1) { provZahl++; - + stats[2] = provZahl; + redrawPlayer(); } } - if(stats[2] < provZahl) - { - stats[2]=provZahl; - - } return provZahl; } public void gotEntities(int gotEnt) { stats[3]+= gotEnt; + redrawPlayer(); } public void lostEntity() { + stats[4]+=1; + redrawPlayer(); } private void maxEntities(int entNumber) @@ -149,6 +150,7 @@ public class Player extends Actor if (stats[5]< entNumber) { stats[5]=entNumber; + redrawPlayer(); } } @@ -168,6 +170,7 @@ public class Player extends Actor } } + redrawPlayer(); return pBesitzer; } @@ -191,31 +194,36 @@ public class Player extends Actor lostProv = true; stats[1]+=1; } + redrawPlayer(); provVgl = provZahl; } public boolean getGotProvince () { + redrawPlayer(); return gotProv; } public boolean getLostProvince() { + redrawPlayer(); return lostProv; } public int[] getStatistics() { + redrawPlayer(); return stats; } + public int setColor(int c) { - color = c; - redrawPlayer(); - return color; - + color = c; + redrawPlayer(); + return color; + } - + public void redrawPlayer() { int textSize = 20; @@ -226,7 +234,7 @@ 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); - + setImage(statistics); oDecide(statistics,textSize); } @@ -239,32 +247,32 @@ public class Player extends Actor { case 2: flag = new GreenfootImage("images\\BlaueArmee.jpg"); - + redraw(statistics,flag,textSize); break; case 5: flag = new GreenfootImage("images\\GelbeArmee.jpg"); - + redraw(statistics,flag,textSize); break; case 6: flag = new GreenfootImage("images\\LilaArmee.jpg"); - + redraw(statistics,flag,textSize); break; case 4: flag = new GreenfootImage("images\\RoteArmee.jpg"); - + redraw(statistics,flag,textSize); break; case 1: flag = new GreenfootImage("images\\SchwarzeArmee.jpg"); - + redraw(statistics,flag,textSize); break; case 3: flag = new GreenfootImage("images\\GrueneArmee.jpg"); - + redraw(statistics,flag,textSize); break; } @@ -273,14 +281,12 @@ public class Player extends Actor private void redraw(GreenfootImage statistics,GreenfootImage flag, int textSize) { - + flag.scale(137,83); 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 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, 123); - statistics.drawImage(playerStatistics2, 0, 123 + 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)); + statistics.drawImage(playerStatistics, 0, 103); + setImage(statistics); } }