mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- CNS: Added Coercive Portal and Council's Judgment
This commit is contained in:
@@ -4,14 +4,18 @@ import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,8 +28,15 @@ public class VoteEffect extends SpellAbilityEffect {
|
||||
*/
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
return StringUtils.join(getDefinedPlayersOrTargeted(sa), ", ") + " vote "
|
||||
+ StringUtils.join(sa.getParam("VoteType").split(","), " or ");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(StringUtils.join(getDefinedPlayersOrTargeted(sa), ", "));
|
||||
sb.append(" vote ");
|
||||
if (sa.hasParam("VoteType")) {
|
||||
sb.append(StringUtils.join(sa.getParam("VoteType").split(","), " or "));
|
||||
} else if (sa.hasParam("VoteMessage")) {
|
||||
sb.append(sa.getParam("VoteMessage"));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -34,20 +45,32 @@ public class VoteEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final List<Player> tgtPlayers = getDefinedPlayersOrTargeted(sa);
|
||||
final List<String> voteType = Arrays.asList(sa.getParam("VoteType").split(","));
|
||||
final List<Object> voteType = new ArrayList<Object>();
|
||||
final Card host = sa.getHostCard();
|
||||
final Game game = host.getGame();
|
||||
|
||||
if (sa.hasParam("VoteType")) {
|
||||
voteType.addAll(Arrays.asList(sa.getParam("VoteType").split(",")));
|
||||
} else if (sa.hasParam("VoteCard")) {
|
||||
ZoneType zone = sa.hasParam("Zone") ? ZoneType.smartValueOf(sa.getParam("Zone")) : ZoneType.Battlefield;
|
||||
voteType.addAll(CardLists.getValidCards(game.getCardsIn(zone), sa.getParam("VoteCard"), host.getController(), host));
|
||||
}
|
||||
if (voteType.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// starting with the activator
|
||||
int pSize = tgtPlayers.size();
|
||||
Player activator = sa.getActivatingPlayer();
|
||||
while (tgtPlayers.contains(activator) && !activator.equals(Iterables.getFirst(tgtPlayers, null))) {
|
||||
tgtPlayers.add(pSize - 1, tgtPlayers.remove(0));
|
||||
}
|
||||
ArrayListMultimap<String, Player> votes = ArrayListMultimap.create();
|
||||
ArrayListMultimap<Object, Player> votes = ArrayListMultimap.create();
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
int voteAmount = p.getAmountOfKeyword("You get an additional vote.") + 1;
|
||||
for (int i = 0; i < voteAmount; i++) {
|
||||
final String result = p.getController().vote(sa, sa.getHostCard() + "Vote:", voteType);
|
||||
final Object result = p.getController().vote(sa, host + "Vote:", voteType, votes);
|
||||
votes.put(result, p);
|
||||
host.getGame().getAction().nofityOfValue(sa, p, result + "\r\nCurrent Votes:" + votes, p);
|
||||
}
|
||||
@@ -55,12 +78,17 @@ public class VoteEffect extends SpellAbilityEffect {
|
||||
|
||||
|
||||
List<String> subAbs = Lists.newArrayList();
|
||||
final List<String> mostVotes = getMostVotes(votes);
|
||||
final List<Object> mostVotes = getMostVotes(votes);
|
||||
if (sa.hasParam("Tied") && mostVotes.size() > 1) {
|
||||
subAbs.add(sa.getParam("Tied"));
|
||||
} else if (sa.hasParam("VoteSubAbility")) {
|
||||
for (final Object o : mostVotes) {
|
||||
host.addRemembered(o);
|
||||
}
|
||||
subAbs.add(sa.getParam("VoteSubAbility"));
|
||||
} else {
|
||||
for (String type : mostVotes) {
|
||||
subAbs.add(sa.getParam("Vote" + type));
|
||||
for (Object type : mostVotes) {
|
||||
subAbs.add(sa.getParam("Vote" + type.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +98,15 @@ public class VoteEffect extends SpellAbilityEffect {
|
||||
((AbilitySub) action).setParent(sa);
|
||||
AbilityUtils.resolve(action);
|
||||
}
|
||||
if (sa.hasParam("VoteSubAbility")) {
|
||||
host.clearRemembered();
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getMostVotes(ArrayListMultimap<String, Player> votes) {
|
||||
List<String> most = Lists.newArrayList();
|
||||
private List<Object> getMostVotes(ArrayListMultimap<Object, Player> votes) {
|
||||
List<Object> most = Lists.newArrayList();
|
||||
int amount = 0;
|
||||
for (String voteType : votes.keySet()) {
|
||||
for (Object voteType : votes.keySet()) {
|
||||
int voteAmount = votes.get(voteType).size();
|
||||
if (voteAmount == amount) {
|
||||
most.add(voteType);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.game.player;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
@@ -176,7 +177,7 @@ public abstract class PlayerController {
|
||||
return chooseSomeType(kindOfType, sa, validTypes, invalidTypes, false);
|
||||
}
|
||||
public abstract String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional);
|
||||
public abstract String vote(SpellAbility sa, String prompt, List<String> options);
|
||||
public abstract Object vote(SpellAbility sa, String prompt, List<Object> options, ArrayListMultimap<Object, Player> votes);
|
||||
public abstract Pair<CounterType,String> chooseAndRemoveOrPutCounter(Card cardWithCounter);
|
||||
public abstract boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question);
|
||||
public abstract List<Card> getCardsToMulligan(boolean isCommander, Player firstPlayer);
|
||||
|
||||
Reference in New Issue
Block a user