Merge pull request #110 from HGE-IT-Course-2016/master

GiveStars - Aktualisierung
master
Achim 8 years ago committed by GitHub
commit 6b6fe7d5f1

@ -19,6 +19,8 @@
"**/*.doc": true,
"**/*.docx": true,
"**/*.pdf": true,
"**/*.xcf": true
"**/*.xcf": true,
// Sonstiges
"**/*.mht": true
}
}

@ -63,6 +63,7 @@ public abstract class GeneralMap extends World implements ButtonEvent
addObject( modus, 1500, 808);
for (int i = 0; i < playerList.length; i++) {
players[i] = new Player(i,playerList[i],colorList[i]);
addObject(players[i],0,0);
players[i].redrawPlayer();
}
@ -118,17 +119,17 @@ public abstract class GeneralMap extends World implements ButtonEvent
}
switch (playerCount) {
case 6:
addObject(players[5],1512,350);
players[5].setLocation(1512,350);
case 5:
addObject(players[4],1512,230);
players[4].setLocation(1512,230);
case 4:
addObject(players[3],1512,110);
players[3].setLocation(1512,110);
case 3:
addObject(players[2],82,350);
players[2].setLocation(82,350);
case 2:
addObject(players[1],82,230);
players[1].setLocation(82,230);
}
addObject(players[0],82,110);
players[0].setLocation(82,110);
}
/**
@ -139,6 +140,20 @@ public abstract class GeneralMap extends World implements ButtonEvent
addObject(provinces[i],((int) Math.floor(provinces[i].getXPos() * SCALE_VALUE)) + X_OFFSET,((int) Math.floor(provinces[i].getYPos() * SCALE_VALUE)) + Y_OFFSET);
}
}
private void redrawProvinces() {
for(int i = 1; i < provinces.length; i++) {
provinces[i].redrawProvince();
}
}
protected void redrawPlayers() {
for(int i = 0; i < players.length; i++) {
players[i].reloadMaxInfluence();
players[i].reloadMaxEntities();
players[i].redrawPlayer();
}
}
/**
Zeigt die angegebene Nachricht in einem JOptionPane Dialogfeld an.
@ -176,6 +191,14 @@ public abstract class GeneralMap extends World implements ButtonEvent
return players[pID].getColor();
}
/**
Gibt die PlayerID des aktuellen Spielers an.
@return PlayerID des aktuellen Spielers
*/
public int getCurrentPlayerID() {
return currentPlayer;
}
/**
Gibt den Namen des aktuellen Spielers aus.
@return Der Name des aktuellen Spielers
@ -234,10 +257,10 @@ public abstract class GeneralMap extends World implements ButtonEvent
@param playerID Die ID des Spielers, für den die Einheiten gezählt werden sollen.
@return Die Anzahl der Einheiten, die dem Spieler gehören.
*/
public int getProvinceEntityCount(int playerID)
public int getPlayerEntityCount(int playerID)
{
int c = 0;
for (int i = 1; i > provinces.length; i++) {
for (int i = 1; i < provinces.length; i++) {
if(provinces[i].getOwner() == playerID) {
c = c + provinces[i].getEntityCount();
}
@ -279,6 +302,8 @@ public abstract class GeneralMap extends World implements ButtonEvent
status=GameStates.SETZEN;
modus.setText("Kampf\nbeginnen");
}
redrawProvinces();
redrawPlayers();
}
}
@ -384,16 +409,21 @@ public abstract class GeneralMap extends World implements ButtonEvent
// berechnet Zahlen und findet Gewinner; führt Konsequenz aus
private void decider(int[] maxDiceOffender, int [] maxDiceDefender)
{
Player offPl = players[offenderProvince.getOwner()];
Player defPl = players[defenderProvince.getOwner()];
int maxDefender = maxDiceDefender[1];
int maxOffender = maxDiceOffender[2];
if (maxOffender > maxDefender)
{
defenderProvince.removeFromEntities(1);
defPl.lostEntity();
if (defenderProvince.getEntityCount() <= 0) {
defenderProvince.setOwner(offenderProvince.getOwner());
offenderProvince.removeFromEntities(1);
defenderProvince.setEntityCount(1);
offPl.gotProvince();
defPl.lostProvince();
JOptionPane.showMessageDialog(null,"Somit gewinnt der Angreifer (" + getPlayerName(offenderProvince.getOwner()) + "). Die Provinz gehört fortan dem Angreifer (" + getPlayerName(offenderProvince.getOwner()) + ").");
} else {
JOptionPane.showMessageDialog(null,"Somit gewinnt der Angreifer (" + getPlayerName(offenderProvince.getOwner()) + "). Dem Verteidiger (" + getPlayerName(defenderProvince.getOwner()) + ") wird eine Einheit abgezogen. Er hat nun noch " + defenderProvince.getEntityCount() + " Einheiten.");
@ -403,12 +433,14 @@ public abstract class GeneralMap extends World implements ButtonEvent
if (maxOffender < maxDefender && offenderProvince.getEntityCount()>1)
{
offenderProvince.removeFromEntities(1);
offPl.lostEntity();
JOptionPane.showMessageDialog(null,"Somit gewinnt der Verteidiger (" + getPlayerName(defenderProvince.getOwner()) + "). Dem Angreifer (" + getPlayerName(offenderProvince.getOwner()) + ") wird eine Einheit abgezogen. Er hat nun noch " + offenderProvince.getEntityCount() + " Einheiten.");
}
if (maxOffender == maxDefender && offenderProvince.getEntityCount()>1)
{
offenderProvince.removeFromEntities(1);
offPl.lostEntity();
JOptionPane.showMessageDialog(null,"Da es unentschieden ist, gewinnt der Verteidiger (" + getPlayerName(defenderProvince.getOwner()) + "). Dem Angreifer (" + getPlayerName(offenderProvince.getOwner()) + ") wird eine Einheit abgezogen. Er hat nun noch " + offenderProvince.getEntityCount() + " Einheiten.");
}
@ -492,6 +524,7 @@ public abstract class GeneralMap extends World implements ButtonEvent
{
if ( freeArmies == -1 ) {
freeArmies = calculateArmies();
players[currentPlayer].gotEntities(freeArmies);
} else if ( freeArmies == 0 ) {
modus.setBackColor(Color.white);
modus.setForeColor(Color.black);

File diff suppressed because it is too large Load Diff

@ -146,5 +146,6 @@ public class Map_World extends GeneralMap
p.setOwner(dataL[(i-1)*2]);
p.setEntityCount(dataL[(i*2)-1]);
}
redrawPlayers();
}
}

@ -140,10 +140,15 @@ public class Player extends Actor
}
return p;
}
public int getEntitiesCount() {
return getWorld().getPlayerEntityCount(id);
}
public void gotEntities(int gotEnt)
{
stats[3]+= gotEnt;
reloadMaxEntities();
redrawPlayer();
}
@ -155,6 +160,7 @@ public class Player extends Actor
public void gotProvince() {
stats[0]++;
reloadMaxInfluence();
redrawPlayer();
}
@ -163,20 +169,22 @@ public class Player extends Actor
redrawPlayer();
}
public void maxInfluence (int influCount)
public void reloadMaxInfluence()
{
if(stats[2]< influCount)
int c = getProvinceCount();
if(stats[2]< c)
{
stats[2]=influCount;
stats[2]=c;
redrawPlayer();
}
}
private void maxEntities(int entNumber)
public void reloadMaxEntities()
{
if (stats[5]< entNumber)
int c = getEntitiesCount();
if (stats[5]< c)
{
stats[5]=entNumber;
stats[5]=c;
redrawPlayer();
}
}
@ -215,6 +223,14 @@ public class Player extends Actor
}
private Color getTextCol() {
return (getWorld().getCurrentPlayerID() == id) ? new Color(0,0,0) : new Color(255,255,255);
}
private Color getTransBackCol() {
return (getWorld().getCurrentPlayerID() == id) ? new Color(255,255,255) : new Color(0,0,0);
}
public void redrawPlayer()
{
int textSize = 20;
@ -223,8 +239,8 @@ public class Player extends Actor
n = "leererSpieler";
}
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 name = new GreenfootImage(n,textSize,getTextCol(),getTransBackCol());
statistics.drawImage(name,0,0);
setImage(statistics);
oDecide(statistics,textSize);
@ -233,45 +249,27 @@ public class Player extends Actor
private void oDecide(GreenfootImage statistics,int textSize)
{
GreenfootImage flag = new GreenfootImage("images\\BlaueArmee.jpg");
redraw(statistics,flag,textSize);
switch(color)
{
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");
redrawArrow(statistics,flag,textSize);
break;
}
}
private void redrawArrow(GreenfootImage statistics,GreenfootImage flag, int textSize)
{
// redraw(statistics,flag,textSize);
redraw(statistics,flag,textSize);
}
@ -279,7 +277,7 @@ 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));
GreenfootImage playerStatistics = new GreenfootImage(stats[0] + "||" + stats[1] + "||" + stats[2] + "||" +stats[3] + "||" + stats[4] + "||" + stats[5],textSize,getTextCol(),getTransBackCol());
statistics.drawImage(playerStatistics, 0, 103);
setImage(statistics);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 KiB

@ -30,6 +30,8 @@ public class Start_Load extends World implements ButtonEvent
addObject (chulien, (1600-chulien.getWidth())/2+100, (900-chulien.getHeight())/2);
addObject (spielanleitung, (1600-spielanleitung.getWidth())/2+100, (900-spielanleitung.getHeight())/2 + 80);
Greenfoot.setSpeed(100);
Greenfoot.start();
}
public void buttonClicked ( Button b)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 659 B

Loading…
Cancel
Save