ArmySchubser-Aktualisierung

Neuer Armyschubser
master
Achim 10 years ago committed by GitHub
parent e26f927c93
commit ce83de8e8e

@ -6,10 +6,13 @@ import javax.swing.JOptionPane;
* Schubst Einheiten umher. * Schubst Einheiten umher.
* *
* @author MaxiJohl, GruenerWal * @author MaxiJohl, GruenerWal
* @version 0.1.1 * @version 0.2.0
*/ */
public class ArmySchubser extends Map_World public class ArmySchubser extends Map_World
{ {
Province firstProvince = null;
Province secondProvince = null;
/** /**
* Constructor for objects of class ArmySchubser. * Constructor for objects of class ArmySchubser.
@ -22,39 +25,47 @@ public class ArmySchubser extends Map_World
public void act() public void act()
{ {
Province firstProvince = null; if (firstProvince == null)
Province secondProvince = null;
for ( int i = 0; i <= provinceCount; i++)
{ {
if (provinces[i].hasClicked() == true) for ( int i = 1; i <= provinceCount; i++)
{ {
provinces[i] = firstProvince; if (provinces[i].hasClicked() == true)
break; {
provinces[i] = firstProvince;
break;
}
} }
} }
for ( int i = 0; i <= provinceCount; i++) if (firstProvince != null)
{ {
if (provinces[i].hasClicked() == true && provinces[i] != firstProvince) for ( int i = 0; i <= provinceCount; i++)
{ {
provinces[i] = secondProvince; if (provinces[i].hasClicked() == true && provinces[i] != firstProvince)
break; {
provinces[i] = secondProvince;
break;
}
} }
}
String toMove = JOptionPane.showInputDialog(null, "Wieviele Einheiten willst du verschieben?"); String toMoveString = JOptionPane.showInputDialog(null, "Wieviele Einheiten willst du verschieben?");
Integer entitiesToMove = Integer.valueOf(toMove); Integer entitiesToMove = Integer.valueOf(toMoveString);
if ( (firstProvince.getEntityCount() - entitiesToMove) > 0 && firstProvince.isProvinceNear(secondProvince.getID()) == true ) if ( (firstProvince.getEntityCount() - entitiesToMove) > 0 && firstProvince.isProvinceNear(secondProvince.getID()) == true )
{ {
firstProvince.removeFromEntities(entitiesToMove); firstProvince.removeFromEntities(entitiesToMove);
secondProvince.addToEntities(entitiesToMove); secondProvince.addToEntities(entitiesToMove);
} }
else if ( (firstProvince.getEntityCount() - entitiesToMove) <= 0 )
{ {
System.out.println("Du hast nicht genügend Einheiten, um die gewünschte Anzahl von " + firstProvince.getDisplayName() + " nach " + secondProvince.getDisplayName() + " zu verschieben, Köhler."); JOptionPane.showMessageDialog(null,"Du hast nicht genügend Einheiten, um die gewünschte Anzahl von " + firstProvince.getDisplayName() + " nach " + secondProvince.getDisplayName() + " zu verschieben, Köhler.");
}
if ( firstProvince.isProvinceNear(secondProvince.getID()) == false )
{
JOptionPane.showMessageDialog(null,"Die Provinzen müssen nebeneinander liegen, wenn du Einheiten verschieben willst.");
}
} }
} }
} }

Loading…
Cancel
Save