mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Merge branch 'master' into 'master'
Add Foretold Event See merge request core-developers/forge!5483
This commit is contained in:
@@ -25,6 +25,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import forge.game.event.GameEventCardForetold;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
@@ -2853,6 +2854,7 @@ public class CardFactoryUtil {
|
|||||||
}
|
}
|
||||||
String sb = TextUtil.concatWithSpace(getActivatingPlayer().toString(),"has foretold.");
|
String sb = TextUtil.concatWithSpace(getActivatingPlayer().toString(),"has foretold.");
|
||||||
game.getGameLog().add(GameLogEntryType.STACK_RESOLVE, sb);
|
game.getGameLog().add(GameLogEntryType.STACK_RESOLVE, sb);
|
||||||
|
game.fireEvent(new GameEventCardForetold(getActivatingPlayer()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final StringBuilder sbDesc = new StringBuilder();
|
final StringBuilder sbDesc = new StringBuilder();
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package forge.game.event;
|
||||||
|
|
||||||
|
import forge.game.player.Player;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
|
public class GameEventCardForetold extends GameEvent {
|
||||||
|
public final Player activatingPlayer;
|
||||||
|
|
||||||
|
public GameEventCardForetold(Player player) {
|
||||||
|
activatingPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T visit(IGameEventVisitor<T> visitor) {
|
||||||
|
return visitor.visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return activatingPlayer.getName()+" has foretold.";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,6 +53,7 @@ public interface IGameEventVisitor<T> {
|
|||||||
T visit(GameEventTurnEnded event);
|
T visit(GameEventTurnEnded event);
|
||||||
T visit(GameEventTurnPhase event);
|
T visit(GameEventTurnPhase event);
|
||||||
T visit(GameEventZone event);
|
T visit(GameEventZone event);
|
||||||
|
T visit(GameEventCardForetold gameEventCardForetold);
|
||||||
|
|
||||||
|
|
||||||
// This is base class for all visitors.
|
// This is base class for all visitors.
|
||||||
@@ -105,5 +106,8 @@ public interface IGameEventVisitor<T> {
|
|||||||
public T visit(GameEventTurnPhase event) { return null; }
|
public T visit(GameEventTurnPhase event) { return null; }
|
||||||
public T visit(GameEventPlayerDamaged event) { return null; }
|
public T visit(GameEventPlayerDamaged event) { return null; }
|
||||||
public T visit(GameEventZone event) { return null; }
|
public T visit(GameEventZone event) { return null; }
|
||||||
|
public T visit(GameEventCardForetold gameEventCardForetold) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -353,8 +353,7 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||||
playersWithTargetables.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
playersWithTargetables.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
||||||
final InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
final InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
||||||
ZoneType previousZone = playerPanel.getZoneByInfoTab(playerPanel.getSelectedTab());
|
updates.add(new PlayerZoneUpdate(player, zoneType));
|
||||||
updates.add(new PlayerZoneUpdate(player, previousZone));
|
|
||||||
if (zoneTab != null) {
|
if (zoneTab != null) {
|
||||||
playerPanel.setSelectedTab(zoneTab);
|
playerPanel.setSelectedTab(zoneTab);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package forge.gui.control;
|
package forge.gui.control;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -36,11 +34,12 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
|||||||
private final Set<PlayerView> livesUpdate = new HashSet<>();
|
private final Set<PlayerView> livesUpdate = new HashSet<>();
|
||||||
private final Set<PlayerView> manaPoolUpdate = new HashSet<>();
|
private final Set<PlayerView> manaPoolUpdate = new HashSet<>();
|
||||||
private final PlayerZoneUpdates zonesUpdate = new PlayerZoneUpdates();
|
private final PlayerZoneUpdates zonesUpdate = new PlayerZoneUpdates();
|
||||||
|
private final Map<PlayerView, Object> playersWithValidTargets = Maps.newHashMap();
|
||||||
|
|
||||||
private boolean processEventsQueued, needPhaseUpdate, needCombatUpdate, needStackUpdate, needPlayerControlUpdate, refreshFieldUpdate;
|
private boolean processEventsQueued, needPhaseUpdate, needCombatUpdate, needStackUpdate, needPlayerControlUpdate, refreshFieldUpdate, showExileUpdate;
|
||||||
private boolean gameOver, gameFinished;
|
private boolean gameOver, gameFinished;
|
||||||
private boolean needSaveState = false;
|
private boolean needSaveState = false;
|
||||||
private PlayerView turnUpdate;
|
private PlayerView turnUpdate, activatingPlayer;
|
||||||
|
|
||||||
public FControlGameEventHandler(final PlayerControllerHuman humanController0) {
|
public FControlGameEventHandler(final PlayerControllerHuman humanController0) {
|
||||||
humanController = humanController0;
|
humanController = humanController0;
|
||||||
@@ -112,6 +111,12 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
|||||||
refreshFieldUpdate = false;
|
refreshFieldUpdate = false;
|
||||||
matchController.refreshField();
|
matchController.refreshField();
|
||||||
}
|
}
|
||||||
|
if (showExileUpdate) {
|
||||||
|
showExileUpdate = false;
|
||||||
|
matchController.openZones(activatingPlayer, Collections.singleton(ZoneType.Exile), playersWithValidTargets);
|
||||||
|
activatingPlayer = null;
|
||||||
|
playersWithValidTargets.clear();
|
||||||
|
}
|
||||||
if (gameOver) {
|
if (gameOver) {
|
||||||
gameOver = false;
|
gameOver = false;
|
||||||
humanController.getInputQueue().onGameOver(true); // this will unlock any game threads waiting for inputs to complete
|
humanController.getInputQueue().onGameOver(true); // this will unlock any game threads waiting for inputs to complete
|
||||||
@@ -417,6 +422,14 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
|||||||
return processCards(event.cards, cardsUpdate);
|
return processCards(event.cards, cardsUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visit(final GameEventCardForetold event) {
|
||||||
|
showExileUpdate = true;
|
||||||
|
activatingPlayer = event.activatingPlayer.getView();
|
||||||
|
playersWithValidTargets.put(activatingPlayer, null);
|
||||||
|
return processEvent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(final GameEventPlayerStatsChanged event) {
|
public Void visit(final GameEventPlayerStatsChanged event) {
|
||||||
final CardCollection cards = new CardCollection();
|
final CardCollection cards = new CardCollection();
|
||||||
|
|||||||
Reference in New Issue
Block a user