Erwan
- fix PSP Compilation issue - Stillmoon cavalier (and other "until end of turn" activated abilities) bug fix - attempt at fixing multi abilities that work "only from time to time"
This commit is contained in:
@@ -137,6 +137,7 @@ spoils_of_evil.txt
|
|||||||
stasis.txt
|
stasis.txt
|
||||||
steelclad_serpent1.txt
|
steelclad_serpent1.txt
|
||||||
steelclad_serpent2.txt
|
steelclad_serpent2.txt
|
||||||
|
stillmoon_cavalier.txt
|
||||||
sword_to_plowshares.txt
|
sword_to_plowshares.txt
|
||||||
telekinetic_sliver.txt
|
telekinetic_sliver.txt
|
||||||
terror.txt
|
terror.txt
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#Bug: Stillmoon cavalier's effects don't wear off at the end of the turn
|
||||||
|
[INIT]
|
||||||
|
FIRSTMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:Stillmoon Cavalier
|
||||||
|
manapool:{B}
|
||||||
|
[PLAYER2]
|
||||||
|
inplay:grizzly bears,raging goblin
|
||||||
|
[DO]
|
||||||
|
Stillmoon Cavalier
|
||||||
|
choice 1
|
||||||
|
next
|
||||||
|
#combat begins
|
||||||
|
next
|
||||||
|
#attackers
|
||||||
|
Stillmoon Cavalier
|
||||||
|
next
|
||||||
|
#blockers
|
||||||
|
Grizzly Bears
|
||||||
|
next
|
||||||
|
#damage
|
||||||
|
next
|
||||||
|
#end
|
||||||
|
eot
|
||||||
|
eot
|
||||||
|
#untap
|
||||||
|
next
|
||||||
|
#upkeep
|
||||||
|
next
|
||||||
|
#draw
|
||||||
|
next
|
||||||
|
#firstmain
|
||||||
|
next
|
||||||
|
#combat begins
|
||||||
|
next
|
||||||
|
#attackers
|
||||||
|
Stillmoon Cavalier
|
||||||
|
next
|
||||||
|
#blockers
|
||||||
|
raging goblin
|
||||||
|
next
|
||||||
|
#damage
|
||||||
|
next
|
||||||
|
#end
|
||||||
|
[ASSERT]
|
||||||
|
COMBATEND
|
||||||
|
[PLAYER1]
|
||||||
|
graveyard:Stillmoon Cavalier
|
||||||
|
manapool:{0}
|
||||||
|
[PLAYER2]
|
||||||
|
graveyard:grizzly bears,raging goblin
|
||||||
|
[END]
|
||||||
@@ -29,7 +29,7 @@ class TrCardAddedToZone:public TriggeredAbility{
|
|||||||
public:
|
public:
|
||||||
TargetChooser * toTc;
|
TargetChooser * toTc;
|
||||||
TargetZoneChooser * fromTc;
|
TargetZoneChooser * fromTc;
|
||||||
TrCardAddedToZone::TrCardAddedToZone(int id,MTGCardInstance * source, TargetChooser * toTc, TargetZoneChooser * fromTc = NULL):TriggeredAbility(id,source), fromTc(fromTc),toTc(toTc){
|
TrCardAddedToZone(int id,MTGCardInstance * source, TargetChooser * toTc, TargetZoneChooser * fromTc = NULL):TriggeredAbility(id,source), fromTc(fromTc),toTc(toTc){
|
||||||
}
|
}
|
||||||
|
|
||||||
int resolve(){
|
int resolve(){
|
||||||
@@ -174,8 +174,10 @@ public:
|
|||||||
int resolve(){
|
int resolve(){
|
||||||
vector<int>::size_type sz = abilities.size();
|
vector<int>::size_type sz = abilities.size();
|
||||||
for (unsigned int i = 0; i < sz; i++){
|
for (unsigned int i = 0; i < sz; i++){
|
||||||
|
Targetable * backup = abilities[i]->target;
|
||||||
if (target && target!= source && abilities[i]->target == abilities[i]->source) abilities[i]->target = target;
|
if (target && target!= source && abilities[i]->target == abilities[i]->source) abilities[i]->target = target;
|
||||||
abilities[i]->resolve();
|
abilities[i]->resolve();
|
||||||
|
abilities[i]->target = backup;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -654,6 +656,10 @@ class AInstantBasicAbilityModifierUntilEOT: public InstantAbility{
|
|||||||
return InstantAbility::addToGame();
|
return InstantAbility::addToGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * getMenuText(){
|
||||||
|
return Constants::MTGBasicAbilities[ability];
|
||||||
|
}
|
||||||
|
|
||||||
int destroy(){
|
int destroy(){
|
||||||
((MTGCardInstance *)target)->basicAbilities[ability] = stateBeforeActivation;
|
((MTGCardInstance *)target)->basicAbilities[ability] = stateBeforeActivation;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -677,40 +683,21 @@ class AInstantBasicAbilityModifierUntilEOT: public InstantAbility{
|
|||||||
//Alteration of Ability until of turn (Aura)
|
//Alteration of Ability until of turn (Aura)
|
||||||
class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{
|
class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{
|
||||||
public:
|
public:
|
||||||
int stateBeforeActivation;
|
AInstantBasicAbilityModifierUntilEOT * ability;
|
||||||
int ability;
|
ABasicAbilityAuraModifierUntilEOT(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _ability, int _value = 1):ActivatedAbility(_id,_source, _cost, 0,0){
|
||||||
int value;
|
|
||||||
ABasicAbilityAuraModifierUntilEOT(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _ability, int _value = 1):ActivatedAbility(_id,_source, _cost, 0,0), ability(_ability), value(_value){
|
|
||||||
target = _target;
|
target = _target;
|
||||||
stateBeforeActivation = _target->basicAbilities[ability];
|
ability = NEW AInstantBasicAbilityModifierUntilEOT(_id,_source,_target,_ability, _value);
|
||||||
}
|
|
||||||
|
|
||||||
void Update(float dt){
|
|
||||||
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP){
|
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
|
||||||
_target->basicAbilities[ability] = stateBeforeActivation;
|
|
||||||
}
|
|
||||||
ActivatedAbility::Update(dt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int resolve(){
|
int resolve(){
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGAbility * a = ability->clone();
|
||||||
stateBeforeActivation = _target->basicAbilities[ability];
|
a->target = target;
|
||||||
_target->basicAbilities[ability] = value;
|
a->addToGame();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * getMenuText(){
|
const char * getMenuText(){
|
||||||
return Constants::MTGBasicAbilities[ability];
|
return ability->getMenuText();
|
||||||
}
|
|
||||||
|
|
||||||
virtual ostream& toString(ostream& out) const
|
|
||||||
{
|
|
||||||
out << "ABasicAbilityAuraModifierUntilEOT ::: stateBeforeActivation : " << stateBeforeActivation
|
|
||||||
<< " ; ability : " << ability
|
|
||||||
<< " ; value : " << value
|
|
||||||
<< " (";
|
|
||||||
return ActivatedAbility::toString(out) << ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ABasicAbilityAuraModifierUntilEOT * clone() const{
|
ABasicAbilityAuraModifierUntilEOT * clone() const{
|
||||||
@@ -719,6 +706,9 @@ class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ABasicAbilityAuraModifierUntilEOT(){
|
||||||
|
if (!isClone) SAFE_DELETE(ability);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -986,62 +976,6 @@ class ATargetterPowerToughnessModifierUntilEOT: public TargetAbility{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Alteration of Power and Toughness until end of turn (Aura)
|
|
||||||
class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{
|
|
||||||
public:
|
|
||||||
int power, toughness;
|
|
||||||
int counters;
|
|
||||||
int maxcounters;
|
|
||||||
APowerToughnessModifierUntilEndOfTurn(int id, MTGCardInstance * _source, MTGCardInstance * _target, int _power, int _toughness, ManaCost * _cost = NULL, int _maxcounters = 0):ActivatedAbility(id,_source,_cost,0,0),power(_power),toughness(_toughness),maxcounters(_maxcounters){
|
|
||||||
counters = 0;
|
|
||||||
target=_target;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update(float dt){
|
|
||||||
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP){
|
|
||||||
while(counters){
|
|
||||||
((MTGCardInstance *)target)->power -= power;
|
|
||||||
((MTGCardInstance *)target)->addToToughness(-toughness);
|
|
||||||
counters--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ActivatedAbility::Update(dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
int fireAbility(){
|
|
||||||
return resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
|
|
||||||
if (!ActivatedAbility::isReactingToClick(card,mana)) return 0;
|
|
||||||
return (!maxcounters || (counters < maxcounters));
|
|
||||||
}
|
|
||||||
|
|
||||||
int resolve(){
|
|
||||||
((MTGCardInstance *)target)->power += power;
|
|
||||||
((MTGCardInstance *)target)->addToToughness(toughness);
|
|
||||||
counters++;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
virtual ostream& toString(ostream& out) const
|
|
||||||
{
|
|
||||||
out << "APowerToughnessModifierUntilEndOfTurn ::: power : " << power
|
|
||||||
<< " ; toughness : " << toughness
|
|
||||||
<< " ; counters : " << counters
|
|
||||||
<< " ; maxcounters : " << maxcounters
|
|
||||||
<< " (";
|
|
||||||
return ActivatedAbility::toString(out) << ")";
|
|
||||||
}
|
|
||||||
APowerToughnessModifierUntilEndOfTurn * clone() const{
|
|
||||||
APowerToughnessModifierUntilEndOfTurn * a = NEW APowerToughnessModifierUntilEndOfTurn(*this);
|
|
||||||
a->isClone = 1;
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//Alteration of Power and toughness until end of turn (instant)
|
//Alteration of Power and toughness until end of turn (instant)
|
||||||
class AInstantPowerToughnessModifierUntilEOT: public InstantAbility{
|
class AInstantPowerToughnessModifierUntilEOT: public InstantAbility{
|
||||||
public:
|
public:
|
||||||
@@ -1076,6 +1010,51 @@ class AInstantPowerToughnessModifierUntilEOT: public InstantAbility{
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Alteration of Power and Toughness until end of turn (Aura)
|
||||||
|
class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{
|
||||||
|
public:
|
||||||
|
AInstantPowerToughnessModifierUntilEOT * ability;
|
||||||
|
int counters;
|
||||||
|
int maxcounters;
|
||||||
|
APowerToughnessModifierUntilEndOfTurn(int id, MTGCardInstance * _source, MTGCardInstance * _target, int _power, int _toughness, ManaCost * _cost = NULL, int _maxcounters = 0):ActivatedAbility(id,_source,_cost,0,0),maxcounters(_maxcounters){
|
||||||
|
counters = 0;
|
||||||
|
target=_target;
|
||||||
|
ability = NEW AInstantPowerToughnessModifierUntilEOT(id,_source,_target,_power,_toughness);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fireAbility(){
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
|
||||||
|
if (!ActivatedAbility::isReactingToClick(card,mana)) return 0;
|
||||||
|
return (!maxcounters || (counters < maxcounters));
|
||||||
|
}
|
||||||
|
|
||||||
|
int resolve(){
|
||||||
|
MTGAbility * a = ability->clone();
|
||||||
|
a->target = target;
|
||||||
|
a->addToGame();
|
||||||
|
counters++;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
APowerToughnessModifierUntilEndOfTurn * clone() const{
|
||||||
|
APowerToughnessModifierUntilEndOfTurn * a = NEW APowerToughnessModifierUntilEndOfTurn(*this);
|
||||||
|
a->isClone = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
~APowerToughnessModifierUntilEndOfTurn(){
|
||||||
|
if (!isClone) SAFE_DELETE(ability);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Untap Blockers with simple Mana Mechanism
|
//Untap Blockers with simple Mana Mechanism
|
||||||
class AUntapManaBlocker: public UntapBlocker{
|
class AUntapManaBlocker: public UntapBlocker{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -685,8 +685,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
|||||||
|
|
||||||
APowerToughnessModifierUntilEndOfTurn * aptmu = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a);
|
APowerToughnessModifierUntilEndOfTurn * aptmu = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a);
|
||||||
if (aptmu){
|
if (aptmu){
|
||||||
if (aptmu->power>=0 && aptmu->toughness>=0) return BAKA_EFFECT_GOOD;
|
return abilityEfficiency(aptmu->ability, p, mode);
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map<int,bool> badAbilities;
|
map<int,bool> badAbilities;
|
||||||
@@ -715,10 +714,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
|||||||
|
|
||||||
ABasicAbilityAuraModifierUntilEOT * abamu = dynamic_cast<ABasicAbilityAuraModifierUntilEOT *>(a);
|
ABasicAbilityAuraModifierUntilEOT * abamu = dynamic_cast<ABasicAbilityAuraModifierUntilEOT *>(a);
|
||||||
if (abamu){
|
if (abamu){
|
||||||
int result = BAKA_EFFECT_GOOD;
|
return abilityEfficiency(abamu->ability, p, mode);
|
||||||
if (badAbilities[abamu->ability]) result = BAKA_EFFECT_BAD;
|
|
||||||
if (abamu->value <= 0) result = -result;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AManaProducer * amp = dynamic_cast<AManaProducer*>(a);
|
AManaProducer * amp = dynamic_cast<AManaProducer*>(a);
|
||||||
@@ -2228,7 +2224,7 @@ InstantAbility::InstantAbility(int _id, MTGCardInstance * source):MTGAbility(_id
|
|||||||
init = 0;
|
init = 0;
|
||||||
for (int i = 0; i < 2; i++){
|
for (int i = 0; i < 2; i++){
|
||||||
if(game->players[i]->game->inPlay->hasCard(source)){
|
if(game->players[i]->game->inPlay->hasCard(source)){
|
||||||
game->players[i]->game->putInGraveyard(source);
|
//game->players[i]->game->putInGraveyard(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2243,7 +2239,7 @@ InstantAbility::InstantAbility(int _id, MTGCardInstance * source, Damageable * _
|
|||||||
init = 0;
|
init = 0;
|
||||||
for (int i = 0; i < 2; i++){
|
for (int i = 0; i < 2; i++){
|
||||||
if(game->players[i]->game->inPlay->hasCard(source)){
|
if(game->players[i]->game->inPlay->hasCard(source)){
|
||||||
game->players[i]->game->putInGraveyard(source);
|
//game->players[i]->game->putInGraveyard(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ void TestSuite::initGame(){
|
|||||||
MTGCardInstance * copy = p->game->putInZone(card, p->game->library, p->game->stack);
|
MTGCardInstance * copy = p->game->putInZone(card, p->game->library, p->game->stack);
|
||||||
Spell * spell = NEW Spell(copy);
|
Spell * spell = NEW Spell(copy);
|
||||||
spell->resolve();
|
spell->resolve();
|
||||||
if (!summoningSickness) p->game->inPlay->cards[k]->summoningSickness = 0;
|
if (!summoningSickness && p->game->inPlay->nb_cards>k) p->game->inPlay->cards[k]->summoningSickness = 0;
|
||||||
delete spell;
|
delete spell;
|
||||||
}else{
|
}else{
|
||||||
if (!p->game->library->hasCard(card)){
|
if (!p->game->library->hasCard(card)){
|
||||||
|
|||||||
Reference in New Issue
Block a user