1 package cz.cuni.amis.pogamut.ut2004.utils;
2
3 import cz.cuni.amis.pogamut.base.utils.DefaultPogamutPlatform;
4 import cz.cuni.amis.pogamut.base.utils.Pogamut;
5 import cz.cuni.amis.pogamut.base.utils.PogamutPlatformProxy;
6 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
7 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.visibility.model.VisibilityMatrix;
8 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
9 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
10 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Initialize;
11
12 public enum PogamutUT2004Property {
13
14
15
16
17 POGAMUT_UT2004_BOT_HOST("pogamut.ut2004.bot.host", String.class, "localhost"),
18
19
20
21
22 POGAMUT_UT2004_BOT_PORT("pogamut.ut2004.bot.port", Integer.class, 3000),
23
24
25
26
27
28 POGAMUT_UT2004_SERVER_HOST("pogamut.ut2004.server.host", String.class, "localhost"),
29
30
31
32
33 POGAMUT_UT2004_SERVER_PORT("pogamut.ut2004.server.port", Integer.class, 3001),
34
35
36
37
38
39 POGAMUT_UT2004_OBSERVER_HOST("pogamut.ut2004.observer.host", String.class, "localhost"),
40
41
42
43
44 POGAMUT_UT2004_OBSERVER_PORT("pogamut.ut2004.observer.port", Integer.class, 3002),
45
46
47 POGAMUT_UNREAL_HOME("pogamut.ut2004.home", String.class, null),
48
49
50 POGAMUT_UNREAL_TEST_EXT_SERVER("pogamut.test.useExternalUCC", Boolean.class, false),
51
52
53
54
55 POGAMUT_UT2004_PATH_EXECUTOR_SEND_SET_ROUTE("pogamut.ut2004.path_executor.send_set_route", Boolean.class, false),
56
57
58
59
60 POGAMUT_UT2004_VISIBILITY_DIRECTORY("pogamut.ut2004.visibility.dir", String.class, "."),
61
62
63
64
65
66
67 POGAMUT_UT2004_BOT_INIT_OVERRIDE_PARAMS("pogamut.ut2004.bot.init.override", Boolean.class, false),
68
69
70
71
72 POGAMUT_UT2004_BOT_INIT_TEAM("pogamut.ut2004.bot.init.team", Integer.class, 255),
73
74
75
76
77 POGAMUT_UT2004_BOT_INIT_SKILL("pogamut.ut2004.bot.init.skill", Integer.class, 5),
78
79
80
81
82 POGAMUT_UT2004_BOT_INIT_SKIN("pogamut.ut2004.bot.init.skin", String.class, null),
83
84
85
86
87 POGAMUT_UT2004_BOT_INIT_NAME("pogamut.ut2004.bot.init.name", String.class, null),
88 ;
89
90 private String key;
91 private Class type;
92 private Object defaultValue;
93
94 private PogamutUT2004Property(String key, Class type, Object defaultValue) {
95 this.key = key;
96 this.type = type;
97 this.defaultValue = defaultValue;
98 }
99
100 public String getKey() {
101 return key;
102 }
103
104 public String toString() {
105 return key;
106 }
107
108 public Object getValue() {
109 String value = Pogamut.getPlatform().getProperty(getKey());
110 if (value == null) return getDefaultValue();
111 if (type == String.class) {
112 return value;
113 } else
114 if (type == Integer.class) {
115 try {
116 return Integer.parseInt(value);
117 } catch (Exception e) {
118 return getDefaultValue();
119 }
120 } else
121 if (type == Float.class) {
122 try {
123 return Float.parseFloat(value);
124 } catch (Exception e) {
125 return getDefaultValue();
126 }
127 } else
128 if (type == Double.class) {
129 try {
130 return Double.parseDouble(value);
131 } catch (Exception e) {
132 return getDefaultValue();
133 }
134 } else
135 if (type == Boolean.class) {
136 if (value.toLowerCase().equals("true")) return true;
137 return false;
138 } else {
139 throw new RuntimeException("Unsupported property type: " + type.getSimpleName());
140 }
141 }
142
143 public Object getDefaultValue() {
144 return defaultValue;
145 }
146 }