mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Merge pull request #2865 from Card-Forge/counterAddedFirstTime
CounterAddedOnce add FirstTime
This commit is contained in:
@@ -1132,6 +1132,20 @@ public class Game {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public int getCounterAddedThisTurn(CounterType cType, Card card) {
|
||||
int result = 0;
|
||||
if (!countersAddedThisTurn.containsRow(cType)) {
|
||||
return result;
|
||||
}
|
||||
for (List<Pair<Card, Integer>> l : countersAddedThisTurn.row(cType).values()) {
|
||||
for (Pair<Card, Integer> p : l) {
|
||||
if (p.getKey().equalsWithTimestamp(card)) {
|
||||
result += p.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clearCounterAddedThisTurn() {
|
||||
countersAddedThisTurn.clear();
|
||||
|
||||
@@ -505,7 +505,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
|
||||
final boolean optional = sa.hasParam("Optional");
|
||||
final boolean shuffle = sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle"));
|
||||
final long ts = game.getNextTimestamp();
|
||||
boolean combatChanged = false;
|
||||
|
||||
Player chooser = player;
|
||||
@@ -703,13 +702,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
combatChanged = true;
|
||||
}
|
||||
|
||||
movedCard.setTimestamp(ts);
|
||||
if (movedCard.isInPlay()) {
|
||||
// need to also update LKI
|
||||
List<Card> lki = movedCard.getZone().getCardsAddedThisTurn(null);
|
||||
lki.get(lki.lastIndexOf(movedCard)).setTimestamp(ts);
|
||||
}
|
||||
|
||||
if (sa.hasParam("AttachAfter") && movedCard.isAttachment()) {
|
||||
CardCollection list = AbilityUtils.getDefinedCards(hostCard, sa.getParam("AttachAfter"), sa);
|
||||
if (list.isEmpty()) {
|
||||
@@ -1284,7 +1276,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
List<ZoneType> origin = HiddenOriginChoicesMap.get(player).origin;
|
||||
ZoneType destination = HiddenOriginChoicesMap.get(player).destination;
|
||||
CardCollection movedCards = new CardCollection();
|
||||
long ts = game.getNextTimestamp();
|
||||
Player decider = ObjectUtils.firstNonNull(chooser, player);
|
||||
|
||||
for (final Card c : chosenCards) {
|
||||
@@ -1391,13 +1382,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
movedCard = game.getAction().moveToPlay(c, c.getController(), sa, moveParams);
|
||||
|
||||
movedCard.setTimestamp(ts);
|
||||
if (movedCard.isInPlay()) {
|
||||
// need to also update LKI
|
||||
List<Card> lki = movedCard.getZone().getCardsAddedThisTurn(null);
|
||||
lki.get(lki.lastIndexOf(movedCard)).setTimestamp(ts);
|
||||
}
|
||||
|
||||
if (sa.hasParam("AttachAfter") && movedCard.isAttachment() && movedCard.isInPlay()) {
|
||||
CardCollection list = AbilityUtils.getDefinedCards(source, sa.getParam("AttachAfter"), sa);
|
||||
if (list.isEmpty()) {
|
||||
|
||||
@@ -1447,6 +1447,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
final int toughnessBonusBefore = getToughnessBonusFromCounters();
|
||||
final int loyaltyBefore = getCurrentLoyalty();
|
||||
|
||||
int addedThisTurn = getGame().getCounterAddedThisTurn(counterType, this);
|
||||
setCounters(counterType, newValue);
|
||||
getGame().addCounterAddedThisTurn(source, counterType, this, addAmount);
|
||||
view.updateCounters(this);
|
||||
@@ -1473,6 +1474,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
if (addAmount > 0) {
|
||||
runParams.put(AbilityKey.CounterAmount, addAmount);
|
||||
runParams.put(AbilityKey.FirstTime, addedThisTurn == 0);
|
||||
getGame().getTriggerHandler().runTrigger(
|
||||
TriggerType.CounterAddedOnce, AbilityKey.newMap(runParams), false);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,12 @@ public class TriggerCounterAddedOnce extends Trigger {
|
||||
* @param runParams*/
|
||||
@Override
|
||||
public final boolean performTest(final Map<AbilityKey, Object> runParams) {
|
||||
if (hasParam("FirstTime")) {
|
||||
if (!(boolean) runParams.get(AbilityKey.FirstTime)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasParam("CounterType")) {
|
||||
final CounterType addedType = (CounterType) runParams.get(AbilityKey.CounterType);
|
||||
final String type = getParam("CounterType");
|
||||
|
||||
8
forge-gui/res/cardsfolder/upcoming/axgard_artisan.txt
Normal file
8
forge-gui/res/cardsfolder/upcoming/axgard_artisan.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
Name:Axgard Artisan
|
||||
ManaCost:1 R
|
||||
Types:Creature Dwarf Artificer
|
||||
PT:2/1
|
||||
T:Mode$ CounterAddedOnce | ValidCard$ Card.Self | TriggerZones$ Battlefield | CounterType$ P1P1 | FirstTime$ True | Execute$ TrigToken | TriggerDescription$ Whenever one or more +1/+1 counters are put on CARDNAME for the first time each turn, create a Treasure token. (it’s an artifact with “{T}, Sacrifice this artifact: Add one mana of any color.”)
|
||||
SVar:TrigToken:DB$ Token | TokenAmount$ 1 | TokenScript$ c_a_treasure_sac | TokenOwner$ You
|
||||
DeckHints:Ability$Counters
|
||||
Oracle:Whenever one or more +1/+1 counters are put on Axgard Artisan for the first time each turn, create a Treasure token. (it’s an artifact with “{T}, Sacrifice this artifact: Add one mana of any color.”)
|
||||
11
forge-gui/res/cardsfolder/upcoming/botanical_brawler.txt
Normal file
11
forge-gui/res/cardsfolder/upcoming/botanical_brawler.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
Name:Botanical Brawler
|
||||
ManaCost:G W
|
||||
Types:Creature Elemental Warrior
|
||||
PT:0/0
|
||||
K:Trample
|
||||
K:etbCounter:P1P1:2
|
||||
T:Mode$ CounterAddedOnce | ValidCard$ Card.Other+YouCtrl+inZoneBattlefield | TriggerZones$ Battlefield | CounterType$ P1P1 | FirstTime$ True | Execute$ TrigPutCounter | TriggerDescription$ Whenever one or more +1/+1 counters are put on another permanent you control, if it’s the first time +1/+1 counters have been put on that permanent this turn, put a +1/+1 counter on CARDNAME.
|
||||
SVar:TrigPutCounter:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 1
|
||||
DeckHas:Ability$Counters
|
||||
DeckHints:Ability$Counters
|
||||
Oracle:Trample\nBotanical Brawler enters the battlefield with two +1/+1 counters on it.\nWhenever one or more +1/+1 counters are put on another permanent you control, if it’s the first time +1/+1 counters have been put on that permanent this turn, put a +1/+1 counter on Botanical Brawler.
|
||||
Reference in New Issue
Block a user