|
2 | 2 |
|
3 | 3 | import java.util.HashMap;
|
4 | 4 | import java.util.Map;
|
| 5 | +import java.util.Map.Entry; |
5 | 6 |
|
6 | 7 | import com.codingame.gameengine.core.AbstractPlayer;
|
7 | 8 | import com.codingame.gameengine.core.GameManager;
|
@@ -67,26 +68,32 @@ public void onAfterGameTurn() {
|
67 | 68 | }
|
68 | 69 |
|
69 | 70 | @Override
|
70 |
| - public void onAfterOnEnd() {} |
| 71 | + public void onAfterOnEnd() { |
| 72 | + } |
71 | 73 |
|
72 | 74 | private void sendFrameData() {
|
73 |
| - HashMap<String, String> data = new HashMap<>(); |
74 |
| - for (int d : newRegistration.keySet()) { |
75 |
| - String key = newRegistration.get(d).name; |
76 |
| - if (!data.containsKey(key)) data.put(key, ""); |
77 |
| - data.put(key, data.get(key) + d + (newRegistration.get(d).state ? "+" : "-")); |
| 75 | + Map<String, String> data = new HashMap<>(); |
| 76 | + for (Entry<Integer, Toggle> e : newRegistration.entrySet()) { |
| 77 | + String key = e.getValue().name; |
| 78 | + int id = e.getKey(); |
| 79 | + data.put(key, data.getOrDefault(key, "") + id + (newRegistration.get(id).state ? "+" : "-")); |
78 | 80 | }
|
79 |
| - if (newRegistration.size() > 0) |
| 81 | + if (newRegistration.size() > 0) { |
80 | 82 | gameManager.setViewData("toggles", data);
|
| 83 | + } |
81 | 84 |
|
82 | 85 | newRegistration.clear();
|
83 | 86 | }
|
| 87 | + |
84 | 88 | /**
|
85 | 89 | * Will display the entity only when the toggle state matches the state you set
|
86 | 90 | *
|
87 |
| - * @param entity which will be displayed |
88 |
| - * @param toggle the name of the toggle you want to use |
89 |
| - * @param state the state of the toggle where the entity will be displayed at |
| 91 | + * @param entity |
| 92 | + * which will be displayed |
| 93 | + * @param toggle |
| 94 | + * the name of the toggle you want to use |
| 95 | + * @param state |
| 96 | + * the state of the toggle where the entity will be displayed at |
90 | 97 | */
|
91 | 98 | public void displayOnToggleState(Entity<?> entity, String toggle, boolean state) {
|
92 | 99 | int id = entity.getId();
|
|
0 commit comments