J :
* Fix the last tests that didn't work, Rampage ability.
This commit is contained in:
@@ -3881,26 +3881,24 @@ class ARampageAbility:public MTGAbility{
|
|||||||
ARampageAbility(int _id, MTGCardInstance * _source,int _PowerModifier, int _ToughnessModifier, int _MaxOpponent):MTGAbility(_id, _source){
|
ARampageAbility(int _id, MTGCardInstance * _source,int _PowerModifier, int _ToughnessModifier, int _MaxOpponent):MTGAbility(_id, _source){
|
||||||
PowerModifier = _PowerModifier;
|
PowerModifier = _PowerModifier;
|
||||||
ToughnessModifier = _ToughnessModifier;
|
ToughnessModifier = _ToughnessModifier;
|
||||||
MaxOpponent = _MaxOpponent;
|
MaxOpponent = _MaxOpponent;
|
||||||
nbOpponents = 0;
|
nbOpponents = 0;
|
||||||
}
|
}
|
||||||
void Update(float dt){
|
int receiveEvent(WEvent * event) {
|
||||||
if (newPhase != currentPhase){
|
if (dynamic_cast<WEventBlockersChosen*>(event)) {
|
||||||
if( source->isAttacker() && newPhase == Constants::MTG_PHASE_COMBATDAMAGE){
|
nbOpponents = source->blockers.size();
|
||||||
nbOpponents = source->blockers.size();
|
source->power += PowerModifier * (nbOpponents - MaxOpponent);
|
||||||
for (int i = MaxOpponent; i < nbOpponents; i++){
|
source->addToToughness(ToughnessModifier * (nbOpponents - MaxOpponent));
|
||||||
source->power+= PowerModifier;
|
}
|
||||||
source->addToToughness(ToughnessModifier);
|
else if (WEventPhaseChange* pe = dynamic_cast<WEventPhaseChange*>(event)) {
|
||||||
|
if (Constants::MTG_PHASE_AFTER_EOT == pe->to->id)
|
||||||
|
{
|
||||||
|
source->power -= PowerModifier * (nbOpponents - MaxOpponent);
|
||||||
|
source->addToToughness(-ToughnessModifier * (nbOpponents - MaxOpponent));
|
||||||
|
nbOpponents = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( newPhase == Constants::MTG_PHASE_AFTER_EOT ){
|
return 1;
|
||||||
for (int i = MaxOpponent; i < nbOpponents; i++){
|
|
||||||
source->power-= PowerModifier;
|
|
||||||
source->addToToughness(-ToughnessModifier);
|
|
||||||
}
|
|
||||||
nbOpponents = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ARampageAbility * clone() const{
|
ARampageAbility * clone() const{
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ struct WEventCreatureBlocker : public WEventCardUpdate {
|
|||||||
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
|
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Event sent when blockers have been chosen and they
|
||||||
|
//cannot be changed any more.
|
||||||
|
struct WEventBlockersChosen : public WEvent {
|
||||||
|
};
|
||||||
|
|
||||||
//Event when a blocker is reordered
|
//Event when a blocker is reordered
|
||||||
//exchangeWith: exchange card's position with exchangeWith's position
|
//exchangeWith: exchange card's position with exchangeWith's position
|
||||||
//attacker:both card and exchangeWith *should* be in attacker's "blockers" list.
|
//attacker:both card and exchangeWith *should* be in attacker's "blockers" list.
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ void GameObserver::nextCombatStep()
|
|||||||
{
|
{
|
||||||
switch (combatStep)
|
switch (combatStep)
|
||||||
{
|
{
|
||||||
case BLOCKERS : receiveEvent(NEW WEventCombatStepChange(combatStep = ORDER)); return;
|
case BLOCKERS : receiveEvent(NEW WEventBlockersChosen());
|
||||||
|
receiveEvent(NEW WEventCombatStepChange(combatStep = ORDER)); return;
|
||||||
case ORDER : receiveEvent(NEW WEventCombatStepChange(combatStep = FIRST_STRIKE)); return;
|
case ORDER : receiveEvent(NEW WEventCombatStepChange(combatStep = FIRST_STRIKE)); return;
|
||||||
case FIRST_STRIKE : receiveEvent(NEW WEventCombatStepChange(combatStep = END_FIRST_STRIKE)); return;
|
case FIRST_STRIKE : receiveEvent(NEW WEventCombatStepChange(combatStep = END_FIRST_STRIKE)); return;
|
||||||
case END_FIRST_STRIKE : receiveEvent(NEW WEventCombatStepChange(combatStep = DAMAGE)); return;
|
case END_FIRST_STRIKE : receiveEvent(NEW WEventCombatStepChange(combatStep = DAMAGE)); return;
|
||||||
|
|||||||
@@ -607,139 +607,42 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
||||||
if (!a) return BAKA_EFFECT_DONTKNOW;
|
if (!a) return BAKA_EFFECT_DONTKNOW;
|
||||||
|
|
||||||
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*>(a);
|
if (GenericTargetAbility * abi = dynamic_cast<GenericTargetAbility*>(a)) {
|
||||||
if (gta) {
|
|
||||||
if (mode == MODE_PUTINTOPLAY) return BAKA_EFFECT_GOOD;
|
if (mode == MODE_PUTINTOPLAY) return BAKA_EFFECT_GOOD;
|
||||||
return abilityEfficiency(gta->ability,p, mode);
|
return abilityEfficiency(abi->ability,p, mode);
|
||||||
}
|
}
|
||||||
|
if (GenericActivatedAbility * abi = dynamic_cast<GenericActivatedAbility*>(a)) {
|
||||||
GenericActivatedAbility * gaa = dynamic_cast<GenericActivatedAbility*>(a);
|
|
||||||
if (gaa) {
|
|
||||||
if (mode == MODE_PUTINTOPLAY) return BAKA_EFFECT_GOOD;
|
if (mode == MODE_PUTINTOPLAY) return BAKA_EFFECT_GOOD;
|
||||||
return abilityEfficiency(gaa->ability,p, mode);
|
return abilityEfficiency(abi->ability,p, mode);
|
||||||
}
|
}
|
||||||
|
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(a)) return abilityEfficiency(abi->abilities[0],p, mode);
|
||||||
MultiAbility * mua = dynamic_cast<MultiAbility*>(a);
|
if (MayAbility * abi = dynamic_cast<MayAbility*>(a)) return abilityEfficiency(abi->ability,p, mode);
|
||||||
if (mua) return abilityEfficiency(mua->abilities[0],p, mode);
|
if (ALord * abi = dynamic_cast<ALord *>(a)) {
|
||||||
|
int myCards = countCards(abi->tc, p);
|
||||||
MayAbility * maya = dynamic_cast<MayAbility*>(a);
|
int theirCards = countCards(abi->tc, p->opponent());
|
||||||
if (maya) return abilityEfficiency(maya->ability,p, mode);
|
int efficiency = abilityEfficiency(abi->ability,p, mode);
|
||||||
|
|
||||||
ALord * alord = dynamic_cast<ALord *>(a);
|
|
||||||
if (alord) {
|
|
||||||
int myCards = countCards(alord->tc, p);
|
|
||||||
int theirCards = countCards(alord->tc, p->opponent());
|
|
||||||
int efficiency = abilityEfficiency(alord->ability,p, mode);
|
|
||||||
if (myCards > theirCards) return efficiency;
|
if (myCards > theirCards) return efficiency;
|
||||||
return -efficiency;
|
return -efficiency;
|
||||||
}
|
}
|
||||||
|
if (AAsLongAs * abi = dynamic_cast<AAsLongAs *>(a)) return abilityEfficiency(abi->ability,p, mode);
|
||||||
AAsLongAs * ala = dynamic_cast<AAsLongAs *>(a);
|
if (AForeach * abi = dynamic_cast<AForeach *>(a)) return abilityEfficiency(abi->ability,p, mode);
|
||||||
if (ala) {
|
if (dynamic_cast<AAFizzler *>(a)) return BAKA_EFFECT_BAD;
|
||||||
return abilityEfficiency(ala->ability,p, mode);
|
if (dynamic_cast<AAUntapper *>(a)) return BAKA_EFFECT_GOOD;
|
||||||
}
|
if (dynamic_cast<AATapper *>(a)) return BAKA_EFFECT_BAD;
|
||||||
|
if (dynamic_cast<ATokenCreator *>(a)) return BAKA_EFFECT_GOOD;
|
||||||
AForeach * af = dynamic_cast<AForeach *>(a);
|
if (dynamic_cast<AAMover *>(a)) return BAKA_EFFECT_BAD; //TODO
|
||||||
if (af) {
|
if (dynamic_cast<AACopier *>(a)) return BAKA_EFFECT_GOOD;
|
||||||
return abilityEfficiency(af->ability,p, mode);
|
if (dynamic_cast<AADestroyer *>(a)) return BAKA_EFFECT_BAD;
|
||||||
}
|
if (dynamic_cast<AStandardRegenerate *>(a)) return BAKA_EFFECT_GOOD;
|
||||||
|
if (dynamic_cast<AStandardRegenerate *>(a)) return BAKA_EFFECT_BAD;
|
||||||
AAFizzler * aaf = dynamic_cast<AAFizzler *>(a);
|
if (AALifer * abi = dynamic_cast<AALifer *>(a)) return abi->life > 0 ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
|
||||||
if (aaf){
|
if (dynamic_cast<AADepleter *>(a)) return BAKA_EFFECT_BAD;
|
||||||
return BAKA_EFFECT_BAD;
|
if (dynamic_cast<AADrawer *>(a)) return BAKA_EFFECT_GOOD;
|
||||||
}
|
if (dynamic_cast<AARandomDiscarder *>(a)) return BAKA_EFFECT_BAD;
|
||||||
|
if (dynamic_cast<ARampageAbility *>(a)) return BAKA_EFFECT_GOOD;
|
||||||
AAUntapper * aau = dynamic_cast<AAUntapper *>(a);
|
if (AInstantPowerToughnessModifierUntilEOT * abi = dynamic_cast<AInstantPowerToughnessModifierUntilEOT *>(a)) return (abi->power>=0 && abi->toughness>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
|
||||||
if (aau){
|
if (APowerToughnessModifier * abi = dynamic_cast<APowerToughnessModifier *>(a)) return (abi->power>=0 && abi->toughness>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
|
||||||
return BAKA_EFFECT_GOOD;
|
if (APowerToughnessModifierUntilEndOfTurn * abi = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a)) return abilityEfficiency(abi->ability, p, mode);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AATapper * aat = dynamic_cast<AATapper *>(a);
|
|
||||||
if (aat){
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ATokenCreator * aatc = dynamic_cast<ATokenCreator *>(a);
|
|
||||||
if (aatc){
|
|
||||||
return BAKA_EFFECT_GOOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AAMover * aam = dynamic_cast<AAMover *>(a);
|
|
||||||
if (aam){
|
|
||||||
//TODO
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AACopier * aac = dynamic_cast<AACopier *>(a);
|
|
||||||
if (aac){
|
|
||||||
return BAKA_EFFECT_GOOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AADestroyer * aad = dynamic_cast<AADestroyer *>(a);
|
|
||||||
if (aad){
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
AStandardRegenerate * asr = dynamic_cast<AStandardRegenerate *>(a);
|
|
||||||
if (asr){
|
|
||||||
return BAKA_EFFECT_GOOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
AADamager * aada = dynamic_cast<AADamager *>(a);
|
|
||||||
if (aada){
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AALifer * aal = dynamic_cast<AALifer *>(a);
|
|
||||||
if (aal){
|
|
||||||
if (aal->life > 0) return BAKA_EFFECT_GOOD;
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AADepleter * aade = dynamic_cast<AADepleter *>(a);
|
|
||||||
if (aade){
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AADrawer * aadr = dynamic_cast<AADrawer *>(a);
|
|
||||||
if (aadr){
|
|
||||||
return BAKA_EFFECT_GOOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
AARandomDiscarder * aard = dynamic_cast<AARandomDiscarder *>(a);
|
|
||||||
if (aard){
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
ARampageAbility * ara = dynamic_cast<ARampageAbility *>(a);
|
|
||||||
if (ara){
|
|
||||||
return BAKA_EFFECT_GOOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
AInstantPowerToughnessModifierUntilEOT * aiptm = dynamic_cast<AInstantPowerToughnessModifierUntilEOT *>(a);
|
|
||||||
if (aiptm){
|
|
||||||
if (aiptm->power>=0 && aiptm->toughness>=0) return BAKA_EFFECT_GOOD;
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
APowerToughnessModifier * aptm = dynamic_cast<APowerToughnessModifier *>(a);
|
|
||||||
if (aptm){
|
|
||||||
if (aptm->power>=0 && aptm->toughness>=0) return BAKA_EFFECT_GOOD;
|
|
||||||
return BAKA_EFFECT_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
APowerToughnessModifierUntilEndOfTurn * aptmu = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a);
|
|
||||||
if (aptmu){
|
|
||||||
return abilityEfficiency(aptmu->ability, p, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
map<int,bool> badAbilities;
|
map<int,bool> badAbilities;
|
||||||
badAbilities[Constants::CANTATTACK] = true;
|
badAbilities[Constants::CANTATTACK] = true;
|
||||||
@@ -749,30 +652,16 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
|||||||
badAbilities[Constants::DOESNOTUNTAP] = true;
|
badAbilities[Constants::DOESNOTUNTAP] = true;
|
||||||
badAbilities[Constants::MUSTATTACK] = true;
|
badAbilities[Constants::MUSTATTACK] = true;
|
||||||
|
|
||||||
AInstantBasicAbilityModifierUntilEOT * aibam = dynamic_cast<AInstantBasicAbilityModifierUntilEOT *>(a);
|
if (AInstantBasicAbilityModifierUntilEOT * abi = dynamic_cast<AInstantBasicAbilityModifierUntilEOT *>(a)) {
|
||||||
if (aibam){
|
int result = badAbilities[abi->ability] ? BAKA_EFFECT_BAD : BAKA_EFFECT_GOOD;
|
||||||
int result = BAKA_EFFECT_GOOD;
|
return (abi->value <= 0) ? result : -result;
|
||||||
if (badAbilities[aibam->ability]) result = BAKA_EFFECT_BAD;
|
}
|
||||||
if (aibam->value <= 0) result = -result;
|
if (ABasicAbilityModifier * abi = dynamic_cast<ABasicAbilityModifier *>(a)){
|
||||||
return result;
|
int result = (badAbilities[abi->ability]) ? BAKA_EFFECT_BAD : BAKA_EFFECT_GOOD;
|
||||||
|
return (abi->modifier <= 0) ? result : -result;
|
||||||
}
|
}
|
||||||
|
if (ABasicAbilityAuraModifierUntilEOT * abi = dynamic_cast<ABasicAbilityAuraModifierUntilEOT *>(a)) return abilityEfficiency(abi->ability, p, mode);
|
||||||
ABasicAbilityModifier * abam = dynamic_cast<ABasicAbilityModifier *>(a);
|
if (dynamic_cast<AManaProducer*>(a)) return BAKA_EFFECT_GOOD;
|
||||||
if (abam){
|
|
||||||
int result = BAKA_EFFECT_GOOD;
|
|
||||||
if (badAbilities[abam->ability]) result = BAKA_EFFECT_BAD;
|
|
||||||
if (abam->modifier <= 0) result = -result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ABasicAbilityAuraModifierUntilEOT * abamu = dynamic_cast<ABasicAbilityAuraModifierUntilEOT *>(a);
|
|
||||||
if (abamu){
|
|
||||||
return abilityEfficiency(abamu->ability, p, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
AManaProducer * amp = dynamic_cast<AManaProducer*>(a);
|
|
||||||
if (amp) return BAKA_EFFECT_GOOD;
|
|
||||||
|
|
||||||
return BAKA_EFFECT_DONTKNOW;
|
return BAKA_EFFECT_DONTKNOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user