Fix player highlighting when selected

This commit is contained in:
tool4EvEr
2021-12-19 20:25:14 +01:00
parent 2c01aa81b8
commit c2f1472db7
5 changed files with 23 additions and 11 deletions

View File

@@ -385,10 +385,10 @@ public class DrawAi extends SpellAbilityAi {
}
}
boolean aiTarget = sa.canTarget(ai);
boolean aiTarget = sa.canTarget(ai) && (mandatory || ai.canDraw());
// checks what the ai prevent from casting it on itself
// if spell is not mandatory
if (aiTarget && !ai.cantLose() && ai.canDraw()) {
if (aiTarget && !ai.cantLose()) {
if (numCards >= computerLibrarySize - 3) {
if (xPaid) {
numCards = computerLibrarySize - 1;
@@ -426,7 +426,7 @@ public class DrawAi extends SpellAbilityAi {
}
if (aiTarget) {
if (computerHandSize + numCards > computerMaxHandSize && game.getPhaseHandler().isPlayerTurn(ai)) {
if (!ai.isCardInPlay("Laboratory Maniac") && computerHandSize + numCards > computerMaxHandSize && game.getPhaseHandler().isPlayerTurn(ai)) {
if (xPaid) {
numCards = computerMaxHandSize - computerHandSize;
if (source.isInZone(ZoneType.Hand)) {
@@ -472,10 +472,8 @@ public class DrawAi extends SpellAbilityAi {
}
// ally would lose because of poison
if (getPoison != null && ally.canReceiveCounters(CounterType.get(CounterEnumType.POISON))) {
if (ally.getPoisonCounters() + numCards > 9) {
if (getPoison != null && ally.canReceiveCounters(CounterType.get(CounterEnumType.POISON)) && ally.getPoisonCounters() + numCards > 9) {
continue;
}
}
sa.getTargets().add(ally);

View File

@@ -179,7 +179,7 @@ public class PumpEffect extends SpellAbilityEffect {
final int atk = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), sa, true);
final int def = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumDef"), sa, true);
boolean gets = (sa.hasParam("NumAtt") || sa.hasParam("NumDef"));
boolean gets = sa.hasParam("NumAtt") || sa.hasParam("NumDef");
boolean gains = !keywords.isEmpty();
if (gets) {

View File

@@ -255,10 +255,9 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
private final Set<PlayerView> highlightedPlayers = Sets.newHashSet();
@Override
public void setHighlighted(final PlayerView pv, final boolean b) {
if (b) {
highlightedPlayers.add(pv);
} else {
highlightedPlayers.remove(pv);
final boolean hasChanged = b ? highlightedPlayers.add(pv) : highlightedPlayers.remove(pv);
if (hasChanged) {
updateLives(Collections.singleton(pv));
}
}

View File

@@ -7,6 +7,8 @@ import com.google.common.collect.Iterables;
import forge.game.GameEntity;
import forge.game.card.Card;
import forge.game.card.CardView;
import forge.game.player.Player;
import forge.game.player.PlayerView;
import forge.game.spellability.SpellAbility;
import forge.localinstance.properties.ForgePreferences;
import forge.model.FModel;
@@ -110,6 +112,9 @@ public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyn
if (c instanceof Card) {
getController().getGui().setUsedToPay(CardView.get((Card) c), newState); // UI supports card highlighting though this abstraction-breaking mechanism
}
else if (c instanceof Player) {
getController().getGui().setHighlighted(PlayerView.get((Player) c), newState);
}
}
private void resetUsedToPay() {
@@ -117,6 +122,9 @@ public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyn
if (c instanceof Card) {
getController().getGui().setUsedToPay(CardView.get((Card) c), false);
}
else if (c instanceof Player) {
getController().getGui().setHighlighted(PlayerView.get((Player) c), false);
}
}
}

View File

@@ -17,6 +17,7 @@ import forge.game.card.Card;
import forge.game.card.CardPredicates;
import forge.game.card.CardView;
import forge.game.player.Player;
import forge.game.player.PlayerView;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import forge.gui.FThreads;
@@ -356,6 +357,9 @@ public final class InputSelectTargets extends InputSyncronizedBase {
getController().getGui().setUsedToPay(CardView.get((Card) ge), true);
lastTarget = (Card) ge;
}
else if (ge instanceof Player) {
getController().getGui().setHighlighted(PlayerView.get((Player) ge), true);
}
final Integer val = targetDepth.get(ge);
targetDepth.put(ge, val == null ? Integer.valueOf(1) : Integer.valueOf(val.intValue() + 1) );
@@ -377,6 +381,9 @@ public final class InputSelectTargets extends InputSyncronizedBase {
if (c instanceof Card) {
getController().getGui().setUsedToPay(CardView.get((Card) c), false);
}
else if (c instanceof Player) {
getController().getGui().setHighlighted(PlayerView.get((Player) c), false);
}
}
this.stop();