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"),
Object("Object"),
Objects("Objects"),
OpponentVotedDiff("OpponentVotedDiff"),
OpponentVotedSame("OpponentVotedSame"),
OtherAttackers("OtherAttackers"),
OtherVoters("OtherVoters"),
Origin("Origin"),
OriginalController("OriginalController"),
OriginalDefender("OriginalDefender"),

View File

@@ -6,6 +6,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import forge.game.event.GameEventRandomLog;
import forge.util.Lang;
import org.apache.commons.lang3.StringUtils;
@@ -57,7 +58,7 @@ public class VoteEffect extends SpellAbilityEffect {
final Game game = host.getGame();
final Player activator = sa.getActivatingPlayer();
final boolean secret = sa.hasParam("Secret");
final StringBuilder secretSB = new StringBuilder();
final StringBuilder record = new StringBuilder();
if (sa.hasParam("VoteType")) {
voteType.addAll(Arrays.asList(sa.getParam("VoteType").split(",")));
@@ -97,18 +98,20 @@ public class VoteEffect extends SpellAbilityEffect {
if (!secret) {
game.getAction().notifyOfValue(sa, p, result + "\r\n" +
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) {
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();
runParams.put(AbilityKey.AllVotes, votes);

View File

@@ -31,11 +31,11 @@ import forge.util.collect.FCollection;
/**
* <p>
* Trigger_Untaps class.
* Trigger_Vote class.
* </p>
*
* @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 {
@@ -66,25 +66,47 @@ public class TriggerVote extends Trigger {
@Override
public final void setTriggeringObjects(final SpellAbility sa, Map<AbilityKey, Object> runParams) {
@SuppressWarnings("unchecked")
FCollection<Player> voters = getVoters(
FCollection<Player> oppVotedDiff = getVoters(
this.getHostCard().getController(),
(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
public String getImportantStackObjects(SpellAbility sa) {
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();
}
private static FCollection<Player> getVoters(final Player player,
final ListMultimap<Object, Player> votes,
final boolean isOpponent, final boolean votedOtherchoice) {
private static FCollection<Player> getVoters (final Player player, final ListMultimap<Object, Player> votes,
final boolean isOpponent, final boolean votedOtherchoice) {
final FCollection<Player> voters = new FCollection<>();
for (final Object voteType : votes.keySet()) {
final List<Player> players = votes.get(voteType);

View File

@@ -1,7 +1,7 @@
Name:Capital Punishment
ManaCost:4 B B
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.
SVar:DBVoteDeath:DB$ Sacrifice | Defined$ Player.Opponent | SacValid$ Creature | SacMessage$ Creature | Amount$ VoteNumDeath | SubAbility$ DBVoteTaxes
SVar:DBVoteTaxes:DB$ Discard | Defined$ Player.Opponent | NumCards$ VoteNumTaxes | Mode$ TgtChoose
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$ 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$ 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.

View File

@@ -2,6 +2,6 @@ Name:Grudge Keeper
ManaCost:1 B
Types:Creature Zombie Wizard
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.
SVar:TrigLoseLife:DB$ LoseLife | Defined$ TriggeredOtherVoters | LifeAmount$ 2
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$ TriggeredOpponentVotedDiff | LifeAmount$ 2
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$ 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.
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: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
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
ManaCost:1 G
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
SVar:DBDig:DB$ Dig | DigNum$ 4 | Reveal$ True | ChangeNum$ All | ChangeValid$ Card.ChosenType | DestinationZone2$ 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 | 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
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.

View File

@@ -1646,7 +1646,8 @@ lblAttachment=Anhang
#TriggerUntaps.java
lblUntapped=nicht getappt
#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
lblCreature=Kreatur
#LimitedWinLoseController.java

View File

@@ -1651,7 +1651,8 @@ lblAttachment=Attachment
#TriggerUntaps.java
lblUntapped=Untapped
#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
lblCreature=Creature
#LimitedWinLoseController.java

View File

@@ -1649,7 +1649,8 @@ lblAttachment=Adjunto
#TriggerUntaps.java
lblUntapped=Enderezado
#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
lblCreature=Criatura
#LimitedWinLoseController.java

View File

@@ -1650,7 +1650,8 @@ lblAttachment=Pièce jointe
#TriggerUntaps.java
lblUntapped=Inexploité
#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
lblCreature=Créature
#LimitedWinLoseController.java

View File

@@ -1648,6 +1648,8 @@ lblAttachment=Assegnazione
lblUntapped=Stappato
#TriggerVote.java
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
lblCreature=Creatura
#LimitedWinLoseController.java

View File

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

View File

@@ -1683,7 +1683,8 @@ lblAttachment=Anexo
#TriggerUntaps.java
lblUntapped=Desvirado
#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
lblCreature=Criatura
#LimitedWinLoseController.java

View File

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