Skip to content

Commit

Permalink
Merge pull request #6208 from Scoppio/autoresolve
Browse files Browse the repository at this point in the history
Autoresolve support
  • Loading branch information
HammerGS authored Nov 29, 2024
2 parents b4f534e + 23a2d45 commit 2fc1f33
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/tmp/
/.metadata
/.recommenders/
/RemoteSystemsTempFiles/
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/bot/ui/swing/BotGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void gameClientFeedbackRequest(GameCFREvent evt) {
}

@Override
public void gameVictory(GameVictoryEvent e) {
public void gameVictory(PostGameResolution e) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public void gameClientFeedbackRequest(GameCFREvent e) {
}

@Override
public void gameVictory(GameVictoryEvent e) {
public void gameVictory(PostGameResolution e) {
systemEvent("Game Victory! (unneeded.)");
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void gameClientFeedbackRequest(GameCFREvent evt) {
}

@Override
public void gameVictory(GameVictoryEvent e) {
public void gameVictory(PostGameResolution e) {
// noaction default
}

Expand Down
8 changes: 4 additions & 4 deletions megamek/src/megamek/common/event/GameListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* removed using the <code>removeGameListener</code> method. When Game is
* changed the appropriate method will be invoked.
* </p>
*
*
* @see GameListenerAdapter
* @see GameEvent
*/
Expand Down Expand Up @@ -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) { }

Expand Down
8 changes: 4 additions & 4 deletions megamek/src/megamek/common/event/GameListenerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Classes that wish to deal with <code>GamedEvent</code>s can extend this
* class and override only the methods which they are interested in.
* </p>
*
*
* @see GameListener
* @see GameEvent
*/
Expand Down Expand Up @@ -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) {
}

}
8 changes: 7 additions & 1 deletion megamek/src/megamek/common/event/GameVictoryEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -73,13 +73,15 @@ public String getEventName() {
/**
* @return an enumeration of all the entities in the game.
*/
@Override
public Enumeration<Entity> getEntities() {
return entities.elements();
}

/**
* @return the entity with the given id number, if any.
*/
@Override
public Entity getEntity(int id) {
return entityIds.get(id);
}
Expand All @@ -88,6 +90,7 @@ public Entity getEntity(int id) {
* @return an enumeration of salvageable entities.
*/
// TODO: Correctly implement "Captured" Entities
@Override
public Enumeration<Entity> getGraveyardEntities() {
Vector<Entity> graveyard = new Vector<>();

Expand All @@ -105,6 +108,7 @@ public Enumeration<Entity> getGraveyardEntities() {
/**
* @return an enumeration of wrecked entities.
*/
@Override
public Enumeration<Entity> getWreckedEntities() {
Vector<Entity> wrecks = new Vector<>();
for (Entity entity : vOutOfGame) {
Expand All @@ -121,6 +125,7 @@ public Enumeration<Entity> getWreckedEntities() {
/**
* Returns an enumeration of entities that have retreated
*/
@Override
public Enumeration<Entity> getRetreatedEntities() {
Vector<Entity> sanctuary = new Vector<>();

Expand All @@ -137,6 +142,7 @@ public Enumeration<Entity> getRetreatedEntities() {
/**
* Returns an enumeration of entities that were utterly destroyed
*/
@Override
public Enumeration<Entity> getDevastatedEntities() {
Vector<Entity> smithereens = new Vector<>();

Expand Down
19 changes: 19 additions & 0 deletions megamek/src/megamek/common/event/PostGameResolution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package megamek.common.event;

import megamek.common.Entity;

import java.util.Enumeration;

public interface PostGameResolution {
Enumeration<Entity> getEntities();

Entity getEntity(int id);

Enumeration<Entity> getGraveyardEntities();

Enumeration<Entity> getWreckedEntities();

Enumeration<Entity> getRetreatedEntities();

Enumeration<Entity> getDevastatedEntities();
}

0 comments on commit 2fc1f33

Please sign in to comment.