Added attacker to canBlock method.

This commit is contained in:
magenoxx 2011-01-13 23:29:15 +03:00
parent 7edffebb5d
commit 42812541b9
11 changed files with 24 additions and 15 deletions

View file

@ -160,12 +160,15 @@ public class MageBook extends JComponent {
final String _set = set;
tab.setObserver(new Command() {
public void execute() {
currentPage = 0;
currentSet = _set;
pageLeft.setVisible(false);
pageRight.setVisible(false);
addSetTabs();
showCards();
if (currentSet != _set || currentPage != 0) {
AudioManager.playAnotherTab();
currentPage = 0;
currentSet = _set;
pageLeft.setVisible(false);
pageRight.setVisible(false);
addSetTabs();
showCards();
}
}
});
currentPanel.add(tab, JLayeredPane.DEFAULT_LAYER + count++, 0);

View file

@ -26,6 +26,7 @@ public class AudioManager {
audioManager = new AudioManager();
audioManager.nextPageClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav"); //sounds better than OnNextPage
audioManager.prevPageClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav");
audioManager.anotherTabClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPage.wav");
audioManager.nextPhaseClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPhase.wav");
audioManager.endTurnClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav");
audioManager.tapPermanentClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav");
@ -51,6 +52,10 @@ public class AudioManager {
checkAndPlayClip(getManager().prevPageClip);
}
public static void playAnotherTab() {
checkAndPlayClip(getManager().anotherTabClip);
}
public static void playNextPhase() {
checkAndPlayClip(getManager().nextPhaseClip);
}
@ -146,6 +151,7 @@ public class AudioManager {
private Clip nextPageClip = null;
private Clip prevPageClip = null;
private Clip anotherTabClip = null;
private Clip nextPhaseClip = null;
private Clip endTurnClip = null;
private Clip tapPermanentClip = null;

View file

@ -106,7 +106,7 @@ class JuggernautEffect extends CantBlockSourceEffect {
}
@Override
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return !blocker.getSubtype().contains("Wall");
}

View file

@ -105,7 +105,7 @@ class PacifismEffect extends RestrictionEffect<PacifismEffect> {
}
@Override
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return false;
}

View file

@ -61,7 +61,7 @@ class CantBlockEffect extends RestrictionEffect<CantBlockEffect> {
}
@Override
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return !blocker.getAbilities().containsKey(CantBlockAbility.getInstance().getId());
}

View file

@ -61,7 +61,7 @@ public abstract class RestrictionEffect<T extends RestrictionEffect<T>> extends
return true;
}
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return true;
}

View file

@ -57,7 +57,7 @@ public class CantBlockSourceEffect extends RestrictionEffect<CantBlockSourceEffe
}
@Override
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return false;
}

View file

@ -87,7 +87,7 @@ class FlyingEffect extends RestrictionEffect<FlyingEffect> {
}
@Override
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
if (blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId()) || blocker.getAbilities().containsKey(ReachAbility.getInstance().getId()))
return true;
return false;

View file

@ -72,7 +72,7 @@ class LandwalkEffect extends RestrictionEffect<LandwalkEffect> {
}
@Override
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return game.getBattlefield().countAll(filter, blocker.getControllerId()) == 0;
}

View file

@ -87,7 +87,7 @@ class UnblockableEffect extends RestrictionEffect<UnblockableEffect> {
}
@Override
public boolean canBlock(Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return false;
}

View file

@ -584,7 +584,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
Permanent attacker = game.getPermanent(attackerId);
//20101001 - 509.1b
for (RestrictionEffect effect: game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game)) {
if (!effect.canBlock(this, game))
if (!effect.canBlock(attacker, this, game))
return false;
}
if (attacker.hasProtectionFrom(this))