- Code cleanup
- fix issue 142 . This will lead to other issues for some cards. These issues can be fixed by using targetcontroller/controller...etc
- Added a few cards
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-11-21 09:40:14 +00:00
parent da9a82cff4
commit f924546dcc
16 changed files with 99 additions and 116 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
text=Target creature gets -1/-1 until end of turn. Draw a card. text=Target creature gets -1/-1 until end of turn. Draw a card.
target=creature target=creature
auto=-1/-1 auto=-1/-1
auto=draw:1 auto=draw:1 controller
id=135206 id=135206
name=Afflict name=Afflict
rarity=C rarity=C
+1 -1
View File
@@ -104,7 +104,7 @@ toughness=3
text={X}{W}, {T}: Ballista Squad deals X damage to target attacking or blocking creature. text={X}{W}, {T}: Ballista Squad deals X damage to target attacking or blocking creature.
id=129477 id=129477
name=Ballista Squad name=Ballista Squad
auto={X}{W}{T}:damage:x target(creature[attacking,blocking]) auto={X}{W}{T}:damage:x target(creature[attacking;blocking])
rarity=U rarity=U
color=White color=White
type=Creature type=Creature
+1
View File
@@ -265,6 +265,7 @@ id=179614
name=Morbid Bloom name=Morbid Bloom
target=creature|graveyard target=creature|graveyard
auto=moveto(exile) auto=moveto(exile)
auto=token(Saproling,Creature Saproling,1/1,green)*t
rarity=U rarity=U
mana={4}{B}{G} mana={4}{B}{G}
type=Sorcery type=Sorcery
+1
View File
@@ -1490,6 +1490,7 @@ text=Destroy target Wall. It can't be regenerated. Word of Blasting deals damage
id=2660 id=2660
target=Wall target=Wall
auto=bury auto=bury
auto=damage:manacost targetcontroller
name=Word of Blasting name=Word of Blasting
rarity=U rarity=U
mana={1}{R} mana={1}{R}
+2
View File
@@ -125,6 +125,8 @@ toughness=5
text=Destroy target artifact. It can't be regenerated. Put X 1/1 green Saproling creature tokens onto the battlefield, where X is its converted mana cost. text=Destroy target artifact. It can't be regenerated. Put X 1/1 green Saproling creature tokens onto the battlefield, where X is its converted mana cost.
id=23195 id=23195
target=artifact target=artifact
auto=bury
auto=token(Saproling,Creature Saproling,1/1,green)*manacost
name=Artifact Mutation name=Artifact Mutation
rarity=R rarity=R
type=Instant type=Instant
+2
View File
@@ -285,6 +285,8 @@ text=Destroy target artifact. You gain life equal to its converted mana cost.
id=1607 id=1607
target=artifact target=artifact
name=Divine Offering name=Divine Offering
auto=destroy
auto=life:manacost controller
rarity=C rarity=C
type=Instant type=Instant
mana={1}{W} mana={1}{W}
+1 -1
View File
@@ -30,7 +30,7 @@ id=29740
name=Afflict name=Afflict
target=Creature target=Creature
auto=-1/-1 auto=-1/-1
auto=draw:1 auto=draw:1 controller
rarity=C rarity=C
mana={2}{B} mana={2}{B}
type=Instant type=Instant
+5
View File
@@ -436,6 +436,7 @@ subtype=Aura
text=Destroy target artifact. It can't be regenerated. That artifact's controller gains life equal to its converted mana cost. text=Destroy target artifact. It can't be regenerated. That artifact's controller gains life equal to its converted mana cost.
target=artifact target=artifact
auto=bury auto=bury
auto=life:manacost targetcontroller
id=1240 id=1240
name=Crumble name=Crumble
rarity=U rarity=U
@@ -656,6 +657,8 @@ subtype=Aura
[/card] [/card]
[card] [card]
text=Earthquake deals X damage to each creature without flying and each player. text=Earthquake deals X damage to each creature without flying and each player.
auto=damage:X all(player)
auto=damage:X all(creature[-flying])
id=1289 id=1289
name=Earthquake name=Earthquake
rarity=R rarity=R
@@ -1052,6 +1055,8 @@ id=1251
name=Hurricane name=Hurricane
rarity=U rarity=U
mana={X}{G} mana={X}{G}
auto=damage:X all(player)
auto=damage:X all(creature[flying])
type=Sorcery type=Sorcery
[/card] [/card]
[card] [card]
+2
View File
@@ -116,6 +116,7 @@ counterspell3.txt
counterspell4.txt counterspell4.txt
creature_bond.txt creature_bond.txt
crimson_kobolds.txt crimson_kobolds.txt
crumble.txt
crystal_rod_i172.txt crystal_rod_i172.txt
dauntless_escort.txt dauntless_escort.txt
dauthi_embrace.txt dauthi_embrace.txt
@@ -170,6 +171,7 @@ harpoon_sniper.txt
hellfire.txt hellfire.txt
howl_from_beyond.txt howl_from_beyond.txt
howl_of_the_night_pack.txt howl_of_the_night_pack.txt
hurricane.txt
hyalopterous_lemure.txt hyalopterous_lemure.txt
hymn_of_rebirth.txt hymn_of_rebirth.txt
hypnotic_specter.txt hypnotic_specter.txt
+19
View File
@@ -0,0 +1,19 @@
#Test Crumble life
[INIT]
FIRSTMAIN
[PLAYER1]
hand:crumble
manapool:{G}
[PLAYER2]
inplay:colossus of Sardia
[DO]
crumble
colossus of sardia
[ASSERT]
FIRSTMAIN
[PLAYER1]
graveyard:crumble
[PLAYER2]
graveyard:colossus of sardia
life:29
[END]
+21
View File
@@ -0,0 +1,21 @@
#Test Hurricane
[INIT]
FIRSTMAIN
[PLAYER1]
hand:hurricane
inplay:grizzly bears,air elemental
manapool:{4}{G}
[PLAYER2]
inplay:serra angel
[DO]
hurricane
[ASSERT]
FIRSTMAIN
[PLAYER1]
life:16
inplay:grizzly bears
graveyard:air elemental,hurricane
[PLAYER2]
graveyard:serra angel
life:16
[END]
+20 -11
View File
@@ -182,9 +182,9 @@ public:
return 1; return 1;
} }
~ TrDamaged (){ ~TrDamaged (){
SAFE_DELETE(tc); SAFE_DELETE(tc);
SAFE_DELETE(fromTc); SAFE_DELETE(fromTc);
} }
TrDamaged * clone() const{ TrDamaged * clone() const{
@@ -502,8 +502,8 @@ class AADrawer:public ActivatedAbilityTP{
/*Gives life to target controller*/ /*Gives life to target controller*/
class AALifer:public ActivatedAbilityTP{ class AALifer:public ActivatedAbilityTP{
public: public:
int life; WParsedInt *life;
AALifer(int _id, MTGCardInstance * card, Targetable * _target, int life, ManaCost * _cost = NULL, int _tap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id, card,_target,_cost,_tap,who),life(life){ AALifer(int _id, MTGCardInstance * card, Targetable * _target, WParsedInt * life, ManaCost * _cost = NULL, int _tap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id, card,_target,_cost,_tap,who),life(life){
} }
int resolve(){ int resolve(){
@@ -512,7 +512,7 @@ class AALifer:public ActivatedAbilityTP{
if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE){ if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE){
_target = ((MTGCardInstance *)_target)->controller(); _target = ((MTGCardInstance *)_target)->controller();
} }
_target->life+=life; _target->life+=life->getValue();
} }
return 1; return 1;
} }
@@ -523,10 +523,15 @@ class AALifer:public ActivatedAbilityTP{
AALifer * clone() const{ AALifer * clone() const{
AALifer * a = NEW AALifer(*this); AALifer * a = NEW AALifer(*this);
a->life = NEW WParsedInt(*(a->life));
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
~AALifer(){
SAFE_DELETE(life);
}
}; };
@@ -1767,15 +1772,15 @@ class AForeach:public ListMaintainerAbility{
class AADamager:public ActivatedAbilityTP{ class AADamager:public ActivatedAbilityTP{
public: public:
int damage; WParsedInt * damage;
AADamager(int _id, MTGCardInstance * _source, Targetable * _target, int _damage = 0, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),damage(_damage){ AADamager(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * damage, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),damage(damage){
aType = MTGAbility::DAMAGER; aType = MTGAbility::DAMAGER;
} }
int resolve(){ int resolve(){
if(target){ if(target){
Damageable * _target = (Damageable *) getTarget(); Damageable * _target = (Damageable *) getTarget();
game->mLayers->stackLayer()->addDamage(source,_target, damage); game->mLayers->stackLayer()->addDamage(source,_target, damage->getValue());
game->mLayers->stackLayer()->resolve(); game->mLayers->stackLayer()->resolve();
return 1; return 1;
} }
@@ -1786,21 +1791,25 @@ AADamager(int _id, MTGCardInstance * _source, Targetable * _target, int _damage
return "Damage"; return "Damage";
} }
AADamager * clone() const{ AADamager * clone() const{
AADamager * a = NEW AADamager(*this); AADamager * a = NEW AADamager(*this);
a->damage = NEW WParsedInt(*(a->damage));
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
~AADamager(){
SAFE_DELETE(damage);
}
}; };
/* Standard Damager, can choose a NEW target each time the price is paid */ /* Standard Damager, can choose a NEW target each time the price is paid */
class TADamager:public TargetAbility{ class TADamager:public TargetAbility{
public: public:
int damage;
TADamager(int id, MTGCardInstance * card, ManaCost * _cost, int _damage, TargetChooser * _tc = NULL, int _tap = 0):TargetAbility(id,card, _tc, _cost,0,_tap),damage(_damage){ TADamager(int id, MTGCardInstance * card, ManaCost * _cost, WParsedInt * damage, TargetChooser * _tc = NULL, int _tap = 0):TargetAbility(id,card, _tc, _cost,0,_tap){
if (!tc) tc = NEW DamageableTargetChooser(card); if (!tc) tc = NEW DamageableTargetChooser(card);
ability = NEW AADamager(id,card,NULL,damage); ability = NEW AADamager(id,card,NULL,damage);
} }
+2 -1
View File
@@ -101,8 +101,9 @@ class Constants
INTIMIDATE = 43, INTIMIDATE = 43,
DEATHTOUCH = 44, DEATHTOUCH = 44,
HORSEMANSHIP = 45, HORSEMANSHIP = 45,
CANTREGENERATE = 46,
NB_BASIC_ABILITIES = 46, NB_BASIC_ABILITIES = 47,
RARITY_M = 'M', RARITY_M = 'M',
+2 -2
View File
@@ -178,10 +178,10 @@ int AIAction::getEfficiency(){
AADamager * aad = (AADamager *) a; AADamager * aad = (AADamager *) a;
if ( p == target->controller()){ if ( p == target->controller()){
efficiency = 0; efficiency = 0;
}else if (aad->damage >= target->toughness){ }else if (aad->damage->getValue() >= target->toughness){
efficiency = 100; efficiency = 100;
}else if (target->toughness){ }else if (target->toughness){
efficiency = (50 * aad->damage) / target->toughness; efficiency = (50 * aad->damage->getValue()) / target->toughness;
}else{ }else{
efficiency = 0; efficiency = 0;
} }
+17 -90
View File
@@ -489,16 +489,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
unsigned int start = s.find(":",found); unsigned int start = s.find(":",found);
if (start == string::npos) start = s.find(" ",found); if (start == string::npos) start = s.find(" ",found);
unsigned int end = s.find(" ",start); unsigned int end = s.find(" ",start);
int damage; string d;
if (end != string::npos){ if (end != string::npos){
damage = atoi(s.substr(start+1,end-start-1).c_str()); d = s.substr(start+1,end-start-1);
}else{ }else{
damage = atoi(s.substr(start+1).c_str()); d = s.substr(start+1);
} }
WParsedInt * damage = NEW WParsedInt(d,spell,card);
Damageable * d = NULL; Damageable * t = NULL;
if (spell) d = spell->getNextDamageableTarget(); if (spell) t = spell->getNextDamageableTarget();
MTGAbility * a = NEW AADamager(id,card,d, damage, NULL, 0, who); MTGAbility * a = NEW AADamager(id,card,t, damage, NULL, 0, who);
a->oneShot = 1; a->oneShot = 1;
return a; return a;
} }
@@ -509,15 +509,15 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (found != string::npos){ if (found != string::npos){
unsigned int start = found+4; unsigned int start = found+4;
unsigned int end = s.find(" ",start); unsigned int end = s.find(" ",start);
int life; string life_s;
if (end != string::npos){ if (end != string::npos){
life = atoi(s.substr(start+1,end-start-1).c_str()); life_s = s.substr(start+1,end-start-1);
}else{ }else{
life = atoi(s.substr(start+1).c_str()); life_s = s.substr(start+1);
} }
WParsedInt * life = NEW WParsedInt(life_s,spell,card);
Damageable * d = NULL; Damageable * d = NULL;
if (spell) d = spell->getNextPlayerTarget(); if (spell) d = spell->getNextDamageableTarget();
MTGAbility * a = NEW AALifer(id,card,d,life,NULL,0,who); MTGAbility * a = NEW AALifer(id,card,d,life,NULL,0,who);
a->oneShot = 1; a->oneShot = 1;
return a; return a;
@@ -536,7 +536,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
} }
Targetable * t = NULL; Targetable * t = NULL;
if (spell) t = spell->getNextPlayerTarget(); if (spell) t = spell->getNextTarget();
MTGAbility * a = NEW AADrawer(id,card,t,NULL,nbcards,0,who); MTGAbility * a = NEW AADrawer(id,card,t,NULL,nbcards,0,who);
a->oneShot = 1; a->oneShot = 1;
return a; return a;
@@ -555,7 +555,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
} }
Targetable * t = NULL; Targetable * t = NULL;
if (spell) t = spell->getNextPlayerTarget(); if (spell) t = spell->getNextTarget();
MTGAbility * a = NEW AADepleter(id,card,t,nbcards,NULL,0,who); MTGAbility * a = NEW AADepleter(id,card,t,nbcards,NULL,0,who);
a->oneShot = 1; a->oneShot = 1;
return a; return a;
@@ -565,7 +565,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
found = s.find("shuffle"); found = s.find("shuffle");
if (found != string::npos){ if (found != string::npos){
Targetable * t = NULL; Targetable * t = NULL;
if (spell) t = spell->getNextPlayerTarget(); if (spell) t = spell->getNextTarget();
MTGAbility * a = NEW AAShuffle(id,card,t,NULL,0,who); MTGAbility * a = NEW AAShuffle(id,card,t,NULL,0,who);
a->oneShot = 1; a->oneShot = 1;
return a; return a;
@@ -677,10 +677,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
delete wppt; delete wppt;
} }
//Mana Producer //Mana Producer
found = s.find("add"); found = s.find("add");
if (found != string::npos){ if (found != string::npos){
@@ -692,7 +688,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a; return a;
} }
//Gain/loose Ability //Gain/loose Ability
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){ for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
found = s.find(Constants::MTGBasicAbilities[j]); found = s.find(Constants::MTGBasicAbilities[j]);
@@ -808,6 +803,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
badAbilities[Constants::DEFENDER] = true; badAbilities[Constants::DEFENDER] = true;
badAbilities[Constants::DOESNOTUNTAP] = true; badAbilities[Constants::DOESNOTUNTAP] = true;
badAbilities[Constants::MUSTATTACK] = true; badAbilities[Constants::MUSTATTACK] = true;
badAbilities[Constants::CANTREGENERATE] = true;
if (AInstantBasicAbilityModifierUntilEOT * abi = dynamic_cast<AInstantBasicAbilityModifierUntilEOT *>(a)) { if (AInstantBasicAbilityModifierUntilEOT * abi = dynamic_cast<AInstantBasicAbilityModifierUntilEOT *>(a)) {
int result = badAbilities[abi->ability] ? BAKA_EFFECT_BAD : BAKA_EFFECT_GOOD; int result = badAbilities[abi->ability] ? BAKA_EFFECT_BAD : BAKA_EFFECT_GOOD;
@@ -1296,26 +1292,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->addObserver(NEW AAspectOfWolf(_id, card, card->target)); game->addObserver(NEW AAspectOfWolf(_id, card, card->target));
break; break;
} }
case 1240: //Crumble case 1262: //Regeneration
{
card->target->controller()->life+= card->target->getManaCost()->getConvertedCost();
break;
}
case 1251: //Hurricane
{
int x = spell->cost->getConvertedCost() - 1;
for (int i = 0; i < 2 ; i++){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (current->basicAbilities[Constants::FLYING] && current->isCreature()){
game->mLayers->stackLayer()->addDamage(card, current, x);
}
}
}
break;
}
case 1262: //Regeneration
{ {
int cost[] = {Constants::MTG_COLOR_GREEN, 1}; int cost[] = {Constants::MTG_COLOR_GREEN, 1};
game->addObserver(NEW AStandardRegenerate(_id,card,card->target,NEW ManaCost(cost,1))); game->addObserver(NEW AStandardRegenerate(_id,card,card->target,NEW ManaCost(cost,1)));
@@ -1365,20 +1342,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->addObserver(NEW AEarthbind(_id, card, card->target)); game->addObserver(NEW AEarthbind(_id, card, card->target));
break; break;
} }
case 1289: //earthquake
{
int x = computeX(spell,card);
for (int i = 0; i < 2 ; i++){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (!current->basicAbilities[Constants::FLYING] && current->isCreature()){
game->mLayers->stackLayer()->addDamage(card, current, x);
}
}
}
break;
}
case 1344: //Eye for an Eye case 1344: //Eye for an Eye
{ {
Damage * damage = spell->getNextDamageTarget(); Damage * damage = spell->getNextDamageTarget();
@@ -1450,12 +1413,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->addObserver(NEW AConvertLandToCreatures(id, card, "land")); game->addObserver(NEW AConvertLandToCreatures(id, card, "land"));
break; break;
} }
case 1607: //Divine Offering
{
card->target->controller()->game->putInGraveyard(card->target);
game->currentlyActing()->life+= card->target->getManaCost()->getConvertedCost();
break;
}
case 1480: //Energy Tap case 1480: //Energy Tap
{ {
card->target->tap(); card->target->tap();
@@ -1481,11 +1438,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
//Addons ICE-AGE Cards //Addons ICE-AGE Cards
case 2660: //Word of Blasting
{
card->target->controller()->life-= card->target->getManaCost()->getConvertedCost();
break;
}
case 2474: //Minion of Leshrac case 2474: //Minion of Leshrac
{ {
game->addObserver(NEW AMinionofLeshrac( _id, card)); game->addObserver(NEW AMinionofLeshrac( _id, card));
@@ -1631,19 +1583,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
} }
// --- addon Invasion---
case 23195: //Artifact Mutation
{
card->target->controller()->game->putInGraveyard(card->target);
int x = card->target->getManaCost()->getConvertedCost();
ATokenCreator * tok = NEW ATokenCreator(id,card,NEW ManaCost(),"Saproling","creature Saproling",1,1,"green",0);
for (int i=0; i < x; i++){
tok->resolve();
}
delete(tok);
break;
}
// --- addon Ravnica--- // --- addon Ravnica---
case 89114: //Psychic Drain case 89114: //Psychic Drain
@@ -1659,18 +1598,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
break; break;
} }
// --- addon ARB---
case 179614: // Morbid Bloom
{
int x = card->target->toughness;
ATokenCreator * tok = NEW ATokenCreator(id,card,NEW ManaCost(),"Saproling","creature Saproling",1,1,"green",0);
for (int i=0; i < x; i++){
tok->resolve();
}
delete(tok);
break;
}
default: default:
break; break;
} }
+2 -9
View File
@@ -231,11 +231,13 @@ int MTGCardInstance::isTapped(){
} }
int MTGCardInstance::regenerate(){ int MTGCardInstance::regenerate(){
if (has(Constants::CANTREGENERATE)) return 0;
return ++regenerateTokens; return ++regenerateTokens;
} }
int MTGCardInstance::triggerRegenerate(){ int MTGCardInstance::triggerRegenerate(){
if (! regenerateTokens) return 0; if (! regenerateTokens) return 0;
if (has(Constants::CANTREGENERATE)) return 0;
regenerateTokens--; regenerateTokens--;
tap(); tap();
life = toughness; life = toughness;
@@ -401,18 +403,9 @@ int MTGCardInstance::toggleAttacker(){
setAttacker(1); setAttacker(1);
return 1; return 1;
}else{ }else{
//Banding needs to be debugged...
/*MTGCardInstance * bandingPartner = getNextPartner();
if (bandingPartner){
if (banding) unband();
if (!bandingPartner->banding) bandingPartner->banding = bandingPartner;
banding = bandingPartner->banding;
return 1;
}else{*/
untap(); untap();
setAttacker(0); setAttacker(0);
return 1; return 1;
//}
} }
return 0; return 0;
} }