- Trying to add generic classes for Triggered abilities. PLEASE DO NOT USE THESE RIGHT NOW, Not Tested AT ALL !
This commit is contained in:
wagic.the.homebrew
2008-11-12 14:38:30 +00:00
parent c97dd1f260
commit a418e10c47
6 changed files with 5003 additions and 5024 deletions
-1
View File
@@ -29,7 +29,6 @@ class ActionElement: public JGuiObject{
int newPhase; int newPhase;
int modal; int modal;
int waitingForAnswer; int waitingForAnswer;
void RenderMessageBackground(float y0, int height);
int getActivity(); int getActivity();
virtual void Update(float dt){}; virtual void Update(float dt){};
virtual void Render(){}; virtual void Render(){};
File diff suppressed because it is too large Load Diff
+193 -118
View File
@@ -1,118 +1,193 @@
#ifndef _MTGABILITY_H_ #ifndef _MTGABILITY_H_
#define _MTGABILITY_H_ #define _MTGABILITY_H_
class MTGCardInstance; class MTGCardInstance;
class GameObserver; class GameObserver;
class Spell; class Spell;
class Damageable; class Damageable;
class PlayGuiObject; class PlayGuiObject;
class TargetChooser; class TargetChooser;
class ManaCost; class ManaCost;
class MTGGameZone; class MTGGameZone;
class Player; class Player;
#include "ActionElement.h" #include "ActionElement.h"
#include <string> #include <string>
#include <map> #include <map>
using std::string; using std::string;
using std::map; using std::map;
#define BAKA_EFFECT_GOOD 10 //Two stupid variables used to give a hint to the AI:
#define BAKA_EFFECT_BAD 11 // Should I cast a spell on an ennemy or friendly unit ?
#define BAKA_EFFECT_GOOD 10
class AbilityFactory{ #define BAKA_EFFECT_BAD 11
private:
int destroyAllFromTypeInPlay(const char * type, MTGCardInstance * source, int bury = 0);
int destroyAllFromColorInPlay(int color, MTGCardInstance * source, int bury = 0);
int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p); class MTGAbility: public ActionElement{
public: protected:
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL); char menuText[25];
void addAbilities(int _id, Spell * spell); Damageable * target;
}; GameObserver * game;
public:
class MTGAbility: public ActionElement{ MTGCardInstance * source;
protected: MTGAbility(int id, MTGCardInstance * card);
char menuText[25]; MTGAbility(int id, MTGCardInstance * _source, Damageable * _target);
Damageable * target; virtual int testDestroy();
GameObserver * game; virtual ~MTGAbility();
public: virtual void Render(){};
MTGCardInstance * source; virtual int isReactingToClick(MTGCardInstance * card){return 0;};
MTGAbility(int id, MTGCardInstance * card); virtual int reactToClick(MTGCardInstance * card){return 0;};
MTGAbility(int id, MTGCardInstance * _source, Damageable * _target); virtual void Update(float dt){};
virtual int testDestroy(); virtual int fireAbility();
virtual ~MTGAbility(); virtual int resolve(){return 0;};
virtual void Render(){};
virtual int isReactingToClick(MTGCardInstance * card){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;}; };
virtual void Update(float dt){};
virtual int fireAbility();
virtual int resolve(){return 0;}; class TriggeredAbility:public MTGAbility{
public:
TriggeredAbility(int id, MTGCardInstance * card);
}; TriggeredAbility(int id, MTGCardInstance * _source, Damageable * _target);
virtual void Update(float dt);
virtual void Render(){};
class TriggeredAbility:public MTGAbility{ virtual int trigger()=0;
public: virtual int resolve() = 0;
TriggeredAbility(int id, MTGCardInstance * card); };
TriggeredAbility(int id, MTGCardInstance * _source, Damageable * _target);
virtual void Update(float dt);
virtual void Render(){}; class ActivatedAbility:public MTGAbility{
virtual int trigger()=0; public:
virtual int resolve() = 0; ManaCost * cost;
}; int playerturnonly;
int needsTapping;
ActivatedAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
class ActivatedAbility:public MTGAbility{ virtual int reactToClick(MTGCardInstance * card);
public: virtual int isReactingToClick(MTGCardInstance * card);
ManaCost * cost; virtual int reactToTargetClick(Targetable * object);
int playerturnonly; virtual int resolve() = 0;
int needsTapping; virtual ~ActivatedAbility();
ActivatedAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1); };
virtual int reactToClick(MTGCardInstance * card);
virtual int isReactingToClick(MTGCardInstance * card); class TargetAbility:public ActivatedAbility{
virtual int reactToTargetClick(Targetable * object); public:
virtual int resolve() = 0; TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual ~ActivatedAbility(); TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
}; virtual void Update(float dt);
virtual int reactToClick(MTGCardInstance * card);
class TargetAbility:public ActivatedAbility{ virtual int reactToTargetClick(Targetable * object);
public: virtual void Render();
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1); };
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual void Update(float dt); class InstantAbility:public MTGAbility{
virtual int reactToClick(MTGCardInstance * card); public:
virtual int reactToTargetClick(Targetable * object); int init;
virtual void Render(); virtual void Update(float dt);
}; virtual int testDestroy();
InstantAbility(int _id, MTGCardInstance * source);
class InstantAbility:public MTGAbility{ InstantAbility(int _id, MTGCardInstance * source,Damageable * _target);
public: virtual int resolve(){return 0;};
int init; };
virtual void Update(float dt);
virtual int testDestroy(); /* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */
InstantAbility(int _id, MTGCardInstance * source); class ListMaintainerAbility:public MTGAbility{
InstantAbility(int _id, MTGCardInstance * source,Damageable * _target); public:
virtual int resolve(){return 0;}; map<MTGCardInstance *,bool> cards;
}; ListMaintainerAbility(int _id):MTGAbility(_id,NULL){};
ListMaintainerAbility(int _id, MTGCardInstance *_source):MTGAbility(_id, _source){};
/* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */ ListMaintainerAbility(int _id, MTGCardInstance *_source,Damageable * _target):MTGAbility(_id, _source, _target){};
class ListMaintainerAbility:public MTGAbility{ virtual void Update(float dt);
public: virtual int canBeInList(MTGCardInstance * card) = 0;
map<MTGCardInstance *,bool> cards; virtual int added(MTGCardInstance * card) = 0;
ListMaintainerAbility(int _id):MTGAbility(_id,NULL){}; virtual int removed(MTGCardInstance * card) = 0;
ListMaintainerAbility(int _id, MTGCardInstance *_source):MTGAbility(_id, _source){}; virtual int destroy();
ListMaintainerAbility(int _id, MTGCardInstance *_source,Damageable * _target):MTGAbility(_id, _source, _target){}; };
virtual void Update(float dt);
virtual int canBeInList(MTGCardInstance * card) = 0; /* An attempt to globalize triggered abilities as much as possible */
virtual int added(MTGCardInstance * card) = 0; class MTGAbilityBasicFeatures{
virtual int removed(MTGCardInstance * card) = 0; public:
virtual int destroy(); Damageable * target;
}; GameObserver * game;
MTGCardInstance * source;
#include "MTGCardInstance.h" MTGAbilityBasicFeatures();
MTGAbilityBasicFeatures(MTGCardInstance * _source, Damageable * _target = NULL);
#endif void init(MTGCardInstance * _source, Damageable * _target = NULL);
};
class Trigger:public MTGAbilityBasicFeatures{
public:
virtual int trigger()=0;
virtual int testDestroy(){return 0;};
};
class TriggerAtPhase:public Trigger{
public:
int currentPhase, newPhase;
int phaseId;
TriggerAtPhase(int _phaseId);
virtual int trigger();
};
class TriggerNextPhase:public TriggerAtPhase{
public:
int destroyActivated;
TriggerNextPhase(int _phaseId);
virtual int testDestroy();
};
class TriggeredEvent:public MTGAbilityBasicFeatures{
public:
virtual int resolve()=0;
};
class DrawEvent:public TriggeredEvent{
public:
Player * player;
int nbcards;
DrawEvent(Player * _player, int _nbcards);
int resolve();
};
class DestroyCondition:public MTGAbilityBasicFeatures{
public:
virtual int testDestroy();
};
class GenericTriggeredAbility:public TriggeredAbility{
public:
Trigger * t;
TriggeredEvent * te;
DestroyCondition * dc;
GenericTriggeredAbility(int id, MTGCardInstance * _source, Trigger * _t, TriggeredEvent * _te, DestroyCondition * _dc = NULL, Damageable * _target = NULL);
virtual int trigger();
virtual int resolve();
virtual int testDestroy();
~GenericTriggeredAbility();
};
/* Ability Factory */
class AbilityFactory{
private:
int destroyAllFromTypeInPlay(const char * type, MTGCardInstance * source, int bury = 0);
int destroyAllFromColorInPlay(int color, MTGCardInstance * source, int bury = 0);
int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p);
Trigger * parseTrigger(string magicText);
public:
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL);
void addAbilities(int _id, Spell * spell);
};
#include "MTGCardInstance.h"
#endif
+190 -176
View File
@@ -1,176 +1,190 @@
#ifndef _MTGDEFINITION_H_ #ifndef _MTGDEFINITION_H_
#define _MTGDEFINITION_H_ #define _MTGDEFINITION_H_
#define TOTAL_NUMBER_OF_CARDS 4000 #define TOTAL_NUMBER_OF_CARDS 4000
#define MTG_NB_COLORS 7 #define MTG_NB_COLORS 7
#define MTG_COLOR_ARTIFACT 0 #define MTG_COLOR_ARTIFACT 0
#define MTG_COLOR_GREEN 1 #define MTG_COLOR_GREEN 1
#define MTG_COLOR_BLUE 2 #define MTG_COLOR_BLUE 2
#define MTG_COLOR_RED 3 #define MTG_COLOR_RED 3
#define MTG_COLOR_BLACK 4 #define MTG_COLOR_BLACK 4
#define MTG_COLOR_WHITE 5 #define MTG_COLOR_WHITE 5
#define MTG_COLOR_LAND 6 #define MTG_COLOR_LAND 6
static char MTGColorChars[] = {'x','g','u','r','b','w','l'}; static char MTGColorChars[] = {'x','g','u','r','b','w','l'};
static const char * MTGColorStrings[] = {"artifact", "green", "blue", "red", "black", "white", "land"}; static const char * MTGColorStrings[] = {"artifact", "green", "blue", "red", "black", "white", "land"};
static int _r[7] = {75, 20, 20, 200,50,255,128}; static int _r[7] = {75, 20, 20, 200,50,255,128};
static int _g[7] = {30, 140, 30, 15, 50,255,128}; static int _g[7] = {30, 140, 30, 15, 50,255,128};
static int _b[7] = {20, 0, 140,15, 50,255,128}; static int _b[7] = {20, 0, 140,15, 50,255,128};
#define MTG_UNCOLORED 0 #define MTG_UNCOLORED 0
#define MTG_FOREST 1 #define MTG_FOREST 1
#define MTG_ISLAND 2 #define MTG_ISLAND 2
#define MTG_MOUNTAIN 3 #define MTG_MOUNTAIN 3
#define MTG_SWAMP 4 #define MTG_SWAMP 4
#define MTG_PLAIN 5 #define MTG_PLAIN 5
#define MTG_TYPE_CREATURE 10 #define MTG_TYPE_CREATURE 10
#define MTG_TYPE_ARTIFACT 11 #define MTG_TYPE_ARTIFACT 11
#define MTG_TYPE_ENCHANTMENT 12 #define MTG_TYPE_ENCHANTMENT 12
#define MTG_TYPE_SORCERY 13 #define MTG_TYPE_SORCERY 13
#define MTG_TYPE_LAND 14 #define MTG_TYPE_LAND 14
#define MTG_TYPE_INSTANT 15 #define MTG_TYPE_INSTANT 15
#define MTG_PHASE_BEFORE_BEGIN 0 #define MTG_PHASE_BEFORE_BEGIN 0
#define MTG_PHASE_UNTAP 1 #define MTG_PHASE_UNTAP 1
#define MTG_PHASE_UPKEEP 2 #define MTG_PHASE_UPKEEP 2
#define MTG_PHASE_DRAW 3 #define MTG_PHASE_DRAW 3
#define MTG_PHASE_FIRSTMAIN 4 #define MTG_PHASE_FIRSTMAIN 4
#define MTG_PHASE_COMBATBEGIN 5 #define MTG_PHASE_COMBATBEGIN 5
#define MTG_PHASE_COMBATATTACKERS 6 #define MTG_PHASE_COMBATATTACKERS 6
#define MTG_PHASE_COMBATBLOCKERS 7 #define MTG_PHASE_COMBATBLOCKERS 7
#define MTG_PHASE_COMBATDAMAGE 8 #define MTG_PHASE_COMBATDAMAGE 8
#define MTG_PHASE_COMBATEND 9 #define MTG_PHASE_COMBATEND 9
#define MTG_PHASE_SECONDMAIN 10 #define MTG_PHASE_SECONDMAIN 10
#define MTG_PHASE_ENDOFTURN 11 #define MTG_PHASE_ENDOFTURN 11
#define MTG_PHASE_EOT 11 #define MTG_PHASE_EOT 11
#define MTG_PHASE_CLEANUP 12 #define MTG_PHASE_CLEANUP 12
#define MTG_PHASE_AFTER_EOT 13 #define MTG_PHASE_AFTER_EOT 13
#define NB_MTG_PHASES 14 #define NB_MTG_PHASES 14
#define TRAMPLE 0 #define TRAMPLE 0
#define FORESTWALK 1 #define FORESTWALK 1
#define ISLANDWALK 2 #define ISLANDWALK 2
#define MOUNTAINWALK 3 #define MOUNTAINWALK 3
#define SWAMPWALK 4 #define SWAMPWALK 4
#define PLAINSWALK 5 #define PLAINSWALK 5
#define FLYING 6 #define FLYING 6
#define FIRSTSTRIKE 7 #define FIRSTSTRIKE 7
#define DOUBLESTRIKE 8 #define DOUBLESTRIKE 8
#define FEAR 9 #define FEAR 9
#define FLASH 10 #define FLASH 10
#define HASTE 11 #define HASTE 11
#define LIFELINK 12 #define LIFELINK 12
#define REACH 13 #define REACH 13
#define SHROUD 14 #define SHROUD 14
#define VIGILANCE 15 #define VIGILANCE 15
#define DEFENSER 16 #define DEFENSER 16
#define DEFENDER 16 #define DEFENDER 16
#define BANDING 17 #define BANDING 17
#define PROTECTIONGREEN 18 #define PROTECTIONGREEN 18
#define PROTECTIONBLUE 19 #define PROTECTIONBLUE 19
#define PROTECTIONRED 20 #define PROTECTIONRED 20
#define PROTECTIONBLACK 21 #define PROTECTIONBLACK 21
#define PROTECTIONWHITE 22 #define PROTECTIONWHITE 22
#define UNBLOCKABLE 23 #define UNBLOCKABLE 23
#define WITHER 24 #define WITHER 24
#define PERSIST 25 #define PERSIST 25
#define RETRACE 26 #define RETRACE 26
#define EXALTED 27 #define EXALTED 27
#define LEGENDARY 28 #define LEGENDARY 28
#define SHADOW 29 #define SHADOW 29
#define REACHSHADOW 30 #define REACHSHADOW 30
#define FORESTHOME 31 #define FORESTHOME 31
#define ISLANDHOME 32 #define ISLANDHOME 32
#define MOUNTAINHOME 33 #define MOUNTAINHOME 33
#define SWAMPHOME 34 #define SWAMPHOME 34
#define PLAINSHOME 35 #define PLAINSHOME 35
#define FLANKING 36
#define RAMPAGE1 37 #define NB_BASIC_ABILITIES 36
#define NB_BASIC_ABILITIES 38 static const char * MTGBasicAbilities[] = {
"trample",
static const char * MTGBasicAbilities[] = { "forestwalk",
"trample", "islandwalk",
"forestwalk", "mountainwalk",
"islandwalk", "swampwalk",
"mountainwalk", "plainwalk",
"swampwalk", "flying",
"plainwalk", "first strike",
"flying", "double strike",
"first strike", "fear",
"double strike", "flash",
"fear", "haste",
"flash", "lifelink",
"haste", "reach",
"lifelink", "shroud",
"reach", "vigilance",
"shroud", "defender",
"vigilance", "banding",
"defender", "protection from green",
"banding", "protection from blue",
"protection from green", "protection from red",
"protection from blue", "protection from black",
"protection from red", "protection from white",
"protection from black", "unblockable",
"protection from white", "wither",
"unblockable", "persist",
"wither", "retrace",
"persist", "exalted",
"retrace", "legendary",
"exalted", "shadow",
"legendary", "reachshadow",
"shadow", "foresthome",
"reachshadow", "islandhome",
"foresthome", "moutainhome",
"islandhome", "swamphome",
"moutainhome", "plainshome"
"swamphome", };
"plainshome",
"flanking",
"rampage", #define RARITY_M 'M'
}; #define RARITY_R 'R'
#define RARITY_U 'U'
#define RARITY_C 'C'
#define RARITY_M 'M' #define RARITY_L 'L'
#define RARITY_R 'R'
#define RARITY_U 'U'
#define RARITY_C 'C' #define MAIN_FONT 0
#define RARITY_L 'L' #define MAGIC_FONT 1
#define MAIN_FONT 0 static const char *MTGPhaseNames[] =
#define MAGIC_FONT 1 {
"---",
"Untap",
static const char *MTGPhaseNames[] = "Upkeep",
{ "Draw",
"---", "Main phase 1",
"Untap", "Combat begins",
"Upkeep", "Attackers",
"Draw", "Blockers",
"Main phase 1", "Combat damage",
"Combat begins", "Combat ends",
"Attackers", "Main phase 2",
"Blockers", "End of turn",
"Combat damage", "cleanup",
"Combat ends", "---"
"Main phase 2", };
"End of turn",
"cleanup", static const char *MTGPhaseCodeNames[] =
"---" {
}; "beginofturn",
"untap",
"upkeep",
"draw",
"firstmain",
"combatbegins",
#endif "attackers",
"blockers",
"combatdamage",
"combatends",
"secondmain",
"endofturn",
"cleanup",
"beforenextturn"
};
#endif
-25
View File
@@ -12,31 +12,6 @@ ActionElement::ActionElement(int id):JGuiObject(id){
tc = NULL; tc = NULL;
} }
/*
void ActionElement::RenderMessageBackground(float y0, int _height){
float height = _height;
PIXEL_TYPE colors_up[] =
{
ARGB(0,255,255,255),
ARGB(0,255,255,255),
ARGB(128,255,255,255),
ARGB(128,255,255,255)
};
PIXEL_TYPE colors_down[] =
{
ARGB(128,255,255,255),
ARGB(128,255,255,255),
ARGB(0,255,255,255),
ARGB(0,255,255,255)
};
JRenderer * renderer = JRenderer::GetInstance();
renderer->FillRect(0,y0,SCREEN_WIDTH,height/2,colors_up);
renderer->FillRect(0,y0+height/2,SCREEN_WIDTH,height/2,colors_down);
// mEngine->DrawLine(0,y0,SCREEN_WIDTH,y0,ARGB(128,255,255,255));
// mEngine->DrawLine(0,y0+height,SCREEN_WIDTH,y0+height,ARGB(128,255,255,255));
}*/
int ActionElement::getActivity(){ int ActionElement::getActivity(){
File diff suppressed because it is too large Load Diff