mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
set up trackable ControlOppSearchLib
This commit is contained in:
@@ -949,6 +949,19 @@ public class Game {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Player getControlOppSearchLib() {
|
||||
Player result = null;
|
||||
long maxValue = 0;
|
||||
for (Player p : getPlayers()) {
|
||||
Long v = p.getHighestControlOppSearchLib();
|
||||
if (v != null && v > maxValue) {
|
||||
maxValue = v;
|
||||
result = p;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void onCleanupPhase() {
|
||||
clearCounterAddedThisTurn();
|
||||
for (Player player : getPlayers()) {
|
||||
|
||||
@@ -797,6 +797,8 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
private static void changeZonePlayerInvariant(Player decider, SpellAbility sa, Player player) {
|
||||
final Game game = player.getGame();
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
final List<Player> players = Lists.newArrayList(sa.getTargets().getTargetPlayers());
|
||||
player = sa.hasParam("DefinedPlayer") ? player : players.get(0);
|
||||
@@ -872,20 +874,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
|
||||
CardCollection fetchList;
|
||||
Player originalDecider = decider;
|
||||
Player deciderControl = null;
|
||||
PlayerCollection opps = decider.getOpponents();
|
||||
long dcts = 0;
|
||||
for (Player o : opps) {
|
||||
for (String k : o.getKeywords()) {
|
||||
if (k.equals("You control your opponents while they're searching their libraries.")) {
|
||||
long ts = o.getKeywordCard().getTimestamp();
|
||||
if (deciderControl == null || ts > (dcts)) {
|
||||
deciderControl = o;
|
||||
dcts = ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Player deciderControl = game.getControlOppSearchLib();
|
||||
boolean shuffleMandatory = true;
|
||||
boolean searchedLibrary = false;
|
||||
if (defined) {
|
||||
@@ -978,7 +967,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
shuffleMandatory = false;
|
||||
}
|
||||
|
||||
final Game game = player.getGame();
|
||||
if (sa.hasParam("Unimprint")) {
|
||||
source.clearImprintedCards();
|
||||
}
|
||||
|
||||
@@ -165,6 +165,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
private Map<Long, Integer> additionalOptionalVotes = Maps.newHashMap();
|
||||
private SortedSet<Long> controlVotes = Sets.newTreeSet();
|
||||
|
||||
private SortedSet<Long> controlOppSearchLib = Sets.newTreeSet();
|
||||
|
||||
private final AchievementTracker achievementTracker = new AchievementTracker();
|
||||
private final PlayerView view;
|
||||
|
||||
@@ -3412,6 +3414,33 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return controlVotes.last();
|
||||
}
|
||||
|
||||
public boolean addControlOppSearchLib(long timestamp) {
|
||||
if (controlOppSearchLib.add(timestamp)) {
|
||||
updateControlOppSearchLib();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void updateControlOppSearchLib() { // needs to update all players
|
||||
Player control = getGame().getControlOppSearchLib();
|
||||
for (Player pl : getGame().getPlayers()) {
|
||||
pl.getView().updateControlOppSearchLib(pl.equals(control));
|
||||
getGame().fireEvent(new GameEventPlayerStatsChanged(pl, false));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Long> getControlOppSearchLib() {
|
||||
return controlOppSearchLib;
|
||||
}
|
||||
|
||||
public Long getHighestControlOppSearchLib() {
|
||||
if (controlOppSearchLib.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return controlOppSearchLib.last();
|
||||
}
|
||||
|
||||
public void addCycled(SpellAbility sp) {
|
||||
cycledThisTurn++;
|
||||
|
||||
|
||||
@@ -296,6 +296,9 @@ public class PlayerView extends GameEntityView {
|
||||
set(TrackableProperty.ControlVotes, val);
|
||||
}
|
||||
|
||||
public boolean getControlOppSearchLib() { return get(TrackableProperty.ControlOppSearchLib); }
|
||||
public void updateControlOppSearchLib(boolean val) { set(TrackableProperty.ControlOppSearchLib, val); }
|
||||
|
||||
public ImmutableMultiset<String> getKeywords() {
|
||||
return get(TrackableProperty.Keywords);
|
||||
}
|
||||
|
||||
@@ -552,6 +552,12 @@ public final class StaticAbilityContinuous {
|
||||
p.addMaxLandPlays(se.getTimestamp(), add);
|
||||
}
|
||||
}
|
||||
if (params.containsKey("ControlOpponentsWhile")) {
|
||||
String cow = params.get("ControlOpponentsWhile");
|
||||
if (cow.equals("SearchingLibrary")) {
|
||||
p.addControlOppSearchLib(se.getTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ControlVote")) {
|
||||
p.addControlVote(se.getTimestamp());
|
||||
|
||||
@@ -149,6 +149,7 @@ public enum TrackableProperty {
|
||||
AdditionalVote(TrackableTypes.IntegerType),
|
||||
OptionalAdditionalVote(TrackableTypes.IntegerType),
|
||||
ControlVotes(TrackableTypes.BooleanType),
|
||||
ControlOppSearchLib(TrackableTypes.BooleanType),
|
||||
Keywords(TrackableTypes.KeywordCollectionViewType, FreezeMode.IgnoresFreeze),
|
||||
Commander(TrackableTypes.CardViewCollectionType, FreezeMode.IgnoresFreeze),
|
||||
CommanderCast(TrackableTypes.IntegerMapType),
|
||||
|
||||
@@ -3,7 +3,7 @@ ManaCost:2 B
|
||||
Types:Creature Human Rogue
|
||||
PT:3/2
|
||||
K:Flash
|
||||
S:Mode$ Continuous | Affected$ You | AddKeyword$ You control your opponents while they're searching their libraries. | Description$ You control your opponents while they're searching their libraries.
|
||||
S:Mode$ Continuous | Affected$ You | ControlOpponentsWhile$ SearchingLibrary | Description$ You control your opponents while they're searching their libraries.
|
||||
R:Event$ Moved | ValidCard$ Card.OppOwn | FoundSearchingLibrary$ True | Origin$ Library | ReplaceWith$ RepExile | ActiveZones$ Battlefield | Description$ While an opponent is searching their library, they exile each card they find. You may play those cards for as long as they remain exiled, and you may spend mana as though it were mana of any color to cast them.
|
||||
SVar:RepExile:DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Exile | Defined$ ReplacedCard | SubAbility$ DBEffect
|
||||
SVar:DBEffect:DB$ Effect | Duration$ Permanent | StaticAbilities$ MayPlay | RememberObjects$ ReplacedCard | ForgetOnMoved$ Exile
|
||||
|
||||
Reference in New Issue
Block a user