mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 17:58:01 +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.Set;
|
||||
|
||||
import forge.game.event.GameEventCardForetold;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -2853,6 +2854,7 @@ public class CardFactoryUtil {
|
||||
}
|
||||
String sb = TextUtil.concatWithSpace(getActivatingPlayer().toString(),"has foretold.");
|
||||
game.getGameLog().add(GameLogEntryType.STACK_RESOLVE, sb);
|
||||
game.fireEvent(new GameEventCardForetold(getActivatingPlayer()));
|
||||
}
|
||||
};
|
||||
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(GameEventTurnPhase event);
|
||||
T visit(GameEventZone event);
|
||||
T visit(GameEventCardForetold gameEventCardForetold);
|
||||
|
||||
|
||||
// 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(GameEventPlayerDamaged 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);
|
||||
playersWithTargetables.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
||||
final InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
||||
ZoneType previousZone = playerPanel.getZoneByInfoTab(playerPanel.getSelectedTab());
|
||||
updates.add(new PlayerZoneUpdate(player, previousZone));
|
||||
updates.add(new PlayerZoneUpdate(player, zoneType));
|
||||
if (zoneTab != null) {
|
||||
playerPanel.setSelectedTab(zoneTab);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package forge.gui.control;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
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> manaPoolUpdate = new HashSet<>();
|
||||
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 needSaveState = false;
|
||||
private PlayerView turnUpdate;
|
||||
private PlayerView turnUpdate, activatingPlayer;
|
||||
|
||||
public FControlGameEventHandler(final PlayerControllerHuman humanController0) {
|
||||
humanController = humanController0;
|
||||
@@ -112,6 +111,12 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
refreshFieldUpdate = false;
|
||||
matchController.refreshField();
|
||||
}
|
||||
if (showExileUpdate) {
|
||||
showExileUpdate = false;
|
||||
matchController.openZones(activatingPlayer, Collections.singleton(ZoneType.Exile), playersWithValidTargets);
|
||||
activatingPlayer = null;
|
||||
playersWithValidTargets.clear();
|
||||
}
|
||||
if (gameOver) {
|
||||
gameOver = false;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(final GameEventCardForetold event) {
|
||||
showExileUpdate = true;
|
||||
activatingPlayer = event.activatingPlayer.getView();
|
||||
playersWithValidTargets.put(activatingPlayer, null);
|
||||
return processEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(final GameEventPlayerStatsChanged event) {
|
||||
final CardCollection cards = new CardCollection();
|
||||
|
||||
Reference in New Issue
Block a user