From 0e26b92e04ecb335335d7e7d5cfd20d83395e5df Mon Sep 17 00:00:00 2001
From: Scoppio
Date: Sun, 17 Nov 2024 08:41:56 -0300
Subject: [PATCH 1/2] feat: creates an interface for post game events, as
necessary to implement the automated auto-resolve
---
.../megamek/client/bot/ui/swing/BotGUI.java | 2 +-
.../client/ui/swing/AbstractPhaseDisplay.java | 2 +-
.../client/ui/swing/AccessibilityWindow.java | 2 +-
.../boardview/BoardViewSpriteHandler.java | 2 +-
.../swing/forceDisplay/ForceDisplayPanel.java | 2 +-
.../megamek/common/event/GameListener.java | 8 ++++----
.../common/event/GameListenerAdapter.java | 8 ++++----
.../common/event/GameVictoryEvent.java | 8 +++++++-
.../common/event/PostGameResolution.java | 19 +++++++++++++++++++
9 files changed, 39 insertions(+), 14 deletions(-)
create mode 100644 megamek/src/megamek/common/event/PostGameResolution.java
diff --git a/megamek/src/megamek/client/bot/ui/swing/BotGUI.java b/megamek/src/megamek/client/bot/ui/swing/BotGUI.java
index 89c273b5471..84ab2208cd8 100644
--- a/megamek/src/megamek/client/bot/ui/swing/BotGUI.java
+++ b/megamek/src/megamek/client/bot/ui/swing/BotGUI.java
@@ -134,7 +134,7 @@ public void gameClientFeedbackRequest(GameCFREvent evt) {
}
@Override
- public void gameVictory(GameVictoryEvent e) {
+ public void gameVictory(PostGameResolution e) {
}
}
diff --git a/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java
index a0a7dfd1798..4239e5a8082 100644
--- a/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java
+++ b/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java
@@ -219,7 +219,7 @@ public void gameNewAction(GameNewActionEvent e) { }
public void gameClientFeedbackRequest(GameCFREvent evt) { }
@Override
- public void gameVictory(GameVictoryEvent e) { }
+ public void gameVictory(PostGameResolution e) { }
//endregion
}
diff --git a/megamek/src/megamek/client/ui/swing/AccessibilityWindow.java b/megamek/src/megamek/client/ui/swing/AccessibilityWindow.java
index 666eb3a5975..8040538ef4c 100644
--- a/megamek/src/megamek/client/ui/swing/AccessibilityWindow.java
+++ b/megamek/src/megamek/client/ui/swing/AccessibilityWindow.java
@@ -266,7 +266,7 @@ public void gameClientFeedbackRequest(GameCFREvent e) {
}
@Override
- public void gameVictory(GameVictoryEvent e) {
+ public void gameVictory(PostGameResolution e) {
systemEvent("Game Victory! (unneeded.)");
}
};
diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardViewSpriteHandler.java b/megamek/src/megamek/client/ui/swing/boardview/BoardViewSpriteHandler.java
index 2f012637793..6418829e8ba 100644
--- a/megamek/src/megamek/client/ui/swing/boardview/BoardViewSpriteHandler.java
+++ b/megamek/src/megamek/client/ui/swing/boardview/BoardViewSpriteHandler.java
@@ -121,6 +121,6 @@ public void gameNewAction(GameNewActionEvent e) { }
public void gameClientFeedbackRequest(GameCFREvent e) { }
@Override
- public void gameVictory(GameVictoryEvent e) { }
+ public void gameVictory(PostGameResolution e) { }
//endregion
}
diff --git a/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayPanel.java b/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayPanel.java
index 023e5a3c212..f14ca359ea4 100644
--- a/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayPanel.java
+++ b/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayPanel.java
@@ -331,7 +331,7 @@ public void gameClientFeedbackRequest(GameCFREvent evt) {
}
@Override
- public void gameVictory(GameVictoryEvent e) {
+ public void gameVictory(PostGameResolution e) {
// noaction default
}
diff --git a/megamek/src/megamek/common/event/GameListener.java b/megamek/src/megamek/common/event/GameListener.java
index cea1067ad0d..cc33f7ba769 100644
--- a/megamek/src/megamek/common/event/GameListener.java
+++ b/megamek/src/megamek/common/event/GameListener.java
@@ -23,7 +23,7 @@
* removed using the removeGameListener
method. When Game is
* changed the appropriate method will be invoked.
*
- *
+ *
* @see GameListenerAdapter
* @see GameEvent
*/
@@ -61,10 +61,10 @@ public interface GameListener extends java.util.EventListener {
void gameEntityChange(GameEntityChangeEvent e);
void gameNewAction(GameNewActionEvent e);
-
+
void gameClientFeedbackRequest(GameCFREvent e);
-
- void gameVictory(GameVictoryEvent e);
+
+ void gameVictory(PostGameResolution e);
default void gameScriptedEvent(GameScriptedEvent event) { }
diff --git a/megamek/src/megamek/common/event/GameListenerAdapter.java b/megamek/src/megamek/common/event/GameListenerAdapter.java
index 3e69b5d6edd..269362c0f00 100644
--- a/megamek/src/megamek/common/event/GameListenerAdapter.java
+++ b/megamek/src/megamek/common/event/GameListenerAdapter.java
@@ -21,7 +21,7 @@
* Classes that wish to deal with GamedEvent
s can extend this
* class and override only the methods which they are interested in.
*
- *
+ *
* @see GameListener
* @see GameEvent
*/
@@ -94,13 +94,13 @@ public void gameEntityChange(GameEntityChangeEvent e) {
@Override
public void gameNewAction(GameNewActionEvent e) {
}
-
+
@Override
public void gameClientFeedbackRequest(GameCFREvent evt) {
}
@Override
- public void gameVictory(GameVictoryEvent e) {
- }
+ public void gameVictory(PostGameResolution e) {
+ }
}
diff --git a/megamek/src/megamek/common/event/GameVictoryEvent.java b/megamek/src/megamek/common/event/GameVictoryEvent.java
index 6d0b98b11b1..7afa4ec0acc 100644
--- a/megamek/src/megamek/common/event/GameVictoryEvent.java
+++ b/megamek/src/megamek/common/event/GameVictoryEvent.java
@@ -29,7 +29,7 @@
* @see Game#end(int, int)
* @see GameListener
*/
-public class GameVictoryEvent extends GameEvent {
+public class GameVictoryEvent extends GameEvent implements PostGameResolution {
private static final long serialVersionUID = -8470655646019563063L;
/**
@@ -73,6 +73,7 @@ public String getEventName() {
/**
* @return an enumeration of all the entities in the game.
*/
+ @Override
public Enumeration getEntities() {
return entities.elements();
}
@@ -80,6 +81,7 @@ public Enumeration getEntities() {
/**
* @return the entity with the given id number, if any.
*/
+ @Override
public Entity getEntity(int id) {
return entityIds.get(id);
}
@@ -88,6 +90,7 @@ public Entity getEntity(int id) {
* @return an enumeration of salvageable entities.
*/
// TODO: Correctly implement "Captured" Entities
+ @Override
public Enumeration getGraveyardEntities() {
Vector graveyard = new Vector<>();
@@ -105,6 +108,7 @@ public Enumeration getGraveyardEntities() {
/**
* @return an enumeration of wrecked entities.
*/
+ @Override
public Enumeration getWreckedEntities() {
Vector wrecks = new Vector<>();
for (Entity entity : vOutOfGame) {
@@ -121,6 +125,7 @@ public Enumeration getWreckedEntities() {
/**
* Returns an enumeration of entities that have retreated
*/
+ @Override
public Enumeration getRetreatedEntities() {
Vector sanctuary = new Vector<>();
@@ -137,6 +142,7 @@ public Enumeration getRetreatedEntities() {
/**
* Returns an enumeration of entities that were utterly destroyed
*/
+ @Override
public Enumeration getDevastatedEntities() {
Vector smithereens = new Vector<>();
diff --git a/megamek/src/megamek/common/event/PostGameResolution.java b/megamek/src/megamek/common/event/PostGameResolution.java
new file mode 100644
index 00000000000..217ebe89b09
--- /dev/null
+++ b/megamek/src/megamek/common/event/PostGameResolution.java
@@ -0,0 +1,19 @@
+package megamek.common.event;
+
+import megamek.common.Entity;
+
+import java.util.Enumeration;
+
+public interface PostGameResolution {
+ Enumeration getEntities();
+
+ Entity getEntity(int id);
+
+ Enumeration getGraveyardEntities();
+
+ Enumeration getWreckedEntities();
+
+ Enumeration getRetreatedEntities();
+
+ Enumeration getDevastatedEntities();
+}
From a88bb8a1fc61935cb0fc8576f08eeba3da146705 Mon Sep 17 00:00:00 2001
From: Scoppio
Date: Sun, 17 Nov 2024 18:15:33 -0300
Subject: [PATCH 2/2] chore: added tmo folder to gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 23314c831c3..8b829940bc7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/tmp/
/.metadata
/.recommenders/
/RemoteSystemsTempFiles/