Merge pull request #3550 from Northmoc/triggervote

TriggerVote improve with new cards
This commit is contained in:
kevlahnota
2023-07-30 18:40:02 +08:00
committed by GitHub
17 changed files with 86 additions and 34 deletions

View File

@@ -96,8 +96,9 @@ public enum AbilityKey {
Number("Number"), Number("Number"),
Object("Object"), Object("Object"),
Objects("Objects"), Objects("Objects"),
OpponentVotedDiff("OpponentVotedDiff"),
OpponentVotedSame("OpponentVotedSame"),
OtherAttackers("OtherAttackers"), OtherAttackers("OtherAttackers"),
OtherVoters("OtherVoters"),
Origin("Origin"), Origin("Origin"),
OriginalController("OriginalController"), OriginalController("OriginalController"),
OriginalDefender("OriginalDefender"), OriginalDefender("OriginalDefender"),

View File

@@ -6,6 +6,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import forge.game.event.GameEventRandomLog;
import forge.util.Lang; import forge.util.Lang;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -57,7 +58,7 @@ public class VoteEffect extends SpellAbilityEffect {
final Game game = host.getGame(); final Game game = host.getGame();
final Player activator = sa.getActivatingPlayer(); final Player activator = sa.getActivatingPlayer();
final boolean secret = sa.hasParam("Secret"); final boolean secret = sa.hasParam("Secret");
final StringBuilder secretSB = new StringBuilder(); final StringBuilder record = new StringBuilder();
if (sa.hasParam("VoteType")) { if (sa.hasParam("VoteType")) {
voteType.addAll(Arrays.asList(sa.getParam("VoteType").split(","))); voteType.addAll(Arrays.asList(sa.getParam("VoteType").split(",")));
@@ -97,18 +98,20 @@ public class VoteEffect extends SpellAbilityEffect {
if (!secret) { if (!secret) {
game.getAction().notifyOfValue(sa, p, result + "\r\n" + game.getAction().notifyOfValue(sa, p, result + "\r\n" +
Localizer.getInstance().getMessage("lblCurrentVote") + ":" + votes, p); Localizer.getInstance().getMessage("lblCurrentVote") + ":" + votes, p);
} else {
if (secretSB.length() > 0) {
secretSB.append("\r\n");
}
secretSB.append(p).append(" ").append(Localizer.getInstance().getMessage("lblVotedFor", result));
} }
if (record.length() > 0) {
record.append("\r\n");
}
record.append(p).append(" ").append(Localizer.getInstance().getMessage("lblVotedFor", result));
} }
} }
final String voteResult = record.toString();
if (secret) { if (secret) {
game.getAction().notifyOfValue(sa, host, secretSB.toString(), null); game.getAction().notifyOfValue(sa, host, voteResult, null);
} }
game.fireEvent(new GameEventRandomLog(voteResult));
final Map<AbilityKey, Object> runParams = AbilityKey.newMap(); final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.AllVotes, votes); runParams.put(AbilityKey.AllVotes, votes);

View File

@@ -31,11 +31,11 @@ import forge.util.collect.FCollection;
/** /**
* <p> * <p>
* Trigger_Untaps class. * Trigger_Vote class.
* </p> * </p>
* *
* @author Forge * @author Forge
* @version $Id: TriggerUntaps.java 24769 2014-02-09 13:56:04Z Hellfish $ * @version $Id: TriggerVote.java 24769 2014-02-09 13:56:04Z Hellfish $
*/ */
public class TriggerVote extends Trigger { public class TriggerVote extends Trigger {
@@ -66,25 +66,47 @@ public class TriggerVote extends Trigger {
@Override @Override
public final void setTriggeringObjects(final SpellAbility sa, Map<AbilityKey, Object> runParams) { public final void setTriggeringObjects(final SpellAbility sa, Map<AbilityKey, Object> runParams) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
FCollection<Player> voters = getVoters( FCollection<Player> oppVotedDiff = getVoters(
this.getHostCard().getController(), this.getHostCard().getController(),
(ListMultimap<Object, Player>) runParams.get(AbilityKey.AllVotes), (ListMultimap<Object, Player>) runParams.get(AbilityKey.AllVotes),
true, true, true
true
); );
sa.setTriggeringObject(AbilityKey.OtherVoters, voters); sa.setTriggeringObject(AbilityKey.OpponentVotedDiff, oppVotedDiff);
FCollection<Player> oppVotedSame = getVoters(
this.getHostCard().getController(),
(ListMultimap<Object, Player>) runParams.get(AbilityKey.AllVotes),
true, false
);
sa.setTriggeringObject(AbilityKey.OpponentVotedSame, oppVotedSame);
} }
@Override @Override
public String getImportantStackObjects(SpellAbility sa) { public String getImportantStackObjects(SpellAbility sa) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(Localizer.getInstance().getMessage("lblVoters")).append(": ").append(sa.getTriggeringObject(AbilityKey.OtherVoters)); if (hasParam("List")) {
final String l = getParam("List");
if (l.contains("OppVotedSame")) {
final String ovs = sa.getTriggeringObject(AbilityKey.OpponentVotedSame).toString();
sb.append(Localizer.getInstance().getMessage("lblOppVotedSame")).append(": ");
sb.append(!ovs.equals("[]") ? ovs.substring(1, ovs.length() - 1)
: Localizer.getInstance().getMessage("lblNone"));
}
if (l.contains("OppVotedDiff")) {
if (sb.length() > 0) {
sb.append("] [");
}
final String ovd = sa.getTriggeringObject(AbilityKey.OpponentVotedDiff).toString();
sb.append(Localizer.getInstance().getMessage("lblOppVotedDiff")).append(": ");
sb.append(!ovd.equals("[]") ? ovd.substring(1, ovd.length() - 1)
: Localizer.getInstance().getMessage("lblNone"));
}
}
return sb.toString(); return sb.toString();
} }
private static FCollection<Player> getVoters(final Player player, private static FCollection<Player> getVoters (final Player player, final ListMultimap<Object, Player> votes,
final ListMultimap<Object, Player> votes, final boolean isOpponent, final boolean votedOtherchoice) {
final boolean isOpponent, final boolean votedOtherchoice) {
final FCollection<Player> voters = new FCollection<>(); final FCollection<Player> voters = new FCollection<>();
for (final Object voteType : votes.keySet()) { for (final Object voteType : votes.keySet()) {
final List<Player> players = votes.get(voteType); final List<Player> players = votes.get(voteType);

View File

@@ -1,7 +1,7 @@
Name:Capital Punishment Name:Capital Punishment
ManaCost:4 B B ManaCost:4 B B
Types:Sorcery Types:Sorcery
A:SP$ Vote | Cost$ 4 B B | Defined$ Player | StoreVoteNum$ True | VoteType$ Death,Taxes | SubAbility$ DBVoteDeath | AILogic$ DeathOrTaxes | SpellDescription$ Council's dilemma — Starting with you, each player votes for death or taxes. Each opponent sacrifices a creature for each death vote and discards a card for each taxes vote. A:SP$ Vote | Defined$ Player | StoreVoteNum$ True | VoteType$ Death,Taxes | SubAbility$ DBVoteDeath | AILogic$ DeathOrTaxes | StackDescription$ SpellDescription | SpellDescription$ Council's dilemma — Starting with you, each player votes for death or taxes.
SVar:DBVoteDeath:DB$ Sacrifice | Defined$ Player.Opponent | SacValid$ Creature | SacMessage$ Creature | Amount$ VoteNumDeath | SubAbility$ DBVoteTaxes SVar:DBVoteDeath:DB$ Sacrifice | Defined$ Opponent | SacValid$ Creature | SacMessage$ Creature | Amount$ VoteNumDeath | SubAbility$ DBVoteTaxes | StackDescription$ SpellDescription | SpellDescription$ Each opponent sacrifices a creature for each death vote and discards a card for each taxes vote.
SVar:DBVoteTaxes:DB$ Discard | Defined$ Player.Opponent | NumCards$ VoteNumTaxes | Mode$ TgtChoose SVar:DBVoteTaxes:DB$ Discard | Defined$ Opponent | NumCards$ VoteNumTaxes | Mode$ TgtChoose | StackDescription$ None
Oracle:Council's dilemma — Starting with you, each player votes for death or taxes. Each opponent sacrifices a creature for each death vote and discards a card for each taxes vote. Oracle:Council's dilemma — Starting with you, each player votes for death or taxes. Each opponent sacrifices a creature for each death vote and discards a card for each taxes vote.

View File

@@ -2,6 +2,6 @@ Name:Grudge Keeper
ManaCost:1 B ManaCost:1 B
Types:Creature Zombie Wizard Types:Creature Zombie Wizard
PT:2/1 PT:2/1
T:Mode$ Vote | TriggerZones$ Battlefield | Execute$ TrigLoseLife | TriggerDescription$ Whenever players finish voting, each opponent who voted for a choice you didn't vote for loses 2 life. T:Mode$ Vote | TriggerZones$ Battlefield | Execute$ TrigLoseLife | List$ OppVotedDiff | TriggerDescription$ Whenever players finish voting, each opponent who voted for a choice you didn't vote for loses 2 life.
SVar:TrigLoseLife:DB$ LoseLife | Defined$ TriggeredOtherVoters | LifeAmount$ 2 SVar:TrigLoseLife:DB$ LoseLife | Defined$ TriggeredOpponentVotedDiff | LifeAmount$ 2
Oracle:Whenever players finish voting, each opponent who voted for a choice you didn't vote for loses 2 life. Oracle:Whenever players finish voting, each opponent who voted for a choice you didn't vote for loses 2 life.

View File

@@ -5,8 +5,8 @@ PT:4/4
A:AB$ Pump | Cost$ G | KW$ Trample | Defined$ Self | SubAbility$ DBToken | SpellDescription$ CARDNAME gains trample until end of turn. Target opponent creates a 1/1 green Hippo creature token. A:AB$ Pump | Cost$ G | KW$ Trample | Defined$ Self | SubAbility$ DBToken | SpellDescription$ CARDNAME gains trample until end of turn. Target opponent creates a 1/1 green Hippo creature token.
A:AB$ Pump | Cost$ W | KW$ Flying | Defined$ Self | SubAbility$ DBGain | SpellDescription$ CARDNAME gains flying until end of turn. Target opponent gains 2 life. A:AB$ Pump | Cost$ W | KW$ Flying | Defined$ Self | SubAbility$ DBGain | SpellDescription$ CARDNAME gains flying until end of turn. Target opponent gains 2 life.
A:AB$ ChangeZone | Cost$ U | Origin$ Battlefield | Destination$ Hand | SubAbility$ DBDraw | SpellDescription$ Return CARDNAME to its owner's hand. Target opponent may draw a card. A:AB$ ChangeZone | Cost$ U | Origin$ Battlefield | Destination$ Hand | SubAbility$ DBDraw | SpellDescription$ Return CARDNAME to its owner's hand. Target opponent may draw a card.
SVar:DBToken:DB$ Token | ValidTgts$ Opponent | TokenAmount$ 1 | TokenScript$ g_1_1_hippo | TokenOwner$ Opponent SVar:DBToken:DB$ Token | ValidTgts$ Opponent | TokenScript$ g_1_1_hippo | TokenOwner$ Targeted
SVar:DBGain:DB$ GainLife | LifeAmount$ 2 | ValidTgts$ Opponent SVar:DBGain:DB$ GainLife | LifeAmount$ 2 | ValidTgts$ Opponent
SVar:DBDraw:DB$ Draw | NumCards$ 1 | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | OptionalDecider$ Opponent SVar:DBDraw:DB$ Draw | NumCards$ 1 | ValidTgts$ Opponent | OptionalDecider$ Opponent
AI:RemoveDeck:All AI:RemoveDeck:All
Oracle:{G}: Phelddagrif gains trample until end of turn. Target opponent creates a 1/1 green Hippo creature token.\n{W}: Phelddagrif gains flying until end of turn. Target opponent gains 2 life.\n{U}: Return Phelddagrif to its owner's hand. Target opponent may draw a card. Oracle:{G}: Phelddagrif gains trample until end of turn. Target opponent creates a 1/1 green Hippo creature token.\n{W}: Phelddagrif gains flying until end of turn. Target opponent gains 2 life.\n{U}: Return Phelddagrif to its owner's hand. Target opponent may draw a card.

View File

@@ -0,0 +1,9 @@
Name:Erestor of the Council
ManaCost:1 G U
Types:Legendary Creature Elf Noble
PT:2/4
T:Mode$ Vote | TriggerZones$ Battlefield | Execute$ TrigTreasure | List$ OppVotedSame,OppVotedDiff | TriggerDescription$ Whenever players finish voting, each opponent who voted for a choice you voted for creates a Treasure token. You scry X, where X is the number of opponents who voted for a choice you didn't vote for. Draw a card.
SVar:TrigTreasure:DB$ Token | TokenScript$ c_a_treasure_sac | TokenOwner$ TriggeredOpponentVotedSame | SubAbility$ DBScry
SVar:DBScry:DB$ Scry | ScryNum$ X
SVar:X:TriggeredPlayersOpponentVotedDiff$Amount
Oracle:Whenever players finish voting, each opponent who voted for a choice you voted for creates a Treasure token. You scry X, where X is the number of opponents who voted for a choice you didn't vote for. Draw a card.

View File

@@ -0,0 +1,7 @@
Name:Model of Unity
ManaCost:3
Types:Artifact
T:Mode$ Vote | TriggerZones$ Battlefield | Execute$ TrigScry | List$ OppVotedSame | TriggerDescription$ Whenever players finish voting, you and each opponent who voted for a choice you voted for may scry 2.
SVar:TrigScry:DB$ Scry | Defined$ TriggeredOpponentVotedSameAndYou | ScryNum$ 2 | Optional$ True
A:AB$ Mana | Cost$ T | Produced$ Any | SpellDescription$ Add one mana of any color.
Oracle:Whenever players finish voting, you and each opponent who voted for a choice you voted for may scry 2.\n{T}: Add one mana of any color.

View File

@@ -1,7 +1,8 @@
Name:Winding Way Name:Winding Way
ManaCost:1 G ManaCost:1 G
Types:Sorcery Types:Sorcery
A:SP$ ChooseType | Cost$ 1 G | Defined$ You | Type$ Card | ValidTypes$ Creature,Land | SubAbility$ DBDig | SpellDescription$ Choose a creature or land. Reveal the top four cards of your library. Put all cards of the chosen type revealed this way into your hand and the rest into your graveyard A:SP$ ChooseType | Type$ Card | ValidTypes$ Creature,Land | SubAbility$ DBDig | StackDescription$ SpellDescription | SpellDescription$ Choose creature or land.
SVar:DBDig:DB$ Dig | DigNum$ 4 | Reveal$ True | ChangeNum$ All | ChangeValid$ Card.ChosenType | DestinationZone2$ Graveyard SVar:DBDig:DB$ Dig | DigNum$ 4 | Reveal$ True | ChangeNum$ All | ChangeValid$ Card.ChosenType | DestinationZone2$ Graveyard | StackDescription$ SpellDescription | SpellDescription$ Reveal the top four cards of your library. Put all cards of the chosen type revealed this way into your hand and the rest into your graveyard.
AI:RemoveDeck:All AI:RemoveDeck:All
DeckHas:Ability$Graveyard
Oracle:Choose creature or land. Reveal the top four cards of your library. Put all cards of the chosen type revealed this way into your hand and the rest into your graveyard. Oracle:Choose creature or land. Reveal the top four cards of your library. Put all cards of the chosen type revealed this way into your hand and the rest into your graveyard.

View File

@@ -1646,7 +1646,8 @@ lblAttachment=Anhang
#TriggerUntaps.java #TriggerUntaps.java
lblUntapped=nicht getappt lblUntapped=nicht getappt
#TriggerVote.java #TriggerVote.java
lblVoters=Abstimmende lblOppVotedDiff=Die Gegner, der für eine Option gestimmt hat, für die du gestimmt hast
lblOppVotedSame=Die Gegner, der für eine Option gestimmt haben, für die du gestimmt hast
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=Kreatur lblCreature=Kreatur
#LimitedWinLoseController.java #LimitedWinLoseController.java

View File

@@ -1651,7 +1651,8 @@ lblAttachment=Attachment
#TriggerUntaps.java #TriggerUntaps.java
lblUntapped=Untapped lblUntapped=Untapped
#TriggerVote.java #TriggerVote.java
lblVoters=Voters lblOppVotedDiff=Opponents that voted for a choice you didn''t vote for
lblOppVotedSame=Opponents that voted for a choice you voted for
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=Creature lblCreature=Creature
#LimitedWinLoseController.java #LimitedWinLoseController.java

View File

@@ -1649,7 +1649,8 @@ lblAttachment=Adjunto
#TriggerUntaps.java #TriggerUntaps.java
lblUntapped=Enderezado lblUntapped=Enderezado
#TriggerVote.java #TriggerVote.java
lblVoters=Votantes lblOppVotedDiff=Oponentes que votaron una opción que tú no votaste
lblOppVotedSame=Oponentes que votaron una opción que tú votaste
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=Criatura lblCreature=Criatura
#LimitedWinLoseController.java #LimitedWinLoseController.java

View File

@@ -1650,7 +1650,8 @@ lblAttachment=Pièce jointe
#TriggerUntaps.java #TriggerUntaps.java
lblUntapped=Inexploité lblUntapped=Inexploité
#TriggerVote.java #TriggerVote.java
lblVoters=Votants lblOppVotedDiff=Adversaires qui ont voté pour un choix pour lequel vous n'avez pas voté
lblOppVotedSame=Adversaires qui a voté pour un choix pour lequel vous avez voté
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=Créature lblCreature=Créature
#LimitedWinLoseController.java #LimitedWinLoseController.java

View File

@@ -1648,6 +1648,8 @@ lblAttachment=Assegnazione
lblUntapped=Stappato lblUntapped=Stappato
#TriggerVote.java #TriggerVote.java
lblVoters=Votanti lblVoters=Votanti
lblOppVotedDiff=Avversari che hanno votato per una scelta per la quale hai votato
lblOppVotedSame=Avversari che hanno votato per una scelta per la quale tu non hai votato
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=Creatura lblCreature=Creatura
#LimitedWinLoseController.java #LimitedWinLoseController.java

View File

@@ -1648,7 +1648,8 @@ lblAttachment=アタッチメント
#TriggerUntaps.java #TriggerUntaps.java
lblUntapped=アンタップした lblUntapped=アンタップした
#TriggerVote.java #TriggerVote.java
lblVoters=投票 lblOppVotedDiff=あなたが投票しなかった選択肢に投票した反対
lblOppVotedSame=あなたが投票した選択肢に投票した反対者
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=クリーチャー lblCreature=クリーチャー
#LimitedWinLoseController.java #LimitedWinLoseController.java

View File

@@ -1683,7 +1683,8 @@ lblAttachment=Anexo
#TriggerUntaps.java #TriggerUntaps.java
lblUntapped=Desvirado lblUntapped=Desvirado
#TriggerVote.java #TriggerVote.java
lblVoters=Votantes lblOppVotedDiff=Oponentes que votaram em uma escolha na qual você não votou
lblOppVotedSame=Oponentes que votaram em uma opção em que você votou
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=Criatura lblCreature=Criatura
#LimitedWinLoseController.java #LimitedWinLoseController.java

View File

@@ -1651,7 +1651,8 @@ lblAttachment=装备
#TriggerUntaps.java #TriggerUntaps.java
lblUntapped=未横置 lblUntapped=未横置
#TriggerVote.java #TriggerVote.java
lblVoters=投票 lblOppVotedDiff=投票支持您未投票的选项的反对者
lblOppVotedSame=为您投票的选项投票的反对者
#PermanentCreatureEffect.java #PermanentCreatureEffect.java
lblCreature=生物 lblCreature=生物
#LimitedWinLoseController.java #LimitedWinLoseController.java