Merge remote-tracking branch 'refs/remotes/origin/master' into Spielanleitung

master
Zocker1999NET 8 years ago
commit 649c4332bd

@ -1,174 +0,0 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import javax.swing.JOptionPane;
/**
* Write a description of class ArmyPlacer here.
*
* @author GruenerWal, MaxiJohl
* @version 1.0.0
*/
public class ArmyPlacer extends Map_World
{
int freeArmies = -1;
/**
* Constructor for objects of class ArmyPlacer.
*
*/
public ArmyPlacer(String[] a1, int[] a2)
{
super(a1,a2);
// Hi.
// Dies
// ist
// ein
// unnützer
// Kommentar
// um
// Zeilen
// zu
// farmen
// :)
// Mit
// freundlichen
// Grüßen
// ,
// GruenerWal
//
//
//
// I'll be back.
}
public int calculateArmies()
{
int armiesToPlace;
Province[] continentArray;
boolean continentChecked = false;
// 1. ArmyMinimum einbeziehen
armiesToPlace = armyMinimum;
// 2. Einheiten durch Provinzen einbeziehen
armiesToPlace = armiesToPlace + Math.round(players[currentPlayer].getProvinceCount() / 3);
// 3. Einheiten durch Kontinente
// Kontinente durchgehen
for ( int i = 1; i < continentBoni.length; i++ )
{
continentArray = giveContinentArray(i);
// Provinzen des aktuellen Kontinents durchgehen
for ( int p = 1; p >= continentArray.length; p++ )
{
// Prüfen, ob eine Provinz NICHT dem aktuellen Spieler gehört
if ( continentArray[p].getOwner() != currentPlayer )
{
break;
}
// Wenn nicht, wird der Kontinent als gecheckt markiert
else
{
continentChecked = true;
}
}
if ( continentChecked == true )
{
armiesToPlace = armiesToPlace + continentBoni[i];
continentChecked = false;
}
}
// 4. Einheiten durch Sterne
if ( players[currentPlayer].getStars() > 0)
{
String toUseString = JOptionPane.showInputDialog(null, "Wieviele Sterne willst du verwenden?");
int starsToUse = Utils.StringToInt(toUseString);
int[] starBoni = new int [] {1,2,4,7,10,13,17,21,25,30};
if ( starsToUse > 0 && starsToUse < 11 )
{
armiesToPlace = armiesToPlace + starBoni[starsToUse -1];
}
if ( starsToUse < 0 && starsToUse > 10 )
{
JOptionPane.showMessageDialog(null,"Ungültige Zahl. Bitte eine Zahl zwischen 0 und 10 eingeben");
}
}
return armiesToPlace;
}
public Province[] giveContinentArray(int cID)
{
Province[] savedProvinces = new Province[provinceCount +1];
Province[] continentProvinces;
int c = 0;
for (int i = 1; i <= provinceCount; i++)
{
if (provinces[i].getContinentID() == cID)
{
savedProvinces[i] = provinces[i];
c++;
}
}
if ( c < 1 )
{
return null;
}
else
{
return Utils.cutArray(savedProvinces);
}
}
public void placeArmies()
{
if ( freeArmies == -1 )
{
freeArmies = calculateArmies();
}
for ( int i = 1; i <= (provinces.length - 1); i++) {
if (provinces[i].hasClicked() == true && provinces[i].getOwner() == currentPlayer)
{
String toUseString = JOptionPane.showInputDialog(null, "Wieviele Einheiten willst du setzen? Du hast noch " + freeArmies + " freie Einheiten.");
int armiesToUse = Utils.StringToInt(toUseString);
if ( armiesToUse <= freeArmies )
{
provinces[i].addToEntities(armiesToUse);
freeArmies = freeArmies- armiesToUse;
JOptionPane.showMessageDialog(null,"Einheiten erfolgreich gesetzt, Kommandant " + getPlayerName() + ".");
}
else if ( armiesToUse > freeArmies )
{
JOptionPane.showMessageDialog(null,"Nicht genügend freie Einheiten.");
}
}
}
}
public void act()
{
placeArmies();
}
}

@ -1,5 +1,6 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
import java.awt.Graphics2D;
/**
Diese Klasse stellt einen Button dar.
@ -149,17 +150,12 @@ public class Button extends GUI_Interface {
sy = tI.getHeight() + (6 * 2) + 4;
}
GreenfootImage all = new GreenfootImage(sx,sy);
Color gray = new Color(133,133,133,255);
Color black = new Color(0,0,0,255);
Color trans = new Color(0,0,0,0);
Utils.drawInsideRectangle(all,gray,0);
Utils.drawInsideRectangle(all,black,2);
Utils.drawInsideRectangle(all,gray,6);
Utils.drawInsideRectangle(all,black,7);
all.setColorAt(0,0,trans);
all.setColorAt(sx-1,0,trans);
all.setColorAt(0,sy-1,trans);
all.setColorAt(sx-1,sy-1,trans);
all.setColor(trans);
all.fill();
Graphics2D g = all.getAwtImage().createGraphics();
g.setColor(backC);
g.fillRoundRect(0,0,sx,sy,24,24);
all.drawImage(tI,(sx-tI.getWidth())/2,(sy-tI.getHeight())/2);
setImage(all);
}

@ -1,4 +1,6 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
import javax.swing.JOptionPane;
/**
* Write a description of class Colors here.
@ -15,46 +17,74 @@ public class Colours extends World implements ButtonEvent
Button lila = new Button ("Lila", 16, this);
Button gelb = new Button ("Gelb", 16, this);
Button weiter = new Button ("Weiter", 16, this);
int [] color = new int [6];
String [] pn = new String [6];
int[] color = new int [5];
String[] pn = new String [5];
int x = 0;
boolean possw = true;
boolean posbl = true;
boolean posgr = true;
boolean posrt = true;
boolean posgb = true;
boolean posli = true;
boolean possw = true; // schwarz
boolean posbl = true; // blau
boolean posgr = true; // gruen
boolean posrt = true; // rot
boolean posgb = true; // gelb
boolean posli = true; // lila
int sw = 1;
int bl = 2;
int gr = 3;
int rt = 4;
int gb = 5;
int li = 6;
Label header = new Label("Klicke auf eine Farbe, um einen Spieler hinzuzufügen:",16);
Button remove = new Button("Rückgängig",16,this);
Label pl1 = new Label("",16);
Label pl2 = new Label("",16);
Label pl3 = new Label("",16);
Label pl4 = new Label("",16);
Label pl5 = new Label("",16);
/**
* Constructor for objects of class Colors.
*
*/
public Colours(int x, int y, int z)
{
super(x, y, z);
{
super(x, y, z);
setBackground(Start_Load.backgroundImage);
addObject(schwarz, 50, 30);
addObject ( blau, 170, 30);
addObject ( grün, 280, 30);
addObject ( rot, 390, 30);
addObject(gelb, 500, 30);
addObject(lila, 610, 30);
addObject (weiter, 335,90);
schwarz.setSize(100, 50);
gelb.setSize(100, 50);
blau.setSize(100, 50);
grün.setSize(100, 50);
rot.setSize(100, 50);
lila.setSize(100, 50);
weiter.setSize(100, 50);
Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter,remove};
Label[] lList = new Label[] {header,pl1,pl2,pl3,pl4,pl5};
addObject(header,200,15);
addObject(schwarz, 70, 50);
addObject ( blau, 190, 50);
addObject ( grün, 300, 50);
addObject ( rot, 410, 50);
addObject(gelb, 520, 50);
addObject(lila, 630, 50);
addObject(remove,300,110);
addObject (weiter, 410,110);
addObject(pl1,355,160);
addObject(pl2,355,180);
addObject(pl3,355,200);
addObject(pl4,355,220);
addObject(pl5,355,240);
schwarz.setForeColor(Color.black);
gelb.setForeColor(Color.yellow);
blau.setForeColor(Color.blue);
grün.setForeColor(Color.green);
rot.setForeColor(Color.red);
lila.setForeColor(new Color(161,70,255));
for(int i = 0; i < bList.length; i++) {
bList[i].setSize(100,50);
}
for(int i = 0; i < lList.length; i++) {
lList[i].setBackColor(new Color(0,0,0,0));
}
redraw();
}
// Überprüft, ob ein Farbbutton geklickt wurde
//Überprüft, ob die Farbe noch nicht ausgewählt wurde
@ -66,55 +96,63 @@ public class Colours extends World implements ButtonEvent
//der per Konstruktor die Daten der Colorklasse übertragen werden, dannach wird die Map die aktive Welt
public void buttonClicked (Button b)
{
if ( b == schwarz && possw == true)
{
color[x] = sw;
pn[x]="Schwarz";
x+=1;
possw = false;
}
if (b == blau && posbl == true)
{
color[x] = bl;
pn[x] = "Blau";
x+=1;
posbl = false;
}
if (b == grün && posgr == true )
{
color[x] = gr;
pn[x]="Grün";
x+=1;
posgr = false;
}
if ( b == rot && posrt == true)
{
color[x] = rt;
pn[x]="Rot";
x+=1;
posrt = false;
}
if ( b == gelb && posgb == true)
{
color [x] = gb;
pn[x]="Gelb";
x+=1;
posgb = false;
if (x < 5) {
if (b == schwarz && possw == true) {
color[x] = sw;
pn[x]=getName(x,"Schwarz");
if(pn[x].length() > 0) {
x+=1;
possw = false;
}
} else if (b == blau && posbl == true) {
color[x] = bl;
pn[x]=getName(x,"Blau");
if(pn[x].length() > 0) {
x+=1;
posbl = false;
}
} else if (b == grün && posgr == true ) {
color[x] = gr;
pn[x]=getName(x,"Grün");
if(pn[x].length() > 0) {
x+=1;
posgr = false;
}
} else if (b == rot && posrt == true) {
color[x] = rt;
pn[x]=getName(x,"Rot");
if(pn[x].length() > 0) {
x+=1;
posrt = false;
}
} else if (b == gelb && posgb == true) {
color [x] = gb;
pn[x]=getName(x,"Gelb");
if(pn[x].length() > 0) {
x+=1;
posgb = false;
}
} else if (b == lila && posli == true) {
color [x] = li;
pn[x]=getName(x,"Lila");
if(pn[x].length() > 0) {
x+=1;
posli = false;
}
}
}
if ( b == lila && posli == true)
{
color [x] = li;
pn[x]="Lila";
x+=1;
posli = false;
if(b == remove && x > 0) {
x -= 1;
switch(color[x]) {
case 1: possw = true; break;
case 2: posbl = true; break;
case 3: posgr = true; break;
case 4: posrt = true; break;
case 5: posgb = true; break;
case 6: posli = true; break;
}
}
if ( b == weiter && x >=2 )
if ( b == weiter && x > 2 )
{
String[] newpn = new String[x];
int[] newcolor = new int[x];
@ -122,13 +160,57 @@ public class Colours extends World implements ButtonEvent
{
newpn[i] = pn[i];
newcolor[i] = color[i];
}
World m = new Map(newcolor,x,newpn);
Greenfoot.setWorld(m);
}
redraw();
}
private Color getC(boolean pos) {
if(x >= 5) {
return Color.gray;
}
return (pos) ? Color.lightGray : Color.gray;
}
/**
Passt alle adaptiven Parameter automatisch an.
*/
private void redraw() {
schwarz.setBackColor(getC(possw));
blau.setBackColor(getC(posbl));
grün.setBackColor(getC(posgr));
rot.setBackColor(getC(posrt));
lila.setBackColor(getC(posli));
gelb.setBackColor(getC(posgb));
remove.setBackColor((x > 0) ? Color.black : Color.gray);
weiter.setBackColor((x > 2) ? Color.black : Color.gray);
pl1.setText("");
pl2.setText("");
pl3.setText("");
pl4.setText("");
pl5.setText("");
switch(x) {
case 5:
pl5.setText(pn[4]);
case 4:
pl4.setText(pn[3]);
case 3:
pl3.setText(pn[2]);
case 2:
pl2.setText(pn[1]);
case 1:
pl1.setText(pn[0]);
}
}
private String getName(int id, String col) {
String name = JOptionPane.showInputDialog(null, "Wie soll Spieler Nr. "+id+" mit der Farbe "+col+" heißen?");
if(name == null) {
name = "";
}
return name;
}
}

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

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

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

@ -13,7 +13,7 @@ import java.util.Arrays; // (World, Actor, GreenfootImage, Greenfoot and Mouse
* @author (your name)
* @version (a version number or a date)
*/
public class Dice_Defender extends Dice
public class Dice_Defender
{
/**
* Act - do whatever the Dice_Offender wants to do. This method is called whenever
@ -32,6 +32,7 @@ public class Dice_Defender extends Dice
*/
public int[] dice_defender(int troupNumberDefender)
{
diceEyesDefender = new int[2];
if(troupNumberDefender == 1)
{
diceEyesDefender[0] = (int) (Math.random() * 6 +1);

@ -13,7 +13,7 @@ import java.util.Arrays; // (World, Actor, GreenfootImage, Greenfoot and Mouse
* @author (your name)
* @version (a version number or a date)
*/
public class Dice_Offender extends Dice
public class Dice_Offender
{
/**
* Act - do whatever the Dice_Offender wants to do. This method is called whenever
@ -32,6 +32,7 @@ public class Dice_Offender extends Dice
*/
public int[] dice_offender(int troupNumberOffender)
{
diceEyesOffender = new int[3];
if(troupNumberOffender == 1)
{
System.out.println("Mit einer verbleibenden Truppe auff dem Feld kann man nicht angreifen!");

File diff suppressed because it is too large Load Diff

@ -90,6 +90,11 @@ public class Label extends GUI_Interface {
*/
public void redraw() {
GreenfootImage tI = new GreenfootImage(text,textSize,foreC,backC);
if(text == "") {
tI = new GreenfootImage(1,1);
tI.setColor(new Color(0,0,0,0));
tI.fill();
}
if(autoSize) {
sx = tI.getWidth();
sy = tI.getHeight();

@ -10,15 +10,11 @@ Klasse der Standard-Welt
public class Map_World extends GeneralMap
{
/**
Anzahl der Provinzen.
*/
/**
Konstruktor der Weltkarte;
konstruiert eine GeneralMap mit den Ausmassen 1600 auf 900 Pixel.
*/
public Map_World(String[] playerList, int[] colorList)
{
super(playerList,colorList);
@ -62,16 +58,16 @@ public class Map_World extends GeneralMap
provinces[6] = new Province( 6 , 1 , 232 , 273 , 2 , "Oststaaten" , new int[] {4 , 5 , 7 , 8});
provinces[7] = new Province( 7 , 1 , 300 , 180 , 2 , "Quebec" , new int[] {4 , 6 , 9});
provinces[8] = new Province( 8 , 1 , 181 , 347 , 1 , "Mittelamerika" , new int[] {5 , 6 , 17});
provinces[9] = new Province( 9 , 1 , 365 , 55 , 1 , "Groenland" , new int[] {2 , 4 , 7 , 10});
provinces[9] = new Province( 9 , 1 , 365 , 55 , 1 , "Grönland" , new int[] {2 , 4 , 7 , 10});
// cID 2 - Europa
provinces[10] = new Province(10 , 2 , 454 , 142 , 1 , "Island" , new int[] {9 , 11 , 12});
provinces[11] = new Province(11 , 2 , 424 , 221 , 2 , "Grossbritannien" , new int[] {10 , 12 , 14 , 15});
provinces[11] = new Province(11 , 2 , 424 , 221 , 2 , "Großbritannien" , new int[] {10 , 12 , 14 , 15});
provinces[12] = new Province(12 , 2 , 520 , 153 , 1 , "Skandinavien" , new int[] {10 , 11 , 13 , 14});
provinces[13] = new Province(13 , 2 , 636 , 180 , 2 , "Russland" , new int[] {12 , 14 , 16 , 27 , 31 , 32});
provinces[14] = new Province(14 , 2 , 528 , 232 , 2 , "Nordeuropa" , new int[] {11 , 12 , 13 , 15 , 16});
provinces[15] = new Province(15 , 2 , 449 , 335 , 2 , "Westeuropa" , new int[] {11 , 14 , 16 , 25});
provinces[16] = new Province(16 , 2 , 537 , 296 , 2 , "Suedeuropa" , new int[] {13 , 14 , 15 , 25 , 26 , 27});
provinces[16] = new Province(16 , 2 , 537 , 296 , 2 , "Südeuropa" , new int[] {13 , 14 , 15 , 25 , 26 , 27});
// cID 3 - Suedamerika
provinces[17] = new Province(17 , 3 , 245 , 396 , 1 , "Venezuela" , new int[] {8 , 18 , 19});
@ -85,7 +81,7 @@ public class Map_World extends GeneralMap
provinces[23] = new Province(23 , 4 , 572 , 537 , 2 , "Zentralafrika" , new int[] {22 , 25 , 24});
provinces[24] = new Province(24 , 4 , 632 , 500 , 2 , "Ostafrika" , new int[] {21 , 22 , 25 , 23 , 26});
provinces[25] = new Province(25 , 4 , 491 , 444 , 1 , "Nordafrika" , new int[] {15 , 16 , 26 , 23 , 24});
provinces[26] = new Province(26 , 4 , 574 , 414 , 1 , "Aegypten" , new int[] {27 , 25 , 24 , 16});
provinces[26] = new Province(26 , 4 , 574 , 414 , 1 , "Ägypten" , new int[] {27 , 25 , 24 , 16});
// cID 5 - Asien
provinces[27] = new Province(27 , 5 , 664 , 345 , 2 , "Mittlerer Osten" , new int[] {24 , 26 , 16 , 23 , 31 , 28});
@ -108,5 +104,47 @@ public class Map_World extends GeneralMap
provinces[42] = new Province(42 , 6 , 934 , 628 , 1 , "West Australien" , new int[] {40 , 41 , 39});
initProvinces();
/*
Legt die Startprovincen der Spieler fest.
*/
int[] dataL = new int[(provinces.length-1)*2];
/*
dataL speichert folgende Daten:
0. Spieler-ID des Besitzers (Provinz 1)
1. Einheitenanzahl (Provinz 1)
2. Spieler-ID des Besitzers (Provinz 2)
3. [...]
*/
if(players.length==3) {
/*
Spieler 1 darf beginnen; Hauptstadt: 40
Spieler 2 ist als zweites dran; Hauptstadt: 20
Spieler 3 ist als drittes dran und bekommt eine Karte; Hauptstadt: 9
*/
dataL = new int[] {0,1,2,2,1,2,1,1,0,1,0,1,2,2,0,1,2,4,2,1,1,2,0,2,0,2,2,3,2,3,2,3,0,1,1,2,1,4,1,3,0,1,2,4,0,2,2,4,1,2,1,1,2,1,0,3,0,3,0,4,2,1,1,1,1,1,0,2,1,2,2,1,1,2,1,4,1,3,0,4,2,1,0,2};
} else if(players.length==4) {
/*
Spieler 1 darf beginnen; Hauptstadt:22
Spieler 2 ist als zweites dran; Hauptstadt:20
Spieler 3 ist als drittes dran und bekommt eine Karte; Hauptstadt:2
Spieler 4 ist als viertes dran und bekommt eine Karte; Hauptstadt:39
*/
dataL = new int[] {0,1,2,3,2,3,2,2,2,2,2,3,1,2,0,2,1,2,2,2,1,3,2,2,1,3,0,3,0,3,0,3,2,2,3,2,1,4,1,4,0,1,0,2,0,5,0,3,1,2,3,3,3,1,3,2,1,2,1,2,3,1,1,1,3,5,2,2,2,2,2,2,3,1,3,1,3,4,3,1,0,2,3,4};
} else if(players.length==5) {
/*
Spieler 1 darf beginnen; Hauptstadt:13
Spieler 2 ist als zweites dran; Hauptstadt:7
Spieler 3 ist als drittes dran und bekommt eine Karte; Hauptstadt:22
Spieler 4 ist als viertes dran und bekommt eine Karte; Hauptstadt:20
Spieler 5 ist als fünftes dran und bekommt zwei Karte; Hauptstadt:41
*/
dataL = new int[] {2,1,0,2,3,2,1,2,1,2,1,2,1,4,3,1,1,2,3,1,3,3,2,1,0,4,0,2,2,3,0,2,1,3,3,2,3,5,3,3,1,2,2,5,2,3,0,2,2,3,2,2,1,3,4,2,4,3,4,3,0,3,0,3,3,1,4,1,4,1,4,2,2,2,3,2,4,2,0,2,4,4,4,2};
}
for(int i = 1; i < provinces.length; i++) {
Province p = provinces[i];
p.setOwner(dataL[(i-1)*2]);
p.setEntityCount(dataL[(i*2)-1]);
}
}
}

@ -4,8 +4,8 @@ import java.awt.Color;
/**
* Write a description of class Player here.
*
* @author (Genosse Betakevin und Genosse Julien)
* @version (version 666)
* @author (Genosse Betakevin und Genosse Julien und Genosse GruenerWal)
* @version 6.6.6-build2
*/
public class Player extends Actor
{
@ -22,6 +22,7 @@ public class Player extends Actor
int color;
int textsize;
int c;
public int active;
//definiert die ID und Namens Variable
public Player(int identity,String name, int c)
@ -47,46 +48,56 @@ public class Player extends Actor
return stars;
}
// Von Felix: Methode nicht architektur-konform
/**
* Gibt die Farbe des Spielers als int-Wert heraus.
* Wahnsinn, dass du dir den Scheiß hier grad durchliest.
* ~GruenerWal
*/
public int getColor()
{
return color;
}
// Von Felix: Methode nicht architektur-konform
/* // erhöht die Sternenzahl um eine random ausgewählte Anzahl von 1-3
public void addToStars()
{
int rand;
int pre;
rand = (int)(1+6*Math.random());
if (rand == 1 || rand == 2|| rand == 3)
{
add = 1;
redrawPlayer();
}
if (rand == 4|| rand == 5)
{
add = 2;
redrawPlayer();
}
if (rand == 6)
{
add = 3;
redrawPlayer();
}
if (gotProv== true)
{
pre = stars;
stars+=add;
System.out.println("Deine vorherige Sternenanzahl betrug " + pre + ".");
System.out.println("Du hast " + add + " Sterne erhalten.");
System.out.println("Deine aktuelle Sternenanzahl beträgt " + stars + ".");
redrawPlayer();
}
int rand;
int pre;
rand = (int)(1+6*Math.random());
if (rand == 1 || rand == 2|| rand == 3)
{
add = 1;
redrawPlayer();
}
if (rand == 4|| rand == 5)
{
add = 2;
redrawPlayer();
}
if (rand == 6)
{
add = 3;
redrawPlayer();
}
if (gotProv== true)
{
pre = stars;
stars+=add;
System.out.println("Deine vorherige Sternenanzahl betrug " + pre + ".");
System.out.println("Du hast " + add + " Sterne erhalten.");
System.out.println("Deine aktuelle Sternenanzahl beträgt " + stars + ".");
redrawPlayer();
}
} */
private void checkStars() {
if(stars < 0) {
stars = 0;
}
}
// Von Felix: Architektur-konforme Funktion
public int addToStars(int s) {
stars += s;
@ -110,7 +121,7 @@ public class Player extends Actor
redrawPlayer();
return stars;
}
public boolean canStarsRemoved(int s) {
return (stars - s) >= 0;
}
@ -233,16 +244,31 @@ public class Player extends Actor
break;
case 3:
flag = new GreenfootImage("images\\GrueneArmee.jpg");
redraw(statistics,flag,textSize);
redrawArrow(statistics,flag,textSize);
break;
}
}
private void redraw(GreenfootImage statistics,GreenfootImage flag, int textSize)
private void redrawArrow(GreenfootImage statistics,GreenfootImage flag, int textSize)
{
// redraw(statistics,flag,textSize);
GreenfootImage Arrow = new GreenfootImage(137,120);
if(id == 0 || id == 1|| id == 2)
{
Arrow.setColor(Color.GRAY);
Arrow.fill();
Arrow.drawImage(statistics,0,0);
redraw(Arrow,flag,textSize);
}
else
{
redraw(statistics,flag,textSize);
}
}
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] + "||" +stats[3] + "||" + stats[4] + "||" + stats[5],textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f));

@ -5,7 +5,7 @@ import java.awt.Color;
* Write a description of class Province here.
*
* @author GruenerWal, Felix Stupp
* @version 0.0.2
* @version 1.1.0
*/
public class Province extends Actor
{
@ -22,7 +22,8 @@ public class Province extends Actor
private int xPos;
private int yPos;
private int eCount;
public int textSize;
private GreenfootImage province;
private boolean clicked = false;
/**
* Überprüft, ob die Provinz angeklickt wurde.
@ -171,63 +172,77 @@ public class Province extends Actor
public void redrawProvince(int ColorInt)
{
int textSize;
textSize = 20;
GreenfootImage province = new GreenfootImage(120,100);
GreenfootImage provinceName = new GreenfootImage(displayName,textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f));
int eCountTanks = eCount / 5;
GreenfootImage LenghtCalculate = new GreenfootImage((eCount / 5) + "x",textSize, new Color(0,0,0), new Color(0,0,0));
int lenght = LenghtCalculate.getWidth() + (textSize *3);
if(lenght < provinceName.getWidth())
{
province = new GreenfootImage(provinceName.getWidth(),2*textSize);
}
else
{
province = new GreenfootImage(lenght,2*textSize);
}
if(ColorInt ==1)
{
GreenfootImage provinceName = new GreenfootImage(displayName,textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f));
province.drawImage(provinceName,0,0);
setImage(province);
oDecide(province,textSize,owner,eCount);
}
if(ColorInt ==2)
{
GreenfootImage provinceName = new GreenfootImage(displayName,textSize,new Color(0,0,0),Color.GREEN);
provinceName = new GreenfootImage(displayName,textSize,new Color(0,0,0),Color.GREEN);
province.drawImage(provinceName,0,0);
setImage(province);
oDecide(province,textSize,owner,eCount);
}
if(ColorInt == 3)
{
GreenfootImage provinceName = new GreenfootImage(displayName,textSize,new Color(0,0,0),Color.RED);
provinceName = new GreenfootImage(displayName,textSize,new Color(0,0,0),Color.RED);
province.drawImage(provinceName,0,0);
setImage(province);
oDecide(province,textSize,owner,eCount);
}
}
/**
* Weist dem Owner der Provinz sein entsprechendes Color-Tag zu.
*/
public void oDecide(GreenfootImage province,int textSize, int owner, int eCount)
{
String ownerString;
if(owner == 0)
if(getWorld().getPlayerColor(owner) == 0)
{
ownerString = "schwarz";
eCalculate(province,ownerString,textSize);
}
else
{
switch(owner)
switch(getWorld().getPlayerColor(owner))
{
case 1:
ownerString = "schwarz";
eCalculate(province,ownerString,textSize);
break;
case 2:
ownerString = "rot";
ownerString = "blau";
eCalculate(province,ownerString,textSize);
break;
case 3:
ownerString = "blau";
ownerString = "gruen";
eCalculate(province,ownerString,textSize);
break;
case 4:
ownerString = "gelb";
ownerString = "rot";
eCalculate(province,ownerString,textSize);
break;
case 5:
ownerString = "gruen";
ownerString = "gelb";
eCalculate(province,ownerString,textSize);
break;
case 6:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Loading…
Cancel
Save