Erwan
-Fixed issue 24 using a Limitor...probably not the best solution, but I think it's clean enough...
This commit is contained in:
@@ -19,8 +19,10 @@ class MTGPutInPlayRule:public MTGAbility{
|
||||
virtual MTGPutInPlayRule * clone() const;
|
||||
};
|
||||
|
||||
class MTGAttackRule:public MTGAbility{
|
||||
class MTGAttackRule:public MTGAbility, public Limitor{
|
||||
public:
|
||||
virtual bool select(Target*);
|
||||
virtual bool greyout(Target*);
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
|
||||
@@ -91,6 +91,20 @@ ostream& MTGPutInPlayRule::toString(ostream& out) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MTGAttackRule::select(Target* t)
|
||||
{
|
||||
if (CardView* c = dynamic_cast<CardView*>(t)) {
|
||||
MTGCardInstance * card = c->getCard();
|
||||
if (card->canAttack()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool MTGAttackRule::greyout(Target* t)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
MTGAttackRule::MTGAttackRule(int _id):MTGAbility(_id,NULL){
|
||||
aType=MTGAbility::MTG_ATTACK_RULE;
|
||||
}
|
||||
@@ -120,6 +134,14 @@ int MTGAttackRule::receiveEvent(WEvent *e){
|
||||
|
||||
int MTGAttackRule::reactToClick(MTGCardInstance * card){
|
||||
if (!isReactingToClick(card)) return 0;
|
||||
|
||||
//Graphically select the next card that can attack
|
||||
if(!card->isAttacker()){
|
||||
CardSelector * cs = game->mLayers->cs;
|
||||
cs->Limit(this,CardSelector::playZone);
|
||||
cs->CheckUserInput(PSP_CTRL_RIGHT);
|
||||
cs->Limit(NULL,CardSelector::playZone);
|
||||
}
|
||||
card->toggleAttacker();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user