-Issue 31 fixed. Land and tokens don't use the stack anymore. Taking control of a card in opponent's battlefield doesn't trigger "spell cast" triggers either
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-09-22 14:45:01 +00:00
parent 7f396b13b4
commit f5ddbd2396
11 changed files with 53 additions and 30 deletions
+8 -4
View File
@@ -110,6 +110,7 @@ Spell::Spell(MTGCardInstance * _source): Interruptible(0){
type = ACTION_SPELL;
cost = NEW ManaCost();
tc = NULL;
from = _source->getCurrentZone();
}
@@ -117,6 +118,7 @@ Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _
source = _source;
mHeight = 40;
type = ACTION_SPELL;
from = _source->getCurrentZone();
}
@@ -132,11 +134,13 @@ Spell::~Spell(){
int Spell::resolve(){
GameObserver * game = GameObserver::GetInstance();
//TODO Remove target if it's not targettable anymore
while (source->next){
/* while (source->next){
source = source->next;
}
if (!source->hasType("instant") && !source->hasType("sorcery")){
source = source->controller()->game->putInPlay(source);
}*/
if (!source->hasType("instant") && !source->hasType("sorcery")){
Player * p = source->controller();
source = p->game->putInZone(source,from,p->game->battlefield);
from = p->game->battlefield;
}
+3 -3
View File
@@ -748,7 +748,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
card->target = spell->getNextCardTarget();
if (card->target && !spell->tc->canTarget(card->target)){
MTGPlayerCards * zones = card->controller()->game;
zones->putInGraveyard(card);
zones->putInZone(card,spell->from,card->owner->game->graveyard);
return; //fizzle
}
}
@@ -1523,13 +1523,13 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
{
Player * player = spell->getNextPlayerTarget();
if (player->life < (INT_MAX / 4) ) player->life += player->life;
zones->putInZone(card,zones->stack,zones->library);
zones->putInZone(card,spell->from,zones->library);
zones->library->shuffle();
break;
}
case 135262:// Beacon of Destruction & unrest
{
zones->putInZone(card,zones->stack,zones->library);
zones->putInZone(card,spell->from,zones->library);
zones->library->shuffle();
break;
}
+3 -2
View File
@@ -159,8 +159,8 @@ MTGGameZone * MTGCardInstance::getCurrentZone(){
GameObserver * game = GameObserver::GetInstance();
for (int i = 0; i < 2; i++){
MTGPlayerCards * g = game->players[i]->game;
MTGGameZone * zones[] = {g->inPlay,g->graveyard,g->hand, g->library};
for (int k = 0; k < 4; k++){
MTGGameZone * zones[] = {g->inPlay,g->graveyard,g->hand, g->library, g->stack, g->temp};
for (int k = 0; k < 6; k++){
MTGGameZone * zone = zones[k];
if (zone->hasCard(this)) return zone;
}
@@ -299,6 +299,7 @@ Player * MTGCardInstance::controller(){
if (game->players[i]->game->graveyard->hasCard(this)) return game->players[i];
if (game->players[i]->game->hand->hasCard(this)) return game->players[i];
if (game->players[i]->game->library->hasCard(this)) return game->players[i];
if (game->players[i]->game->temp->hasCard(this)) return game->players[i];
}
return lastController;
}
+7 -5
View File
@@ -49,6 +49,7 @@ MTGPlayerCards::~MTGPlayerCards(){
SAFE_DELETE(stack);
SAFE_DELETE(removedFromGame);
SAFE_DELETE(garbage);
SAFE_DELETE(temp);
}
void MTGPlayerCards::setOwner(Player * player){
@@ -59,6 +60,7 @@ void MTGPlayerCards::setOwner(Player * player){
removedFromGame->setOwner(player);
stack->setOwner(player);
garbage->setOwner(player);
temp->setOwner(player);
}
void MTGPlayerCards::initGame(int shuffle, int draw){
@@ -71,13 +73,12 @@ void MTGPlayerCards::initGame(int shuffle, int draw){
}
void MTGPlayerCards::drawFromLibrary(){
MTGCardInstance * drownCard = library->draw();
if(drownCard){
hand->addCard(drownCard);
MTGCardInstance * drawnCard = library->draw();
if(drawnCard){
hand->addCard(drawnCard);
GameObserver *g = GameObserver::GetInstance();
WEvent * e = NEW WEventZoneChange(drownCard,library,hand);
WEvent * e = NEW WEventZoneChange(drawnCard,library,hand);
g->receiveEvent(e);
//delete e;
}
}
@@ -92,6 +93,7 @@ void MTGPlayerCards::init(){
removedFromGame = NEW MTGRemovedFromGame();
exile = removedFromGame;
garbage = NEW MTGGameZone();
temp = NEW MTGGameZone();
}
+7 -7
View File
@@ -54,7 +54,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
delete previousManaPool;
if (card->hasType("land")){
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack);
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->temp);
Spell * spell = NEW Spell(copy);
spell->resolve();
delete spellCost;
@@ -62,13 +62,13 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
player->canPutLandsIntoPlay--;
}else{
Spell * spell = NULL;
if (game->targetChooser){
spell = game->mLayers->stackLayer()->addSpell(card,game->targetChooser, spellCost);
game->targetChooser = NULL;
}else
spell = game->mLayers->stackLayer()->addSpell(card,NULL, spellCost);
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack);
spell->source = copy;
if (game->targetChooser){
spell = game->mLayers->stackLayer()->addSpell(copy,game->targetChooser, spellCost);
game->targetChooser = NULL;
}else{
spell = game->mLayers->stackLayer()->addSpell(copy,NULL, spellCost);
}
}
return 1;
}