mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Crew ability - added selected and needed power info while choosing, colorozing;
This commit is contained in:
parent
b45864070c
commit
83afca8bda
2 changed files with 27 additions and 3 deletions
|
@ -29,7 +29,7 @@ public class HintUtils {
|
|||
|
||||
// text
|
||||
if (text != null && color != null) {
|
||||
String hex = String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getGreen());
|
||||
String hex = String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
|
||||
res = String.format("<font color=%s>%s</font>", hex, text);
|
||||
} else {
|
||||
res = text;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.effects.common.continuous.AddCardTypeSourceEffect;
|
||||
import mage.abilities.hint.HintUtils;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -20,6 +20,10 @@ import mage.game.permanent.Permanent;
|
|||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author emerald000
|
||||
*/
|
||||
|
@ -70,7 +74,24 @@ class CrewCost extends CostImpl {
|
|||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Target target = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE, filter, true);
|
||||
Target target = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE, filter, true) {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
// shows selected power
|
||||
int selectedPower = this.targets.entrySet().stream()
|
||||
.map(entry -> (game.getPermanent(entry.getKey())))
|
||||
.filter(Objects::nonNull)
|
||||
.mapToInt(p -> (p.getPower().getValue()))
|
||||
.sum();
|
||||
String extraInfo = "(selected power " + selectedPower + " of " + value + ")";
|
||||
if (selectedPower >= value) {
|
||||
extraInfo = HintUtils.prepareText(extraInfo, Color.GREEN);
|
||||
}
|
||||
return super.getMessage() + " " + extraInfo;
|
||||
}
|
||||
};
|
||||
|
||||
// can cancel
|
||||
if (target.choose(Outcome.Tap, controllerId, sourceId, game)) {
|
||||
int sumPower = 0;
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
|
@ -88,7 +109,10 @@ class CrewCost extends CostImpl {
|
|||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CREWED_VEHICLE, targetId, sourceId, controllerId));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return paid;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue