Skip to content

Commit 2ef7d89

Browse files
tool4EvErtool4EvEr
authored andcommitted
Clean up
1 parent 278d72f commit 2ef7d89

File tree

3 files changed

+17
-36
lines changed

3 files changed

+17
-36
lines changed

forge-game/src/main/java/forge/game/GameAction.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,14 +738,24 @@ private void handleStaticEffect(Card copied, SpellAbility cause) {
738738
}
739739
}
740740

741-
Integer timestamp = cause.getSVarInt("StaticEffectTimestamp");
742-
String name = "Static Effect #" + timestamp;
741+
Long timestamp;
742+
// check if player ordered it manually
743+
if (cause.hasSVar("StaticEffectTimestamp")) {
744+
timestamp = Long.parseLong(cause.getSVar("StaticEffectTimestamp"));
745+
} else {
746+
// else create default value (or realign)
747+
timestamp = game.getNextTimestamp();
748+
cause.setSVar("StaticEffectTimestamp", String.valueOf(timestamp));
749+
}
750+
String name = "Static Effect #" + source.getGameTimestamp();
743751
// check if this isn't the first card being moved
744752
Optional<Card> opt = IterableUtil.tryFind(cause.getActivatingPlayer().getZone(ZoneType.Command).getCards(), CardPredicates.nameEquals(name));
745753

746754
Card eff;
747755
if (opt.isPresent()) {
748756
eff = opt.get();
757+
// update in case player manually ordered
758+
eff.setLayerTimestamp(timestamp);
749759
} else {
750760
// otherwise create effect first
751761
eff = SpellAbilityEffect.createEffect(cause, cause.getActivatingPlayer(), name, source.getImageKey(), timestamp);

forge-game/src/main/java/forge/game/GameActionUtil.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,9 @@ public static CardCollectionView orderCardsByTheirOwners(Game game, CardCollecti
857857
subList.add(c);
858858
}
859859
}
860-
if (sa.getActivatingPlayer() == p && sa.hasParam("StaticEffect")) {
861-
String name = "Static Effect of " + sa.getHostCard();
860+
if (sa != null && sa.getActivatingPlayer() == p && sa.hasParam("StaticEffect")) {
862861
// create helper card for ordering
863-
eff = new DetachedCardEffect(sa.getHostCard(), name);
862+
eff = new DetachedCardEffect(sa.getHostCard(), "Static Effect of " + sa.getHostCard());
864863
subList.add(eff);
865864
}
866865
CardCollectionView subListView = subList;
@@ -874,8 +873,8 @@ public static CardCollectionView orderCardsByTheirOwners(Game game, CardCollecti
874873
// add generous buffer to timestamp, to ensure it applies last compared to cards that were ordered to ETB before it
875874
sa.setSVar("StaticEffectTimestamp", String.valueOf(game.getTimestamp() + idx + 100));
876875
// effects with this param have the responsibility to realign it when later cards are reached
877-
if (idx < completeList.size() - 1) {
878-
sa.setSVar("StaticEffectUntilCardID", String.valueOf(completeList.get(idx + 1).getId()));
876+
if (idx > 0) {
877+
sa.setSVar("StaticEffectUntilCardID", String.valueOf(completeList.get(idx - 1).getId()));
879878
}
880879
completeList.remove(eff);
881880
}

forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,9 @@ private void changeKnownOriginResolve(final SpellAbility sa) {
529529
}
530530
}
531531

532-
// if the player didn't order the effect above use default
533-
if (sa.hasParam("StaticEffect") && !sa.hasSVar("StaticEffectTimestamp")) {
534-
sa.setSVar("StaticEffectTimestamp", String.valueOf(game.getNextTimestamp()));
535-
}
536-
537532
for (final Card tgtC : tgtCards) {
538533
if (sa.hasSVar("StaticEffectUntilCardID") && sa.getSVarInt("StaticEffectUntilCardID") == tgtC.getId()) {
539-
sa.setSVar("StaticEffectTimestamp", String.valueOf(game.getNextTimestamp()));
534+
sa.removeSVar("StaticEffectTimestamp");
540535
}
541536

542537
final Card gameCard = game.getCardState(tgtC, null);
@@ -661,19 +656,6 @@ private void changeKnownOriginResolve(final SpellAbility sa) {
661656
}
662657
}
663658

664-
if (sa.hasAdditionalAbility("AnimateSubAbility")) {
665-
// need LKI before Animate does apply
666-
if (!moveParams.containsKey(AbilityKey.CardLKI)) {
667-
moveParams.put(AbilityKey.CardLKI, CardCopyService.getLKICopy(gameCard));
668-
}
669-
670-
final SpellAbility animate = sa.getAdditionalAbility("AnimateSubAbility");
671-
hostCard.addRemembered(gameCard);
672-
AbilityUtils.resolve(animate);
673-
hostCard.removeRemembered(gameCard);
674-
animate.setSVar("unanimateTimestamp", String.valueOf(game.getTimestamp()));
675-
}
676-
677659
// need to be facedown before it hits the battlefield in case of Replacement Effects or Trigger
678660
if (sa.hasParam("FaceDown")) {
679661
gameCard.turnFaceDown(true);
@@ -1286,16 +1268,6 @@ else if (destination.equals(ZoneType.Battlefield)) {
12861268
if (sa.hasParam("Tapped")) {
12871269
c.setTapped(true);
12881270
}
1289-
if (sa.hasAdditionalAbility("AnimateSubAbility")) {
1290-
// need LKI before Animate does apply
1291-
moveParams.put(AbilityKey.CardLKI, CardCopyService.getLKICopy(c));
1292-
1293-
final SpellAbility animate = sa.getAdditionalAbility("AnimateSubAbility");
1294-
source.addRemembered(c);
1295-
AbilityUtils.resolve(animate);
1296-
source.removeRemembered(c);
1297-
animate.setSVar("unanimateTimestamp", String.valueOf(game.getTimestamp()));
1298-
}
12991271
if (sa.hasParam("GainControl")) {
13001272
final String g = sa.getParam("GainControl");
13011273
Player newController = g.equals("True") ? sa.getActivatingPlayer() :

0 commit comments

Comments
 (0)