Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

set defaults as default values, in case the properties can not be read

* use booleans instead of 1/0
  • Loading branch information...
commit 794fccb41906286de669ac82f7ca821cc209cca7 1 parent c498d77
Benoit Daloze authored
6 assets/Configuration/config.properties
@@ -7,8 +7,7 @@ screen.height=640
7 7 ai.depth=4
8 8
9 9 # if it runs too slow
10   -# boolean: 1:true, 0:false
11   -graphics.low=0
  10 +graphics.low=false
12 11
13 12 # network setup
14 13 rmi.port=1723
@@ -16,5 +15,4 @@ rmi.port=1723
16 15 rmi.timeout=5000
17 16
18 17 # if you want to be able to play for the other player, even when he is not local
19   -# boolean: 1:true, 0:false
20   -game.canMoveOther=0
  18 +game.canMoveOther=false
28 src/pylos/Config.java
@@ -14,13 +14,13 @@
14 14 import java.util.logging.SimpleFormatter;
15 15
16 16 public class Config {
17   - public static int[] RESOLUTION = new int[2];
18   - public static int AI_DEPTH;
19   - public static boolean LOW_GRAPHICS;
20   - public static int RMI_PORT;
21   - public static long CREATE_RMI_REGISTRY_TIMEOUT;
22   - public static boolean CAN_MOVE_OTHER;
23   - public static boolean FIRE;
  17 + public static int[] RESOLUTION = { 800, 640 };
  18 + public static int AI_DEPTH = 4;
  19 + public static boolean LOW_GRAPHICS = false;
  20 + public static int RMI_PORT = 1723;
  21 + public static long CREATE_RMI_REGISTRY_TIMEOUT = 5000;
  22 + public static boolean CAN_MOVE_OTHER = false;
  23 + public static boolean FIRE = false;
24 24
25 25 static final File logDir = new File(Pylos.rootPath + "/log");
26 26 static final File defaultPropertiesFile = new File(Pylos.rootPath + "/assets/Configuration/config.properties");
@@ -50,13 +50,13 @@ public static void configureProject() {
50 50
51 51 try {
52 52 properties.load(new FileInputStream(propertiesFile));
53   - RESOLUTION[0] = Integer.valueOf(properties.getProperty("screen.width", "800"));
54   - RESOLUTION[1] = Integer.valueOf(properties.getProperty("screen.height", "640"));
55   - AI_DEPTH = Integer.valueOf(properties.getProperty("ai.depth", "4"));
56   - LOW_GRAPHICS = Integer.valueOf(properties.getProperty("graphics.low", "0")) == 1;
57   - RMI_PORT = Integer.valueOf(properties.getProperty("rmi.port", "1723"));
58   - CREATE_RMI_REGISTRY_TIMEOUT = Integer.valueOf(properties.getProperty("rmi.timeout", "5000"));
59   - CAN_MOVE_OTHER = Integer.valueOf(properties.getProperty("game.canMoveOther", "0")) == 1;
  53 + RESOLUTION[0] = Integer.valueOf(properties.getProperty("screen.width", Integer.toString(RESOLUTION[0])));
  54 + RESOLUTION[1] = Integer.valueOf(properties.getProperty("screen.height", Integer.toString(RESOLUTION[1])));
  55 + AI_DEPTH = Integer.valueOf(properties.getProperty("ai.depth", Integer.toString(AI_DEPTH)));
  56 + LOW_GRAPHICS = Boolean.valueOf(properties.getProperty("graphics.low", Boolean.toString(LOW_GRAPHICS)));
  57 + RMI_PORT = Integer.valueOf(properties.getProperty("rmi.port", Integer.toString(RMI_PORT)));
  58 + CREATE_RMI_REGISTRY_TIMEOUT = Integer.valueOf(properties.getProperty("rmi.timeout", Long.toString(CREATE_RMI_REGISTRY_TIMEOUT)));
  59 + CAN_MOVE_OTHER = Boolean.valueOf(properties.getProperty("game.canMoveOther", Boolean.toString(CAN_MOVE_OTHER)));
60 60 // Not quite ready yet
61 61 FIRE = false; // Integer.valueOf(properties.getProperty("extra.fire", "0")) == 1;
62 62 } catch (Exception e) {

0 comments on commit 794fccb

Please sign in to comment.
Something went wrong with that request. Please try again.