Page 1 of 1
"Blocking, or being blocked by"

Posted:
26 Jun 2009, 20:11
by zerker2000
Quick question: what is the easiest way to get the canTarget cardList / CanPlay for an ability that targets creatures "blocking, or being blocked by" something? Also, is there a method "getOpponent(String player)" somewhere, or should I just put the
- Code: Select all
String opponent;
if (card.getController==Constant.Player.Human)opponent=
Constant.Player.Computer/*.clone()?*/;
else opponent=Constant.Player.Human/*.clone()?*/;
in everywhere I need it?
Re: "Blocking, or being blocked by"

Posted:
27 Jun 2009, 12:36
by DennisBergkamp
There is an AllZone.GameAction.getOpponent(String player) (a lot of the cards in CardFactory.java use it).
As for your first question, I'm not sure if there's an easy way of doing this, you'll have to play around with it... I know there's an AllZone.Combat.isBlocked(Card attacker) and an AllZone.Combat.getAllBlockers() (or AllZone.Combat.getBlockers(Card attacker)).
Re: "Blocking, or being blocked by"

Posted:
01 Jul 2009, 07:40
by zerker2000
Should this work?:
- Code: Select all
final Ability_Tap ability = new Ability_Tap(card){
public boolean canPlay()
{
return card.isUntapped() && !card.hasSickness() && AllZone.GameAction.isCardInPlay(card) && (AllZone.Combat.isBlocked(card) || AllZone.Combat.getAllBlockers().contains(card));
}
public boolean canPlayAI()
{
return false;
//TODO
}
public void resolve()
{
AllZone.GameAction.destroy(getTargetCard());
}//resolve()
};
Input runtime = new Input()
{
public void showMessage()
{
CardList targets;
if(AllZone.Combat.isBlocked(card) || AllZone.Combat.getAllBlockers().contains(card)){
if (AllZone.Combat.isBlocked(card)){ targets = AllZone.Combat.getBlockers(card); }
else {
targets = new CardList();
for (Card c : AllZone.Combat.getAttackers()){
if (AllZone.Combat.isBlocked(c))
if (AllZone.Combat.getBlockers(c).contains(card)) targets.add(c);
}
}
}
stopSetNext(CardFactoryUtil.input_targetSpecific(ability, targets, "Select target blocking or blocked by " + card, true));
}
};
ability.setBeforePayMana(runtime);
card.addSpellAbility(ability);
Re: "Blocking, or being blocked by"

Posted:
01 Jul 2009, 15:41
by DennisBergkamp
Yes it should! Might not, but I think it will... by the way, for which card is this?
Re: "Blocking, or being blocked by"

Posted:
02 Jul 2009, 18:40
by mtgrares
Maybe you should add the "blocking, or being blocked by" code to Combat because you could reuse the code for other cards. Combat.isBlockedOrBeingBlocked(Card) and return a boolean.