mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Merge origin/master
This commit is contained in:
commit
d3d6243bc1
7 changed files with 45 additions and 48 deletions
|
@ -9,6 +9,7 @@ import mage.client.plugins.adapters.MageActionCallback;
|
|||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.components.ImagePanel;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.utils.CardUtil;
|
||||
|
@ -31,8 +32,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.MageObjectType;
|
||||
|
||||
/**
|
||||
* Main class for drawing Mage card object.
|
||||
|
@ -310,16 +309,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
}
|
||||
|
||||
private void setText(CardView card) {
|
||||
if (displayTitleAnyway) {
|
||||
titleText.setText(card.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasImage) {
|
||||
titleText.setText("");
|
||||
} else {
|
||||
titleText.setText(card.getName());
|
||||
}
|
||||
titleText.setText(!displayTitleAnyway && hasImage ? "" : card.getName());
|
||||
}
|
||||
|
||||
private void setImage(Image srcImage) {
|
||||
|
|
|
@ -47,14 +47,13 @@ public class CardPluginImpl implements CardPlugin {
|
|||
|
||||
private static final Logger log = Logger.getLogger(CardPluginImpl.class);
|
||||
|
||||
private static final int ATTACHMENT_DY_OFFSET = 10;
|
||||
|
||||
private static final int GUTTER_Y = 15;
|
||||
private static final int GUTTER_X = 5;
|
||||
static final float EXTRA_CARD_SPACING_X = 0.04f;
|
||||
private static final float CARD_SPACING_Y = 0.03f;
|
||||
private static final float STACK_SPACING_X = 0.07f;
|
||||
private static final float STACK_SPACING_Y = 0.13f;
|
||||
private static final float ATTACHMENT_SPACING_Y = 0.13f;
|
||||
|
||||
private int landStackMax = 5;
|
||||
private int cardWidthMin = 50, cardWidthMax = Constants.CARD_SIZE_FULL.width;
|
||||
|
@ -63,7 +62,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
private int playAreaWidth, playAreaHeight;
|
||||
private int cardWidth, cardHeight;
|
||||
private int extraCardSpacingX, cardSpacingX, cardSpacingY;
|
||||
private int stackSpacingX, stackSpacingY;
|
||||
private int stackSpacingX, stackSpacingY, attachmentSpacingY;
|
||||
private List<Row> rows = new ArrayList<>();
|
||||
|
||||
@Init
|
||||
|
@ -185,6 +184,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
cardSpacingY = Math.round(cardHeight * CARD_SPACING_Y);
|
||||
stackSpacingX = stackVertical ? 0 : Math.round(cardWidth * STACK_SPACING_X);
|
||||
stackSpacingY = Math.round(cardHeight * STACK_SPACING_Y);
|
||||
attachmentSpacingY = Math.round(cardHeight * ATTACHMENT_SPACING_Y);
|
||||
Row creatures = (Row) allCreatures.clone();
|
||||
Row lands = (Row) allLands.clone();
|
||||
Row others = (Row) allOthers.clone();
|
||||
|
@ -449,7 +449,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
private int getHeight() {
|
||||
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY + ATTACHMENT_DY_OFFSET*maxAttachedCount;
|
||||
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY + attachmentSpacingY*maxAttachedCount;
|
||||
}
|
||||
|
||||
public int getMaxAttachedCount() {
|
||||
|
|
|
@ -64,6 +64,7 @@ public class CursedScroll extends CardImpl {
|
|||
// {3}, {tap}: Name a card. Reveal a card at random from your hand. If it's the named card, Cursed Scroll deals 2 damage to target creature or player.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CursedScrollEffect(), new ManaCostsImpl("{3}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addTarget(new TargetCreatureOrPlayer());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,6 @@ class CursedScrollEffect extends OneShotEffect {
|
|||
if (!you.isInGame()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
String cardName = cardChoice.getChoice();
|
||||
game.informPlayers("Cursed Scroll, named card: [" + cardName + "]");
|
||||
|
@ -109,24 +109,20 @@ class CursedScrollEffect extends OneShotEffect {
|
|||
revealed.add(card);
|
||||
you.revealCards("Cursed Scroll", revealed, game);
|
||||
if (card.getName().equals(cardName)) {
|
||||
TargetCreatureOrPlayer target = new TargetCreatureOrPlayer();
|
||||
if (target.canChoose(you.getId(), game)) {
|
||||
if (you.chooseTarget(Outcome.Damage, target, source, game)) {
|
||||
Permanent creature = game.getPermanent(target.getFirstTarget());
|
||||
if (creature != null) {
|
||||
creature.damage(2, source.getSourceId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
Player player = game.getPlayer(target.getFirstTarget());
|
||||
if (player != null) {
|
||||
player.damage(2, source.getSourceId(), game, true, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
if (creature != null) {
|
||||
creature.damage(2, source.getSourceId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
player.damage(2, source.getSourceId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ public class PreventDamageByTargetEffect extends PreventionEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game)) {
|
||||
if (!game.getState().getStack().isEmpty()) {
|
||||
|
||||
}
|
||||
return this.getTargetPointer().getTargets(game, source).contains(event.getSourceId());
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1995,6 +1995,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
break;
|
||||
}
|
||||
}
|
||||
for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) {
|
||||
if (!playable.contains(ability) && canPlay(ability, available, game)) {
|
||||
playable.add(card.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ public abstract class TargetImpl implements Target {
|
|||
this.targets.putAll(target.targets);
|
||||
this.zoneChangeCounters.putAll(target.zoneChangeCounters);
|
||||
this.atRandom = target.atRandom;
|
||||
this.notTarget = target.notTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -228,7 +229,7 @@ public abstract class TargetImpl implements Target {
|
|||
if (maxNumberOfTargets == 0 || targets.size() < maxNumberOfTargets) {
|
||||
if (!targets.containsKey(id)) {
|
||||
if (source != null) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getSourceId(), source.getControllerId()))) {
|
||||
if (!skipEvent && !game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getSourceId(), source.getControllerId()))) {
|
||||
targets.put(id, 0);
|
||||
rememberZoneChangeCounter(id, game);
|
||||
chosen = targets.size() >= minNumberOfTargets;
|
||||
|
@ -267,7 +268,7 @@ public abstract class TargetImpl implements Target {
|
|||
amount += targets.get(id);
|
||||
}
|
||||
if (source != null) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getId(), source.getControllerId()))) {
|
||||
if (!skipEvent && !game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getId(), source.getControllerId()))) {
|
||||
targets.put(id, amount);
|
||||
rememberZoneChangeCounter(id, game);
|
||||
chosen = targets.size() >= minNumberOfTargets;
|
||||
|
@ -337,7 +338,7 @@ public abstract class TargetImpl implements Target {
|
|||
continue; // it's not legal so continue to have a look at other targeted objects
|
||||
}
|
||||
}
|
||||
if (game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId()))) {
|
||||
if (!notTarget && game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId()))) {
|
||||
replacedTargets++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -63,17 +63,14 @@ public class TargetSource extends TargetObject {
|
|||
}
|
||||
|
||||
public TargetSource(int minNumTargets, int maxNumTargets, FilterObject filter) {
|
||||
this.minNumberOfTargets = minNumTargets;
|
||||
this.maxNumberOfTargets = maxNumTargets;
|
||||
this.zone = Zone.ALL;
|
||||
super(minNumTargets, maxNumTargets, Zone.ALL, true);
|
||||
this.filter = filter;
|
||||
this.targetName = filter.getMessage();
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
public TargetSource(final TargetSource target) {
|
||||
super(target);
|
||||
this.filter = target.filter.copy();
|
||||
setNotTarget(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,17 +80,21 @@ public class TargetSource extends TargetObject {
|
|||
|
||||
@Override
|
||||
public void add(UUID id, Game game) {
|
||||
addTarget(id, null, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTarget(UUID id, Ability source, Game game) {
|
||||
if (targets.size() < maxNumberOfTargets) {
|
||||
if (!targets.containsKey(id)) {
|
||||
MageObject object = game.getObject(id);
|
||||
if (object != null && object instanceof StackObject) {
|
||||
targets.put(((StackObject) object).getSourceId(), 0);
|
||||
}
|
||||
else {
|
||||
targets.put(id, 0);
|
||||
}
|
||||
MageObject object = game.getObject(id);
|
||||
if (object != null && object instanceof StackObject) {
|
||||
addTarget(((StackObject) object).getSourceId(), source, game, notTarget);
|
||||
}
|
||||
else {
|
||||
addTarget(id, source, game, notTarget);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue