Erwan
- added "targetplayer" functionality to ManaProducer objects. As a collateral benefit, this fixes issue 191 (seismic spike)
This commit is contained in:
@@ -232,6 +232,7 @@ scourge_of_kher_ridges2.txt
|
|||||||
sedge_sliver.txt
|
sedge_sliver.txt
|
||||||
seedcradle_witch.txt
|
seedcradle_witch.txt
|
||||||
seismic_assault.txt
|
seismic_assault.txt
|
||||||
|
seismic_spike_i191.txt
|
||||||
selesnya_guildmage.txt
|
selesnya_guildmage.txt
|
||||||
siege_gang_commander.txt
|
siege_gang_commander.txt
|
||||||
shepherd_of_rot.txt
|
shepherd_of_rot.txt
|
||||||
|
|||||||
@@ -454,28 +454,7 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ActivatedAbilityTP:public ActivatedAbility{
|
|
||||||
public:
|
|
||||||
int who;
|
|
||||||
ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbility(id,card,cost,0,doTap),who(who){
|
|
||||||
if (_target) target = _target;
|
|
||||||
}
|
|
||||||
|
|
||||||
Targetable * getTarget(){
|
|
||||||
switch(who){
|
|
||||||
case TargetChooser::TARGET_CONTROLLER:
|
|
||||||
if (target) return ((MTGCardInstance *)target)->controller();
|
|
||||||
return NULL;
|
|
||||||
case TargetChooser::CONTROLLER:
|
|
||||||
return source->controller();
|
|
||||||
case TargetChooser::OPPONENT:
|
|
||||||
return source->controller()->opponent();
|
|
||||||
default:
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//Drawer, allows to draw a card for a cost:
|
//Drawer, allows to draw a card for a cost:
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ class GameObserver;
|
|||||||
class Spell;
|
class Spell;
|
||||||
class Damageable;
|
class Damageable;
|
||||||
class PlayGuiObject;
|
class PlayGuiObject;
|
||||||
class TargetChooser;
|
|
||||||
class ManaCost;
|
class ManaCost;
|
||||||
class MTGGameZone;
|
class MTGGameZone;
|
||||||
class Player;
|
class Player;
|
||||||
@@ -20,6 +19,7 @@ class WEvent;
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <hge/hgeparticle.h>
|
#include <hge/hgeparticle.h>
|
||||||
#include "../include/Damage.h"
|
#include "../include/Damage.h"
|
||||||
|
#include "../include/TargetChooser.h"
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
||||||
@@ -217,7 +217,14 @@ class AbilityFactory{
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AManaProducer: public MTGAbility{
|
class ActivatedAbilityTP:public ActivatedAbility{
|
||||||
|
public:
|
||||||
|
int who;
|
||||||
|
ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int doTap = 0, int who = TargetChooser::UNSET);
|
||||||
|
Targetable * getTarget();
|
||||||
|
};
|
||||||
|
|
||||||
|
class AManaProducer: public ActivatedAbilityTP{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
@@ -227,7 +234,7 @@ class AManaProducer: public MTGAbility{
|
|||||||
public:
|
public:
|
||||||
ManaCost * output;
|
ManaCost * output;
|
||||||
int tap;
|
int tap;
|
||||||
AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1 );
|
AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1, int who = TargetChooser::UNSET );
|
||||||
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
|
||||||
int resolve();
|
int resolve();
|
||||||
int reactToClick(MTGCardInstance * _card);
|
int reactToClick(MTGCardInstance * _card);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#define _MTGCARD_H_
|
#define _MTGCARD_H_
|
||||||
|
|
||||||
#define MTGCARD_NAME_SIZE 30
|
#define MTGCARD_NAME_SIZE 30
|
||||||
#define MTGCARD_TEXT_SIZE 300
|
|
||||||
|
|
||||||
#define MTG_IMAGE_WIDTH 200
|
#define MTG_IMAGE_WIDTH 200
|
||||||
#define MTG_IMAGE_HEIGHT 285
|
#define MTG_IMAGE_HEIGHT 285
|
||||||
|
|||||||
@@ -661,7 +661,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
found = s.find("add");
|
found = s.find("add");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
ManaCost * output = ManaCost::parseManaCost(s.substr(found));
|
ManaCost * output = ManaCost::parseManaCost(s.substr(found));
|
||||||
MTGAbility * a = NEW AManaProducer(id, target, output);
|
Targetable * t = NULL;
|
||||||
|
if (spell) t = spell->getNextPlayerTarget();
|
||||||
|
MTGAbility * a = NEW AManaProducer(id, card, t, output, NULL, 1, who);
|
||||||
a->oneShot = 1;
|
a->oneShot = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -1077,7 +1079,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
|
|||||||
case 1124: //Mana Vault
|
case 1124: //Mana Vault
|
||||||
{
|
{
|
||||||
int output[] = {Constants::MTG_COLOR_ARTIFACT, 3};
|
int output[] = {Constants::MTG_COLOR_ARTIFACT, 3};
|
||||||
game->addObserver(NEW AManaProducer(_id,card,NEW ManaCost(output,1)));
|
game->addObserver(NEW AManaProducer(_id,card,card,NEW ManaCost(output,1)));
|
||||||
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4};
|
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4};
|
||||||
game->addObserver(NEW AUntapManaBlocker(_id+1, card, NEW ManaCost(cost,1)));
|
game->addObserver(NEW AUntapManaBlocker(_id+1, card, NEW ManaCost(cost,1)));
|
||||||
game->addObserver(NEW ARegularLifeModifierAura(_id+2, card, card, Constants::MTG_PHASE_DRAW, -1, 1));
|
game->addObserver(NEW ARegularLifeModifierAura(_id+2, card, card, Constants::MTG_PHASE_DRAW, -1, 1));
|
||||||
@@ -2180,15 +2182,9 @@ GenericTriggeredAbility* GenericTriggeredAbility::clone() const{
|
|||||||
//That means the player has to choose one. although that is perfect for cards such as birds of paradise or badlands,
|
//That means the player has to choose one. although that is perfect for cards such as birds of paradise or badlands,
|
||||||
other solutions need to be provided for abilities that add mana (ex: mana flare)
|
other solutions need to be provided for abilities that add mana (ex: mana flare)
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
Currently the mana is added to the pool AFTER the animation
|
|
||||||
This is VERY BAD, since we don't have any control on the duration of the animation. This can lead to bugs with
|
|
||||||
the AI, who is expecting to have the mana in its manapool right after clicking the land card !!!
|
|
||||||
The sum of "dt" has to be 0.25 for the mana to be in the manapool currently
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost , int doTap):MTGAbility(id, card), tap(doTap){
|
AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost , int doTap, int who):ActivatedAbilityTP(id, card,t,_cost,doTap,who){
|
||||||
|
|
||||||
LOG("==Creating ManaProducer Object");
|
LOG("==Creating ManaProducer Object");
|
||||||
aType = MTGAbility::MANA_PRODUCER;
|
aType = MTGAbility::MANA_PRODUCER;
|
||||||
@@ -2212,9 +2208,18 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AManaProducer::resolve(){
|
int AManaProducer::resolve(){
|
||||||
controller = source->controller();
|
Targetable * _target = getTarget();
|
||||||
controller->getManaPool()->add(output,source);
|
Player * player;
|
||||||
return 1;
|
if (_target){
|
||||||
|
if (_target->typeAsTarget() == TARGET_CARD){
|
||||||
|
player = ((MTGCardInstance *)_target)->controller();
|
||||||
|
}else{
|
||||||
|
player = (Player *) _target;
|
||||||
|
}
|
||||||
|
player->getManaPool()->add(output,source);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AManaProducer::reactToClick(MTGCardInstance * _card){
|
int AManaProducer::reactToClick(MTGCardInstance * _card){
|
||||||
@@ -2291,3 +2296,22 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ActivatedAbilityTP::ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target, ManaCost * cost, int doTap, int who):ActivatedAbility(id,card,cost,0,doTap),who(who){
|
||||||
|
if (_target) target = _target;
|
||||||
|
}
|
||||||
|
|
||||||
|
Targetable * ActivatedAbilityTP::getTarget(){
|
||||||
|
switch(who){
|
||||||
|
case TargetChooser::TARGET_CONTROLLER:
|
||||||
|
if (target) return ((MTGCardInstance *)target)->controller();
|
||||||
|
return NULL;
|
||||||
|
case TargetChooser::CONTROLLER:
|
||||||
|
return source->controller();
|
||||||
|
case TargetChooser::OPPONENT:
|
||||||
|
return source->controller()->opponent();
|
||||||
|
default:
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user