Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defines/Typos #557

Merged
merged 13 commits into from
Nov 20, 2013
25 changes: 9 additions & 16 deletions projects/mtg/include/ActionElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
#include <JGui.h>
#include "MTGDefinitions.h"

#define INACTIVE 0
#define ACTION_REQUESTED 1
#define ACTIVE 2

class MTGCardInstance;
class ManaCost;
class Targetable;
Expand All @@ -22,31 +18,33 @@ class WEvent;
class ActionElement: public JGuiObject
{
protected:
int activeState;
enum Activity{
Inactive,
ActionRequested,
Active
};

Activity activity;
TargetChooser * tc;
public:
GamePhase currentPhase;
GamePhase newPhase;
int modal;
int waitingForAnswer;
int getActivity();
virtual void Update(float){};
virtual void Render(){};
virtual void Update(float){}
virtual void Render(){}
virtual int testDestroy()
{
return 0;
}
;
virtual int destroy()
{
return 0;
}
;
virtual bool CheckUserInput(JButton)
{
return false;
}
;
ActionElement(int id);
ActionElement(const ActionElement& copyFromMe);
TargetChooser * getActionTc(){return tc;}
Expand All @@ -62,27 +60,22 @@ class ActionElement: public JGuiObject
{
return 0;
}
;
virtual int stillInUse(MTGCardInstance *)
{
return 0;
}
;
virtual int receiveEvent(WEvent *)
{
return 0;
}
;
virtual int reactToClick(MTGCardInstance *)
{
return 0;
}
;
virtual const char * getMenuText()
{
return "Ability";
}
;
virtual ActionElement * clone() const = 0;

};
Expand Down
14 changes: 6 additions & 8 deletions projects/mtg/include/ActionStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,9 @@ class DamageStack;
class ManaCost;
class TargetChooser;


#define ACTIONSTACK_STANDARD 0
#define ACTIONSTACK_TARGET 1

class Interruptible: public PlayGuiObject, public Targetable
{
public:
//TODO : remove these when they are back in PlayGuiObject
float x, y;

int state, display;
MTGCardInstance * source;
virtual void Entering()
Expand Down Expand Up @@ -186,6 +179,11 @@ class LifeAction: public Interruptible
class ActionStack :public GuiLayer
{
public:
enum ActionStackMode{
ACTIONSTACK_STANDARD = 0,
ACTIONSTACK_TARGET = 1
};

typedef enum
{
NOT_DECIDED = 0,
Expand All @@ -207,7 +205,7 @@ class ActionStack :public GuiLayer
InterruptDecision interruptDecision[2];
float timer;
int currentState;
int mode;
ActionStackMode mode;
int checked;
ATutorialMessage* currentTutorial;
int interruptBtnXOffset, noBtnXOffset, noToAllBtnXOffset, interruptDialogWidth;
Expand Down
10 changes: 5 additions & 5 deletions projects/mtg/include/AllAbilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,8 @@ class TrDamaged: public Trigger
return 0;
if (!tc->canTarget(e->damage->target)) return 0;
if (fromTc && !fromTc->canTarget(e->damage->source)) return 0;
if (type == 1 && e->damage->typeOfDamage != DAMAGE_COMBAT) return 0;
if (type == 2 && e->damage->typeOfDamage == DAMAGE_COMBAT) return 0;
if (type == 1 && e->damage->typeOfDamage != Damage::DAMAGE_COMBAT) return 0;
if (type == 2 && e->damage->typeOfDamage == Damage::DAMAGE_COMBAT) return 0;
e->damage->target->thatmuch = e->damage->damage;
e->damage->source->thatmuch = e->damage->damage;
this->source->thatmuch = e->damage->damage;
Expand Down Expand Up @@ -2577,7 +2577,7 @@ class ALord: public ListMaintainerAbility, public NestedAbility
}
else
{
if (d->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
if (d->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
{
a->source = (MTGCardInstance *) d;
}
Expand Down Expand Up @@ -2725,7 +2725,7 @@ class ATeach: public ListMaintainerAbility, public NestedAbility
}
else
{
if (d->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
if (d->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
{
a->source = (MTGCardInstance *) d;
}
Expand Down Expand Up @@ -5549,7 +5549,7 @@ class ASpiritLinkAbility: public MTGAbility
{
WEventDamage * e = (WEventDamage *) event;
Damage * d = e->damage;
if (combatonly && e->damage->typeOfDamage != DAMAGE_COMBAT)
if (combatonly && e->damage->typeOfDamage != Damage::DAMAGE_COMBAT)
return 0;
MTGCardInstance * card = d->source;
if (d->damage > 0 && card && (card == source || card == source->target))
Expand Down
10 changes: 6 additions & 4 deletions projects/mtg/include/CardDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#include "MTGGameZones.h"
#include "Counters.h"

#define CD_OR 1
#define CD_AND 2

enum ENUM_COMPARISON_MODES
{
COMPARISON_NONE = 0, // Needs to remain 0 for quick if(comparison_mode) checks
Expand All @@ -31,7 +28,12 @@ class CardDescriptor: public MTGCardInstance
MTGCardInstance * match_not(MTGCardInstance * card);
bool valueInRange(int comparisonMode, int value, int criterion);
public:
int mode;
enum Operator{
CD_OR = 1,
CD_AND = 2
};

Operator mode;
int powerComparisonMode;
int toughnessComparisonMode;
int manacostComparisonMode;
Expand Down
38 changes: 22 additions & 16 deletions projects/mtg/include/Damage.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ class JGuiObject;
class MTGCardInstance;
class GameObserver;

#define DAMAGEABLE_MTGCARDINSTANCE 0
#define DAMAGEABLE_PLAYER 1

#define DAMAGE_ALL_TYPES 0
#define DAMAGE_COMBAT 1
#define DAMAGE_OTHER 2

class Damageable:public Targetable
{
protected:
public:
enum DamageableType{
DAMAGEABLE_MTGCARDINSTANCE = 0,
DAMAGEABLE_PLAYER
};

int life;
int handsize;
int poisonCount;
int damageCount;
int preventable;
int thatmuch;
int lifeLostThisTurn;
int type_as_damageable;
DamageableType type_as_damageable;
Damageable(GameObserver* observer, int _life)
: Targetable(observer)
{life=_life;lifeLostThisTurn = 0;};
int getLife(){return life;};
virtual int dealDamage(int damage){life-=damage;return life;};
: Targetable(observer), life(_life), handsize(0),
poisonCount(0), damageCount(0), preventable(0), thatmuch(0),
lifeLostThisTurn(0), type_as_damageable(DAMAGEABLE_MTGCARDINSTANCE)
{}
int getLife(){return life;}
virtual int dealDamage(int damage){life-=damage;return life;}
virtual int afterDamage(){return 0;}
virtual int poisoned(){return 0;}
virtual int prevented(){return 0;}
Expand All @@ -47,17 +47,23 @@ class Damageable:public Targetable

class Damage: public Interruptible
{
protected:
void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage);
public:
enum DamageType{
DAMAGE_ALL_TYPES = 0,
DAMAGE_COMBAT,
DAMAGE_OTHER
};

Damageable * target;
int typeOfDamage;
DamageType typeOfDamage;
int damage;
void Render();
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target);
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target, int damage, int typeOfDamage = DAMAGE_OTHER);
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target, int damage, DamageType typeOfDamage = DAMAGE_OTHER);
int resolve();
virtual ostream& toString(ostream& out) const;
protected:
void init(MTGCardInstance * source, Damageable * target, int damage, DamageType typeOfDamage);
};

class DamageStack : public GuiLayer, public Interruptible
Expand Down
5 changes: 3 additions & 2 deletions projects/mtg/include/ReplacementEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ class REDamagePrevention: public ReplacementEffect
TargetChooser * tcTarget;
int damage;
bool oneShot;
int typeOfDamage;
Damage::DamageType typeOfDamage;
public:
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL, TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true, int typeOfDamage = DAMAGE_ALL_TYPES);
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL, TargetChooser *_tcTarget = NULL,
int _damage = -1, bool _oneShot = true, Damage::DamageType typeOfDamage = Damage::DAMAGE_ALL_TYPES);
WEvent * replace(WEvent *e);
~REDamagePrevention();
};
Expand Down
14 changes: 6 additions & 8 deletions projects/mtg/src/AIHints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ AIHint::AIHint(string _line)

if(action.find( "combo ") != string::npos)
{
string Combo = "";
Combo = action.c_str() + 6;
string Combo = action.c_str() + 6;
combos.push_back(Combo);
}

Expand Down Expand Up @@ -307,14 +306,13 @@ bool AIHints::canWeCombo(GameObserver* observer,MTGCardInstance * card,AIPlayerB
TargetChooserFactory tfc(observer);
TargetChooser * hintTc = NULL;
bool gotCombo = false;
int comboPartsHold = 0;
int comboPartsUntil = 0;
int comboPartsRestriction = 0;

for(unsigned int i = 0; i < hints.size();i++)
{
comboPartsHold = 0;
comboPartsUntil = 0;
comboPartsRestriction = 0;
int comboPartsHold = 0;
int comboPartsUntil = 0;
int comboPartsRestriction = 0;

if(gotCombo)
return gotCombo;//because more then one might be possible at any time.
if (hints[i]->hold.size())
Expand Down
8 changes: 2 additions & 6 deletions projects/mtg/src/AIMomirPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,12 @@ int AIMomirPlayer::computeActions()
}
else if (p == this && observer->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
{ //standard actions
CardDescriptor cd;
MTGCardInstance * card = NULL;

switch (currentGamePhase)
{
case MTG_PHASE_FIRSTMAIN:
{
CardDescriptor cd;
ManaCost * potentialMana = getPotentialMana();
int converted = potentialMana->getConvertedCost();
SAFE_DELETE(potentialMana);
Expand All @@ -106,7 +105,7 @@ int AIMomirPlayer::computeActions()
//Attempt to put land into play
cd.init();
cd.setColor(Constants::MTG_COLOR_LAND);
card = cd.match(game->hand);
MTGCardInstance *card = cd.match(game->hand);
int canPutLandsIntoPlay = game->playRestrictions->canPutIntoZone(card, game->inPlay);
if (card && (canPutLandsIntoPlay == PlayRestriction::CAN_PLAY))
{
Expand All @@ -118,15 +117,12 @@ int AIMomirPlayer::computeActions()
}
momir();
return 1;
break;
}
case MTG_PHASE_SECONDMAIN:
selectAbility();
return 1;
break;
default:
return AIPlayerBaka::computeActions();
break;
}
}
return AIPlayerBaka::computeActions();
Expand Down
4 changes: 2 additions & 2 deletions projects/mtg/src/AIPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int AIAction::clickMultiAct(vector<Targetable*>& actionTargets)
ite = actionTargets.erase(ite);
continue;
}
ite++;
++ite;
}

//shuffle to make it less predictable, otherwise ai will always seem to target from right to left. making it very obvious.
Expand Down Expand Up @@ -167,7 +167,7 @@ int AIPlayer::clickMultiTarget(TargetChooser * tc, vector<Targetable*>& potentia
ite = potentialTargets.erase(ite);
continue;
}
ite++;
++ite;
}

randomGenerator.random_shuffle(potentialTargets.begin(), potentialTargets.end());
Expand Down
Loading