Erwan
- removed some unused code. Please review! - Added protection from() auto keyword. It is still possible to use protection from [color] in abilities, but when it is not possible, please use protection from([target]) in auto=
This commit is contained in:
@@ -112,6 +112,19 @@ auto=@next end:bury
|
||||
abilities=trample,haste
|
||||
[/card]
|
||||
[card]
|
||||
id=191065
|
||||
name=Baneslayer Angel
|
||||
mana={3}{W}{W}
|
||||
type=Creature
|
||||
subtype=Angel
|
||||
power=5
|
||||
toughness=5
|
||||
text=Flying, first strike, lifelink, protection from Demons and from Dragons
|
||||
abilities=flying,first strike,lifelink
|
||||
auto=protection from(demon,dragon)
|
||||
rarity=M
|
||||
[/card]
|
||||
[card]
|
||||
id=191071
|
||||
name=Berserkers of Blood Ridge
|
||||
mana={4}{R}
|
||||
|
||||
@@ -30,17 +30,7 @@ toughness=1
|
||||
text=When Awakener Druid enters the battlefield, target Forest becomes a 4/5 green Treefolk creature for as long as Awakener Druid is on the battlefield. It's still a land.
|
||||
rarity=U
|
||||
[/card]
|
||||
[card]
|
||||
id=191065
|
||||
name=Baneslayer Angel
|
||||
mana={3}{W}{W}
|
||||
type=Creature
|
||||
subtype=Angel
|
||||
power=5
|
||||
toughness=5
|
||||
text=Flying, first strike, lifelink, protection from Demons and from Dragons
|
||||
rarity=M
|
||||
[/card]
|
||||
|
||||
[card]
|
||||
id=191340
|
||||
name=Bogardan Hellkite
|
||||
|
||||
@@ -9,3 +9,15 @@ toughness=4
|
||||
text=Flying
|
||||
rarity=U
|
||||
[/card]
|
||||
[card]
|
||||
id=6605
|
||||
name=Brimstone Dragon
|
||||
mana={6}{R}{R}
|
||||
type=Creature
|
||||
subtype=Dragon
|
||||
power=6
|
||||
toughness=6
|
||||
text=Flying, haste
|
||||
abilities=flying,haste
|
||||
rarity=R
|
||||
[/card]
|
||||
|
||||
@@ -244,17 +244,7 @@ type=Sorcery
|
||||
text=Return target creature card from your graveyard to the battlefield.
|
||||
rarity=U
|
||||
[/card]
|
||||
[card]
|
||||
id=6605
|
||||
name=Brimstone Dragon
|
||||
mana={6}{R}{R}
|
||||
type=Creature
|
||||
subtype=Dragon
|
||||
power=6
|
||||
toughness=6
|
||||
text=Flying, haste
|
||||
rarity=R
|
||||
[/card]
|
||||
|
||||
[card]
|
||||
id=6566
|
||||
name=Brutal Nightstalker
|
||||
|
||||
@@ -71,6 +71,8 @@ ascendant_evincar3.txt
|
||||
ashen_firebeast.txt
|
||||
ashen_firebeast2.txt
|
||||
aura_mutation.txt
|
||||
baneslayer_angel.txt
|
||||
baneslayer_angel2.txt
|
||||
barbed_sliver.txt
|
||||
basal_sliver.txt
|
||||
beacon_of_unrest.txt
|
||||
|
||||
26
projects/mtg/bin/Res/test/baneslayer_angel.txt
Normal file
26
projects/mtg/bin/Res/test/baneslayer_angel.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
#Test: prtection from(
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:Brimstone Dragon
|
||||
[PLAYER2]
|
||||
inplay:baneslayer angel
|
||||
[DO]
|
||||
Brimstone Dragon
|
||||
next
|
||||
#blockers
|
||||
baneslayer angel
|
||||
next
|
||||
#damage 1st strike
|
||||
next
|
||||
#damage
|
||||
next
|
||||
#end combat
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:Brimstone Dragon
|
||||
[PLAYER2]
|
||||
inplay:baneslayer angel
|
||||
life:25
|
||||
[END]
|
||||
26
projects/mtg/bin/Res/test/baneslayer_angel2.txt
Normal file
26
projects/mtg/bin/Res/test/baneslayer_angel2.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
#Test: prtection from(
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:Denizen of the deep
|
||||
[PLAYER2]
|
||||
inplay:baneslayer angel
|
||||
[DO]
|
||||
Denizen of the deep
|
||||
next
|
||||
#blockers
|
||||
baneslayer angel
|
||||
next
|
||||
#damage 1st strike
|
||||
next
|
||||
#damage
|
||||
next
|
||||
#end combat
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:Denizen of the deep
|
||||
[PLAYER2]
|
||||
graveyard:baneslayer angel
|
||||
life:25
|
||||
[END]
|
||||
@@ -24,7 +24,6 @@ class ActionLayer: public GuiLayer, public JGuiListener{
|
||||
int stuffHappened;
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
int unstoppableRenderInProgress();
|
||||
bool CheckUserInput(u32 key);
|
||||
ActionLayer();
|
||||
~ActionLayer();
|
||||
|
||||
@@ -1034,6 +1034,38 @@ class AUnBlocker:public MTGAbility{
|
||||
|
||||
};
|
||||
|
||||
//Protection From (creature/aura)
|
||||
class AProtectionFrom: public MTGAbility{
|
||||
public:
|
||||
TargetChooser * fromTc;
|
||||
AProtectionFrom(int id, MTGCardInstance * _source, MTGCardInstance * _target, TargetChooser *fromTc):MTGAbility(id,_source,_target),fromTc(fromTc){
|
||||
|
||||
}
|
||||
|
||||
int addToGame(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
_target->addProtection(fromTc);
|
||||
return MTGAbility::addToGame();
|
||||
}
|
||||
|
||||
int destroy(){
|
||||
((MTGCardInstance *)target)->removeProtection(fromTc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
AProtectionFrom * clone() const{
|
||||
AProtectionFrom * a = NEW AProtectionFrom(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
~AProtectionFrom(){
|
||||
SAFE_DELETE(fromTc);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//Alteration of Power and Toughness (enchantments)
|
||||
class APowerToughnessModifier: public MTGAbility{
|
||||
public:
|
||||
|
||||
@@ -28,13 +28,6 @@ class CardDisplay:public PlayGuiObjectController{
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DefaultTargetDisplay:CardDisplay{
|
||||
public:
|
||||
DefaultTargetDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener, int nb_displayed_items );
|
||||
~DefaultTargetDisplay();
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const CardDisplay& m);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,6 @@ public:
|
||||
void Render();
|
||||
void Add(GuiLayer * layer);
|
||||
void Remove();
|
||||
int unstoppableRenderInProgress();
|
||||
int receiveEvent(WEvent * e);
|
||||
float RightBoundary();
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ class GameObserver{
|
||||
ReplacementEffects *replacementEffects;
|
||||
Player * gameOver;
|
||||
Player * players[2]; //created outside
|
||||
MTGGamePhase * gamePhaseManager; //Created Outside ?
|
||||
|
||||
TargetChooser * getCurrentTargetChooser();
|
||||
void stackObjectClicked(Interruptible * action);
|
||||
@@ -67,7 +66,6 @@ class GameObserver{
|
||||
Player * currentlyActing();
|
||||
GameObserver(Player * _players[], int _nbplayers);
|
||||
~GameObserver();
|
||||
void setGamePhaseManager(MTGGamePhase * _phases);
|
||||
void stateEffects();
|
||||
void eventOccured();
|
||||
void addObserver(MTGAbility * observer);
|
||||
@@ -76,7 +74,6 @@ class GameObserver{
|
||||
void untapPhase();
|
||||
void draw();
|
||||
int isInPlay(MTGCardInstance * card);
|
||||
bool isCreature(MTGCardInstance * card);
|
||||
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
|
||||
@@ -25,13 +25,10 @@ class GuiLayer{
|
||||
bool hasFocus;
|
||||
virtual void resetObjects();
|
||||
int getMaxId();
|
||||
void RenderMessageBackground(float x0, float y0, float width, int height);
|
||||
void RenderMessageBackground(float y0, int height);
|
||||
GuiLayer();
|
||||
virtual ~GuiLayer();
|
||||
virtual void Update(float dt);
|
||||
virtual bool CheckUserInput(u32 key){ return false; };
|
||||
virtual int unstoppableRenderInProgress(){return 0;};
|
||||
int getIndexOf(JGuiObject * object);
|
||||
JGuiObject * getByIndex (int index);
|
||||
virtual void Render();
|
||||
|
||||
@@ -211,7 +211,6 @@ class AbilityFactory{
|
||||
int moveAll(TargetChooser * tc, string destinationZone);
|
||||
int damageAll(TargetChooser * tc, int damage);
|
||||
int TapAll(TargetChooser * tc);
|
||||
int CantBlock(TargetChooser * tc);
|
||||
int UntapAll(TargetChooser * tc);
|
||||
void addAbilities(int _id, Spell * spell);
|
||||
};
|
||||
|
||||
@@ -42,7 +42,6 @@ class MTGCard {
|
||||
int power;
|
||||
int toughness;
|
||||
int setId;
|
||||
static const char * const Colors_To_Text[];
|
||||
int nb_types;
|
||||
int types[MAX_TYPES_PER_CARD];
|
||||
MTGCard();
|
||||
@@ -55,7 +54,6 @@ class MTGCard {
|
||||
int getColor();
|
||||
int hasColor(int _color);
|
||||
int countColors();
|
||||
const char * colorToString();
|
||||
|
||||
void setMTGId(int id);
|
||||
int getMTGId();
|
||||
|
||||
@@ -35,7 +35,6 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
UntapBlockers * untapBlockers;
|
||||
MTGPlayerCards * belongs_to;
|
||||
MTGAbility * untapBlockerAbilities[10];
|
||||
void unband();
|
||||
MTGCardInstance * getNextPartner();
|
||||
void initMTGCI();
|
||||
int setDefenser(MTGCardInstance * c);
|
||||
@@ -81,7 +80,6 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
int attacker;
|
||||
int toggleDefenser(MTGCardInstance * opponent);
|
||||
int raiseBlockerRankOrder(MTGCardInstance * blocker);
|
||||
int bringBlockerToFrontOfOrder(MTGCardInstance * blocker);
|
||||
|
||||
//Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise
|
||||
int getDefenserRank(MTGCardInstance * blocker);
|
||||
@@ -94,7 +92,6 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
MTGCardInstance * isDefenser();
|
||||
int initAttackersDefensers();
|
||||
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
||||
MTGCardInstance * getNextDefenser(MTGCardInstance * previous=NULL);
|
||||
int nbOpponents();
|
||||
int stepPower(CombatStep step);
|
||||
|
||||
@@ -102,8 +99,6 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
|
||||
int has(int ability);
|
||||
int cleanup();
|
||||
int reset();
|
||||
|
||||
|
||||
MTGCard * model;
|
||||
MTGCardInstance();
|
||||
@@ -121,13 +116,12 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
int addToToughness(int value);
|
||||
int setToughness(int value);
|
||||
|
||||
CardDescriptor * protections[10];
|
||||
int nbprotections;
|
||||
int addProtection(CardDescriptor * cd);
|
||||
int removeProtection(CardDescriptor *cd, int erase = 0);
|
||||
vector<TargetChooser *>protections;
|
||||
int addProtection(TargetChooser * tc);
|
||||
int removeProtection(TargetChooser *tc, int erase = 0);
|
||||
int protectedAgainst(MTGCardInstance * card);
|
||||
|
||||
void copy(MTGCardInstance * card);
|
||||
// in game
|
||||
|
||||
void setUntapping();
|
||||
int isUntapping();
|
||||
@@ -137,7 +131,6 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
void attemptUntap();
|
||||
|
||||
int isInPlay();
|
||||
void resetAllDamage();
|
||||
JSample * getSample();
|
||||
|
||||
JQuad * getIcon();
|
||||
|
||||
@@ -93,7 +93,6 @@ class MTGGameZone {
|
||||
|
||||
class MTGLibrary: public MTGGameZone {
|
||||
public:
|
||||
// MTGLibrary();
|
||||
void shuffleTopToBottom(int nbcards);
|
||||
MTGCardInstance * draw();
|
||||
virtual ostream& toString(ostream&) const;
|
||||
@@ -102,7 +101,6 @@ class MTGLibrary: public MTGGameZone {
|
||||
|
||||
class MTGGraveyard: public MTGGameZone {
|
||||
public:
|
||||
// MTGGraveyard();
|
||||
virtual ostream& toString(ostream&) const;
|
||||
const char * getName(){return "graveyard";}
|
||||
};
|
||||
@@ -127,12 +125,8 @@ class MTGStack: public MTGGameZone {
|
||||
|
||||
class MTGInPlay: public MTGGameZone {
|
||||
public:
|
||||
//MTGInPlay();
|
||||
void untapAll();
|
||||
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
|
||||
MTGCardInstance * getNextDefenser(MTGCardInstance * previous, MTGCardInstance * attacker);
|
||||
int nbDefensers( MTGCardInstance * attacker);
|
||||
int nbPartners(MTGCardInstance * attacker);
|
||||
virtual ostream& toString(ostream&) const;
|
||||
const char * getName(){return "battlefield";}
|
||||
};
|
||||
|
||||
@@ -41,7 +41,6 @@ class ManaCost{
|
||||
int getCost(int color);
|
||||
//Returns NULL if i is greater than nbhybrids
|
||||
ManaCostHybrid * getHybridCost(unsigned int i);
|
||||
int getMainColor();
|
||||
int hasColor(int color);
|
||||
int remove (int color, int value);
|
||||
int add(int color, int value);
|
||||
@@ -52,7 +51,6 @@ class ManaCost{
|
||||
int addExtraCost(ExtraCost * _cost);
|
||||
int setExtraCostsAction(MTGAbility * action, MTGCardInstance * card);
|
||||
int isExtraPaymentSet();
|
||||
int resetExtraPayment();
|
||||
int doPayExtra();
|
||||
|
||||
int addHybrid(int c1, int v1, int c2, int v2);
|
||||
|
||||
@@ -261,23 +261,6 @@ protected:
|
||||
JGuiListener * mListener;
|
||||
};
|
||||
|
||||
|
||||
class WGuiImage: public WGuiItem{
|
||||
public:
|
||||
WGuiImage(string _file, int _w, int _h, int _margin);
|
||||
virtual bool Selectable() {return false;};
|
||||
virtual JQuad * getImage();
|
||||
virtual void Render();
|
||||
virtual float getHeight();
|
||||
|
||||
virtual void imageScale(float w, float h);
|
||||
protected:
|
||||
bool exact;
|
||||
int margin;
|
||||
int imgW, imgH;
|
||||
string filename;
|
||||
};
|
||||
|
||||
class WGuiText:public WGuiItem {
|
||||
public:
|
||||
WGuiText(string _displayValue): WGuiItem(_displayValue) {};
|
||||
@@ -376,19 +359,6 @@ class OptionInteger:public OptionItem{
|
||||
virtual void updateValue(){value+=increment; if (value>maxValue) value=0;};
|
||||
};
|
||||
|
||||
class OptionString:public OptionItem{
|
||||
public:
|
||||
string value;
|
||||
OptionString(int _id, string _displayValue);
|
||||
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
virtual void updateValue();
|
||||
virtual bool Changed() {return value != options[id].str;};
|
||||
virtual void Reload() {if(id != INVALID_OPTION) value = options[id].str;};
|
||||
bool bShowValue;
|
||||
};
|
||||
|
||||
class OptionSelect:public OptionItem{
|
||||
public:
|
||||
size_t value;
|
||||
|
||||
@@ -42,6 +42,8 @@ class TargetChooser: public TargetsList {
|
||||
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
|
||||
|
||||
int maxtargets; //Set to -1 for "unlimited"
|
||||
|
||||
virtual int setAllZones(){return 0;}
|
||||
virtual bool targetsZone(MTGGameZone * z){return false;};
|
||||
int ForceTargetListReady();
|
||||
int targetsReadyCheck();
|
||||
@@ -65,13 +67,14 @@ class TargetChooserFactory{
|
||||
|
||||
class TargetZoneChooser:public TargetChooser{
|
||||
public:
|
||||
int zones[10];
|
||||
int zones[15];
|
||||
int nbzones;
|
||||
int init(int * _zones, int _nbzones);
|
||||
bool targetsZone(MTGGameZone * z);
|
||||
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
||||
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
||||
virtual bool canTarget(Targetable * _card);
|
||||
int setAllZones();
|
||||
};
|
||||
|
||||
class CardTargetChooser:public TargetZoneChooser {
|
||||
@@ -155,10 +158,5 @@ class DamageTargetChooser:public TargetChooser{
|
||||
virtual bool canTarget(Targetable * target);
|
||||
};
|
||||
|
||||
class DamageOrPermanentTargetChooser:public TargetZoneChooser{
|
||||
public:
|
||||
int color;
|
||||
DamageOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, bool other = false);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,20 +50,6 @@ int ActionLayer::reactToTargetClick(ActionElement* ability, Targetable * card){
|
||||
return result;
|
||||
}
|
||||
|
||||
int ActionLayer::unstoppableRenderInProgress(){
|
||||
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]!=NULL){
|
||||
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
||||
if (currentAction->getActivity() > 0){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool ActionLayer::CheckUserInput(u32 key){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (g->waitForExtraPayment && key == PSP_CTRL_CROSS){
|
||||
|
||||
@@ -190,13 +190,6 @@ ostream& CardDisplay::toString(ostream& out) const
|
||||
return (out << "CardDisplay ::: x,y : " << x << "," << y << " ; start_item : " << start_item << " ; nb_displayed_items " << nb_displayed_items << " ; tc : " << tc << " ; listener : " << listener);
|
||||
}
|
||||
|
||||
DefaultTargetDisplay::DefaultTargetDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener, int nb_displayed_items ):CardDisplay(id, game, x, y, listener, NULL, nb_displayed_items ){
|
||||
tc = NEW TargetChooser();
|
||||
}
|
||||
|
||||
DefaultTargetDisplay::~DefaultTargetDisplay(){
|
||||
SAFE_DELETE(tc);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const CardDisplay& m)
|
||||
{
|
||||
|
||||
@@ -90,13 +90,6 @@ DuelLayers::~DuelLayers(){
|
||||
Trash::cleanup();
|
||||
}
|
||||
|
||||
int DuelLayers::unstoppableRenderInProgress(){
|
||||
for (int i = 0; i < nbitems; ++i)
|
||||
if (objects[i]->unstoppableRenderInProgress())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DuelLayers::Add(GuiLayer * layer){
|
||||
objects.push_back(layer);
|
||||
nbitems++;
|
||||
|
||||
@@ -52,10 +52,6 @@ GameObserver::GameObserver(Player * _players[], int _nb_players){
|
||||
combatStep = BLOCKERS;
|
||||
}
|
||||
|
||||
void GameObserver::setGamePhaseManager(MTGGamePhase * _phases){
|
||||
gamePhaseManager = _phases;
|
||||
}
|
||||
|
||||
int GameObserver::getCurrentGamePhase(){
|
||||
return currentGamePhase;
|
||||
}
|
||||
@@ -467,12 +463,6 @@ int GameObserver::receiveEvent(WEvent * e){
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool GameObserver::isCreature(MTGCardInstance * card){
|
||||
return card->isCreature();
|
||||
}
|
||||
|
||||
|
||||
Player * GameObserver::currentlyActing(){
|
||||
if (isInterrupting) return isInterrupting;
|
||||
return currentActionPlayer;
|
||||
|
||||
@@ -998,8 +998,7 @@ void GameStateDeckViewer::updateStats() {
|
||||
return;
|
||||
}
|
||||
|
||||
AbilityFactory * af;
|
||||
af = NEW AbilityFactory();
|
||||
AbilityFactory * af = NEW AbilityFactory();
|
||||
|
||||
stw.needUpdate = false;
|
||||
|
||||
@@ -1180,7 +1179,7 @@ void GameStateDeckViewer::renderCard(int id, float rotation){
|
||||
MTGCard * card = cardIndex[id];
|
||||
|
||||
|
||||
float max_scale = 0.96;
|
||||
float max_scale = 0.96f;
|
||||
float x_center_0 = 180;
|
||||
float right_border = SCREEN_WIDTH - 20 ;
|
||||
|
||||
|
||||
@@ -59,36 +59,6 @@ void GuiLayer::resetObjects(){
|
||||
mCurr = 0;
|
||||
}
|
||||
|
||||
void GuiLayer::RenderMessageBackground(float x0, float y0, float width, int 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(x0,y0,width,height/2,colors_up);
|
||||
renderer->FillRect(x0,y0+height/2,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));
|
||||
}
|
||||
|
||||
void GuiLayer::RenderMessageBackground(float y0, int height){
|
||||
RenderMessageBackground(0,y0,SCREEN_WIDTH, height);
|
||||
|
||||
}
|
||||
|
||||
int GuiLayer::getIndexOf(JGuiObject * object){
|
||||
for (int i=0; i<mCount; i++){
|
||||
if (mObjects[i] == object)
|
||||
|
||||
@@ -36,22 +36,6 @@ int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option){
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AbilityFactory::CantBlock(TargetChooser * tc){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
MTGCardInstance * source = tc->source;
|
||||
for (int j = g->opponent()->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||
MTGCardInstance * current = g->opponent()->game->inPlay->cards[j];
|
||||
if (tc->canTarget(current)){
|
||||
current->canBlock(source);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AbilityFactory::parsePowerToughness(string s, int *power, int *toughness){
|
||||
size_t found = s.find("/");
|
||||
if (found != string::npos){
|
||||
@@ -587,18 +571,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
//CannotBeBlockedBy
|
||||
found = s.find("cantbeblockedby(");
|
||||
if (found != string::npos){
|
||||
int end = s.find(")",found);
|
||||
string starget = s.substr(16, end - 16);
|
||||
TargetChooserFactory tcf;
|
||||
tc = tcf.createTargetChooser(starget,card);
|
||||
return NULL; //NEW ACantBlock(tc); //hu ? CantBlock(tc);
|
||||
}
|
||||
|
||||
*/
|
||||
//Discard
|
||||
found = s.find("discard:");
|
||||
if (found != string::npos){
|
||||
@@ -707,6 +679,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Mana Producer
|
||||
found = s.find("add");
|
||||
if (found != string::npos){
|
||||
@@ -735,6 +709,24 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
}
|
||||
|
||||
//Protection from...
|
||||
found = s.find("protection from(");
|
||||
if (found == 0){
|
||||
size_t end = s.find (")", found);
|
||||
string targets = s.substr(found+16,end - found - 16);
|
||||
TargetChooserFactory tcf;
|
||||
TargetChooser * fromTc = tcf.createTargetChooser(targets, card);
|
||||
if (!fromTc) return NULL;
|
||||
fromTc->setAllZones();
|
||||
if (!activated){
|
||||
if(card->hasType("instant") || card->hasType("sorcery") || forceUEOT){
|
||||
return NULL; //TODO
|
||||
}
|
||||
return NEW AProtectionFrom(id, card,target,fromTc);
|
||||
}
|
||||
return NULL; //TODO
|
||||
}
|
||||
|
||||
//Untapper (Ley Druid...)
|
||||
found = s.find("untap");
|
||||
if (found != string::npos){
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
const char * const MTGCard::Colors_To_Text[] = {"Artifact", "Green", "Blue", "Red", "Black", "White", "Land"};
|
||||
|
||||
MTGCard::MTGCard(){
|
||||
init();
|
||||
}
|
||||
@@ -177,16 +174,6 @@ void MTGCard::setManaCost(string s){
|
||||
|
||||
}
|
||||
|
||||
|
||||
const char * MTGCard::colorToString(){
|
||||
int color = getColor();
|
||||
if (color>=0 && color <=5){
|
||||
return Colors_To_Text[color];
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
|
||||
void MTGCard::setMTGId(int id){
|
||||
mtgid = id;
|
||||
if (id < 0){
|
||||
|
||||
@@ -94,7 +94,6 @@ void MTGCardInstance::initMTGCI(){
|
||||
untapping = 0;
|
||||
summoningSickness = 1;
|
||||
target = NULL;
|
||||
nbprotections = 0;
|
||||
type_as_damageable = DAMAGEABLE_MTGCARDINSTANCE;
|
||||
banding = NULL;
|
||||
owner = NULL;
|
||||
@@ -231,10 +230,6 @@ int MTGCardInstance::isTapped(){
|
||||
return tapped;
|
||||
}
|
||||
|
||||
void MTGCardInstance::resetAllDamage(){
|
||||
nb_damages = 0;
|
||||
}
|
||||
|
||||
int MTGCardInstance::regenerate(){
|
||||
return ++regenerateTokens;
|
||||
}
|
||||
@@ -301,16 +296,6 @@ MTGCardInstance * MTGCardInstance::changeController(Player * newController){
|
||||
return copy;
|
||||
}
|
||||
|
||||
//Reset the card parameters
|
||||
int MTGCardInstance::reset(){
|
||||
cleanup();
|
||||
untap();
|
||||
SAFE_DELETE(counters);
|
||||
counters = NEW Counters(this);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Player * MTGCardInstance::controller(){
|
||||
return lastController;
|
||||
}
|
||||
@@ -398,32 +383,6 @@ MTGCardInstance * MTGCardInstance::getNextPartner(){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MTGCardInstance::unband(){
|
||||
if (!banding) return;
|
||||
|
||||
MTGCardInstance * _banding = banding;
|
||||
banding = NULL;
|
||||
MTGCardInstance * newbanding = NULL;
|
||||
MTGInPlay * inplay = controller()->game->inPlay;
|
||||
int nbpartners = inplay->nbPartners(this);
|
||||
MTGCardInstance * card = inplay->getNextAttacker(NULL);
|
||||
while(card){
|
||||
if (card != this){
|
||||
if (card->banding == _banding){
|
||||
if (nbpartners == 1){
|
||||
card->banding = NULL;
|
||||
return;
|
||||
}else{
|
||||
if (!newbanding) newbanding = card;
|
||||
card->banding = newbanding;
|
||||
}
|
||||
}
|
||||
}
|
||||
card = inplay->getNextAttacker(card);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
int MTGCardInstance::setAttacker(int value){
|
||||
Targetable * previousTarget = NULL;
|
||||
Targetable * target = NULL;
|
||||
@@ -477,18 +436,6 @@ int MTGCardInstance::nbOpponents(){
|
||||
return result;
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGCardInstance::getNextDefenser(MTGCardInstance * previous){
|
||||
int found_previous = 0;
|
||||
if (!previous) found_previous = 1;
|
||||
list<MTGCardInstance *>::iterator it;
|
||||
for (it= blockers.begin(); it != blockers.end(); ++it){
|
||||
MTGCardInstance * c = *it;
|
||||
if (found_previous && c->isInPlay()) return c;
|
||||
if (c == previous) found_previous = 1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int MTGCardInstance::raiseBlockerRankOrder(MTGCardInstance * blocker){
|
||||
list<MTGCardInstance *>::iterator it1 = find(blockers.begin(), blockers.end(), blocker);
|
||||
list<MTGCardInstance *>::iterator it2 = it1;
|
||||
@@ -501,19 +448,6 @@ int MTGCardInstance::raiseBlockerRankOrder(MTGCardInstance * blocker){
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MTGCardInstance::bringBlockerToFrontOfOrder(MTGCardInstance * blocker){
|
||||
list<MTGCardInstance *>::iterator it1 = find(blockers.begin(), blockers.end(), blocker);
|
||||
list<MTGCardInstance *>::iterator it2 = blockers.begin();
|
||||
if (it2 != it1)
|
||||
{
|
||||
std::iter_swap(it1,it2);
|
||||
WEvent* e = NEW WEventCreatureBlockerRank(blocker,*it2,this);
|
||||
GameObserver::GetInstance()->receiveEvent(e);
|
||||
//delete(e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MTGCardInstance::getDefenserRank(MTGCardInstance * blocker){
|
||||
int result = 0;
|
||||
for(list<MTGCardInstance *>::iterator it1 = blockers.begin(); it1 != blockers.end(); ++it1){
|
||||
@@ -598,19 +532,17 @@ int MTGCardInstance::toggleDefenser(MTGCardInstance * opponent){
|
||||
}
|
||||
|
||||
|
||||
int MTGCardInstance::addProtection(CardDescriptor * cd){
|
||||
protections[nbprotections] = cd;
|
||||
nbprotections++;
|
||||
return nbprotections;
|
||||
int MTGCardInstance::addProtection(TargetChooser * tc){
|
||||
tc->targetter = NULL;
|
||||
protections.push_back(tc);
|
||||
return protections.size();
|
||||
}
|
||||
|
||||
int MTGCardInstance::removeProtection(CardDescriptor * cd, int erase){
|
||||
for (int i = 0; i < nbprotections ; i++){
|
||||
if (protections[i] == cd){
|
||||
int MTGCardInstance::removeProtection(TargetChooser * tc, int erase){
|
||||
for (size_t i = 0; i < protections.size() ; i++){
|
||||
if (protections[i] == tc){
|
||||
if (erase) delete (protections[i]);
|
||||
protections[i] = protections[nbprotections -1];
|
||||
protections[nbprotections -1] = NULL;
|
||||
nbprotections--;
|
||||
protections.erase(protections.begin()+i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -624,8 +556,9 @@ int MTGCardInstance::protectedAgainst(MTGCardInstance * card){
|
||||
}
|
||||
|
||||
//General protections
|
||||
for (int i = 0; i < nbprotections ; i++){
|
||||
if (protections[i]->match(card)) return 1;
|
||||
for (size_t i = 0; i < protections.size() ; i++){
|
||||
if (protections[i]->canTarget(card))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -306,31 +306,6 @@ void MTGGameZone::debugPrint(){
|
||||
|
||||
|
||||
//------------------------------
|
||||
int MTGInPlay::nbDefensers( MTGCardInstance * attacker){
|
||||
int result = 0;
|
||||
MTGCardInstance * defenser = getNextDefenser(NULL, attacker);
|
||||
while (defenser){
|
||||
result++;
|
||||
defenser = getNextDefenser(defenser, attacker);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//Return the number of creatures this card is banded with
|
||||
//Number of creatures in the band is n+1 !!!
|
||||
int MTGInPlay::nbPartners(MTGCardInstance * attacker){
|
||||
int result = 0;
|
||||
if (!attacker->banding) return 0;
|
||||
for (int i = 0; i < nb_cards; i ++){
|
||||
if (cards[i]->banding == attacker->banding) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGInPlay::getNextDefenser(MTGCardInstance * previous, MTGCardInstance * attacker){
|
||||
return attacker->getNextDefenser(previous);
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGInPlay::getNextAttacker(MTGCardInstance * previous){
|
||||
int foundprevious = 0;
|
||||
if (previous == NULL){
|
||||
|
||||
@@ -187,13 +187,6 @@ ManaCostHybrid * ManaCost::getHybridCost(unsigned int i){
|
||||
return hybrids[i];
|
||||
}
|
||||
|
||||
int ManaCost::getMainColor(){
|
||||
for (int i=0; i< Constants::MTG_NB_COLORS; i++){
|
||||
if (cost[i]) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ManaCost::hasColor(int color){
|
||||
if (cost[color]) return 1;
|
||||
for (unsigned int i = 0; i < nbhybrids; i++){
|
||||
@@ -267,11 +260,6 @@ int ManaCost::isExtraPaymentSet(){
|
||||
return extraCosts->isPaymentSet();
|
||||
}
|
||||
|
||||
int ManaCost::resetExtraPayment(){
|
||||
if (!extraCosts) return 1;
|
||||
return extraCosts->reset();
|
||||
}
|
||||
|
||||
int ManaCost::doPayExtra(){
|
||||
if (!extraCosts) return 0;
|
||||
return extraCosts->doPay(); //TODO reset ?
|
||||
|
||||
@@ -707,39 +707,6 @@ void WGuiList::Reload()
|
||||
listItems[i]->Reload();
|
||||
}
|
||||
}
|
||||
//OptionString
|
||||
|
||||
void OptionString::Render(){
|
||||
|
||||
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
|
||||
mFont->SetColor(getColor(WGuiColor::TEXT));
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
|
||||
if(!bShowValue){
|
||||
mFont->DrawString(_(displayValue).c_str(),x+(width/2),y,JGETEXT_CENTER);
|
||||
}
|
||||
else{
|
||||
mFont->DrawString(_(displayValue).c_str(),x,y);
|
||||
int w = mFont->GetStringWidth(value.c_str()-10);
|
||||
mFont->DrawString(_(value).c_str(),width - w,y,JGETEXT_RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
void OptionString::setData(){
|
||||
if(id != INVALID_OPTION)
|
||||
options[id] = GameOption(value);
|
||||
}
|
||||
void OptionString::updateValue(){
|
||||
options.keypadStart(value,&value);
|
||||
options.keypadTitle(displayValue);
|
||||
}
|
||||
|
||||
OptionString::OptionString(int _id, string _displayValue): OptionItem(_id, _displayValue)
|
||||
{
|
||||
bShowValue=true;
|
||||
if(id != INVALID_OPTION)
|
||||
value=options[_id].str;
|
||||
}
|
||||
|
||||
OptionTheme::OptionTheme(): OptionDirectory(RESPATH"/themes",Options::ACTIVE_THEME, "Current Theme"){
|
||||
addSelection("Default");
|
||||
@@ -987,52 +954,6 @@ void WDecoConfirm::ButtonPressed(int controllerId, int controlId){
|
||||
it->ButtonPressed(controllerId,controlId);
|
||||
}
|
||||
|
||||
//WDecoImage
|
||||
WGuiImage::WGuiImage(string _file, int _w, int _h, int _margin): WGuiItem("") {
|
||||
imgW = 0;
|
||||
imgH = 0;
|
||||
margin = _margin;
|
||||
filename = _file;
|
||||
exact = false;
|
||||
}
|
||||
|
||||
void WGuiImage::imageScale(float w, float h){
|
||||
imgH = h;
|
||||
imgW = w;
|
||||
}
|
||||
|
||||
float WGuiImage::getHeight(){
|
||||
|
||||
if(imgH == 0 ){
|
||||
JQuad * q = getImage();
|
||||
if(q)
|
||||
return MAX(height,q->mHeight+(2*margin));
|
||||
}
|
||||
|
||||
return MAX(height,imgH+(2*margin));
|
||||
}
|
||||
|
||||
JQuad * WGuiImage::getImage(){
|
||||
if(exact)
|
||||
return resources.RetrieveQuad(filename,0,0,0,0,"temporary",RETRIEVE_NORMAL,TEXTURE_SUB_EXACT);
|
||||
else
|
||||
return resources.RetrieveTempQuad(filename);
|
||||
}
|
||||
|
||||
void WGuiImage::Render(){
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
JQuad * q = getImage();
|
||||
if(q){
|
||||
float xS = 1, yS = 1;
|
||||
if(imgH != 0 && q->mHeight != 0)
|
||||
yS = imgH / q->mHeight;
|
||||
if(imgW != 0 && q->mWidth != 0)
|
||||
xS = imgW / q->mWidth;
|
||||
|
||||
renderer->RenderQuad(q,x+margin, y+margin,0,xS,yS);
|
||||
}
|
||||
}
|
||||
|
||||
WGuiButton::WGuiButton( WGuiBase* _it, int _controller, int _control, JGuiListener * jgl): WGuiDeco(_it) {
|
||||
control = _control;
|
||||
controller = _controller;
|
||||
|
||||
@@ -296,22 +296,14 @@ bool TargetChooser::canTarget(Targetable * target){
|
||||
|
||||
|
||||
int TargetChooser::addTarget(Targetable * target){
|
||||
if (canTarget(target) && TargetsList::addTarget(target)){
|
||||
if (canTarget(target)){
|
||||
TargetsList::addTarget(target);
|
||||
}
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "TARGETCHOOSER Nb targets : %i\n", cursor);
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
return targetsReadyCheck();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int TargetChooser::ForceTargetListReady(){
|
||||
int state = targetsReadyCheck() ;
|
||||
if (state == TARGET_OK){
|
||||
@@ -510,6 +502,27 @@ int TargetZoneChooser::init(int * _zones, int _nbzones){
|
||||
return nbzones;
|
||||
}
|
||||
|
||||
int TargetZoneChooser::setAllZones(){
|
||||
int zones[] = {
|
||||
MTGGameZone::MY_BATTLEFIELD,
|
||||
MTGGameZone::MY_EXILE,
|
||||
MTGGameZone::MY_GRAVEYARD,
|
||||
MTGGameZone::MY_HAND,
|
||||
MTGGameZone::MY_LIBRARY,
|
||||
MTGGameZone::MY_STACK,
|
||||
MTGGameZone::OPPONENT_BATTLEFIELD,
|
||||
MTGGameZone::OPPONENT_EXILE,
|
||||
MTGGameZone::OPPONENT_GRAVEYARD,
|
||||
MTGGameZone::OPPONENT_HAND,
|
||||
MTGGameZone::OPPONENT_LIBRARY,
|
||||
MTGGameZone::OPPONENT_STACK
|
||||
};
|
||||
|
||||
init(zones,12);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool TargetZoneChooser::canTarget(Targetable * target){
|
||||
if (!TargetChooser::canTarget(target)) return false;
|
||||
if (target->typeAsTarget() == TARGET_CARD){
|
||||
@@ -619,27 +632,3 @@ bool DamageTargetChooser::canTarget(Targetable * target){
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*Damage or Permanent */
|
||||
DamageOrPermanentTargetChooser::DamageOrPermanentTargetChooser(MTGCardInstance * card,int _color, int _maxtargets, bool other):TargetZoneChooser(card, _maxtargets, other){
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
color = _color;
|
||||
}
|
||||
|
||||
bool DamageOrPermanentTargetChooser::canTarget(Targetable * target){
|
||||
MTGCardInstance * card = NULL;
|
||||
if (target->typeAsTarget() == TARGET_CARD){
|
||||
card = (MTGCardInstance *) target;
|
||||
if (color == -1 || card->hasColor(color)) return TargetZoneChooser::canTarget(target);
|
||||
}else if (target->typeAsTarget() == TARGET_STACKACTION){
|
||||
Interruptible * action = (Interruptible *) target;
|
||||
if (action->type == ACTION_DAMAGE){
|
||||
Damage * damage = (Damage *) action;
|
||||
card = damage->source;
|
||||
if (card && (color == -1 || card->hasColor(color))) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user