mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Fix bug that prevented dying triggers from firing
This commit is contained in:
@@ -218,6 +218,17 @@ public abstract class GameEntity extends GameObject implements IIdentifiable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean equals(Object o) {
|
||||||
|
if (o == null) { return false; }
|
||||||
|
return o.hashCode() == id && o.getClass().equals(getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int hashCode() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
@@ -3078,11 +3078,6 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
|||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int compareTo(final Card that) {
|
public final int compareTo(final Card that) {
|
||||||
/*
|
|
||||||
* Return a negative integer of this < that, a positive integer if this
|
|
||||||
* > that, and zero otherwise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (that == null) {
|
if (that == null) {
|
||||||
/*
|
/*
|
||||||
* "Here we can arbitrarily decide that all non-null Cards are
|
* "Here we can arbitrarily decide that all non-null Cards are
|
||||||
@@ -3090,20 +3085,9 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
|||||||
* return in this case, as long as it is consistent. I rather think
|
* return in this case, as long as it is consistent. I rather think
|
||||||
* of null as being lowly." --Braids
|
* of null as being lowly." --Braids
|
||||||
*/
|
*/
|
||||||
return +1;
|
return 1;
|
||||||
} else if (id > that.id) {
|
|
||||||
return +1;
|
|
||||||
} else if (id < that.id) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
return Integer.compare(id, that.id);
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final int hashCode() {
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|||||||
@@ -2005,34 +2005,12 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
mustAttackEntity = o;
|
mustAttackEntity = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final boolean equals(final Object o) {
|
|
||||||
if (o instanceof Player) {
|
|
||||||
final Player p1 = (Player) o;
|
|
||||||
return p1.getName().equals(getName());
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Player o) {
|
public int compareTo(Player o) {
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
return +1;
|
return 1;
|
||||||
}
|
}
|
||||||
int subtractedHash = o.hashCode() - hashCode();
|
return getName().compareTo(o.getName());
|
||||||
if (subtractedHash == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.abs(subtractedHash) / subtractedHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return (41 * (41 + getName().hashCode()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Predicates {
|
public static class Predicates {
|
||||||
|
|||||||
@@ -285,23 +285,21 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
// NAPs
|
// NAPs
|
||||||
for (Player nap : game.getPlayers()) {
|
for (Player nap : game.getPlayers()) {
|
||||||
if (!nap.equals(playerAP))
|
if (!nap.equals(playerAP)) {
|
||||||
checkStatics |= runNonStaticTriggersForPlayer(nap, mode, runParams, delayedTriggersWorkingCopy);
|
checkStatics |= runNonStaticTriggersForPlayer(nap, mode, runParams, delayedTriggersWorkingCopy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkStatics;
|
return checkStatics;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean runNonStaticTriggersForPlayer(final Player player, final TriggerType mode,
|
private boolean runNonStaticTriggersForPlayer(final Player player, final TriggerType mode,
|
||||||
final Map<String, Object> runParams, final ArrayList<Trigger> delayedTriggersWorkingCopy ) {
|
final Map<String, Object> runParams, final ArrayList<Trigger> delayedTriggersWorkingCopy ) {
|
||||||
|
|
||||||
|
Card card = null;
|
||||||
boolean checkStatics = false;
|
boolean checkStatics = false;
|
||||||
|
|
||||||
Card card = null;
|
|
||||||
for (final Trigger t : activeTriggers) {
|
for (final Trigger t : activeTriggers) {
|
||||||
if (!t.isStatic() && t.getHostCard().getController().equals(player)
|
if (!t.isStatic() && t.getHostCard().getController().equals(player) && canRunTrigger(t, mode, runParams)) {
|
||||||
&& canRunTrigger(t, mode, runParams)) {
|
|
||||||
|
|
||||||
if (runParams.containsKey("Card")) {
|
if (runParams.containsKey("Card")) {
|
||||||
card = (Card) runParams.get("Card");
|
card = (Card) runParams.get("Card");
|
||||||
if (runParams.containsKey("Destination") && !ZoneType.Battlefield.name().equals(runParams.get("Destination"))) {
|
if (runParams.containsKey("Destination") && !ZoneType.Battlefield.name().equals(runParams.get("Destination"))) {
|
||||||
@@ -352,11 +350,9 @@ public class TriggerHandler {
|
|||||||
if (!regtrig.requirementsCheck(game)) {
|
if (!regtrig.requirementsCheck(game)) {
|
||||||
return false; // Conditions aren't right.
|
return false; // Conditions aren't right.
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean canRunTrigger(final Trigger regtrig, final TriggerType mode, final Map<String, Object> runParams) {
|
private boolean canRunTrigger(final Trigger regtrig, final TriggerType mode, final Map<String, Object> runParams) {
|
||||||
if (regtrig.getMode() != mode) {
|
if (regtrig.getMode() != mode) {
|
||||||
return false; // Not the right mode.
|
return false; // Not the right mode.
|
||||||
@@ -396,7 +392,6 @@ public class TriggerHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Checks if the conditions are right for a single trigger to go off, and
|
// Checks if the conditions are right for a single trigger to go off, and
|
||||||
// runs it if so.
|
// runs it if so.
|
||||||
// Return true if the trigger went off, false otherwise.
|
// Return true if the trigger went off, false otherwise.
|
||||||
@@ -419,7 +414,8 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
if (trigCard != null && (host.getId() == trigCard.getId())) {
|
if (trigCard != null && (host.getId() == trigCard.getId())) {
|
||||||
host = trigCard;
|
host = trigCard;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
host = game.getCardState(regtrig.getHostCard());
|
host = game.getCardState(regtrig.getHostCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +427,8 @@ public class TriggerHandler {
|
|||||||
public void resolve() {
|
public void resolve() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sa = AbilityFactory.getAbility(host.getSVar(triggerParams.get("Execute")), host);
|
sa = AbilityFactory.getAbility(host.getSVar(triggerParams.get("Execute")), host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,7 +491,8 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
if (regtrig.isStatic()) {
|
if (regtrig.isStatic()) {
|
||||||
wrapperAbility.getActivatingPlayer().getController().playTrigger(host, wrapperAbility, isMandatory);
|
wrapperAbility.getActivatingPlayer().getController().playTrigger(host, wrapperAbility, isMandatory);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
game.getStack().addSimultaneousStackEntry(wrapperAbility);
|
game.getStack().addSimultaneousStackEntry(wrapperAbility);
|
||||||
}
|
}
|
||||||
regtrig.setTriggeredSA(wrapperAbility);
|
regtrig.setTriggeredSA(wrapperAbility);
|
||||||
@@ -503,7 +501,8 @@ public class TriggerHandler {
|
|||||||
if (regtrig.getHostCard().isImmutable()) {
|
if (regtrig.getHostCard().isImmutable()) {
|
||||||
Player p = regtrig.getHostCard().getController();
|
Player p = regtrig.getHostCard().getController();
|
||||||
p.getZone(ZoneType.Command).remove(regtrig.getHostCard());
|
p.getZone(ZoneType.Command).remove(regtrig.getHostCard());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
regtrig.getHostCard().removeTrigger(regtrig);
|
regtrig.getHostCard().removeTrigger(regtrig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ public abstract class TrackableObject implements IIdentifiable {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean equals(Object o) {
|
||||||
|
if (o == null) { return false; }
|
||||||
|
return o.hashCode() == id && o.getClass().equals(getClass());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected <T> T get(TrackableProperty key) {
|
protected <T> T get(TrackableProperty key) {
|
||||||
T value = (T)props.get(key);
|
T value = (T)props.get(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user