44import model .*;
55import core .model .Map ;
66import data .*;
7- import util .Constants ;
7+ import util .ServerConstants ;
88import server .Server ;
99import server .core .GameLogic ;
1010import server .core .model .ClientInfo ;
1919 */
2020public class MitosisGameLogic implements GameLogic {
2121
22- private final long GAME_LONG_TIME_TURN = 100 ; //TODO can change
22+ private final long GAME_LONG_TIME_TURN = 500 ;
2323
2424 private static final String RESOURCE_PATH_CLIENTS = "resources/mitosis/clients.conf" ;
2525
@@ -43,7 +43,7 @@ public static void main(String[] args) {
4343 public MitosisGameLogic (String [] options ) throws IOException {
4444 super ();
4545
46- ctx = new Context (Constants .TURN_INIT , options [0 ], RESOURCE_PATH_CLIENTS );
46+ ctx = new Context (ServerConstants .TURN_INIT , options [0 ], RESOURCE_PATH_CLIENTS );
4747
4848 Map map = ctx .getMap ();
4949
@@ -59,7 +59,7 @@ public void init() {
5959 }
6060
6161 ArrayList <String > viewsList = (ArrayList <String >) teamsList .clone ();
62- viewsList .add (Constants .VIEW_GLOBAL );
62+ viewsList .add (ServerConstants .VIEW_GLOBAL );
6363
6464 Map map = ctx .getMap ();
6565
@@ -74,14 +74,14 @@ public void init() {
7474 for (int col = 0 ; col < width ; col ++) {
7575 HashMap <String , Object > blockMap = new HashMap <>();
7676 Block block = map .at (col , row );
77- blockMap .put (Constants .GAME_OBJECT_KEY_ID , block .getId ());
78- blockMap .put (Constants .GAME_OBJECT_KEY_TYPE , Constants .BLOCK_TYPE_NONE );
79- blockMap .put (Constants .GAME_OBJECT_KEY_TURN , Constants .TURN_WORLD_CREATION );
80- blockMap .put (Constants .GAME_OBJECT_KEY_POSITION , new Position (block .getX (), block .getY ()));
77+ blockMap .put (ServerConstants .GAME_OBJECT_KEY_ID , block .getId ());
78+ blockMap .put (ServerConstants .GAME_OBJECT_KEY_TYPE , ServerConstants .BLOCK_TYPE_NONE );
79+ blockMap .put (ServerConstants .GAME_OBJECT_KEY_TURN , ServerConstants .TURN_WORLD_CREATION );
80+ blockMap .put (ServerConstants .GAME_OBJECT_KEY_POSITION , new Position (block .getX (), block .getY ()));
8181 HashMap <String ,Object > otherDict = new HashMap <>();
82- otherDict .put (Constants .BLOCK_KEY_HEIGHT , 0 );
83- otherDict .put (Constants .BLOCK_KEY_RESOURCE , 0 );
84- blockMap .put (Constants .GAME_OBJECT_KEY_OTHER , otherDict );
82+ otherDict .put (ServerConstants .BLOCK_KEY_HEIGHT , 0 );
83+ otherDict .put (ServerConstants .BLOCK_KEY_RESOURCE , 0 );
84+ blockMap .put (ServerConstants .GAME_OBJECT_KEY_OTHER , otherDict );
8585 unknownMap .add (blockMap );
8686 }
8787 }
@@ -96,10 +96,10 @@ public void init() {
9696 TeamInfo teamInfo = new TeamInfo (ctx .getClientsInfo ()[t ].getName (), ctx .getClientsInfo ()[t ].getID ());
9797
9898 HashMap <String , Object > info = new HashMap <>();
99- info .put (Constants .INFO_KEY_TURN , ctx .getTurn ());
100- info .put (Constants .INFO_KEY_TEAMS , teamsList );
101- info .put (Constants .INFO_KEY_YOUR_INFO , teamInfo );
102- info .put (Constants . INFO_KEY_MAPSIZE , mapSize );
99+ info .put (ServerConstants .INFO_KEY_TURN , ctx .getTurn ());
100+ info .put (ServerConstants .INFO_KEY_TEAMS , teamsList );
101+ info .put (ServerConstants .INFO_KEY_YOUR_INFO , teamInfo );
102+ info .put (ServerConstants . INFO_KEY_MAP_SIZE , mapSize );
103103
104104
105105 //make static diff
@@ -117,10 +117,10 @@ public void init() {
117117
118118 //make info
119119 HashMap <String , Object > info = new HashMap <>();
120- info .put (Constants .INFO_KEY_TURN , ctx .getTurn ());
121- info .put (Constants .INFO_KEY_TEAMS , teamsList );
122- info .put (Constants .INFO_KEY_VIEWS , viewsList );
123- info .put (Constants . INFO_KEY_MAPSIZE , mapSize );
120+ info .put (ServerConstants .INFO_KEY_TURN , ctx .getTurn ());
121+ info .put (ServerConstants .INFO_KEY_TEAMS , teamsList );
122+ info .put (ServerConstants .INFO_KEY_VIEWS , viewsList );
123+ info .put (ServerConstants . INFO_KEY_MAP_SIZE , mapSize );
124124
125125 //make map
126126 // map is ready
@@ -132,7 +132,7 @@ public void init() {
132132 for (int t = 0 ; t < mTeams .length ; t ++)
133133 {
134134 HashMap <String ,Object > viewDif = new HashMap <>();
135- viewDif .put (Constants .VIEW ,"team" + t );
135+ viewDif .put (ServerConstants .VIEW ,"team" + t );
136136
137137 //calculate static diff for each team
138138 ArrayList <StaticGameObject > staticDiff = new ArrayList <>();
@@ -146,7 +146,7 @@ public void init() {
146146 //Generate Global diff
147147 {
148148 HashMap <String , Object > viewDif = new HashMap <>();
149- viewDif .put (Constants .VIEW , Constants .VIEW_GLOBAL );
149+ viewDif .put (ServerConstants .VIEW , ServerConstants .VIEW_GLOBAL );
150150
151151 //calculate static diff for global view
152152 ArrayList <StaticData > staticDiff = new ArrayList <>();
@@ -267,7 +267,7 @@ public void simulateEvents(Event[] terminalEvent, Event[] environmentEvent, Even
267267 if (cell == null ) continue ;
268268
269269 Block block = map .at (cell .getPos ());
270- if (!block .getType ().equals (Constants .BLOCK_TYPE_MITOSIS ))
270+ if (!block .getType ().equals (ServerConstants .BLOCK_TYPE_MITOSIS ))
271271 {
272272 continue ;
273273 }
@@ -318,7 +318,7 @@ public void simulateEvents(Event[] terminalEvent, Event[] environmentEvent, Even
318318 if (cell == null ) continue ;
319319
320320 Block block = map .at (cell .getPos ());
321- if (!block .getType ().equals (Constants .BLOCK_TYPE_RESOURCE ))
321+ if (!block .getType ().equals (ServerConstants .BLOCK_TYPE_RESOURCE ))
322322 {
323323 continue ;
324324 }
@@ -446,7 +446,7 @@ public void generateOutputs() {
446446 }
447447 }
448448
449- uiTurnData .setView ( Constants .VIEW_GLOBAL );
449+ uiTurnData .setView ( ServerConstants .VIEW_GLOBAL );
450450 uiTurnData .setDynamics (dynamics );
451451 uiTurnData .setStatics (statics );
452452 uiTurnData .setTransients (transients );
0 commit comments