mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- Little code simplifications in TriggerHandler class.
This commit is contained in:
@@ -352,7 +352,9 @@ public class TriggerHandler {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private boolean runSingleTrigger(final Trigger regtrig, final String mode, final Map<String, Object> runParams) {
|
private boolean runSingleTrigger(final Trigger regtrig, final String mode, final Map<String, Object> runParams) {
|
||||||
if (!regtrig.getMapParams().get("Mode").equals(mode)) {
|
final Map<String, String> params = regtrig.getMapParams();
|
||||||
|
|
||||||
|
if (!params.get("Mode").equals(mode)) {
|
||||||
return false; //Not the right mode.
|
return false; //Not the right mode.
|
||||||
}
|
}
|
||||||
if (!regtrig.zonesCheck()) {
|
if (!regtrig.zonesCheck()) {
|
||||||
@@ -384,24 +386,23 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
if(torporOrbs.size() != 0)
|
if(torporOrbs.size() != 0)
|
||||||
{
|
{
|
||||||
if(regtrig.getMapParams().containsKey("Destination"))
|
if(params.containsKey("Destination"))
|
||||||
{
|
{
|
||||||
if ((regtrig.getMapParams().get("Destination").equals("Battlefield") || regtrig.getMapParams().get("Destination").equals("Any")) && mode.equals("ChangesZone") && ((regtrig.getMapParams().get("ValidCard").contains("Creature")) || (regtrig.getMapParams().get("ValidCard").contains("Self") && regtrig.getHostCard().isCreature() )))
|
if ((params.get("Destination").equals("Battlefield") || params.get("Destination").equals("Any")) && mode.equals("ChangesZone") && ((params.get("ValidCard").contains("Creature")) || (params.get("ValidCard").contains("Self") && regtrig.getHostCard().isCreature() )))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mode.equals("ChangesZone") && ((regtrig.getMapParams().get("ValidCard").contains("Creature")) || (regtrig.getMapParams().get("ValidCard").contains("Self") && regtrig.getHostCard().isCreature() )))
|
if (mode.equals("ChangesZone") && ((params.get("ValidCard").contains("Creature")) || (params.get("ValidCard").contains("Self") && regtrig.getHostCard().isCreature() )))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}//Torpor Orb check
|
||||||
|
|
||||||
HashMap<String, String> trigParams = regtrig.getMapParams();
|
|
||||||
final Player[] decider = new Player[1];
|
final Player[] decider = new Player[1];
|
||||||
|
|
||||||
// Any trigger should cause the phase not to skip
|
// Any trigger should cause the phase not to skip
|
||||||
@@ -434,14 +435,14 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
sa[0] = regtrig.getOverridingAbility();
|
sa[0] = regtrig.getOverridingAbility();
|
||||||
if (sa[0] == null) {
|
if (sa[0] == null) {
|
||||||
if (!trigParams.containsKey("Execute")) {
|
if (!params.containsKey("Execute")) {
|
||||||
sa[0] = new Ability(regtrig.getHostCard(), "0") {
|
sa[0] = new Ability(regtrig.getHostCard(), "0") {
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
sa[0] = abilityFactory.getAbility(host.getSVar(trigParams.get("Execute")), host);
|
sa[0] = abilityFactory.getAbility(host.getSVar(params.get("Execute")), host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sa[0].setTrigger(true);
|
sa[0].setTrigger(true);
|
||||||
@@ -454,10 +455,10 @@ public class TriggerHandler {
|
|||||||
sa[0].setActivatingPlayer(host.getController());
|
sa[0].setActivatingPlayer(host.getController());
|
||||||
sa[0].setStackDescription(sa[0].toString());
|
sa[0].setStackDescription(sa[0].toString());
|
||||||
boolean mand = false;
|
boolean mand = false;
|
||||||
if (trigParams.containsKey("OptionalDecider")) {
|
if (params.containsKey("OptionalDecider")) {
|
||||||
sa[0].setOptionalTrigger(true);
|
sa[0].setOptionalTrigger(true);
|
||||||
mand = false;
|
mand = false;
|
||||||
decider[0] = AbilityFactory.getDefinedPlayers(host, trigParams.get("OptionalDecider"), sa[0]).get(0);
|
decider[0] = AbilityFactory.getDefinedPlayers(host, params.get("OptionalDecider"), sa[0]).get(0);
|
||||||
} else {
|
} else {
|
||||||
mand = true;
|
mand = true;
|
||||||
|
|
||||||
@@ -971,7 +972,7 @@ public class TriggerHandler {
|
|||||||
StringBuilder buildQuestion = new StringBuilder("Use triggered ability of ");
|
StringBuilder buildQuestion = new StringBuilder("Use triggered ability of ");
|
||||||
buildQuestion.append(regtrig.getHostCard().getName()).append("(").append(regtrig.getHostCard().getUniqueNumber()).append(")?");
|
buildQuestion.append(regtrig.getHostCard().getName()).append("(").append(regtrig.getHostCard().getUniqueNumber()).append(")?");
|
||||||
buildQuestion.append("\r\n(");
|
buildQuestion.append("\r\n(");
|
||||||
buildQuestion.append(regtrig.getMapParams().get("TriggerDescription").replace("CARDNAME", regtrig.getHostCard().getName()));
|
buildQuestion.append(params.get("TriggerDescription").replace("CARDNAME", regtrig.getHostCard().getName()));
|
||||||
buildQuestion.append(")");
|
buildQuestion.append(")");
|
||||||
if (!GameActionUtil.showYesNoDialog(regtrig.getHostCard(), buildQuestion.toString())) {
|
if (!GameActionUtil.showYesNoDialog(regtrig.getHostCard(), buildQuestion.toString())) {
|
||||||
return;
|
return;
|
||||||
@@ -996,8 +997,8 @@ public class TriggerHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Add eventual delayed trigger.
|
//Add eventual delayed trigger.
|
||||||
if (regtrig.getMapParams().containsKey("DelayedTrigger")) {
|
if (params.containsKey("DelayedTrigger")) {
|
||||||
String sVarName = regtrig.getMapParams().get("DelayedTrigger");
|
String sVarName = params.get("DelayedTrigger");
|
||||||
Trigger deltrig = parseTrigger(regtrig.getHostCard().getSVar(sVarName), regtrig.getHostCard(), true);
|
Trigger deltrig = parseTrigger(regtrig.getHostCard().getSVar(sVarName), regtrig.getHostCard(), true);
|
||||||
deltrig.setStoredTriggeredObjects(this.getTriggeringObjects());
|
deltrig.setStoredTriggeredObjects(this.getTriggeringObjects());
|
||||||
registerDelayedTrigger(deltrig);
|
registerDelayedTrigger(deltrig);
|
||||||
@@ -1022,17 +1023,12 @@ public class TriggerHandler {
|
|||||||
//Card src = (Card)(sa[0].getSourceCard().getTriggeringObject("Card"));
|
//Card src = (Card)(sa[0].getSourceCard().getTriggeringObject("Card"));
|
||||||
//System.out.println("Trigger going on stack for "+mode+". Card = "+src);
|
//System.out.println("Trigger going on stack for "+mode+". Card = "+src);
|
||||||
|
|
||||||
if (regtrig.getMapParams().containsKey("Static")) {
|
if (params.containsKey("Static") && params.get("Static").equals("True")) {
|
||||||
if (regtrig.getMapParams().get("Static").equals("True")) {
|
|
||||||
AllZone.getGameAction().playSpellAbility_NoStack(wrapperAbility, false);
|
AllZone.getGameAction().playSpellAbility_NoStack(wrapperAbility, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AllZone.getStack().addSimultaneousStackEntry(wrapperAbility);
|
AllZone.getStack().addSimultaneousStackEntry(wrapperAbility);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
AllZone.getStack().addSimultaneousStackEntry(wrapperAbility);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user