diff --git a/ArmySchubser.java b/ArmySchubser.java index 307b18e..9bd5bc9 100644 --- a/ArmySchubser.java +++ b/ArmySchubser.java @@ -6,7 +6,7 @@ import javax.swing.JOptionPane; * Schubst Einheiten umher. * * @author MaxiJohl, GruenerWal - * @version 0.3.0 + * @version 1.1.0 */ public class ArmySchubser extends Map_World @@ -28,20 +28,24 @@ public class ArmySchubser extends Map_World * Nimmt zwei Provinzen entgegen, und fragt, wieviele Einheiten vom ersten zum zweiten Eintrag verschoben werden sollen. * Überprüft, ob eine Verschiebung möglich ist und führt sie bei Erfolg aus. */ - public static void moveEntities(Province sourceProvince, Province destinationProvince) + public void moveEntities(Province sourceProvince, Province destinationProvince) { String toMoveString = JOptionPane.showInputDialog(null, "Wieviele Einheiten willst du verschieben?"); Integer entitiesToMove = Integer.valueOf(toMoveString); - if ( (sourceProvince.getEntityCount() - entitiesToMove) > 0) + if ( entitiesToMove != null ) { - sourceProvince.removeFromEntities(entitiesToMove); - destinationProvince.addToEntities(entitiesToMove); - } + if ( (sourceProvince.getEntityCount() - entitiesToMove) > 0) + { + sourceProvince.removeFromEntities(entitiesToMove); + destinationProvince.addToEntities(entitiesToMove); + JOptionPane.showMessageDialog(null,"Einheiten erfolgreich verschoben, Kommandant " + getPlayerName() + "."); + } - if ( (sourceProvince.getEntityCount() - entitiesToMove) <= 0 ) - { - JOptionPane.showMessageDialog(null,"Du hast nicht genügend Einheiten, um die gewünschte Anzahl von " + sourceProvince.getDisplayName() + " nach " + destinationProvince.getDisplayName() + " zu verschieben, Köhler."); + else if ( (sourceProvince.getEntityCount() - entitiesToMove) <= 0) + { + JOptionPane.showMessageDialog(null,"Du hast nicht genügend Einheiten, um die gewünschte Anzahl von " + sourceProvince.getDisplayName() + " nach " + destinationProvince.getDisplayName() + " zu verschieben, Köhler."); + } } } @@ -50,25 +54,22 @@ public class ArmySchubser extends Map_World * Ist er das, so wird überprüft, ob eine neue, an savedProvince angrenzende Provinz angeklickt wurde. * Ist dies der Fall, werden beide Provinzen an moveEntities übergeben. */ - public static void useProvincesToMove(Province givenProvince) + public void useProvincesToMove(Province givenProvince) { if (savedProvince == null) { savedProvince = givenProvince; } - if (savedProvince != null && givenProvince != savedProvince) + else if ((savedProvince != null) && (givenProvince != savedProvince) && (savedProvince.getOwner() == givenProvince.getOwner()) && (savedProvince.getOwner() == currentPlayer) ) { if (givenProvince.isProvinceNear(savedProvince.getID()) == true) { moveEntities(savedProvince,givenProvince); } - - else - { - savedProvince = null; - } - } + + savedProvince = null; + } } /** @@ -79,9 +80,9 @@ public class ArmySchubser extends Map_World */ public void act() { - Province clickedProvince = null; - - for ( int i = 1; i <= provinceCount; i++) + Province clickedProvince; + + for ( int i = 1; i <= (provinces.length - 1); i++) { if (provinces[i].hasClicked() == true) { @@ -91,5 +92,4 @@ public class ArmySchubser extends Map_World } } } -} - +} \ No newline at end of file