private void parseTickChangesPart String _cmd if _cmd length return St

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
private void parseTickChangesPart (String _cmd) {
if (_cmd.length() == 0) return;
String[] changes = _cmd.split(","), current;
boolean isAdded = false, isDeleted = false; // Add or remove
char type, mapMark;
int x, y;
int pid = 0;
for (int i = 0; i < changes.length; i++) {
current = changes[i].trim().split(" "); // Parse <change-info>
isAdded = current[0].charAt(0) == '+'; // Parse common parts
isDeleted = current[0].charAt(0) == '-';
type = current[0].charAt(1);
x = Utils.parseInt(current[1]);
y = Utils.parseInt(current[2]);
mapMark = isAdded ? type : '.';
switch (type)
{
case '*': // Bomb
{
Point pos = new Point(x, y);
if (isAdded) m_BE.m_bombs.add(new Bomb(pos, Utils.parseInt(current[3]), Utils.parseInt(current[4])));
else for (int k = 0; k < m_BE.m_bombs.size(); k++)
if (m_BE.m_bombs.get(k).m_pos.equals(pos)) {
m_BE.m_bombs.remove(k);
break;
}
} break;
case '#': // Explode
{
mapMark = '.';
} break;
case 'w': // Destructable wall
{
} break;
case 'X': // Indestructable wall
{
} break;
case 'b':
case 'v':
case 'f':
case 'r':
case 's':
case 'u':
case 'o':
{
if ((m_BE.m_bot.m_pos.x == x) &&(m_BE.m_bot.m_pos.y == y)) {
if (isDeleted){
m_BE.m_bot.addBonus(type);
}}
else{
for(int j = 0; j<m_BE.m_enemies.length-1;++j){
if ((m_BE.m_enemies[j].m_pos.x == x )&&(m_BE.m_enemies[j].m_pos.y == y )) {
pid = j;
break;
}}
if (isDeleted && (pid != 0)){
m_BE.m_enemies[pid].addBonus(type); }}}
break;
default: // Bonuses
{
} break;
}
m_BE.m_map[y][x] = mapMark;
//m_BE.traceMap();
}
}