Erwan
- fix issue 392 (broken tests) - Fix a bunch of memory leaks (guys please be careful!) - Added Logging facility in JGE - HBL Compatibility (cleaned up some code with MP3 in JGE) - Added "winGame" ability. Currently used mostly by the story mode, but some cards could probably need it too - Improved story mode and uncommented it from the source. -- The current campaign is of course very basic, anybody who wants to improve it or create other ones feel free to do so -- TODO (short term): save progress, rewards system, improve tutorial campaign -- I'll talk a bit more about this on the forums/email after a night of sleep
This commit is contained in:
@@ -400,7 +400,9 @@ class GenericActivatedAbility:public ActivatedAbility, public NestedAbility{
|
||||
|
||||
int resolve(){
|
||||
counters++;
|
||||
source->X = abilityCost->Diff(cost)->hasX();
|
||||
ManaCost * diff = abilityCost->Diff(cost);
|
||||
source->X = diff->hasX();
|
||||
SAFE_DELETE(diff);
|
||||
SAFE_DELETE(abilityCost);
|
||||
ability->target = target; //may have been updated...
|
||||
if (ability) return ability->resolve();
|
||||
@@ -630,6 +632,35 @@ class AALifer:public ActivatedAbilityTP{
|
||||
|
||||
};
|
||||
|
||||
/*Player Wins Game*/
|
||||
class AAWinGame:public ActivatedAbilityTP{
|
||||
public:
|
||||
AAWinGame(int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost = NULL, int _tap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id, card,_target,_cost,_tap,who){
|
||||
}
|
||||
|
||||
int resolve(){
|
||||
Damageable * _target = (Damageable *) getTarget();
|
||||
if (_target){
|
||||
if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE){
|
||||
_target = ((MTGCardInstance *)_target)->controller();
|
||||
}
|
||||
game->gameOver = ((Player *)_target)->opponent();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * getMenuText(){
|
||||
return "Win Game";
|
||||
}
|
||||
|
||||
AAWinGame * clone() const{
|
||||
AAWinGame * a = NEW AAWinGame(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ATokenCreator:public ActivatedAbility{
|
||||
@@ -1968,10 +1999,10 @@ class AThisForEach:public MTGAbility, public NestedAbility{
|
||||
int matches;
|
||||
matches = td->match(source);
|
||||
if (matches > 0) {
|
||||
if (abilities.size() > matches){
|
||||
if ((int)(abilities.size()) > matches){
|
||||
removeAbilityFromGame();
|
||||
}
|
||||
for (int i = 0; i < matches - abilities.size(); i++) {
|
||||
for (int i = 0; i < matches - (int)(abilities.size()); i++) {
|
||||
addAbilityToGame();
|
||||
}
|
||||
}
|
||||
@@ -2988,53 +3019,6 @@ class ALivingArtifact:public MTGAbility{
|
||||
}
|
||||
};
|
||||
|
||||
//Lord of the Pit
|
||||
class ALordOfThePit: public TargetAbility{
|
||||
public:
|
||||
int paidThisTurn;
|
||||
ALordOfThePit(int _id, MTGCardInstance * source):TargetAbility(_id, source, NEW CreatureTargetChooser(),0,1,0){
|
||||
paidThisTurn = 1;
|
||||
}
|
||||
|
||||
void Update(float dt){
|
||||
if (newPhase != currentPhase && source->controller() == game->currentPlayer){
|
||||
if (newPhase == Constants::MTG_PHASE_UNTAP){
|
||||
paidThisTurn = 0;
|
||||
}else if( newPhase == Constants::MTG_PHASE_UPKEEP + 1 && !paidThisTurn){
|
||||
game->mLayers->stackLayer()->addDamage(source,source->controller(), 7);
|
||||
}
|
||||
}
|
||||
TargetAbility::Update(dt);
|
||||
}
|
||||
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
|
||||
if (currentPhase != Constants::MTG_PHASE_UPKEEP || paidThisTurn) return 0;
|
||||
return TargetAbility::isReactingToClick(card,mana);
|
||||
}
|
||||
|
||||
int resolve(){
|
||||
MTGCardInstance * card = tc->getNextCardTarget();
|
||||
if (card && card != source && card->controller() == source->controller()){
|
||||
card->controller()->game->putInGraveyard(card);
|
||||
paidThisTurn = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual ostream& toString(ostream& out) const
|
||||
{
|
||||
out << "ALordOfThePit ::: paidThisTurn : " << paidThisTurn
|
||||
<< " (";
|
||||
return TargetAbility::toString(out) << ")";
|
||||
}
|
||||
ALordOfThePit * clone() const{
|
||||
ALordOfThePit * a = NEW ALordOfThePit(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
//1143 Animate Dead
|
||||
class AAnimateDead:public MTGAbility{
|
||||
public:
|
||||
@@ -3577,48 +3561,6 @@ class AFireball:public InstantAbility{
|
||||
}
|
||||
};
|
||||
|
||||
//1245 ForceOfNature
|
||||
class AForceOfNature:public ActivatedAbility{
|
||||
public:
|
||||
int dealDamageThisTurn;
|
||||
AForceOfNature(int _id, MTGCardInstance * card):ActivatedAbility(_id,card, NEW ManaCost(),1,0){
|
||||
dealDamageThisTurn = 0;
|
||||
cost->add(Constants::MTG_COLOR_GREEN,4);
|
||||
}
|
||||
|
||||
void Update(float dt){
|
||||
if (newPhase !=currentPhase){
|
||||
if (newPhase == Constants::MTG_PHASE_UNTAP){
|
||||
dealDamageThisTurn = 1;
|
||||
}else if (newPhase == Constants::MTG_PHASE_DRAW && dealDamageThisTurn && game->currentPlayer==source->controller() ){
|
||||
game->mLayers->stackLayer()->addDamage(source,source->controller(),8);
|
||||
}
|
||||
}
|
||||
ActivatedAbility::Update(dt);
|
||||
}
|
||||
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
|
||||
return (dealDamageThisTurn && currentPhase == Constants::MTG_PHASE_UPKEEP && ActivatedAbility::isReactingToClick(card,mana));
|
||||
}
|
||||
|
||||
int resolve(){
|
||||
dealDamageThisTurn = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual ostream& toString(ostream& out) const
|
||||
{
|
||||
out << "AForceOfNature ::: dealDamageThisTurn : " << dealDamageThisTurn
|
||||
<< " (";
|
||||
return ActivatedAbility::toString(out) << ")";
|
||||
}
|
||||
AForceOfNature * clone() const{
|
||||
AForceOfNature * a = NEW AForceOfNature(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//1351 Island Sanctuary
|
||||
class AIslandSanctuary:public MTGAbility{
|
||||
|
||||
@@ -35,12 +35,14 @@
|
||||
#define PLAYER_TYPE_HUMAN 1
|
||||
#define PLAYER_TYPE_TESTSUITE 2
|
||||
|
||||
|
||||
#define GAME_TYPE_CLASSIC 0
|
||||
#define GAME_TYPE_MOMIR 1
|
||||
#define GAME_TYPE_RANDOM1 2
|
||||
#define GAME_TYPE_RANDOM2 3
|
||||
#define GAME_TYPE_STORY 4
|
||||
enum
|
||||
{
|
||||
GAME_TYPE_CLASSIC,
|
||||
GAME_TYPE_MOMIR,
|
||||
GAME_TYPE_RANDOM1,
|
||||
GAME_TYPE_RANDOM2,
|
||||
GAME_TYPE_STORY
|
||||
};
|
||||
|
||||
class MTGAllCards;
|
||||
class TransitionBase;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#ifndef _LOGGER_H
|
||||
#define _LOGGER_H_
|
||||
|
||||
//TODO Remove this and use the jge logging facility (same system)
|
||||
//#define DOLOG
|
||||
|
||||
#ifdef DOLOG
|
||||
#define LOG(x) Logger::Log(x);
|
||||
#else
|
||||
|
||||
@@ -10,12 +10,39 @@ using namespace std;
|
||||
class GameObserver;
|
||||
#define CAMPAIGNS_FOLDER "Res/campaigns/"
|
||||
|
||||
|
||||
class StoryGraphicalElement:public JGuiObject {
|
||||
public:
|
||||
float mX;
|
||||
float mY;
|
||||
StoryGraphicalElement(float x, float y);
|
||||
};
|
||||
|
||||
class StoryText:public StoryGraphicalElement {
|
||||
public :
|
||||
string text;
|
||||
int align;
|
||||
StoryText(string text, float mX, float mY, string align = "center");
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
class StoryImage:public StoryGraphicalElement {
|
||||
public :
|
||||
string img;
|
||||
StoryImage(string img, float mX, float mY);
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
|
||||
class StoryChoice:public JGuiObject {
|
||||
public:
|
||||
string pageId;
|
||||
string text;
|
||||
int mX;
|
||||
int mY;
|
||||
float mX;
|
||||
float mY;
|
||||
|
||||
bool mHasFocus;
|
||||
float mScale;
|
||||
float mTargetScale;
|
||||
@@ -42,10 +69,12 @@ public:
|
||||
|
||||
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController {
|
||||
private:
|
||||
string text;
|
||||
vector<StoryGraphicalElement *>graphics;
|
||||
string safeAttribute(TiXmlElement* element, string attribute);
|
||||
|
||||
public:
|
||||
StoryDialog(TiXmlElement* el,StoryFlow * mParent);
|
||||
~StoryDialog();
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
void ButtonPressed(int,int);
|
||||
|
||||
@@ -16,6 +16,7 @@ class ThisDescriptor{
|
||||
int comparisonCriterion;
|
||||
virtual int match(MTGCardInstance * card) = 0;
|
||||
int matchValue(int value);
|
||||
virtual ~ThisDescriptor();
|
||||
};
|
||||
|
||||
class ThisDescriptorFactory{
|
||||
|
||||
Reference in New Issue
Block a user