- fixed issue 267 (hope charm)
- fixed an issue in which the core Rules where not correctly loaded for the test suite
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-01-10 03:32:18 +00:00
parent 0892516ef4
commit b3dc2bcda2
5 changed files with 37 additions and 57 deletions

View File

@@ -242,6 +242,7 @@ harpoon_sniper.txt
hellfire.txt
helm_of_kaldra1.txt
holy_day_i226.txt
hope_charm_i267.txt
hopping_automaton_i232.txt
horned_helm.txt
howl_from_beyond.txt

View File

@@ -899,6 +899,11 @@ class ABasicAbilityModifierUntilEOT:public TargetAbility{
return 1;
}
int addToGame(){
resolve();
return ActivatedAbility::addToGame();
}
const char * getMenuText(){
return Constants::MTGBasicAbilities[ability];
}
@@ -973,6 +978,11 @@ class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{
ability = NEW AInstantBasicAbilityModifierUntilEOT(_id,_source,_target,_ability, _value);
}
int isReactingToClick(MTGCardInstance * card, ManaCost * cost = NULL){
//The upper level "GenericTargetAbility" takes care of the click so we always return 0 here
return 0;
}
int resolve(){
MTGAbility * a = ability->clone();
a->target = target;
@@ -980,6 +990,11 @@ class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{
return 1;
}
int addToGame(){
resolve();
return ActivatedAbility::addToGame();
}
const char * getMenuText(){
return ability->getMenuText();
}
@@ -1266,58 +1281,6 @@ class APowerToughnessModifier: public MTGAbility{
};
//Alteration of Power and Toughness until end of turn (TargetAbility)
// Gives +n/+m until end of turn to any card that's a target
class ATargetterPowerToughnessModifierUntilEOT: public TargetAbility{
public:
MTGCardInstance * mTargets[50];
int nbTargets;
WParsedPT * wppt;
ATargetterPowerToughnessModifierUntilEOT(int _id, MTGCardInstance * _source, WParsedPT * wppt, ManaCost * _cost, TargetChooser * _tc = NULL, int doTap=1):TargetAbility(_id,_source,_tc,_cost,0,doTap),wppt(wppt){
if (!tc) tc = NEW CreatureTargetChooser(_source);
nbTargets = 0;
}
void Update(float dt){
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP){
for (int i = 0; i < nbTargets; i++){
MTGCardInstance * mTarget = mTargets[i];
if(mTarget){
mTarget->power-=wppt->power.getValue();
mTarget->addToToughness(-wppt->toughness.getValue());
}
}
nbTargets = 0;
}
TargetAbility::Update(dt);
}
int resolve(){
MTGCardInstance * mTarget = tc->getNextCardTarget();
if (mTarget){
mTargets[nbTargets] = mTarget;
mTarget->power+= wppt->power.getValue();
mTarget->addToToughness(wppt->toughness.getValue());
nbTargets++;
}
return 1;
}
ATargetterPowerToughnessModifierUntilEOT * clone() const{
ATargetterPowerToughnessModifierUntilEOT * a = NEW ATargetterPowerToughnessModifierUntilEOT(*this);
a->wppt = NEW WParsedPT(*(a->wppt));
a->isClone = 1;
return a;
}
~ATargetterPowerToughnessModifierUntilEOT(){
delete(wppt);
}
};
//Alteration of Power and toughness until end of turn (instant)
class AInstantPowerToughnessModifierUntilEOT: public InstantAbility{
public:
@@ -1369,6 +1332,11 @@ class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{
ability = NEW AInstantPowerToughnessModifierUntilEOT(id,_source,_target,wppt);
}
int isReactingToClick(MTGCardInstance * card, ManaCost * cost = NULL){
//The upper level "GenericTargetAbility" takes care of the click so we always return 0 here
return 0;
}
void Update(float dt){
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_AFTER_EOT){
counters = 0;
@@ -1384,10 +1352,10 @@ class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{
return ability->getMenuText();
}
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
/* int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
if (!ActivatedAbility::isReactingToClick(card,mana)) return 0;
return (!maxcounters || (counters < maxcounters));
}
}*/
int resolve(){
MTGAbility * a = ability->clone();
@@ -1397,6 +1365,11 @@ class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{
return 1;
}
int addToGame(){
resolve();
return ActivatedAbility::addToGame();
}
APowerToughnessModifierUntilEndOfTurn * clone() const{
APowerToughnessModifierUntilEndOfTurn * a = NEW APowerToughnessModifierUntilEndOfTurn(*this);
a->isClone = 1;
@@ -3355,6 +3328,11 @@ class ADragonWhelp: public APowerToughnessModifierUntilEndOfTurn{
cost->add(Constants::MTG_COLOR_RED, 1);
}
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
if (!ActivatedAbility::isReactingToClick(card,mana)) return 0;
return (!maxcounters || (counters < maxcounters));
}
void Update(float dt){
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_AFTER_EOT && counters > 3){
source->controller()->game->putInGraveyard(source);

View File

@@ -232,9 +232,8 @@ void GameStateDuel::Update(float dt)
#ifdef TESTSUITE
else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
if (testSuite && testSuite->loadNext()){
loadTestSuitePlayers();
rules = NEW Rules("testsuite.txt");
loadTestSuitePlayers();
mGamePhase = DUEL_STATE_PLAY;
testSuite->initGame();
char buf[4096];

View File

@@ -1840,7 +1840,9 @@ int TargetAbility::resolve(){
Targetable * t = tc->getNextTarget();
if (t && ability){
ability->target = t;
return ability->resolve();
if (ability->oneShot) return ability->resolve();
MTGAbility * a = ability->clone();
return a->addToGame();
}
return 0;
}