Erwan
- Fixed a bug with Composite golem (and summoning sickness for Mana abilities in general) - Improved test suite speed
This commit is contained in:
@@ -616,195 +616,7 @@ class ASpellCounterEnchantment:public TargetAbility{
|
||||
|
||||
};
|
||||
|
||||
/*Mana Producers (lands)
|
||||
//These have a reactToClick function, and therefore two manaProducers on the same card conflict with each other
|
||||
//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)
|
||||
*/
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
class AManaProducer: public MTGAbility{
|
||||
protected:
|
||||
static int currentlyTapping;
|
||||
ManaCost * cost;
|
||||
ManaCost * output;
|
||||
string menutext;
|
||||
float x0,y0,x1,y1,x,y;
|
||||
float animation;
|
||||
Player * controller;
|
||||
|
||||
hgeParticleSystem * mParticleSys;
|
||||
public:
|
||||
AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost = NULL ):MTGAbility(id, card){
|
||||
LOG("==Creating ManaProducer Object");
|
||||
if (!_cost) OutputDebugString("NO COST???\n");
|
||||
cost = _cost;
|
||||
output=_output;
|
||||
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 = "";
|
||||
|
||||
int landColor = output->getMainColor();
|
||||
|
||||
if (landColor == Constants::MTG_COLOR_RED){
|
||||
mParticleSys = NEW hgeParticleSystem("graphics/manared.psi",GameApp::CommonRes->GetQuad("particles"));
|
||||
}else if (landColor == Constants::MTG_COLOR_BLUE){
|
||||
mParticleSys = NEW hgeParticleSystem("graphics/manablue.psi", GameApp::CommonRes->GetQuad("particles"));
|
||||
}else if (landColor == Constants::MTG_COLOR_GREEN){
|
||||
mParticleSys = NEW hgeParticleSystem("graphics/managreen.psi", GameApp::CommonRes->GetQuad("particles"));
|
||||
}else if (landColor == Constants::MTG_COLOR_BLACK){
|
||||
mParticleSys = NEW hgeParticleSystem("graphics/manablack.psi", GameApp::CommonRes->GetQuad("particles"));
|
||||
}else if (landColor == Constants::MTG_COLOR_WHITE){
|
||||
mParticleSys = NEW hgeParticleSystem("graphics/manawhite.psi", GameApp::CommonRes->GetQuad("particles"));
|
||||
}else{
|
||||
mParticleSys = NEW hgeParticleSystem("graphics/mana.psi", GameApp::CommonRes->GetQuad("particles"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
LOG("==ManaProducer Object Creation successful !");
|
||||
}
|
||||
|
||||
void 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){
|
||||
animation = 0;
|
||||
currentlyTapping--;
|
||||
resolve();
|
||||
if (mParticleSys) mParticleSys->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void 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 isReactingToClick(MTGCardInstance * _card){
|
||||
int result = 0;
|
||||
if (_card == source && !source->isTapped() && game->currentlyActing()->game->inPlay->hasCard(source) && (source->hasType("land") || !source->hasSummoningSickness()) ){
|
||||
if (!cost || game->currentlyActing()->getManaPool()->canAfford(cost)) result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int resolve(){
|
||||
controller = source->controller();
|
||||
controller->getManaPool()->add(output);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int reactToClick(MTGCardInstance * _card){
|
||||
if (!isReactingToClick( _card)) return 0;
|
||||
OutputDebugString("React To click 1\n");
|
||||
if (cost){
|
||||
cost->setExtraCostsAction(this, _card);
|
||||
OutputDebugString("React To click 2\n");
|
||||
if (!cost->isExtraPaymentSet()){
|
||||
OutputDebugString("React To click 3\n");
|
||||
|
||||
GameObserver::GetInstance()->waitForExtraPayment = cost->extraCosts;
|
||||
return 0;
|
||||
}
|
||||
GameObserver::GetInstance()->currentlyActing()->getManaPool()->pay(cost);
|
||||
cost->doPayExtra();
|
||||
}
|
||||
source->tapped = 1;
|
||||
currentlyTapping++;
|
||||
|
||||
animation = 1.f;
|
||||
CardGui * cardg = game->mLayers->playLayer()->getByCard(source);
|
||||
if (cardg){
|
||||
x0 = cardg->x + 15;
|
||||
y0 = cardg->y + 20;
|
||||
}
|
||||
|
||||
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0 && currentlyTapping < 3){
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
|
||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * getMenuText(){
|
||||
if (menutext.size())return menutext.c_str();
|
||||
menutext = "Add ";
|
||||
char buffer[128];
|
||||
int alreadyHasOne = 0;
|
||||
for (int i= 0; i < 6; i++){
|
||||
int value = output->getCost(i);
|
||||
if (value){
|
||||
if (alreadyHasOne) menutext.append(",");
|
||||
sprintf(buffer, "%i ", value);
|
||||
menutext.append(buffer);
|
||||
switch (i){
|
||||
case Constants::MTG_COLOR_RED:
|
||||
menutext.append("red");
|
||||
break;
|
||||
case Constants::MTG_COLOR_BLUE:
|
||||
menutext.append("blue");
|
||||
break;
|
||||
case Constants::MTG_COLOR_GREEN:
|
||||
menutext.append("green");
|
||||
break;
|
||||
case Constants::MTG_COLOR_WHITE:
|
||||
menutext.append("white");
|
||||
break;
|
||||
case Constants::MTG_COLOR_BLACK:
|
||||
menutext.append("black");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
alreadyHasOne = 1;
|
||||
}
|
||||
}
|
||||
menutext.append(" mana");
|
||||
return menutext.c_str();
|
||||
}
|
||||
|
||||
int testDestroy(){
|
||||
if (animation >0) return 0;
|
||||
return MTGAbility::testDestroy();
|
||||
}
|
||||
|
||||
~AManaProducer(){
|
||||
LOG("==Destroying ManaProducer Object");
|
||||
SAFE_DELETE(cost);
|
||||
SAFE_DELETE(output);
|
||||
SAFE_DELETE(mParticleSys);
|
||||
LOG("==Destroying ManaProducer Object Successful!");
|
||||
}
|
||||
|
||||
};
|
||||
int AManaProducer::currentlyTapping = 0;
|
||||
|
||||
/* Lifelink Ability */
|
||||
class ALifeLink:public MTGAbility{
|
||||
|
||||
@@ -12,10 +12,12 @@ class TargetChooser;
|
||||
class ManaCost;
|
||||
class MTGGameZone;
|
||||
class Player;
|
||||
class AManaProducer;
|
||||
|
||||
#include "ActionElement.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <hge/hgeparticle.h>
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
||||
@@ -207,6 +209,31 @@ class AbilityFactory{
|
||||
};
|
||||
|
||||
|
||||
class AManaProducer: public MTGAbility{
|
||||
protected:
|
||||
|
||||
ManaCost * cost;
|
||||
ManaCost * output;
|
||||
string menutext;
|
||||
float x0,y0,x1,y1,x,y;
|
||||
float animation;
|
||||
Player * controller;
|
||||
int tap;
|
||||
|
||||
hgeParticleSystem * mParticleSys;
|
||||
public:
|
||||
static int currentlyTapping;
|
||||
AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1 );
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
int isReactingToClick(MTGCardInstance * _card);
|
||||
int resolve();
|
||||
int reactToClick(MTGCardInstance * _card);
|
||||
const char * getMenuText();
|
||||
int testDestroy();
|
||||
~AManaProducer();
|
||||
};
|
||||
|
||||
#include "MTGCardInstance.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -47,6 +47,7 @@ class TestSuiteState{
|
||||
};
|
||||
class TestSuite{
|
||||
public:
|
||||
int summoningSickness;
|
||||
float timerLimit;
|
||||
int currentAction;
|
||||
TestSuiteState initState;
|
||||
|
||||
Reference in New Issue
Block a user