@ -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,10 +25,9 @@ public class ArmySchubser extends Map_World
public void act ( )
public void act ( )
{
{
Province firstProvince = null ;
if ( firstProvince = = null )
Province secondProvince = null ;
{
for ( int i = 1 ; i < = provinceCount ; i + + )
for ( int i = 0 ; i < = provinceCount ; i + + )
{
{
if ( provinces [ i ] . hasClicked ( ) = = true )
if ( provinces [ i ] . hasClicked ( ) = = true )
{
{
@ -33,7 +35,10 @@ public class ArmySchubser extends Map_World
break ;
break ;
}
}
}
}
}
if ( firstProvince ! = null )
{
for ( int i = 0 ; i < = provinceCount ; i + + )
for ( int i = 0 ; i < = provinceCount ; i + + )
{
{
if ( provinces [ i ] . hasClicked ( ) = = true & & provinces [ i ] ! = firstProvince )
if ( provinces [ i ] . hasClicked ( ) = = true & & provinces [ i ] ! = firstProvince )
@ -43,8 +48,8 @@ public class ArmySchubser extends Map_World
}
}
}
}
String toMove = JOptionPane . showInputDialog ( null , "Wieviele Einheiten willst du verschieben?" ) ;
String toMove String = JOptionPane . showInputDialog ( null , "Wieviele Einheiten willst du verschieben?" ) ;
Integer entitiesToMove = Integer . valueOf ( toMove ) ;
Integer entitiesToMove = Integer . valueOf ( toMove String ) ;
if ( ( firstProvince . getEntityCount ( ) - entitiesToMove ) > 0 & & firstProvince . isProvinceNear ( secondProvince . getID ( ) ) = = true )
if ( ( firstProvince . getEntityCount ( ) - entitiesToMove ) > 0 & & firstProvince . isProvinceNear ( secondProvince . getID ( ) ) = = true )
{
{
@ -52,9 +57,15 @@ public class ArmySchubser extends Map_World
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." ) ;
}
}
}
}
}
}
}