Wayta, Trainer Prodigy - fixed cost reduction ad to Way (#11782)

This commit is contained in:
Kleanthis Zymaris 2024-02-12 17:38:17 -05:00 committed by GitHub
parent 08eb000453
commit 190edf0c3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -101,22 +101,35 @@ enum WaytaTrainerProdigyAdjuster implements CostAdjuster {
@Override
public void adjustCosts(Ability ability, Game game) {
Target secondTarget = null;
for (Target target : ability.getTargets()){
if (target.getTargetTag() == 2){
secondTarget = target;
break;
if (game.inCheckPlayableState()) {
int controllerTargets = 0; //number of possible targets controlled by the ability's controller
for (UUID permId : CardUtil.getAllPossibleTargets(ability, game)) {
Permanent permanent = game.getPermanent(permId);
if (permanent != null && permanent.isControlledBy(ability.getControllerId())) {
controllerTargets++;
}
}
if (controllerTargets > 1) {
CardUtil.reduceCost(ability, 2);
}
} else {
Target secondTarget = null;
for (Target target : ability.getTargets()) {
if (target.getTargetTag() == 2) {
secondTarget = target;
break;
}
}
if (secondTarget == null) {
return;
}
// Having to call getFirstTarget() on a Target object called secondTarget
// (because it's the second target of a two-target ability)
// seems like an insult, but this is just getting the UUID of that target
Permanent permanent = game.getPermanentOrLKIBattlefield(secondTarget.getFirstTarget());
if (permanent != null && permanent.isControlledBy(ability.getControllerId())) {
CardUtil.reduceCost(ability, 2);
}
}
if (secondTarget == null){
return;
}
// Having to call getFirstTarget() on a Target object called secondTarget
// (because it's the second target of a two-target ability)
// seems like an insult, but this is just getting the UUID of that target
Permanent permanent = game.getPermanentOrLKIBattlefield(secondTarget.getFirstTarget());
if (permanent != null && permanent.isControlledBy(ability.getControllerId())) {
CardUtil.reduceCost(ability, 2);
}
}
}