- fix issue 111
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-10-24 13:06:02 +00:00
parent fb52ea5452
commit 60845ee3b3
3 changed files with 24 additions and 5 deletions

View File

@@ -82,6 +82,9 @@ class MTGCardInstance: public MTGCard, public Damageable {
int toggleDefenser(MTGCardInstance * opponent);
int raiseBlockerRankOrder(MTGCardInstance * blocker);
int bringBlockerToFrontOfOrder(MTGCardInstance * blocker);
//Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise
int getDefenserRank(MTGCardInstance * blocker);
int toggleAttacker();
MTGCardInstance * banding; // If belongs to a band when attacking
int canBlock();
@@ -141,8 +144,8 @@ class MTGCardInstance: public MTGCard, public Damageable {
ostream& toString(ostream&) const;
static MTGCardInstance AnyCard;
static MTGCardInstance NoCard;
static MTGCardInstance AnyCard;
static MTGCardInstance NoCard;
};

View File

@@ -84,9 +84,14 @@ void GuiPlay::BattleField::EnstackAttacker(CardView* card)
void GuiPlay::BattleField::EnstackBlocker(CardView* card)
{
GameObserver* game = GameObserver::GetInstance();
if (card->card && card->card->defenser && card->card->defenser->view)
card->x = card->card->defenser->view->x;
card->y = baseY + (game->players[0] == card->card->controller() ? 20 + y : -20 - y);
MTGCardInstance * c = card->card;
if (!c) return;
int offset = 0;
if (c->defenser && c->defenser->view){
offset = c->defenser->getDefenserRank(c);
card->x = c->defenser->view->x + 5 * offset;
}
card->y = baseY + (game->players[0] == card->card->controller() ? 20 + y + 6 * offset : -20 - y + 6 * offset);
}
void GuiPlay::BattleField::Update(float dt)
{

View File

@@ -512,6 +512,15 @@ int MTGCardInstance::bringBlockerToFrontOfOrder(MTGCardInstance * blocker){
return 1;
}
int MTGCardInstance::getDefenserRank(MTGCardInstance * blocker){
int result = 0;
for(list<MTGCardInstance *>::iterator it1 = blockers.begin(); it1 != blockers.end(); ++it1){
result++;
if ((*it1) == blocker) return result;
}
return 0;
};
int MTGCardInstance::removeBlocker(MTGCardInstance * blocker){
blockers.remove(blocker);
if (!blockers.size()) blocked = false;
@@ -558,6 +567,8 @@ MTGCardInstance * MTGCardInstance::getNextOpponent(MTGCardInstance * previous){
return NULL;
}
int MTGCardInstance::setDefenser(MTGCardInstance * opponent){
GameObserver * g = GameObserver::GetInstance();
if (defenser) {