Erwan
-fixesRockslide Elemental, Welkin Hawk -Added messages for Manapool updates -Cleaned up ManaProducer code
This commit is contained in:
@@ -154,6 +154,7 @@ resurrection.txt
|
|||||||
rhox_meditant.txt
|
rhox_meditant.txt
|
||||||
rhox_meditant2.txt
|
rhox_meditant2.txt
|
||||||
righteous_cause.txt
|
righteous_cause.txt
|
||||||
|
rockslide_elemental.txt
|
||||||
rootwalla.txt
|
rootwalla.txt
|
||||||
royal_assassin.txt
|
royal_assassin.txt
|
||||||
safehold_duo.txt
|
safehold_duo.txt
|
||||||
@@ -184,6 +185,7 @@ tranquil_domain.txt
|
|||||||
volcanic_island.txt
|
volcanic_island.txt
|
||||||
wall_of_diffusion.txt
|
wall_of_diffusion.txt
|
||||||
wall_of_diffusion2.txt
|
wall_of_diffusion2.txt
|
||||||
|
welkin_hawk.txt
|
||||||
white_knight1.txt
|
white_knight1.txt
|
||||||
wrath_of_god.txt
|
wrath_of_god.txt
|
||||||
zombie_master.txt
|
zombie_master.txt
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#Bug: Crash when Rockslide elemental goes to graveyard
|
||||||
|
[INIT]
|
||||||
|
FIRSTMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:rockslide elemental
|
||||||
|
manapool:{R}
|
||||||
|
hand:shock
|
||||||
|
[PLAYER2]
|
||||||
|
[DO]
|
||||||
|
shock
|
||||||
|
rockslide elemental
|
||||||
|
[ASSERT]
|
||||||
|
FIRSTMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
graveyard:shock,rockslide elemental
|
||||||
|
[PLAYER2]
|
||||||
|
[END]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#Bug: Crash whenWelki hawk goes to graveyard
|
||||||
|
[INIT]
|
||||||
|
FIRSTMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:welkin hawk
|
||||||
|
manapool:{R}
|
||||||
|
hand:shock
|
||||||
|
[PLAYER2]
|
||||||
|
[DO]
|
||||||
|
shock
|
||||||
|
welkin hawk
|
||||||
|
choice 1
|
||||||
|
[ASSERT]
|
||||||
|
FIRSTMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
graveyard:shock,welkin hawk
|
||||||
|
[PLAYER2]
|
||||||
|
[END]
|
||||||
@@ -150,10 +150,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int testDestroy(){
|
int testDestroy(){
|
||||||
if (triggered && !game->mLayers->actionLayer()->menuObject && game->mLayers->actionLayer()->getIndexOf(mClone) ==-1){
|
if (triggered){
|
||||||
|
if (game->mLayers->actionLayer()->menuObject) return 0;
|
||||||
|
if (game->mLayers->actionLayer()->getIndexOf(mClone) !=-1) return 0;
|
||||||
|
if (game->mLayers->actionLayer()->getIndexOf(this) !=-1) return 0;
|
||||||
OutputDebugString("Destroy!\n");
|
OutputDebugString("Destroy!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,11 +176,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
~MayAbility(){
|
~MayAbility(){
|
||||||
if (!isClone) SAFE_DELETE(ability);
|
SAFE_DELETE(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
MayAbility * clone() const{
|
MayAbility * clone() const{
|
||||||
MayAbility * a = NEW MayAbility(*this);
|
MayAbility * a = NEW MayAbility(*this);
|
||||||
|
a->ability = ability->clone();
|
||||||
a->isClone = 1;
|
a->isClone = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -292,8 +297,13 @@ public:
|
|||||||
counters = 0;
|
counters = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~GenericTargetAbility(){
|
||||||
|
if (isClone) SAFE_DELETE(ability);
|
||||||
|
}
|
||||||
|
|
||||||
GenericTargetAbility * clone() const{
|
GenericTargetAbility * clone() const{
|
||||||
GenericTargetAbility * a = NEW GenericTargetAbility(*this);
|
GenericTargetAbility * a = NEW GenericTargetAbility(*this);
|
||||||
|
a->ability = ability->clone();
|
||||||
a->isClone = 1;
|
a->isClone = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,28 +221,18 @@ class AManaProducer: public MTGAbility{
|
|||||||
|
|
||||||
|
|
||||||
string menutext;
|
string menutext;
|
||||||
float x0,y0,x1,y1,x,y;
|
|
||||||
float animation;
|
|
||||||
Player * controller;
|
Player * controller;
|
||||||
|
|
||||||
|
|
||||||
hgeParticleSystem * mParticleSys;
|
|
||||||
public:
|
public:
|
||||||
ManaCost * output;
|
ManaCost * output;
|
||||||
int tap;
|
int tap;
|
||||||
static int currentlyTapping;
|
|
||||||
AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1 );
|
AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1 );
|
||||||
void Update(float dt);
|
|
||||||
void Render();
|
|
||||||
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
|
||||||
int resolve();
|
int resolve();
|
||||||
int destroy();
|
|
||||||
int reactToClick(MTGCardInstance * _card);
|
int reactToClick(MTGCardInstance * _card);
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
int testDestroy();
|
|
||||||
~AManaProducer();
|
~AManaProducer();
|
||||||
virtual AManaProducer * clone() const;
|
virtual AManaProducer * clone() const;
|
||||||
virtual ostream& toString(ostream& out) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "MTGCardInstance.h"
|
#include "MTGCardInstance.h"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class ExtraCosts;
|
|||||||
class ExtraCost;
|
class ExtraCost;
|
||||||
class MTGAbility;
|
class MTGAbility;
|
||||||
class MTGCardInstance;
|
class MTGCardInstance;
|
||||||
|
class Player;
|
||||||
|
|
||||||
class ManaCost{
|
class ManaCost{
|
||||||
protected:
|
protected:
|
||||||
@@ -21,7 +22,7 @@ class ManaCost{
|
|||||||
public:
|
public:
|
||||||
ExtraCosts * extraCosts;
|
ExtraCosts * extraCosts;
|
||||||
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
|
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
|
||||||
void init();
|
virtual void init();
|
||||||
void x();
|
void x();
|
||||||
ManaCost(int _cost[], int nb_elems = 1);
|
ManaCost(int _cost[], int nb_elems = 1);
|
||||||
ManaCost();
|
ManaCost();
|
||||||
@@ -66,4 +67,17 @@ class ManaCost{
|
|||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, const ManaCost& m);
|
std::ostream& operator<<(std::ostream& out, const ManaCost& m);
|
||||||
|
|
||||||
|
class ManaPool:public ManaCost{
|
||||||
|
protected:
|
||||||
|
Player * player;
|
||||||
|
public:
|
||||||
|
void init();
|
||||||
|
ManaPool(Player * player);
|
||||||
|
ManaPool(ManaCost * _manaCost, Player * player);
|
||||||
|
int remove (int color, int value);
|
||||||
|
int add(int color, int value, MTGCardInstance * source = NULL);
|
||||||
|
int add(ManaCost * _cost, MTGCardInstance * source = NULL);
|
||||||
|
int pay (ManaCost * _cost);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
#define _PLAYER_H_
|
#define _PLAYER_H_
|
||||||
|
|
||||||
#include "JGE.h"
|
#include "JGE.h"
|
||||||
#include "ManaCost.h"
|
|
||||||
#include "MTGGameZones.h"
|
#include "MTGGameZones.h"
|
||||||
#include "Damage.h"
|
#include "Damage.h"
|
||||||
#include "Targetable.h"
|
#include "Targetable.h"
|
||||||
|
|
||||||
class MTGPlayerCards;
|
class MTGPlayerCards;
|
||||||
class MTGInPlay;
|
class MTGInPlay;
|
||||||
|
class ManaPool;
|
||||||
|
|
||||||
class Player: public Damageable{
|
class Player: public Damageable{
|
||||||
protected:
|
protected:
|
||||||
ManaCost * manaPool;
|
ManaPool * manaPool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void End();
|
virtual void End();
|
||||||
@@ -28,7 +28,7 @@ class Player: public Damageable{
|
|||||||
virtual ~Player();
|
virtual ~Player();
|
||||||
void unTapPhase();
|
void unTapPhase();
|
||||||
MTGInPlay * inPlay();
|
MTGInPlay * inPlay();
|
||||||
ManaCost * getManaPool();
|
ManaPool * getManaPool();
|
||||||
void cleanupPhase();
|
void cleanupPhase();
|
||||||
virtual int Act(float dt){return 0;};
|
virtual int Act(float dt){return 0;};
|
||||||
virtual int isAI(){return 0;};
|
virtual int isAI(){return 0;};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class MTGGameZone;
|
|||||||
class Damage;
|
class Damage;
|
||||||
class Phase;
|
class Phase;
|
||||||
class Targetable;
|
class Targetable;
|
||||||
|
class ManaPool;
|
||||||
|
|
||||||
class WEvent{
|
class WEvent{
|
||||||
public:
|
public:
|
||||||
@@ -87,14 +88,23 @@ struct WEventCreatureBlockerRank: public WEventCardUpdate{
|
|||||||
struct WEventEngageMana : public WEvent {
|
struct WEventEngageMana : public WEvent {
|
||||||
int color;
|
int color;
|
||||||
MTGCardInstance* card;
|
MTGCardInstance* card;
|
||||||
WEventEngageMana(int color, MTGCardInstance* card);
|
ManaPool * destination;
|
||||||
|
WEventEngageMana(int color, MTGCardInstance* card, ManaPool * destination);
|
||||||
};
|
};
|
||||||
|
|
||||||
//Event when a mana is consumed
|
//Event when a mana is consumed
|
||||||
//color : color
|
//color : color
|
||||||
struct WEventConsumeMana : public WEvent {
|
struct WEventConsumeMana : public WEvent {
|
||||||
int color;
|
int color;
|
||||||
WEventConsumeMana(int color);
|
ManaPool * source;
|
||||||
|
WEventConsumeMana(int color, ManaPool * source);
|
||||||
|
};
|
||||||
|
|
||||||
|
//Event when a manapool is emptied
|
||||||
|
//color : color
|
||||||
|
struct WEventEmptyManaPool : public WEvent {
|
||||||
|
ManaPool * source;
|
||||||
|
WEventEmptyManaPool(ManaPool * source);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -736,7 +736,7 @@ int AIPlayerBaka::Act(float dt){
|
|||||||
oldGamePhase = currentGamePhase;
|
oldGamePhase = currentGamePhase;
|
||||||
|
|
||||||
timer-= dt;
|
timer-= dt;
|
||||||
if (AManaProducer::currentlyTapping || timer>0){
|
if (timer>0){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
initTimer();
|
initTimer();
|
||||||
|
|||||||
@@ -235,8 +235,10 @@ void ActionLayer::doReactTo(int menuIndex){
|
|||||||
char buf[4096];
|
char buf[4096];
|
||||||
sprintf(buf, "doReact To %i\n",controlid);
|
sprintf(buf, "doReact To %i\n",controlid);
|
||||||
OutputDebugString(buf);
|
OutputDebugString(buf);
|
||||||
|
if (controlid != -1){
|
||||||
ActionElement * currentAction = (ActionElement *)mObjects[controlid];
|
ActionElement * currentAction = (ActionElement *)mObjects[controlid];
|
||||||
currentAction->reactToTargetClick(menuObject);
|
currentAction->reactToTargetClick(menuObject);
|
||||||
|
}
|
||||||
menuObject = 0;
|
menuObject = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ int GuiMana::receiveEventPlus(WEvent* e)
|
|||||||
{
|
{
|
||||||
if (WEventEngageMana *event = dynamic_cast<WEventEngageMana*>(e))
|
if (WEventEngageMana *event = dynamic_cast<WEventEngageMana*>(e))
|
||||||
{
|
{
|
||||||
if (event->card->view)
|
if (event->card && event->card->view)
|
||||||
manas.push_back(NEW ManaIcon(event->color, event->card->view->actX, event->card->view->actY));
|
manas.push_back(NEW ManaIcon(event->color, event->card->view->actX, event->card->view->actY));
|
||||||
else
|
else
|
||||||
manas.push_back(NEW ManaIcon(event->color, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
|
manas.push_back(NEW ManaIcon(event->color, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
|
||||||
@@ -162,10 +162,10 @@ int GuiMana::receiveEventMinus(WEvent* e)
|
|||||||
if ((event->color == (*it)->color) && (ManaIcon::ALIVE == (*it)->mode)) { (*it)->Wither(); return 1; }
|
if ((event->color == (*it)->color) && (ManaIcon::ALIVE == (*it)->mode)) { (*it)->Wither(); return 1; }
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e))
|
else if (WEventEmptyManaPool *event = dynamic_cast<WEventEmptyManaPool*>(e))
|
||||||
{
|
{
|
||||||
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
(*it)->Drop();
|
(*it)->Drop(); //TODO: split according to which manapool was emptied...
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1823,7 +1823,8 @@ int MTGAbility::removeFromGame(){
|
|||||||
int MTGAbility::testDestroy(){
|
int MTGAbility::testDestroy(){
|
||||||
if (game->mLayers->stackLayer()->has(this)) return 0;
|
if (game->mLayers->stackLayer()->has(this)) return 0;
|
||||||
if (waitingForAnswer) return 0;
|
if (waitingForAnswer) return 0;
|
||||||
if (forceDestroy) return 1;
|
if (forceDestroy == 1) return 1;
|
||||||
|
if (forceDestroy == -1) return 0;
|
||||||
if (!game->isInPlay(source) ){
|
if (!game->isInPlay(source) ){
|
||||||
OutputDebugString("Destroying Ability !!!\n");
|
OutputDebugString("Destroying Ability !!!\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2292,74 +2293,14 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output,
|
|||||||
aType = MTGAbility::MANA_PRODUCER;
|
aType = MTGAbility::MANA_PRODUCER;
|
||||||
cost = _cost;
|
cost = _cost;
|
||||||
output = _output;
|
output = _output;
|
||||||
cout << "!" << card->view << endl;
|
|
||||||
if (card->view)
|
|
||||||
{
|
|
||||||
x1 = card->view->actX; y1 = card->view->actY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
x1 = 10; y1 = 220;
|
|
||||||
}
|
|
||||||
Player * player = card->controller();
|
|
||||||
if (player == game->players[1]) y1 = 100;
|
|
||||||
x = x1;
|
|
||||||
y = y1;
|
|
||||||
animation = 0.f;
|
|
||||||
mParticleSys = NULL;
|
|
||||||
menutext = "";
|
menutext = "";
|
||||||
|
|
||||||
int landColor = output->getMainColor();
|
|
||||||
|
|
||||||
switch (landColor)
|
|
||||||
{
|
|
||||||
case Constants::MTG_COLOR_RED :
|
|
||||||
mParticleSys = NEW hgeParticleSystem("graphics/manared.psi",GameApp::CommonRes->GetQuad("particles"));
|
|
||||||
break;
|
|
||||||
case Constants::MTG_COLOR_BLUE :
|
|
||||||
mParticleSys = NEW hgeParticleSystem("graphics/manablue.psi", GameApp::CommonRes->GetQuad("particles"));
|
|
||||||
break;
|
|
||||||
case Constants::MTG_COLOR_GREEN :
|
|
||||||
mParticleSys = NEW hgeParticleSystem("graphics/managreen.psi", GameApp::CommonRes->GetQuad("particles"));
|
|
||||||
break;
|
|
||||||
case Constants::MTG_COLOR_BLACK :
|
|
||||||
mParticleSys = NEW hgeParticleSystem("graphics/manablack.psi", GameApp::CommonRes->GetQuad("particles"));
|
|
||||||
break;
|
|
||||||
case Constants::MTG_COLOR_WHITE :
|
|
||||||
mParticleSys = NEW hgeParticleSystem("graphics/manawhite.psi", GameApp::CommonRes->GetQuad("particles"));
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
mParticleSys = NEW hgeParticleSystem("graphics/mana.psi", GameApp::CommonRes->GetQuad("particles"));
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG("==ManaProducer Object Creation successful !");
|
LOG("==ManaProducer Object Creation successful !");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AManaProducer::Update(float dt){
|
|
||||||
if (mParticleSys) mParticleSys->Update(dt);
|
|
||||||
if (animation){
|
|
||||||
x = (1.f - animation)*x1 + animation * x0;
|
|
||||||
y = (1.f - animation)*y1 + animation * y0;
|
|
||||||
if (mParticleSys) mParticleSys->MoveTo(x, y);
|
|
||||||
if (mParticleSys && animation == 1.f) mParticleSys->Fire();
|
|
||||||
animation -= 4 *dt;
|
|
||||||
if (!animation) animation = -1;
|
|
||||||
if (animation < 0){
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AManaProducer::Render(){
|
|
||||||
JRenderer * renderer = JRenderer::GetInstance();
|
|
||||||
if (animation){
|
|
||||||
// renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
|
|
||||||
// if (mParticleSys) mParticleSys->Render();
|
|
||||||
// set normal blending
|
|
||||||
// renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana){
|
int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana){
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (!mana) mana = game->currentlyActing()->getManaPool();
|
if (!mana) mana = game->currentlyActing()->getManaPool();
|
||||||
@@ -2370,11 +2311,8 @@ void AManaProducer::Render(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AManaProducer::resolve(){
|
int AManaProducer::resolve(){
|
||||||
animation = 0;
|
|
||||||
if (currentlyTapping > 0) currentlyTapping--;
|
|
||||||
controller = source->controller();
|
controller = source->controller();
|
||||||
controller->getManaPool()->add(output);
|
controller->getManaPool()->add(output,source);
|
||||||
if (mParticleSys) mParticleSys->Stop();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2394,31 +2332,14 @@ void AManaProducer::Render(){
|
|||||||
cost->doPayExtra();
|
cost->doPayExtra();
|
||||||
}
|
}
|
||||||
if (tap) source->tap();
|
if (tap) source->tap();
|
||||||
currentlyTapping++;
|
|
||||||
|
|
||||||
animation = 1.f;
|
if (options[Options::SFXVOLUME].number > 0){
|
||||||
|
|
||||||
if (options[Options::SFXVOLUME].number > 0 && currentlyTapping < 3){
|
|
||||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
|
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
|
||||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||||
}
|
}
|
||||||
|
return resolve();
|
||||||
for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i)
|
|
||||||
{
|
|
||||||
for (int cost = output->getCost(i); cost > 0; --cost)
|
|
||||||
{
|
|
||||||
WEvent * e = NEW WEventEngageMana(i, source);
|
|
||||||
GameObserver::GetInstance()->receiveEvent(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AManaProducer::destroy(){
|
|
||||||
if (animation >0) resolve(); //if we get destroyed while the animation was taking place (dirty...)
|
|
||||||
return MTGAbility::destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * AManaProducer::getMenuText(){
|
const char * AManaProducer::getMenuText(){
|
||||||
if (menutext.size())return menutext.c_str();
|
if (menutext.size())return menutext.c_str();
|
||||||
@@ -2457,17 +2378,12 @@ void AManaProducer::Render(){
|
|||||||
return menutext.c_str();
|
return menutext.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AManaProducer::testDestroy(){
|
|
||||||
if (animation >0) return 0;
|
|
||||||
return MTGAbility::testDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
AManaProducer::~AManaProducer(){
|
AManaProducer::~AManaProducer(){
|
||||||
if (isClone) return;
|
if (isClone) return;
|
||||||
LOG("==Destroying ManaProducer Object");
|
LOG("==Destroying ManaProducer Object");
|
||||||
SAFE_DELETE(cost);
|
SAFE_DELETE(cost);
|
||||||
SAFE_DELETE(output);
|
SAFE_DELETE(output);
|
||||||
SAFE_DELETE(mParticleSys);
|
|
||||||
LOG("==Destroying ManaProducer Object Successful!");
|
LOG("==Destroying ManaProducer Object Successful!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2477,19 +2393,4 @@ void AManaProducer::Render(){
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AManaProducer::currentlyTapping = 0;
|
|
||||||
|
|
||||||
ostream& AManaProducer::toString(ostream& out) const
|
|
||||||
{
|
|
||||||
out << "AManaProducer ::: cost : " << cost
|
|
||||||
<< " ; output : " << output
|
|
||||||
<< " ; menutext : " << menutext
|
|
||||||
<< " ; x0,y0 : " << x0 << "," << y0
|
|
||||||
<< " ; x1,y1 : " << x1 << "," << y1
|
|
||||||
<< " ; x,y : " << x << "," << y
|
|
||||||
<< " ; animation : " << animation
|
|
||||||
<< " ; controller : " << controller
|
|
||||||
<< " ; tap : " << tap
|
|
||||||
<< " (";
|
|
||||||
return MTGAbility::toString(out) << ")";
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void MTGGamePhase::Update(float dt){
|
|||||||
int newState = GameObserver::GetInstance()->getCurrentGamePhase();
|
int newState = GameObserver::GetInstance()->getCurrentGamePhase();
|
||||||
if (newState != currentState){
|
if (newState != currentState){
|
||||||
activeState = ACTIVE;
|
activeState = ACTIVE;
|
||||||
animation = 1;
|
animation = 4;
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
|
|
||||||
switch (currentState){
|
switch (currentState){
|
||||||
@@ -28,7 +28,7 @@ void MTGGamePhase::Update(float dt){
|
|||||||
|
|
||||||
if (animation > 0){
|
if (animation > 0){
|
||||||
// fprintf(stderr, "animation = %f", animation);
|
// fprintf(stderr, "animation = %f", animation);
|
||||||
animation -= dt *5 ;
|
animation -- ;
|
||||||
}else{
|
}else{
|
||||||
activeState = INACTIVE;
|
activeState = INACTIVE;
|
||||||
animation = 0;
|
animation = 0;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/Logger.h"
|
|
||||||
#include "../include/ManaCost.h"
|
#include "../include/ManaCost.h"
|
||||||
#include "../include/ManaCostHybrid.h"
|
#include "../include/ManaCostHybrid.h"
|
||||||
#include "../include/ExtraCost.h"
|
#include "../include/ExtraCost.h"
|
||||||
#include "../include/TargetChooser.h"
|
#include "../include/TargetChooser.h"
|
||||||
#include "../include/Targetable.h"
|
#include "../include/Targetable.h"
|
||||||
|
#include "../include/Player.h"
|
||||||
|
#include "../include/WEvent.h"
|
||||||
|
|
||||||
#if defined (WIN32)
|
#if defined (WIN32)
|
||||||
|
|
||||||
@@ -121,7 +122,6 @@ ManaCost::ManaCost(ManaCost * _manaCost){
|
|||||||
}
|
}
|
||||||
|
|
||||||
ManaCost::~ManaCost(){
|
ManaCost::~ManaCost(){
|
||||||
LOG("==Deleting ManaCost==");
|
|
||||||
for (unsigned int i = 0; i < nbhybrids ; i++){
|
for (unsigned int i = 0; i < nbhybrids ; i++){
|
||||||
SAFE_DELETE(hybrids[i]);
|
SAFE_DELETE(hybrids[i]);
|
||||||
}
|
}
|
||||||
@@ -396,3 +396,58 @@ ostream& operator<<(ostream& out, const ManaCost& m)
|
|||||||
{
|
{
|
||||||
return out << "(manacost)";
|
return out << "(manacost)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ManaPool::init(){
|
||||||
|
ManaCost::init();
|
||||||
|
WEvent * e = NEW WEventEmptyManaPool(this);
|
||||||
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
ManaPool::ManaPool(Player * player):ManaCost(),player(player){}
|
||||||
|
ManaPool::ManaPool(ManaCost * _manaCost,Player * player):ManaCost(_manaCost),player(player){}
|
||||||
|
|
||||||
|
int ManaPool::remove (int color, int value){
|
||||||
|
int result = ManaCost::remove(color, value);
|
||||||
|
for (int i = 0; i < value; ++i){
|
||||||
|
WEvent * e = NEW WEventConsumeMana(color, this);
|
||||||
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ManaPool::add(int color, int value, MTGCardInstance * source ){
|
||||||
|
int result = ManaCost::add(color, value);
|
||||||
|
for (int i = 0; i < value; ++i){
|
||||||
|
WEvent * e = NEW WEventEngageMana(color, source,this);
|
||||||
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ManaPool::add(ManaCost * _cost, MTGCardInstance * source){
|
||||||
|
if(!_cost) return 0;
|
||||||
|
int result = ManaCost::add(_cost);
|
||||||
|
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++){
|
||||||
|
for (int j = 0; j < _cost->getCost(i); j++){
|
||||||
|
WEvent * e = NEW WEventEngageMana(i, source, this);
|
||||||
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
int ManaPool::pay (ManaCost * _cost){
|
||||||
|
int current[Constants::MTG_NB_COLORS];
|
||||||
|
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++){
|
||||||
|
current[i] = cost[i];
|
||||||
|
}
|
||||||
|
int result = ManaCost::pay(_cost);
|
||||||
|
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++){
|
||||||
|
int value = current[i] - cost[i];
|
||||||
|
for (int j = 0; j <value; j++){
|
||||||
|
WEvent * e = NEW WEventConsumeMana(i, this);
|
||||||
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "../include/Player.h"
|
#include "../include/Player.h"
|
||||||
#include "../include/GameObserver.h"
|
#include "../include/GameObserver.h"
|
||||||
#include "../include/DeckStats.h"
|
#include "../include/DeckStats.h"
|
||||||
|
#include "../include/ManaCost.h"
|
||||||
|
|
||||||
|
|
||||||
Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageable(20){
|
Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageable(20){
|
||||||
@@ -9,7 +10,7 @@ Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageabl
|
|||||||
deckFileSmall = fileSmall;
|
deckFileSmall = fileSmall;
|
||||||
game = deck;
|
game = deck;
|
||||||
game->setOwner(this);
|
game->setOwner(this);
|
||||||
manaPool = NEW ManaCost();
|
manaPool = NEW ManaPool(this);
|
||||||
canPutLandsIntoPlay = 1;
|
canPutLandsIntoPlay = 1;
|
||||||
mAvatar = NULL;
|
mAvatar = NULL;
|
||||||
type_as_damageable = DAMAGEABLE_PLAYER;
|
type_as_damageable = DAMAGEABLE_PLAYER;
|
||||||
@@ -21,9 +22,9 @@ void Player::End(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(){
|
Player::~Player(){
|
||||||
if (manaPool) delete manaPool;
|
SAFE_DELETE(manaPool);
|
||||||
if (mAvatarTex) delete mAvatarTex;
|
SAFE_DELETE(mAvatarTex);
|
||||||
if (mAvatar) delete mAvatar;
|
SAFE_DELETE(mAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
const string Player::getDisplayName(){
|
const string Player::getDisplayName(){
|
||||||
@@ -63,7 +64,7 @@ HumanPlayer::HumanPlayer(MTGPlayerCards * deck, string file, string fileSmall) :
|
|||||||
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
|
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
ManaCost * Player::getManaPool(){
|
ManaPool * Player::getManaPool(){
|
||||||
return manaPool;
|
return manaPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ int TestSuiteAI::Act(float dt){
|
|||||||
|
|
||||||
|
|
||||||
timer+= dt;
|
timer+= dt;
|
||||||
if (AManaProducer::currentlyTapping || timer < suite->timerLimit) return 1;
|
if (timer < suite->timerLimit) return 1;
|
||||||
timer = 0;
|
timer = 0;
|
||||||
|
|
||||||
string action = suite->getNextAction();
|
string action = suite->getNextAction();
|
||||||
|
|||||||
@@ -22,5 +22,6 @@ WEventCreatureBlocker::WEventCreatureBlocker(MTGCardInstance * card, MTGCardInst
|
|||||||
|
|
||||||
WEventCreatureBlockerRank::WEventCreatureBlockerRank(MTGCardInstance * card, MTGCardInstance * exchangeWith, MTGCardInstance * attacker) : WEventCardUpdate(card), exchangeWith(exchangeWith), attacker(attacker){}
|
WEventCreatureBlockerRank::WEventCreatureBlockerRank(MTGCardInstance * card, MTGCardInstance * exchangeWith, MTGCardInstance * attacker) : WEventCardUpdate(card), exchangeWith(exchangeWith), attacker(attacker){}
|
||||||
|
|
||||||
WEventEngageMana::WEventEngageMana(int color, MTGCardInstance* card) : WEvent(), color(color), card(card) {}
|
WEventEngageMana::WEventEngageMana(int color, MTGCardInstance* card, ManaPool * destination) : WEvent(), color(color), card(card), destination(destination) {}
|
||||||
WEventConsumeMana::WEventConsumeMana(int color) : WEvent(), color(color) {}
|
WEventConsumeMana::WEventConsumeMana(int color, ManaPool * source) : WEvent(), color(color),source(source) {}
|
||||||
|
WEventEmptyManaPool::WEventEmptyManaPool(ManaPool * source):WEvent(),source(source){}
|
||||||
|
|||||||
Reference in New Issue
Block a user