mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Match: add extra Event Loop to Match for Events when the Game is closed
This commit is contained in:
@@ -126,6 +126,8 @@ public class HostedMatch {
|
||||
title = TextUtil.concatNoSpace("Multiplayer Game (", String.valueOf(sortedPlayers.size()), " players)");
|
||||
}
|
||||
this.match = new Match(gameRules, sortedPlayers, title);
|
||||
this.match.subscribeToEvents(SoundSystem.instance);
|
||||
this.match.subscribeToEvents(visitor);
|
||||
startGame();
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
combat.addAttacker(card, currentDefender, activeBand);
|
||||
activateBand(activeBand);
|
||||
|
||||
card.getGame().fireEvent(new UiEventAttackerDeclared(
|
||||
card.getGame().getMatch().fireEvent(new UiEventAttackerDeclared(
|
||||
CardView.get(card),
|
||||
GameEntityView.get(currentDefender)));
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
// When removing an attacker clear the attacking band
|
||||
activateBand(null);
|
||||
|
||||
card.getGame().fireEvent(new UiEventAttackerDeclared(
|
||||
card.getGame().getMatch().fireEvent(new UiEventAttackerDeclared(
|
||||
CardView.get(card), null));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class InputBlock extends InputSyncronizedBase {
|
||||
boolean isCorrectAction = false;
|
||||
if (triggerEvent != null && triggerEvent.getButton() == 3 && card.getController() == defender) {
|
||||
combat.removeFromCombat(card);
|
||||
card.getGame().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
|
||||
card.getGame().getMatch().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
|
||||
isCorrectAction = true;
|
||||
}
|
||||
else {
|
||||
@@ -137,14 +137,14 @@ public class InputBlock extends InputSyncronizedBase {
|
||||
if (combat.isBlocking(card, currentAttacker)) {
|
||||
//if creature already blocking current attacker, remove blocker from combat
|
||||
combat.removeBlockAssignment(currentAttacker, card);
|
||||
card.getGame().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
|
||||
card.getGame().getMatch().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
|
||||
isCorrectAction = true;
|
||||
}
|
||||
else {
|
||||
isCorrectAction = CombatUtil.canBlock(currentAttacker, card, combat);
|
||||
if (isCorrectAction) {
|
||||
combat.addBlocker(currentAttacker, card);
|
||||
card.getGame().fireEvent(new UiEventBlockerAssigned(
|
||||
card.getGame().getMatch().fireEvent(new UiEventBlockerAssigned(
|
||||
CardView.get(card),
|
||||
CardView.get(currentAttacker)));
|
||||
}
|
||||
|
||||
@@ -2936,11 +2936,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
|
||||
@Override
|
||||
public void nextGameDecision(final NextGameDecision decision) {
|
||||
Game game = getGame();
|
||||
// in case the game ended before the button is pressed, then match doesn't remember the game anymore
|
||||
if (game != null) {
|
||||
game.fireEvent(new UiEventNextGameDecision(this, decision));
|
||||
}
|
||||
gameView.getMatch().fireEvent(new UiEventNextGameDecision(this, decision));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user