Merge pull request #935 from kevlahnota/master

Some New Changes
This commit is contained in:
Anthony Calosa
2017-02-16 22:33:58 +08:00
committed by GitHub
31 changed files with 1292 additions and 420 deletions
@@ -412,16 +412,6 @@ type=Sorcery
text=Destroy all creatures target player controls. For each creature that died this way, put two 1/1 red Goblin creature tokens onto the battlefield under that player's control. text=Destroy all creatures target player controls. For each creature that died this way, put two 1/1 red Goblin creature tokens onto the battlefield under that player's control.
[/card] [/card]
[card] [card]
name=Necropotence
#exile cards are faceup
auto=@movedTo(*|mygraveyard):all(trigger[to]) moveTo(exile)
auto=phasealter(remove,draw,controller)
auto={L:1}:name(exile) reveal:1 optionone all(*|reveal) transforms((,newability[moveto(exile)],newability[phaseaction[my endofturn once checkex] moveto(ownerhand)])) optiononeend revealend
text=Skip your draw step. -- Whenever you discard a card, exile that card from your graveyard. -- Pay 1 life: Exile the top card of your library face down. Put that card into your hand at the beginning of your next end step.
mana={B}{B}{B}
type=Enchantment
[/card]
[card]
name=Nightshade Seer name=Nightshade Seer
auto={2}{B}{T}:foreach(*[black]|myhand) -1/-1 target(creature) auto={2}{B}{T}:foreach(*[black]|myhand) -1/-1 target(creature)
text={2}{B}, {T}: Reveal any number of black cards in your hand. Target creature gets -X/-X until end of turn, where X is the number of cards revealed this way. text={2}{B}, {T}: Reveal any number of black cards in your hand. Target creature gets -X/-X until end of turn, where X is the number of cards revealed this way.
@@ -800,7 +790,7 @@ type=Instant
name=Villainous Wealth name=Villainous Wealth
#can't order stack #can't order stack
target=opponent target=opponent
auto=reveal:castx revealzone(targetedpersonslibrary) optionone all(*|reveal) moveto(exile) and!( if cantargetcard(*[-land;manacost<=castx]|*) then transforms((,newability[may activate castcard(normal)]])) oneshot )! optiononeend revealend auto=moveto(exile) and!( if cantargetcard(*[-land;manacost<=castx]|*) then transforms((,newability[may activate castcard(normal)]])) ueot )! all(*[zpos<=castx]|mylibrary)
text=Target opponent exiles the top X cards of his or her library. You may cast any number of nonland cards with converted mana cost X or less from among them without paying their mana costs. text=Target opponent exiles the top X cards of his or her library. You may cast any number of nonland cards with converted mana cost X or less from among them without paying their mana costs.
mana={X}{B}{G}{U} mana={X}{B}{G}{U}
type=Sorcery type=Sorcery
File diff suppressed because it is too large Load Diff
@@ -593,15 +593,6 @@ power=4
toughness=1 toughness=1
[/card] [/card]
[card] [card]
name=Ashen Ghoul
text=Haste -- {B}: Return Ashen Ghoul from your graveyard to the battlefield. Activate this ability only during your upkeep and only if three or more creature cards are above Ashen Ghoul.
mana={3}{B}
type=Creature
subtype=Zombie
power=3
toughness=1
[/card]
[card]
name=Ashiok, Nightmare Weaver name=Ashiok, Nightmare Weaver
text=+2: Exile the top three cards of target opponent's library. -- -X: Put a creature card with converted mana cost X exiled with Ashiok, Nightmare Weaver onto the battlefield under your control. That creature is a Nightmare in addition to its other types. -- -10: Exile all cards from all opponents' hands and graveyards. text=+2: Exile the top three cards of target opponent's library. -- -X: Put a creature card with converted mana cost X exiled with Ashiok, Nightmare Weaver onto the battlefield under your control. That creature is a Nightmare in addition to its other types. -- -10: Exile all cards from all opponents' hands and graveyards.
mana={1}{U}{B} mana={1}{U}{B}
@@ -3485,12 +3476,6 @@ mana={4}{W}
type=Sorcery type=Sorcery
[/card] [/card]
[card] [card]
name=Death Spark
text=Death Spark deals 1 damage to target creature or player. -- At the beginning of your upkeep, if Death Spark is in your graveyard with a creature card directly above it, you may pay {1}. If you do, return Death Spark to your hand.
mana={R}
type=Instant
[/card]
[card]
name=Death Wish name=Death Wish
text=You may choose a card you own from outside the game and put it into your hand. You lose half your life, rounded up. Exile Death Wish. text=You may choose a card you own from outside the game and put it into your hand. You lose half your life, rounded up. Exile Death Wish.
mana={1}{B}{B} mana={1}{B}{B}
@@ -8482,15 +8467,6 @@ power=3
toughness=2 toughness=2
[/card] [/card]
[card] [card]
name=Krovikan Horror
text=At the beginning of the end step, if Krovikan Horror is in your graveyard with a creature card directly above it, you may return Krovikan Horror to your hand. -- {1}, Sacrifice a creature: Krovikan Horror deals 1 damage to target creature or player.
mana={3}{B}
type=Creature
subtype=Horror Spirit
power=2
toughness=2
[/card]
[card]
name=Krovikan Vampire name=Krovikan Vampire
text=At the beginning of each end step, if a creature dealt damage by Krovikan Vampire this turn died, put that card onto the battlefield under your control. Sacrifice it when you lose control of Krovikan Vampire. text=At the beginning of each end step, if a creature dealt damage by Krovikan Vampire this turn died, put that card onto the battlefield under your control. Sacrifice it when you lose control of Krovikan Vampire.
mana={3}{B}{B} mana={3}{B}{B}
@@ -10495,15 +10471,6 @@ power=6
toughness=6 toughness=6
[/card] [/card]
[card] [card]
name=Nether Shadow
text=Haste -- At the beginning of your upkeep, if Nether Shadow is in your graveyard with three or more creature cards above it, you may put Nether Shadow onto the battlefield.
mana={B}{B}
type=Creature
subtype=Spirit
power=1
toughness=1
[/card]
[card]
name=Nettlevine Blight name=Nettlevine Blight
text=Enchant creature or land -- Enchanted permanent has "At the beginning of your end step, sacrifice this permanent and attach Nettlevine Blight to a creature or land you control." text=Enchant creature or land -- Enchanted permanent has "At the beginning of your end step, sacrifice this permanent and attach Nettlevine Blight to a creature or land you control."
mana={4}{B}{B} mana={4}{B}{B}
+1 -1
View File
@@ -9,7 +9,7 @@ hand:shock
[DO] [DO]
shock shock
welkin hawk welkin hawk
choice 1 choice 0
[ASSERT] [ASSERT]
FIRSTMAIN FIRSTMAIN
[PLAYER1] [PLAYER1]
@@ -11,7 +11,7 @@ library:Forest,Plains,Mountain,Swamp,Island
[PLAYER2] [PLAYER2]
[DO] [DO]
Windswept Heath Windswept Heath
choice 1 choice 0
Plains Plains
[ASSERT] [ASSERT]
firstmain firstmain
+1 -1
View File
@@ -77,7 +77,7 @@ public:
} }
virtual const string getDisplayName() const; virtual const string getDisplayName() const;
void Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad = false, int aType = 0); void Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad = false, int aType = 0, vector<JQuadPtr> targetIcons = vector<JQuadPtr>());
virtual int receiveEvent(WEvent *) virtual int receiveEvent(WEvent *)
{ {
+50
View File
@@ -997,6 +997,10 @@ private:
intValue += card->controller()->game->inPlay->cards[j]->power; intValue += card->controller()->game->inPlay->cards[j]->power;
} }
} }
else if (s == "mypos")
{//hand,exile,grave & library only (library zpos is inverted so the recent one is always the top)
intValue = card->zpos;
}
else if (s == "revealedp") else if (s == "revealedp")
{ {
if (card->revealedLast) if (card->revealedLast)
@@ -1328,6 +1332,50 @@ public:
} }
}; };
class TrCardPhasesIn: public Trigger
{
public:
TrCardPhasesIn(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc, bool once = false) :
Trigger(observer, id, source, once, tc)
{
}
int triggerOnEventImpl(WEvent * event)
{
WEventCardPhasesIn * e = dynamic_cast<WEventCardPhasesIn *> (event);
if (!e) return 0;
if (!tc->canTarget(e->card)) return 0;
return 1;
}
TrCardPhasesIn * clone() const
{
return NEW TrCardPhasesIn(*this);
}
};
class TrCardFaceUp: public Trigger
{
public:
TrCardFaceUp(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc, bool once = false) :
Trigger(observer, id, source, once, tc)
{
}
int triggerOnEventImpl(WEvent * event)
{
WEventCardFaceUp * e = dynamic_cast<WEventCardFaceUp *> (event);
if (!e) return 0;
if (!tc->canTarget(e->card)) return 0;
return 1;
}
TrCardFaceUp * clone() const
{
return NEW TrCardFaceUp(*this);
}
};
class TrCardTransformed: public Trigger class TrCardTransformed: public Trigger
{ {
public: public:
@@ -2111,6 +2159,7 @@ public:
class AAMover: public ActivatedAbility class AAMover: public ActivatedAbility
{ {
public: public:
bool necro;
string destination; string destination;
MTGAbility * andAbility; MTGAbility * andAbility;
string named; string named;
@@ -2119,6 +2168,7 @@ public:
AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string _name, ManaCost * _cost = NULL, bool undying = false, bool persist = false); AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string _name, ManaCost * _cost = NULL, bool undying = false, bool persist = false);
MTGGameZone * destinationZone(Targetable * target = NULL); MTGGameZone * destinationZone(Targetable * target = NULL);
int resolve(); int resolve();
string overrideNamed(string destination = "");
const string getMenuText(); const string getMenuText();
const char * getMenuText(TargetChooser * fromTc); const char * getMenuText(TargetChooser * fromTc);
AAMover * clone() const; AAMover * clone() const;
+2
View File
@@ -39,6 +39,8 @@ class CardDescriptor: public MTGCardInstance
int manacostComparisonMode; int manacostComparisonMode;
int counterComparisonMode; int counterComparisonMode;
int convertedManacost; // might fit better into MTGCardInstance? int convertedManacost; // might fit better into MTGCardInstance?
int zposComparisonMode;
int zposition;
int anyCounter; int anyCounter;
int init(); int init();
CardDescriptor(); CardDescriptor();
+2
View File
@@ -134,6 +134,7 @@ class GameObserver{
int isInGrave(MTGCardInstance * card); int isInGrave(MTGCardInstance * card);
int isInExile(MTGCardInstance * card); int isInExile(MTGCardInstance * card);
int isInHand(MTGCardInstance * card); int isInHand(MTGCardInstance * card);
int isInLibrary(MTGCardInstance * card);
virtual void Update(float dt); virtual void Update(float dt);
void Render(); void Render();
void ButtonPressed(PlayGuiObject*); void ButtonPressed(PlayGuiObject*);
@@ -141,6 +142,7 @@ class GameObserver{
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
bool connectRule; bool connectRule;
bool LPWeffect;
void logAction(Player* player, const string& s=""); void logAction(Player* player, const string& s="");
void logAction(int playerId, const string& s="") { void logAction(int playerId, const string& s="") {
+1
View File
@@ -221,6 +221,7 @@ public:
BLOCK_COST = 37, BLOCK_COST = 37,
GRANTEDFLASHBACK_COST = 38, GRANTEDFLASHBACK_COST = 38,
FORCED_TOKEN_CREATOR = 39, FORCED_TOKEN_CREATOR = 39,
HIDDENVIEW = 40,
}; };
}; };
+3 -6
View File
@@ -114,6 +114,7 @@ public:
int CountedObjects; int CountedObjects;
int kicked; int kicked;
int dredge; int dredge;
int zpos;
bool isDualWielding; bool isDualWielding;
bool stillNeeded; bool stillNeeded;
Player * lastController; Player * lastController;
@@ -252,6 +253,7 @@ public:
int LKIpower; int LKIpower;
int LKItoughness; int LKItoughness;
int countDuplicateCardNames(); int countDuplicateCardNames();
int countDuplicateCardTypes();
void cdaPT(int p = 0, int t = 0); void cdaPT(int p = 0, int t = 0);
bool isCDA; bool isCDA;
void switchPT(bool apply = false); void switchPT(bool apply = false);
@@ -284,12 +286,7 @@ public:
int imprintR; int imprintR;
int imprintB; int imprintB;
int imprintW; int imprintW;
int canproduceG; int canproduceMana(int color = -1);
int canproduceU;
int canproduceR;
int canproduceB;
int canproduceW;
int canproduceC;
int entersBattlefield; int entersBattlefield;
string currentimprintName; string currentimprintName;
vector<string>imprintedNames; vector<string>imprintedNames;
+2 -1
View File
@@ -265,7 +265,8 @@ class Constants
CANTCREW = 143, CANTCREW = 143,
HIDDENFACE = 144, HIDDENFACE = 144,
ANYTYPEOFMANA = 145, ANYTYPEOFMANA = 145,
NB_BASIC_ABILITIES = 146, NECROED = 146,
NB_BASIC_ABILITIES = 147,
RARITY_S = 'S', //Special Rarity RARITY_S = 'S', //Special Rarity
RARITY_M = 'M', //Mythics RARITY_M = 'M', //Mythics
+30 -9
View File
@@ -421,7 +421,36 @@ public:
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
virtual MTGTokensCleanup * clone() const; virtual MTGTokensCleanup * clone() const;
}; };
//New Legend Rule
class MTGNewLegend: public PermanentAbility
{
public:
TargetChooser * tcL;
MTGAbility * Legendrule;
MTGAbility * LegendruleAbility;
MTGAbility * LegendruleGeneric;
//vector<MTGCardInstance *> list;
MTGNewLegend(GameObserver* observer, int _id);
int CheckLegend(MTGCardInstance * card);
void MoveLegend(MTGCardInstance * card);
int receiveEvent(WEvent * event);
virtual MTGNewLegend * clone() const;
};
//New Planeswalker Rule
class MTGNewPlaneswalker: public PermanentAbility
{
public:
TargetChooser * tcP;
MTGAbility * PWrule;
MTGAbility * PWruleAbility;
MTGAbility * PWruleGeneric;
//vector<MTGCardInstance *> list;
MTGNewPlaneswalker(GameObserver* observer, int _id);
int CheckPW(MTGCardInstance * card);
void MovePW(MTGCardInstance * card);
int receiveEvent(WEvent * event);
virtual MTGNewPlaneswalker * clone() const;
};
/* /*
* 704.5k If a player controls two or more legendary permanents with the same name, * 704.5k If a player controls two or more legendary permanents with the same name,
* that player chooses one of them, and the rest are put into their owners graveyards. * that player chooses one of them, and the rest are put into their owners graveyards.
@@ -430,10 +459,6 @@ public:
class MTGLegendRule: public ListMaintainerAbility class MTGLegendRule: public ListMaintainerAbility
{ {
public: public:
TargetChooser * tcL;
MTGAbility * Legendrule;
MTGAbility * LegendruleAbility;
MTGAbility * LegendruleGeneric;
MTGLegendRule(GameObserver* observer, int _id); MTGLegendRule(GameObserver* observer, int _id);
int canBeInList(MTGCardInstance * card); int canBeInList(MTGCardInstance * card);
int added(MTGCardInstance * card); int added(MTGCardInstance * card);
@@ -445,10 +470,6 @@ public:
class MTGPlaneWalkerRule: public ListMaintainerAbility class MTGPlaneWalkerRule: public ListMaintainerAbility
{ {
public: public:
TargetChooser * tcP;
MTGAbility * PWrule;
MTGAbility * PWruleAbility;
MTGAbility * PWruleGeneric;
MTGPlaneWalkerRule(GameObserver* observer, int _id); MTGPlaneWalkerRule(GameObserver* observer, int _id);
int canBeInList(MTGCardInstance * card); int canBeInList(MTGCardInstance * card);
int added(MTGCardInstance * card); int added(MTGCardInstance * card);
+18
View File
@@ -305,12 +305,30 @@ struct WEventCardControllerChange : public WEventCardUpdate {
virtual Targetable * getTarget(int target); virtual Targetable * getTarget(int target);
}; };
//event when card with phases in
struct WEventCardPhasesIn : public WEventCardUpdate {
WEventCardPhasesIn(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card with morph faces up
struct WEventCardFaceUp : public WEventCardUpdate {
WEventCardFaceUp(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card transforms //event when card transforms
struct WEventCardTransforms : public WEventCardUpdate { struct WEventCardTransforms : public WEventCardUpdate {
WEventCardTransforms(MTGCardInstance * card); WEventCardTransforms(MTGCardInstance * card);
virtual Targetable * getTarget(int target); virtual Targetable * getTarget(int target);
}; };
//event when card copies a card
struct WEventCardCopiedACard : public WEventCardUpdate {
WEventCardCopiedACard(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//alterenergy event //alterenergy event
struct WEventplayerEnergized : public WEvent { struct WEventplayerEnergized : public WEvent {
WEventplayerEnergized(Player * player,int nb_count); WEventplayerEnergized(Player * player,int nb_count);
+7
View File
@@ -617,6 +617,13 @@ int OrderedAIAction::getEfficiency()
efficiency = 0; efficiency = 0;
} }
else if (GenericRevealAbility * grA = dynamic_cast<GenericRevealAbility *>(a))
{
if(grA->source->getAICustomCode().size())
efficiency = 45 + (owner->getRandomGenerator()->random() % 50);
else
efficiency = 0;
}
//At this point the "basic" efficiency is computed, we further tweak it depending on general decisions, independent of theAbility type //At this point the "basic" efficiency is computed, we further tweak it depending on general decisions, independent of theAbility type
MayAbility * may = dynamic_cast<MayAbility*>(ability); MayAbility * may = dynamic_cast<MayAbility*>(ability);
+114 -16
View File
@@ -88,12 +88,13 @@ float Interruptible::GetVerticalTextOffset() const
} }
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action,
bool bigQuad, int aType) bool bigQuad, int aType, vector<JQuadPtr> mytargetsQuad)
{ {
WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT); WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
bool hiddenview = aType == MTGAbility::HIDDENVIEW?true:false;
if (!targetQuad) if (!targetQuad)
{ {
@@ -105,22 +106,58 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string
} }
else else
{ {
renderer->FillRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(235,10,10,10));
/*if(source->controller()->isHuman() && source->controller()->opponent()->isAI()) /*if(source->controller()->isHuman() && source->controller()->opponent()->isAI())
renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,0,255,0)); renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,0,255,0));
else else
renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,255,0,0));*/ renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,255,0,0));*/
mFont->DrawString(">", x + 32, y + GetVerticalTextOffset(), JGETEXT_LEFT); float xnadj = 0;
mFont->DrawString(_(action).c_str(), x + 75, y + GetVerticalTextOffset(), JGETEXT_LEFT); int count = 1;
if(mytargetsQuad.size())
{
count = mytargetsQuad.size();
for(unsigned int k = 0; k < mytargetsQuad.size(); k++)
{
if(k > 10)
break;
xnadj+=4;
}
}
ostringstream aa;
aa << action << " " << "(" << count << ")";
if(count > 1)
xnadj -= 4;
if(!hiddenview)
{
mFont->DrawString(">", x + 32, y + GetVerticalTextOffset(), JGETEXT_LEFT);
if(count > 1)
{
mFont->DrawString(_(aa.str()).c_str(), x + 75 + xnadj, y + GetVerticalTextOffset(), JGETEXT_LEFT);
}
else
mFont->DrawString(_(action).c_str(), x + 75 + xnadj, y + GetVerticalTextOffset(), JGETEXT_LEFT);
}
else
mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT);
} }
JQuadPtr quad = observer->getResourceManager()->RetrieveCard(source, CACHE_THUMB); JQuadPtr quad = observer->getResourceManager()->RetrieveCard(source, CACHE_THUMB);
JQuadPtr fakeborder = observer->getResourceManager()->GetQuad("white");
if (!quad.get()) if (!quad.get())
quad = CardGui::AlternateThumbQuad(source); quad = CardGui::AlternateThumbQuad(source);
if (quad.get()) if (quad.get())
{ {
quad->SetColor(ARGB(255,255,255,255)); quad->SetColor(ARGB(255,255,255,255));
float scale = mHeight / quad->mHeight; float scale = mHeight / quad->mHeight;
if (fakeborder.get())
{
fakeborder->SetColor(ARGB(255,15,15,15));
renderer->RenderQuad(fakeborder.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, (29 * actZ + 1) / 16, 42 * actZ / 16);
}
renderer->RenderQuad(quad.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale); renderer->RenderQuad(quad.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale);
} }
else if (alt1.size()) else if (alt1.size())
@@ -147,19 +184,49 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string
} }
if (targetQuad) if(mytargetsQuad.size() && !hiddenview)
{ {
float backupX = targetQuad->mHotSpotX; float xadj = 0;
float backupY = targetQuad->mHotSpotY; for(unsigned int k = 0; k < mytargetsQuad.size(); k++)
targetQuad->SetColor(ARGB(255,255,255,255)); {
targetQuad->SetHotSpot(targetQuad->mWidth / 2, targetQuad->mHeight / 2); if(k > 10)
float scale = mHeight / targetQuad->mHeight; break;
renderer->RenderQuad(targetQuad, x + 55, y + ((mHeight - targetQuad->mHeight) / 2) + targetQuad->mHotSpotY, 0, scale, scale);
targetQuad->SetHotSpot(backupX, backupY); JQuadPtr multiQ = mytargetsQuad[k];
if(multiQ.get())
{
float backupX = multiQ->mHotSpotX;
float backupY = multiQ->mHotSpotY;
multiQ->SetColor(ARGB(255,255,255,255));
multiQ->SetHotSpot(multiQ->mWidth / 2, multiQ->mHeight / 2);
float scale = mHeight / multiQ->mHeight;
if (fakeborder.get())
{
fakeborder->SetColor(ARGB(255,15,15,15));
renderer->RenderQuad(fakeborder.get(), x + 55 + xadj, y + ((mHeight - multiQ->mHeight) / 2) + multiQ->mHotSpotY, 0, (29 * actZ + 1) / 16, 42 * actZ / 16);
}
renderer->RenderQuad(multiQ.get(), x + 55 + xadj, y + ((mHeight - multiQ->mHeight) / 2) + multiQ->mHotSpotY, 0, scale, scale);
multiQ->SetHotSpot(backupX, backupY);
xadj+=4;
}
}
} }
else if (alt2.size()) else if(!hiddenview)
{ {
mFont->DrawString(_(alt2).c_str(), x + 35, y+15 + GetVerticalTextOffset()); if (targetQuad)
{
float backupX = targetQuad->mHotSpotX;
float backupY = targetQuad->mHotSpotY;
targetQuad->SetColor(ARGB(255,255,255,255));
targetQuad->SetHotSpot(targetQuad->mWidth / 2, targetQuad->mHeight / 2);
float scale = mHeight / targetQuad->mHeight;
renderer->RenderQuad(targetQuad, x + 55, y + ((mHeight - targetQuad->mHeight) / 2) + targetQuad->mHotSpotY, 0, scale, scale);
targetQuad->SetHotSpot(backupX, backupY);
}
else if (alt2.size())
{
mFont->DrawString(_(alt2).c_str(), x + 35, y+15 + GetVerticalTextOffset());
}
} }
} }
@@ -173,6 +240,9 @@ void StackAbility::Render()
string action = ability->getMenuText(); string action = ability->getMenuText();
MTGCardInstance * source = ability->source; MTGCardInstance * source = ability->source;
string alt1 = source->getName(); string alt1 = source->getName();
vector<JQuadPtr> mytargetQuads;
int fmLibrary = 0;
int force = 0;
Targetable * _target = ability->target; Targetable * _target = ability->target;
if (ability->getActionTc()) if (ability->getActionTc())
@@ -180,6 +250,31 @@ void StackAbility::Render()
Targetable * t = ability->getActionTc()->getNextTarget(); Targetable * t = ability->getActionTc()->getNextTarget();
if (t) if (t)
_target = t; _target = t;
//test vector quads
if(ability->getActionTc()->getTargetsFrom().size())
{
for(size_t i = 0; i < ability->getActionTc()->getTargetsFrom().size(); i++)
{
Targetable * tt = ability->getActionTc()->getTargetsFrom()[i];
if(tt)
{
if( ((Damageable *)(tt))->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE )
{
if( source->has(Constants::HIDDENFACE) && !observer->isInLibrary(((MTGCardInstance *)(tt))) )
mytargetQuads.push_back( ((Damageable *)(tt))->getIcon() );
else if ( !source->has(Constants::HIDDENFACE) )
mytargetQuads.push_back( ((Damageable *)(tt))->getIcon() );
else
fmLibrary++;
}
else
mytargetQuads.push_back( ((Damageable *)(tt))->getIcon() );
}
}
}
//end
} }
Damageable * target = NULL; Damageable * target = NULL;
if (_target != ability->source && (dynamic_cast<MTGCardInstance *>(_target) || dynamic_cast<Player *>(_target))) if (_target != ability->source && (dynamic_cast<MTGCardInstance *>(_target) || dynamic_cast<Player *>(_target)))
@@ -198,10 +293,13 @@ void StackAbility::Render()
} }
} }
if(source->has(Constants::HIDDENFACE) && fmLibrary)
force = MTGAbility::HIDDENVIEW;
if(observer->gameType() == GAME_TYPE_MOMIR) if(observer->gameType() == GAME_TYPE_MOMIR)
Interruptible::Render(source, quad.get(), alt1, alt2, action, true, ability->aType); Interruptible::Render(source, quad.get(), alt1, alt2, action, true, ability->aType, mytargetQuads);
else else
Interruptible::Render(source, quad.get(), alt1, alt2, action); Interruptible::Render(source, quad.get(), alt1, alt2, action, false, force, mytargetQuads);
} }
StackAbility::StackAbility(GameObserver* observer, int id, MTGAbility * _ability) : StackAbility::StackAbility(GameObserver* observer, int id, MTGAbility * _ability) :
Interruptible(observer, id), ability(_ability) Interruptible(observer, id), ability(_ability)
+93 -17
View File
@@ -54,6 +54,18 @@ GenericRevealAbility::GenericRevealAbility(GameObserver* observer, int id, MTGCa
int GenericRevealAbility::resolve() int GenericRevealAbility::resolve()
{ {
if(source->lastController->isAI() && source->getAICustomCode().size())
{
string abi = source->getAICustomCode();
std::transform(abi.begin(), abi.end(), abi.begin(), ::tolower);//fix crash
AbilityFactory af(game);
MTGAbility * a3 = af.parseMagicLine(abi, this->GetId(), NULL, source);
a3->oneShot = 1;
a3->canBeInterrupted = false;
a3->resolve();
SAFE_DELETE(a3);
return 1;
}
MTGAbility * ability = NEW MTGRevealingCards(game, this->GetId(), source, howMany); MTGAbility * ability = NEW MTGRevealingCards(game, this->GetId(), source, howMany);
ability->addToGame(); ability->addToGame();
return 1; return 1;
@@ -180,7 +192,7 @@ void MTGRevealingCards::Update(float dt)
//if any carddisplays are open, dont do anything until theyre closed, then wait your turn if multiple reveals trigger. //if any carddisplays are open, dont do anything until theyre closed, then wait your turn if multiple reveals trigger.
return; return;
} }
if (game->mLayers->actionLayer()->menuObject) if (game->mLayers->actionLayer()->menuObject || game->LPWeffect)
return;//dont do any of this if a menuobject exist. return;//dont do any of this if a menuobject exist.
if (!source->getObserver()->mLayers->actionLayer()->getCurrentTargetChooser() && !revealDisplay && !initCD) if (!source->getObserver()->mLayers->actionLayer()->getCurrentTargetChooser() && !revealDisplay && !initCD)
{ {
@@ -1662,6 +1674,7 @@ int AACopier::resolve()
} }
} }
} }
currentAbilities.clear();
return 1; return 1;
} }
return 0; return 0;
@@ -3272,6 +3285,8 @@ int AAMorph::resolve()
} }
} }
} }
WEvent * e = NEW WEventCardFaceUp(_target);
game->receiveEvent(e);
currentAbilities.clear(); currentAbilities.clear();
testDestroy(); testDestroy();
} }
@@ -4171,6 +4186,8 @@ int AACloner::resolve()
Spell * spell = NEW Spell(game, myClone); Spell * spell = NEW Spell(game, myClone);
spell->source->isToken = 1; spell->source->isToken = 1;
spell->resolve(); spell->resolve();
spell->source->owner = targetPlayer;
spell->source->lastController = targetPlayer;
spell->source->fresh = 1; spell->source->fresh = 1;
spell->source->entersBattlefield = 1; spell->source->entersBattlefield = 1;
spell->source->model = spell->source; spell->source->model = spell->source;
@@ -4377,6 +4394,9 @@ AAMover::AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTG
if (_target) if (_target)
target = _target; target = _target;
andAbility = NULL; andAbility = NULL;
if(!named.size() && source->controller()->isAI())
named = overrideNamed(destination);
necro = false;
} }
MTGGameZone * AAMover::destinationZone(Targetable * target) MTGGameZone * AAMover::destinationZone(Targetable * target)
@@ -4397,6 +4417,8 @@ int AAMover::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
if (target) if (target)
{ {
if(necro)
_target->basicAbilities[Constants::NECROED] = 1;
Player* p = _target->controller(); Player* p = _target->controller();
if (p) if (p)
{ {
@@ -4479,21 +4501,26 @@ int AAMover::resolve()
else else
return 0; return 0;
} }
p->game->putInZone(_target, fromZone, destZone); MTGCardInstance *newTarget = p->game->putInZone(_target, fromZone, destZone);
while(_target->next) /*while(_target->next)
_target = _target->next; _target = _target->next;*/
if(andAbility) if(newTarget)
{ {
MTGAbility * andAbilityClone = andAbility->clone(); if(necro)
andAbilityClone->target = _target; newTarget->basicAbilities[Constants::NECROED] = 1;
if(andAbility->oneShot) if(andAbility)
{ {
andAbilityClone->resolve(); MTGAbility * andAbilityClone = andAbility->clone();
SAFE_DELETE(andAbilityClone); andAbilityClone->target = newTarget;
} if(andAbility->oneShot)
else {
{ andAbilityClone->resolve();
andAbilityClone->addToGame(); SAFE_DELETE(andAbilityClone);
}
else
{
andAbilityClone->addToGame();
}
} }
} }
} }
@@ -4503,11 +4530,36 @@ int AAMover::resolve()
return 0; return 0;
} }
string AAMover::overrideNamed(string destination)
{
string name = "Move";
if(destination.size())
{
if(destination.find("library") != string::npos)
name = "Put in Library";
else if(destination.find("hand") != string::npos)
name = "Put in Hand";
else if(destination.find("exile") != string::npos)
name = "Put in Exile";
else if(destination.find("removedfromgame") != string::npos)
name = "Put in Exile";
else if(destination.find("graveyard") != string::npos)
name = "Put in Graveyard";
else if(destination.find("previous") != string::npos)
name = "Previous Zone";
else if(destination.find("inplay") != string::npos)
name = "Put in Play";
else if(destination.find("battlefield") != string::npos)
name = "Put in Play";
}
return name;
}
const string AAMover::getMenuText() const string AAMover::getMenuText()
{ {
if(named.size()) if(named.size())
return named.c_str(); return named.c_str();
return "Put in Zone"; return "Move";
} }
const char* AAMover::getMenuText(TargetChooser * tc) const char* AAMover::getMenuText(TargetChooser * tc)
@@ -4569,7 +4621,7 @@ const char* AAMover::getMenuText(TargetChooser * tc)
} }
} }
return "Put in Zone"; return "Move";
} }
AAMover * AAMover::clone() const AAMover * AAMover::clone() const
@@ -8065,7 +8117,31 @@ int AACastCard::resolveSpell()
if (_target) if (_target)
{ {
if (_target->isLand()) if (_target->isLand())
putinplay = true; {
if(theNamedCard)
{
MTGCardInstance * copy = _target->controller()->game->putInZone(_target, _target->currentZone, _target->controller()->game->temp);
copy->changeController(source->controller(),true);
Spell * spell = NEW Spell(game, 0,copy,NULL,NULL, 1);
spell->resolve();
delete spell;
this->forceDestroy = true;
processed = true;
return 1;
}
else
{
MTGAbility * a = NEW AAMover(game, -1, source, _target, "mybattlefield", "");
a->oneShot = true;
a->resolve();
SAFE_DELETE(a);
this->forceDestroy = true;
processed = true;
return 1;
}
}
Spell * spell = NULL; Spell * spell = NULL;
MTGCardInstance * copy = NULL; MTGCardInstance * copy = NULL;
+24 -10
View File
@@ -18,6 +18,8 @@ CardDescriptor::CardDescriptor()
manacostComparisonMode = COMPARISON_NONE; manacostComparisonMode = COMPARISON_NONE;
counterComparisonMode = COMPARISON_NONE; counterComparisonMode = COMPARISON_NONE;
convertedManacost = -1; convertedManacost = -1;
zposComparisonMode = COMPARISON_NONE;
zposition = -1;
compareName =""; compareName ="";
nameComparisonMode = COMPARISON_NONE; nameComparisonMode = COMPARISON_NONE;
colorComparisonMode = COMPARISON_NONE; colorComparisonMode = COMPARISON_NONE;
@@ -145,6 +147,8 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card)
return NULL; return NULL;
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost)) if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost))
return NULL; return NULL;
if (zposComparisonMode && !valueInRange(zposComparisonMode, card->zpos, zposition))
return NULL;
if (nameComparisonMode && compareName != card->name) if (nameComparisonMode && compareName != card->name)
return NULL; return NULL;
return card; return card;
@@ -186,6 +190,8 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card)
match = NULL; match = NULL;
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost)) if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost))
match = NULL; match = NULL;
if (zposComparisonMode && !valueInRange(zposComparisonMode, card->zpos, zposition))
match = NULL;
if(nameComparisonMode && compareName != card->name) if(nameComparisonMode && compareName != card->name)
match = NULL; match = NULL;
@@ -257,32 +263,40 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
} }
} }
if ((CDcanProduceC == -1 && card->canproduceC == 1) || (CDcanProduceC == 1 && card->canproduceC == 0)) if (CDcanProduceC == -1)
{
int count = card->canproduceMana(Constants::MTG_COLOR_ARTIFACT) + card->canproduceMana(Constants::MTG_COLOR_WASTE);
if (count)
match = NULL;
}
if (CDcanProduceC == 1)
{
int count = card->canproduceMana(Constants::MTG_COLOR_ARTIFACT) + card->canproduceMana(Constants::MTG_COLOR_WASTE);
if (!count)
match = NULL;
}
if ((CDcanProduceG == -1 && card->canproduceMana(Constants::MTG_COLOR_GREEN) == 1) || (CDcanProduceG == 1 && card->canproduceMana(Constants::MTG_COLOR_GREEN) == 0))
{ {
match = NULL; match = NULL;
} }
if ((CDcanProduceG == -1 && card->canproduceG == 1) || (CDcanProduceG == 1 && card->canproduceG == 0)) if ((CDcanProduceU == -1 && card->canproduceMana(Constants::MTG_COLOR_BLUE) == 1) || (CDcanProduceU == 1 && card->canproduceMana(Constants::MTG_COLOR_BLUE) == 0))
{ {
match = NULL; match = NULL;
} }
if ((CDcanProduceU == -1 && card->canproduceU == 1) || (CDcanProduceU == 1 && card->canproduceU == 0)) if ((CDcanProduceR == -1 && card->canproduceMana(Constants::MTG_COLOR_RED) == 1) || (CDcanProduceR == 1 && card->canproduceMana(Constants::MTG_COLOR_RED) == 0))
{ {
match = NULL; match = NULL;
} }
if ((CDcanProduceR == -1 && card->canproduceR == 1) || (CDcanProduceR == 1 && card->canproduceR == 0)) if ((CDcanProduceB == -1 && card->canproduceMana(Constants::MTG_COLOR_BLACK) == 1) || (CDcanProduceB == 1 && card->canproduceMana(Constants::MTG_COLOR_BLACK) == 0))
{ {
match = NULL; match = NULL;
} }
if ((CDcanProduceB == -1 && card->canproduceB == 1) || (CDcanProduceB == 1 && card->canproduceB == 0)) if ((CDcanProduceW == -1 && card->canproduceMana(Constants::MTG_COLOR_WHITE) == 1) || (CDcanProduceW == 1 && card->canproduceMana(Constants::MTG_COLOR_WHITE) == 0))
{
match = NULL;
}
if ((CDcanProduceW == -1 && card->canproduceW == 1) || (CDcanProduceW == 1 && card->canproduceW == 0))
{ {
match = NULL; match = NULL;
} }
+7 -4
View File
@@ -44,9 +44,11 @@ void CardDisplay::init(MTGGameZone * zone)
resetObjects(); resetObjects();
if (!zone) return; if (!zone) return;
start_item = 0; start_item = 0;
for (int i = 0; i < zone->nb_cards; i++) vector<MTGCardInstance*> newCD (zone->cards.rbegin(), zone->cards.rend());
for (int i = 0; i < zone->nb_cards; i++)//invert display so the top will always be the first one to show
{ {
AddCard(zone->cards[i]); //AddCard(zone->cards[i]);
AddCard(newCD[i]);
} }
if (mObjects.size()) mObjects[0]->Entering(); if (mObjects.size()) mObjects[0]->Entering();
} }
@@ -78,7 +80,8 @@ void CardDisplay::Update(float dt)
bool update = false; bool update = false;
if (zone) if (zone)
{ {//invert display so the top will always be the first one to show
vector<MTGCardInstance*> newCD (zone->cards.rbegin(), zone->cards.rend());
int size = zone->cards.size(); int size = zone->cards.size();
for (int i = start_item; i < start_item + nb_displayed_items && i < (int)(mObjects.size()); i++) for (int i = start_item; i < start_item + nb_displayed_items && i < (int)(mObjects.size()); i++)
{ {
@@ -88,7 +91,7 @@ void CardDisplay::Update(float dt)
break; break;
} }
CardGui * cardg = (CardGui *) mObjects[i]; CardGui * cardg = (CardGui *) mObjects[i];
if (cardg->card != zone->cards[i]) update = true; if (cardg->card != newCD[i]) update = true;
} }
} }
PlayGuiObjectController::Update(dt); PlayGuiObjectController::Update(dt);
+82 -39
View File
@@ -254,8 +254,8 @@ void CardGui::Render()
highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white"); highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
if(fakeborder) if(fakeborder)
{ {
if(card->has(Constants::CANPLAYFROMGRAVEYARD)||card->has(Constants::CANPLAYFROMEXILE)||card->has(Constants::PAYZERO) if((card->has(Constants::CANPLAYFROMEXILE)||card->has(Constants::PAYZERO))||
||((card->has(Constants::TEMPFLASHBACK) || card->getManaCost()->getFlashback()) && game->isInGrave(card))) ((card->has(Constants::CANPLAYFROMGRAVEYARD) || card->has(Constants::TEMPFLASHBACK) || card->getManaCost()->getFlashback()) && game->isInGrave(card)))
fakeborder->SetColor(ARGB((int)(actA),7,235,7));//green border fakeborder->SetColor(ARGB((int)(actA),7,235,7));//green border
else else
fakeborder->SetColor(ARGB((int)(actA),15,15,15)); fakeborder->SetColor(ARGB((int)(actA),15,15,15));
@@ -401,6 +401,23 @@ void CardGui::Render()
} }
} }
// Render a mask over the card, if set
if (mask && quad)
JRenderer::GetInstance()->FillRect(actX - (scale * quad->mWidth / 2),actY - (scale * quad->mHeight / 2), scale * quad->mWidth, scale* quad->mHeight, mask);
if ((tc && tc->alreadyHasTarget(card)) || (game && card == game->mLayers->actionLayer()->currentActionCard))//paint targets red.
{
JQuadPtr rMask = card->getObserver()->getResourceManager()->GetQuad("white");
rMask->SetColor(ARGB(128,255,0,0));//red
renderer->RenderQuad(rMask.get(), actX, actY, actT, (27 * actZ + 1) / 16, 40 * actZ / 16);
}
if(tc && tc->source && tc->source->view && tc->source->view->actZ >= 1.3 && card == tc->source)//paint the source green while infocus.
{
JQuadPtr gMask = card->getObserver()->getResourceManager()->GetQuad("white");
gMask->SetColor(ARGB(128,0,255,0));//green
renderer->RenderQuad(gMask.get(), actX, actY, actT, (27 * actZ + 1) / 16, 40 * actZ / 16);
}
//draws the numbers power/toughness //draws the numbers power/toughness
if (card->isCreature()) if (card->isCreature())
{ {
@@ -443,15 +460,30 @@ void CardGui::Render()
if(card->chooseacolor >= 1) if(card->chooseacolor >= 1)
{ {
if(card->chooseacolor == 1) if(card->chooseacolor == 1)
buff += "\n-Green"; {
renderer->FillRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(255,0,255,0));
renderer->DrawRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(180,10,10,10));
}
else if(card->chooseacolor == 2) else if(card->chooseacolor == 2)
buff += "\n-Blue"; {
renderer->FillRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(255,0,206,209));
renderer->DrawRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(180,10,10,10));
}
else if(card->chooseacolor == 3) else if(card->chooseacolor == 3)
buff += "\n-Red"; {
renderer->FillRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(255,255,0,0));
renderer->DrawRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(180,10,10,10));
}
else if(card->chooseacolor == 4) else if(card->chooseacolor == 4)
buff += "\n-Black"; {
renderer->FillRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(255,20,20,20));
renderer->DrawRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(180,210,210,210));
}
else if(card->chooseacolor == 5) else if(card->chooseacolor == 5)
buff += "\n-White"; {
renderer->FillRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(255,250,235,215));
renderer->DrawRect(actX - 10 * actZ, actY - (1 * actZ), 6.f,6.f,ARGB(180,10,10,10));
}
} }
if(!alternate && buff != "" && game->gameType() == GAME_TYPE_CLASSIC)//it seems that other game modes makes cards as tokens!!! hmmm... if(!alternate && buff != "" && game->gameType() == GAME_TYPE_CLASSIC)//it seems that other game modes makes cards as tokens!!! hmmm...
{ {
@@ -459,8 +491,8 @@ void CardGui::Render()
char buffer[200]; char buffer[200];
sprintf(buffer, "%s", buff.c_str()); sprintf(buffer, "%s", buff.c_str());
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,215,0));//Gold indicator mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,215,0));//Gold indicator
mFont->SetScale(0.8f); mFont->SetScale(actZ);
mFont->DrawString(buffer, actX - 10 * actZ, actY - (16 * actZ)); mFont->DrawString(buffer, actX - 10 * actZ, actY - (18.3f * actZ));
mFont->SetScale(1); mFont->SetScale(1);
} }
@@ -480,47 +512,36 @@ void CardGui::Render()
sprintf(buffer, "%i", card->counters->counters[0]->nb); sprintf(buffer, "%i", card->counters->counters[0]->nb);
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255)); mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
mFont->SetScale(actZ); mFont->SetScale(actZ);
mFont->DrawString(buffer, actX - 10 * actZ, actY - (12 * actZ)); mFont->DrawString(buffer, actX - 10 * actZ, actY - (10.8f * actZ));
mFont->SetScale(1); mFont->SetScale(1);
} }
} }
//shadow that covers the whole card for targetchooser...
if (tc && !tc->canTarget(card)) if (tc && !tc->canTarget(card))
{ {
if (!shadow) if (!shadow)
shadow = card->getObserver()->getResourceManager()->GetQuad("shadow"); shadow = card->getObserver()->getResourceManager()->GetQuad("shadow");
if (shadow) if (shadow)
{ {
shadow->SetColor(ARGB(200,255,255,255)); shadow->SetColor(ARGB(190,255,255,255));
renderer->RenderQuad(shadow.get(), actX, actY, actT, (28 * actZ + 1) / 16, 40 * actZ / 16); renderer->RenderQuad(shadow.get(), actX, actY, actT, (28 * actZ + 1) / 16, 40 * actZ / 16);
} }
} }
// Render a mask over the card, if set //for necro
if (mask && quad) if (!shadow)
JRenderer::GetInstance()->FillRect(actX - (scale * quad->mWidth / 2),actY - (scale * quad->mHeight / 2), scale * quad->mWidth, scale* quad->mHeight, mask); shadow = card->getObserver()->getResourceManager()->GetQuad("shadow");
if (shadow)
{
int myA = 0;
if(game && card->has(Constants::NECROED))//no peeking...
myA = 255;
else
myA = 0;
if ((tc && tc->alreadyHasTarget(card)) || (game && card == game->mLayers->actionLayer()->currentActionCard))//paint targets red. shadow->SetColor(ARGB(myA,255,255,255));
{ renderer->RenderQuad(shadow.get(), actX, actY, actT, (28 * actZ + 1) / 16, 40 * actZ / 16);
if (card->isTapped())
{
renderer->FillRect(actX - (scale * quad->mWidth / 2)-7,actY - (scale * quad->mHeight / 2)+7,scale* quad->mHeight,scale * quad->mWidth, ARGB(128,255,0,0));
}
else
{
renderer->FillRect(actX - (scale * quad->mWidth / 2),actY - (scale * quad->mHeight / 2), scale * quad->mWidth, scale* quad->mHeight, ARGB(128,255,0,0));
}
}
if(tc && tc->source && tc->source->view && tc->source->view->actZ >= 1.3 && card == tc->source)//paint the source green while infocus.
{
if (tc->source->isTapped())
{
renderer->FillRect(actX - (scale * quad->mWidth / 2)-7,actY - (scale * quad->mHeight / 2)+7,scale* quad->mHeight,scale * quad->mWidth, ARGB(128,0,255,0));
}
else
{
renderer->FillRect(tc->source->view->actX - (scale * quad->mWidth / 2),tc->source->view->actY - (scale * quad->mHeight / 2), scale*quad->mWidth, scale*quad->mHeight, ARGB(128,0,255,0));
}
} }
PlayGuiObject::Render(); PlayGuiObject::Render();
@@ -555,7 +576,7 @@ void CardGui::AlternateRender(MTGCard * card, const Pos& pos)
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
JQuadPtr q; JQuadPtr q;
MTGCardInstance * thiscard = dynamic_cast<MTGCardInstance*> (card); MTGCardInstance * thiscard = dynamic_cast<MTGCardInstance*> (card);
int zpos = 0;
float x = pos.actX; float x = pos.actX;
vector<ModRulesBackGroundCardGuiItem *>items = gModRules.cardgui.background; vector<ModRulesBackGroundCardGuiItem *>items = gModRules.cardgui.background;
@@ -579,6 +600,7 @@ void CardGui::AlternateRender(MTGCard * card, const Pos& pos)
//draw black border ingame only //draw black border ingame only
if(thiscard && thiscard->getObserver()) if(thiscard && thiscard->getObserver())
{ {
zpos = thiscard->zpos;
renderer->FillRoundRect((pos.actX - (pos.actZ * 84.f))-11.5f,(pos.actY - (pos.actZ * 119.7f))-14.f,pos.actZ * 168.f + 6.5f,pos.actZ * 239.4f + 12.f,8.f,ARGB(255,5,5,5)); renderer->FillRoundRect((pos.actX - (pos.actZ * 84.f))-11.5f,(pos.actY - (pos.actZ * 119.7f))-14.f,pos.actZ * 168.f + 6.5f,pos.actZ * 239.4f + 12.f,8.f,ARGB(255,5,5,5));
renderer->DrawRoundRect((pos.actX - (pos.actZ * 84.f))-11.5f,(pos.actY - (pos.actZ * 119.7f))-14.f,pos.actZ * 168.f + 6.5f,pos.actZ * 239.4f + 12.f,8.f,ARGB(50,240,240,240)); renderer->DrawRoundRect((pos.actX - (pos.actZ * 84.f))-11.5f,(pos.actY - (pos.actZ * 119.7f))-14.f,pos.actZ * 168.f + 6.5f,pos.actZ * 239.4f + 12.f,8.f,ARGB(50,240,240,240));
} }
@@ -742,7 +764,7 @@ void CardGui::AlternateRender(MTGCard * card, const Pos& pos)
if (found != string::npos) if (found != string::npos)
{ {
stringstream st; stringstream st;
st << card->getMTGId(); st << "id:" << card->getMTGId() << " zpos:" << zpos;
formattedfield = FormattedData(formattedfield, "mtgid", st.str()); formattedfield = FormattedData(formattedfield, "mtgid", st.str());
} }
@@ -1160,6 +1182,20 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder
JQuadPtr quad = thumb ? WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_THUMB) JQuadPtr quad = thumb ? WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_THUMB)
: WResourceManager::Instance()->RetrieveCard(card); : WResourceManager::Instance()->RetrieveCard(card);
MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card); MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card);
GameObserver * game = NULL;
//TargetChooser * tc = NULL;
bool myA = true;
if(kcard)
{
game = kcard->getObserver();
if(game)
{
if(kcard->has(Constants::NECROED))
myA = false;
else
myA = true;
}
}
if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name) if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name)
{ {
MTGCard * fcard = MTGCollection()->getCardByName(kcard->name); MTGCard * fcard = MTGCollection()->getCardByName(kcard->name);
@@ -1171,7 +1207,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder
quad = thumb ? WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_THUMB, 1, abs(kcard->copiedID)) quad = thumb ? WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_THUMB, 1, abs(kcard->copiedID))
: WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_NORMAL, 1, abs(kcard->copiedID)); : WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_NORMAL, 1, abs(kcard->copiedID));
} }
if (quad.get()) if (quad.get() && myA)
{ {
if (quad->mHeight < quad->mWidth) if (quad->mHeight < quad->mWidth)
{ {
@@ -1225,7 +1261,8 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder
//DebugTrace("Unable to fetch image: " << card->getImageName()); //DebugTrace("Unable to fetch image: " << card->getImageName());
// If we come here, we do not have the picture. // If we come here, we do not have the picture.
AlternateRender(card, pos); if(myA)
AlternateRender(card, pos);
} }
string CardGui::FormattedData(string data, string replace, string value) string CardGui::FormattedData(string data, string replace, string value)
@@ -1519,6 +1556,12 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
{ {
cd.setToughness(comparisonCriterion); cd.setToughness(comparisonCriterion);
cd.toughnessComparisonMode = comparisonMode; cd.toughnessComparisonMode = comparisonMode;
//zpos restrictions
}
else if (attribute.find("zpos") != string::npos)
{//using > or < don't have effect unless like this: >= or <= or =
cd.zposition = comparisonCriterion;
cd.zposComparisonMode = comparisonMode;
//Manacost restrictions //Manacost restrictions
} }
else if (attribute.find("manacost") != string::npos) else if (attribute.find("manacost") != string::npos)
+3 -3
View File
@@ -334,8 +334,8 @@ void CardPrimitive::addMagicText(string value, string key)
void CardPrimitive::setdoubleFaced(const string& value) void CardPrimitive::setdoubleFaced(const string& value)
{ {
std::transform(doubleFaced.begin(), doubleFaced.end(), doubleFaced.begin(), ::tolower);
doubleFaced = value; doubleFaced = value;
std::transform(doubleFaced.begin(), doubleFaced.end(), doubleFaced.begin(), ::tolower);
} }
const string& CardPrimitive::getdoubleFaced() const const string& CardPrimitive::getdoubleFaced() const
@@ -345,8 +345,8 @@ const string& CardPrimitive::getdoubleFaced() const
void CardPrimitive::setAICustomCode(const string& value) void CardPrimitive::setAICustomCode(const string& value)
{ {
std::transform(AICustomCode.begin(), AICustomCode.end(), AICustomCode.begin(), ::tolower);
AICustomCode = value; AICustomCode = value;
std::transform(AICustomCode.begin(), AICustomCode.end(), AICustomCode.begin(), ::tolower);
} }
const string& CardPrimitive::getAICustomCode() const const string& CardPrimitive::getAICustomCode() const
@@ -356,8 +356,8 @@ const string& CardPrimitive::getAICustomCode() const
void CardPrimitive::setCrewAbility(const string& value) void CardPrimitive::setCrewAbility(const string& value)
{ {
std::transform(CrewAbility.begin(), CrewAbility.end(), CrewAbility.begin(), ::tolower);
CrewAbility = value; CrewAbility = value;
std::transform(CrewAbility.begin(), CrewAbility.end(), CrewAbility.begin(), ::tolower);
} }
const string& CardPrimitive::getCrewAbility() const const string& CardPrimitive::getCrewAbility() const
+9 -3
View File
@@ -95,7 +95,7 @@ ExtraManaCost * ExtraManaCost::clone() const
} }
ExtraManaCost::ExtraManaCost(ManaCost * costToPay) ExtraManaCost::ExtraManaCost(ManaCost * costToPay)
: ExtraCost("Pay The Cost",NULL, costToPay) : ExtraCost("",NULL, costToPay)
{ {
} }
@@ -321,13 +321,19 @@ SpecificLifeCost::SpecificLifeCost(TargetChooser *_tc, int slc)
int SpecificLifeCost::canPay() int SpecificLifeCost::canPay()
{ {
MTGCardInstance * _target = (MTGCardInstance *) target; if(source->controller()->life >= slc && !source->controller()->inPlay()->hasAbility(Constants::CANTCHANGELIFE) &&
!source->controller()->opponent()->game->battlefield->hasAbility(Constants::CANTPAYLIFE) &&
!source->controller()->game->battlefield->hasAbility(Constants::CANTPAYLIFE))
{
return 1;
}
/*MTGCardInstance * _target = (MTGCardInstance *) target;
if(_target->controller()->life >= slc && !_target->controller()->inPlay()->hasAbility(Constants::CANTCHANGELIFE) && if(_target->controller()->life >= slc && !_target->controller()->inPlay()->hasAbility(Constants::CANTCHANGELIFE) &&
!_target->controller()->opponent()->game->battlefield->hasAbility(Constants::CANTPAYLIFE) && !_target->controller()->opponent()->game->battlefield->hasAbility(Constants::CANTPAYLIFE) &&
!_target->controller()->game->battlefield->hasAbility(Constants::CANTPAYLIFE)) !_target->controller()->game->battlefield->hasAbility(Constants::CANTPAYLIFE))
{ {
return 1; return 1;
} }*/
return 0; return 0;
} }
+27
View File
@@ -50,6 +50,7 @@ void GameObserver::cleanup()
replacementEffects = NEW ReplacementEffects(); replacementEffects = NEW ReplacementEffects();
combatStep = BLOCKERS; combatStep = BLOCKERS;
connectRule = false; connectRule = false;
LPWeffect = false;
actionsList.clear(); actionsList.clear();
gameTurn.clear(); gameTurn.clear();
OpenedDisplay = NULL; OpenedDisplay = NULL;
@@ -106,6 +107,7 @@ GameObserver::GameObserver(WResourceManager *output, JGE* input)
combatStep = BLOCKERS; combatStep = BLOCKERS;
mRules = NULL; mRules = NULL;
connectRule = false; connectRule = false;
LPWeffect = false;
mLoading = false; mLoading = false;
mLayers = NULL; mLayers = NULL;
mTrash = new Trash(); mTrash = new Trash();
@@ -672,6 +674,16 @@ void GameObserver::gameStateBasedEffects()
for (int i = 0; i < ManaCost::MANA_PAID_WITH_BESTOW +1; i++) for (int i = 0; i < ManaCost::MANA_PAID_WITH_BESTOW +1; i++)
card->alternateCostPaid[i] = 0; card->alternateCostPaid[i] = 0;
} }
//test zone position
if(card && (isInGrave(card)||isInHand(card)||isInExile(card)))
{
card->zpos = w+1;
}
else if(card && (isInLibrary(card)))
{//invert so we get the top one...
int onum = w+1;
card->zpos = abs(onum - zone->nb_cards)+1;
}
} }
@@ -847,6 +859,9 @@ void GameObserver::gameStateBasedEffects()
card->phasedTurn = turn; card->phasedTurn = turn;
if(card->view) if(card->view)
card->view->alpha = 255; card->view->alpha = 255;
//add event phases in here
WEvent * evphasein = NEW WEventCardPhasesIn(card);
receiveEvent(evphasein);
} }
if (card->target && isInPlay(card->target) && (card->hasSubtype(Subtypes::TYPE_EQUIPMENT) || card->hasSubtype(Subtypes::TYPE_AURA))) if (card->target && isInPlay(card->target) && (card->hasSubtype(Subtypes::TYPE_EQUIPMENT) || card->hasSubtype(Subtypes::TYPE_AURA)))
{ {
@@ -1042,6 +1057,7 @@ void GameObserver::gameStateBasedEffects()
userRequestNextGamePhase(); userRequestNextGamePhase();
} }
this->LPWeffect = false;
//WEventGameStateBasedChecked event checked //WEventGameStateBasedChecked event checked
receiveEvent(NEW WEventGameStateBasedChecked()); receiveEvent(NEW WEventGameStateBasedChecked());
} }
@@ -1630,6 +1646,17 @@ int GameObserver::isInHand(MTGCardInstance * card)
} }
return 0; return 0;
} }
int GameObserver::isInLibrary(MTGCardInstance * card)
{
for (int i = 0; i < 2; i++)
{
MTGGameZone * library = players[i]->game->library;
if (players[i]->game->isInZone(card, library))
return 1;
}
return 0;
}
void GameObserver::cleanupPhase() void GameObserver::cleanupPhase()
{ {
currentPlayer->cleanupPhase(); currentPlayer->cleanupPhase();
+4
View File
@@ -426,6 +426,10 @@ int GuiPlay::receiveEventPlus(WEvent * e)
Replace(); Replace();
else if (dynamic_cast<WEventCardTransforms*> (e)) else if (dynamic_cast<WEventCardTransforms*> (e))
Replace(); Replace();
else if (dynamic_cast<WEventCardCopiedACard*> (e))
Replace();
else if (dynamic_cast<WEventCardFaceUp*> (e))
Replace();
Replace(); Replace();
return 0; return 0;
} }
+8 -3
View File
@@ -397,9 +397,14 @@ int GuiOpponentHand::receiveEventPlus(WEvent* e)
t = NEW CardView(CardView::nullZone, event->card, *(event->card->view)); t = NEW CardView(CardView::nullZone, event->card, *(event->card->view));
else else
t = NEW CardView(CardView::nullZone, event->card, x, y); t = NEW CardView(CardView::nullZone, event->card, x, y);
t->x = x + Width / 2; //t->x = x + Width / 2;
t->y = y + Height / 2; //t->y = y + Height / 2;
t->zoom = 0.6f; //t->zoom = 0.6f;
//I set to negative so we don't see the face when the cards move...
t->x = -400.f;
t->y = -400.f;
t->mask = ARGB(0,0,0,0);
t->zoom = -0.6f;
t->alpha = 0; t->alpha = 0;
cards.push_back(t); cards.push_back(t);
return 1; return 1;
+31 -15
View File
@@ -314,6 +314,21 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
return 0; return 0;
} }
} }
check = restriction[i].find("gravecast");
if(check != string::npos)
{
int count = 0;
for(unsigned int k = 0; k < player->game->stack->cardsSeenThisTurn.size(); k++)
{
MTGCardInstance * stackCard = player->game->stack->cardsSeenThisTurn[k];
if(stackCard->next && stackCard->next == card && (card->previousZone == card->controller()->game->graveyard||card->previousZone == card->controller()->opponent()->game->graveyard))
count++;
if(stackCard == card && (card->previousZone == card->controller()->game->graveyard||card->previousZone == card->controller()->opponent()->game->graveyard))
count++;
}
if(!count)
return 0;
}
check = restriction[i].find("rebound"); check = restriction[i].find("rebound");
if(check != string::npos) if(check != string::npos)
{ {
@@ -321,9 +336,9 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
for(unsigned int k = 0; k < player->game->stack->cardsSeenThisTurn.size(); k++) for(unsigned int k = 0; k < player->game->stack->cardsSeenThisTurn.size(); k++)
{ {
MTGCardInstance * stackCard = player->game->stack->cardsSeenThisTurn[k]; MTGCardInstance * stackCard = player->game->stack->cardsSeenThisTurn[k];
if(stackCard->next && stackCard->next == card && card->previousZone == card->controller()->game->hand) if(stackCard->next && stackCard->next == card && (card->previousZone == card->controller()->game->hand||card->previousZone == card->controller()->opponent()->game->hand))
count++; count++;
if(stackCard == card && card->previousZone == card->controller()->game->hand) if(stackCard == card && (card->previousZone == card->controller()->game->hand||card->previousZone == card->controller()->opponent()->game->hand))
count++; count++;
} }
if(!count) if(!count)
@@ -1021,6 +1036,14 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
if (TargetChooser *tc = parseSimpleTC(s,"transformed", card)) if (TargetChooser *tc = parseSimpleTC(s,"transformed", card))
return NEW TrCardTransformed(observer, id, card, tc,once); return NEW TrCardTransformed(observer, id, card, tc,once);
//Card Faces Up
if (TargetChooser *tc = parseSimpleTC(s,"facedup", card))
return NEW TrCardFaceUp(observer, id, card, tc,once);
//Card Phases In
if (TargetChooser *tc = parseSimpleTC(s,"phasedin", card))
return NEW TrCardPhasesIn(observer, id, card, tc,once);
//CombatTrigger //CombatTrigger
//Card card attacked and is blocked //Card card attacked and is blocked
found = s.find("combat("); found = s.find("combat(");
@@ -1463,14 +1486,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
found = s.find("legendrule"); found = s.find("legendrule");
if(found != string::npos) if(found != string::npos)
{ {
observer->addObserver(NEW MTGLegendRule(observer, -1)); //observer->addObserver(NEW MTGLegendRule(observer, -1));
observer->addObserver(NEW MTGNewLegend(observer, -1));
return NULL; return NULL;
} }
//this handles the planeswalker named legend rule which is dramatically different from above. //this handles the planeswalker named legend rule which is dramatically different from above.
found = s.find("planeswalkerrule"); found = s.find("planeswalkerrule");
if(found != string::npos) if(found != string::npos)
{ {
observer->addObserver(NEW MTGPlaneWalkerRule(observer, -1)); //observer->addObserver(NEW MTGPlaneWalkerRule(observer, -1));
observer->addObserver(NEW MTGNewPlaneswalker(observer, -1));
return NULL; return NULL;
} }
found = s.find("planeswalkerdamage"); found = s.find("planeswalkerdamage");
@@ -2782,6 +2807,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
MTGAbility * a = NEW AAMover(observer, id, card, target, splitMove[1],newName); MTGAbility * a = NEW AAMover(observer, id, card, target, splitMove[1],newName);
a->oneShot = true; a->oneShot = true;
((AAMover*)a)->necro = s.find("hiddenmoveto") != string::npos?true:false;
if(storedAndAbility.size()) if(storedAndAbility.size())
{ {
string stored = storedAndAbility; string stored = storedAndAbility;
@@ -3684,17 +3710,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
a->oneShot = 1; a->oneShot = 1;
a->canBeInterrupted = false; a->canBeInterrupted = false;
a->named = newName; a->named = newName;
if(card->getAICustomCode().size() && card->controller()->isAI()) return a;
{
string abi = card->getAICustomCode();
std::transform(abi.begin(), abi.end(), abi.begin(), ::tolower);//fix crash
MTGAbility * a3 = parseMagicLine(abi, id, spell, card);
a3->oneShot = 1;
a3->canBeInterrupted = false;
return a3;
}
else
return a;
} }
//scry:x (activate aility) //scry:x (activate aility)
+58 -7
View File
@@ -98,7 +98,11 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
void MTGCardInstance::copy(MTGCardInstance * card) void MTGCardInstance::copy(MTGCardInstance * card)
{ {
MTGCard * source = NULL; MTGCard * source = NULL;
if(card->isToken || card->hasCopiedToken) if(card->isACopier && card->copiedID)
{
source = MTGCollection()->getCardById(card->copiedID);
}
else if(card->isToken || card->hasCopiedToken)
{ {
if(card->getMTGId() > 0)//not generated token if(card->getMTGId() > 0)//not generated token
source = MTGCollection()->getCardById(card->getMTGId()); source = MTGCollection()->getCardById(card->getMTGId());
@@ -165,6 +169,11 @@ void MTGCardInstance::copy(MTGCardInstance * card)
backupTargets = this->backupTargets; backupTargets = this->backupTargets;
storedCard = oldStored; storedCard = oldStored;
miracle = false; miracle = false;
//add event here copied a card...
WEvent * e = NEW WEventCardCopiedACard(this);
getObserver()->receiveEvent(e);
} }
MTGCardInstance::~MTGCardInstance() MTGCardInstance::~MTGCardInstance()
@@ -237,6 +246,7 @@ void MTGCardInstance::initMTGCI()
stillNeeded = true; stillNeeded = true;
kicked = 0; kicked = 0;
dredge = 0; dredge = 0;
zpos = 0;
chooseacolor = -1; chooseacolor = -1;
chooseasubtype = ""; chooseasubtype = "";
coinSide = -1; coinSide = -1;
@@ -262,12 +272,6 @@ void MTGCardInstance::initMTGCI()
imprintR = 0; imprintR = 0;
imprintB = 0; imprintB = 0;
imprintW = 0; imprintW = 0;
canproduceG = 0;
canproduceU = 0;
canproduceR = 0;
canproduceB = 0;
canproduceW = 0;
canproduceC = 0;
entersBattlefield = 0; entersBattlefield = 0;
currentimprintName = ""; currentimprintName = "";
imprintedNames.clear(); imprintedNames.clear();
@@ -850,6 +854,53 @@ int MTGCardInstance::countDuplicateCardNames()
return count; return count;
} }
int MTGCardInstance::countDuplicateCardTypes()
{
int count = 0;
if(observer)
{
int nb_cards = controller()->game->battlefield->nb_cards;
for(int x = 0; x < nb_cards; x++)
{
if(controller()->game->battlefield->cards[x] != this && controller()->game->battlefield->cards[x]->types == this->types)
count+=1;
}
}
return count;
}
//check can produce mana
int MTGCardInstance::canproduceMana(int color)
{
int count = 0;
//start
if(hasSubtype("forest") && color == 1)
count++;
if(hasSubtype("island") && color == 2)
count++;
if(hasSubtype("mountain") && color == 3)
count++;
if(hasSubtype("swamp") && color == 4)
count++;
if(hasSubtype("plains") && color == 5)
count++;
if(cardsAbilities.size())
{
for(unsigned int j = 0; j < cardsAbilities.size(); j++)
{
if(dynamic_cast<AManaProducer*> (cardsAbilities[j]) && dynamic_cast<AManaProducer*> (cardsAbilities[j])->output->hasColor(color))
count++;
}
}
if(count)
return 1;
return 0;
}
//check stack //check stack
bool MTGCardInstance::StackIsEmptyandSorcerySpeed() bool MTGCardInstance::StackIsEmptyandSorcerySpeed()
{ {
+3 -2
View File
@@ -175,8 +175,9 @@ const char* Constants::MTGBasicAbilities[] = {
"canblocktapped", "canblocktapped",
"oppnomaxhand", "oppnomaxhand",
"cantcrew", "cantcrew",
"hiddenface",//test for facedown "hiddenface",//test for hiding card
"anytypeofmana" "anytypeofmana",
"necroed"//hide necored
}; };
map<string,int> Constants::MTGBasicAbilitiesMap; map<string,int> Constants::MTGBasicAbilitiesMap;
+272 -44
View File
@@ -3228,15 +3228,244 @@ MTGTokensCleanup * MTGTokensCleanup::clone() const
return NEW MTGTokensCleanup(*this); return NEW MTGTokensCleanup(*this);
} }
/* Legend Rule */ //new legend rule
MTGLegendRule::MTGLegendRule(GameObserver* observer, int _id) : MTGNewLegend::MTGNewLegend(GameObserver* observer, int _id) :
ListMaintainerAbility(observer, _id) PermanentAbility(observer, _id)
{ {
tcL = NULL; tcL = NULL;
Legendrule = NULL; Legendrule = NULL;
LegendruleAbility = NULL; LegendruleAbility = NULL;
LegendruleGeneric = NULL; LegendruleGeneric = NULL;
} }
int MTGNewLegend::receiveEvent(WEvent * e)
{
if(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer())
return 0;
if (WEventZoneChange* ev1 = dynamic_cast<WEventZoneChange*>(e))
{
if (ev1->to == game->players[0]->game->inPlay || ev1->to == game->players[1]->game->inPlay)
{
MTGCardInstance * card = ev1->card;
if(card && card->countDuplicateCardNames() > 1 && card->hasType(Subtypes::TYPE_LEGENDARY))
{
CheckLegend(card);
return 1;
}
}
}
else if(WEventCardControllerChange* ev2 = dynamic_cast<WEventCardControllerChange*>(e))
{
MTGCardInstance * card = ev2->card;
if(card && card->countDuplicateCardNames() > 1 && card->hasType(Subtypes::TYPE_LEGENDARY))
{
CheckLegend(card);
return 1;
}
}
else if(WEventCardTransforms* ev3 = dynamic_cast<WEventCardTransforms*>(e))
{
MTGCardInstance * card = ev3->card;
if(card && card->countDuplicateCardNames() > 1 && card->hasType(Subtypes::TYPE_LEGENDARY))
{
CheckLegend(card);
return 1;
}
}
else if(WEventCardCopiedACard* ev4 = dynamic_cast<WEventCardCopiedACard*>(e))
{
MTGCardInstance * card = ev4->card;
if(card && card->countDuplicateCardNames() > 1 && card->hasType(Subtypes::TYPE_LEGENDARY))
{
CheckLegend(card);
return 1;
}
}
else if(WEventCardFaceUp* ev5 = dynamic_cast<WEventCardFaceUp*>(e))
{
MTGCardInstance * card = ev5->card;
if(card && card->countDuplicateCardNames() > 1 && card->hasType(Subtypes::TYPE_LEGENDARY))
{
CheckLegend(card);
return 1;
}
}
else if(WEventCardPhasesIn* ev6 = dynamic_cast<WEventCardPhasesIn*>(e))
{
MTGCardInstance * card = ev6->card;
if(card && card->countDuplicateCardNames() > 1 && card->hasType(Subtypes::TYPE_LEGENDARY))
{
CheckLegend(card);
return 1;
}
}
return 0;
}
int MTGNewLegend::CheckLegend(MTGCardInstance * card)
{
if(!card)
return 0;
if(card->isPhased)
return 0;
if (card->hasType(Subtypes::TYPE_LEGENDARY) && card->controller()->game->inPlay->hasCard(card))
if(card->has(Constants::NOLEGEND)||card->controller()->opponent()->inPlay()->hasAbility(Constants::NOLEGENDRULE)||card->controller()->inPlay()->hasAbility(Constants::NOLEGENDRULE))
return 0;
if(card->countDuplicateCardNames() <= 1)
return 0;
MoveLegend(card);
return 1;
}
void MTGNewLegend::MoveLegend(MTGCardInstance * card)
{
game->LPWeffect = true;
vector<MTGAbility*>selection;
MTGCardInstance * myClone = NEW MTGCardInstance(card, card->controller()->game);
TargetChooserFactory tfL(game);
tcL = tfL.createTargetChooser("*[share!name!]|mybattlefield",myClone);
tcL->targetter = NULL;
tcL->maxtargets = 1;
Legendrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), myClone, NULL,"ownergraveyard","Put in Graveyard");
Legendrule->oneShot = true;
Legendrule->canBeInterrupted = false;
LegendruleAbility = NEW GenericTargetAbility(game, "","",game->mLayers->actionLayer()->getMaxId(), myClone,tcL, Legendrule->clone());
SAFE_DELETE(Legendrule);
LegendruleAbility->oneShot = true;
LegendruleAbility->canBeInterrupted = false;
LegendruleGeneric = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), myClone,NULL,LegendruleAbility->clone());
SAFE_DELETE(LegendruleAbility);
LegendruleGeneric->oneShot = true;
selection.push_back(LegendruleGeneric->clone());
SAFE_DELETE(LegendruleGeneric);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Legendary Rule");
menuChoice->addToGame();
return;
}
MTGNewLegend * MTGNewLegend::clone() const
{
return NEW MTGNewLegend(*this);
}
//new pw rule
MTGNewPlaneswalker::MTGNewPlaneswalker(GameObserver* observer, int _id) :
PermanentAbility(observer, _id)
{
tcP = NULL;
PWrule = NULL;
PWruleAbility = NULL;
PWruleGeneric = NULL;
}
int MTGNewPlaneswalker::receiveEvent(WEvent * e)
{
if(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer())
return 0;
if (WEventZoneChange* ev1 = dynamic_cast<WEventZoneChange*>(e))
{
if (ev1->to == game->players[0]->game->inPlay || ev1->to == game->players[1]->game->inPlay)
{
MTGCardInstance * card = ev1->card;
if(card && card->hasType(Subtypes::TYPE_PLANESWALKER))
{
CheckPW(card);
return 1;
}
}
}
else if(WEventCardControllerChange* ev2 = dynamic_cast<WEventCardControllerChange*>(e))
{
MTGCardInstance * card = ev2->card;
if(card && card->hasType(Subtypes::TYPE_PLANESWALKER))
{
CheckPW(card);
return 1;
}
}
else if(WEventCardTransforms* ev3 = dynamic_cast<WEventCardTransforms*>(e))
{
MTGCardInstance * card = ev3->card;
if(card && card->hasType(Subtypes::TYPE_PLANESWALKER))
{
CheckPW(card);
return 1;
}
}
else if(WEventCardCopiedACard* ev4 = dynamic_cast<WEventCardCopiedACard*>(e))
{
MTGCardInstance * card = ev4->card;
if(card && card->hasType(Subtypes::TYPE_PLANESWALKER))
{
CheckPW(card);
return 1;
}
}
else if(WEventCardFaceUp* ev5 = dynamic_cast<WEventCardFaceUp*>(e))
{
MTGCardInstance * card = ev5->card;
if(card && card->hasType(Subtypes::TYPE_PLANESWALKER))
{
CheckPW(card);
return 1;
}
}
else if(WEventCardPhasesIn* ev6 = dynamic_cast<WEventCardPhasesIn*>(e))
{
MTGCardInstance * card = ev6->card;
if(card && card->hasType(Subtypes::TYPE_PLANESWALKER))
{
CheckPW(card);
return 1;
}
}
return 0;
}
int MTGNewPlaneswalker::CheckPW(MTGCardInstance * card)
{
if(!card)
return 0;
if(card->isPhased)
return 0;
if(card->countDuplicateCardTypes() < 1)
return 0;
MovePW(card);
return 1;
}
void MTGNewPlaneswalker::MovePW(MTGCardInstance * card)
{
game->LPWeffect = true;
vector<MTGAbility*>selection;
MTGCardInstance * myClone = NEW MTGCardInstance(card, card->controller()->game);
TargetChooserFactory tfL(game);
tcP = tfL.createTargetChooser("planeswalker[share!types!]|mybattlefield",myClone);
tcP->targetter = NULL;
tcP->maxtargets = 1;
PWrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), myClone, NULL,"ownergraveyard","Put in Graveyard");
PWrule->oneShot = true;
PWrule->canBeInterrupted = false;
PWruleAbility = NEW GenericTargetAbility(game, "","",game->mLayers->actionLayer()->getMaxId(), myClone,tcP, PWrule->clone());
SAFE_DELETE(PWrule);
PWruleAbility->oneShot = true;
PWruleAbility->canBeInterrupted = false;
PWruleGeneric = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), myClone,NULL,PWruleAbility->clone());
SAFE_DELETE(PWruleAbility);
PWruleGeneric->oneShot = true;
selection.push_back(PWruleGeneric->clone());
SAFE_DELETE(PWruleGeneric);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Planeswalker Uniqueness Rule");
menuChoice->addToGame();
return;
}
MTGNewPlaneswalker * MTGNewPlaneswalker::clone() const
{
return NEW MTGNewPlaneswalker(*this);
}
////end new////
///old below///
/* Legend Rule */
MTGLegendRule::MTGLegendRule(GameObserver* observer, int _id) :
ListMaintainerAbility(observer, _id)
{
}
; ;
int MTGLegendRule::canBeInList(MTGCardInstance * card) int MTGLegendRule::canBeInList(MTGCardInstance * card)
@@ -3257,35 +3486,36 @@ int MTGLegendRule::added(MTGCardInstance * card)
{ {
map<MTGCardInstance *, bool>::iterator it; map<MTGCardInstance *, bool>::iterator it;
int destroy = 0; int destroy = 0;
vector<MTGCardInstance*>oldCards;
for (it = cards.begin(); it != cards.end(); it++) for (it = cards.begin(); it != cards.end(); it++)
{ {
MTGCardInstance * comparison = (*it).first; MTGCardInstance * comparison = (*it).first;
if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName()))) if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName())))
if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer())) if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer()))
{
oldCards.push_back(comparison);
destroy = 1; destroy = 1;
game->LPWeffect = true;
}
} }
if(destroy) if(destroy)
{ {
vector<MTGAbility*>selection; vector<MTGAbility*>selection;
MTGCardInstance * myClone = NEW MTGCardInstance(card, card->controller()->game); MultiAbility * multi = NEW MultiAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card, NULL);
TargetChooserFactory tfL(game); for(unsigned int i = 0;i < oldCards.size();i++)
tcL = tfL.createTargetChooser("*[share!name!]|mybattlefield",myClone); {
tcL->targetter = NULL; AAMover *a = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, oldCards[i],"ownergraveyard","Keep New");
tcL->maxtargets = 1; a->oneShot = true;
Legendrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), myClone, NULL,"ownergraveyard","Put in Graveyard"); multi->Add(a);
Legendrule->oneShot = true; }
Legendrule->canBeInterrupted = false; multi->oneShot = 1;
LegendruleAbility = NEW GenericTargetAbility(game, "","",game->mLayers->actionLayer()->getMaxId(), myClone,tcL, Legendrule->clone()); MTGAbility * a1 = multi;
SAFE_DELETE(Legendrule); selection.push_back(a1);
LegendruleAbility->oneShot = true; AAMover *b = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, card,"ownergraveyard","Keep Old");
LegendruleAbility->canBeInterrupted = false; b->oneShot = true;
LegendruleGeneric = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), myClone,NULL,LegendruleAbility->clone()); MTGAbility * b1 = b;
SAFE_DELETE(LegendruleAbility); selection.push_back(b1);
LegendruleGeneric->oneShot = true; MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule");
selection.push_back(LegendruleGeneric->clone());
SAFE_DELETE(LegendruleGeneric);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Legendary Rule");
menuChoice->addToGame(); menuChoice->addToGame();
} }
return 1; return 1;
@@ -3314,10 +3544,6 @@ MTGLegendRule * MTGLegendRule::clone() const
MTGPlaneWalkerRule::MTGPlaneWalkerRule(GameObserver* observer, int _id) : MTGPlaneWalkerRule::MTGPlaneWalkerRule(GameObserver* observer, int _id) :
ListMaintainerAbility(observer, _id) ListMaintainerAbility(observer, _id)
{ {
tcP = NULL;
PWrule = NULL;
PWruleAbility = NULL;
PWruleGeneric = NULL;
} }
; ;
@@ -3342,29 +3568,31 @@ int MTGPlaneWalkerRule::added(MTGCardInstance * card)
MTGCardInstance * comparison = (*it).first; MTGCardInstance * comparison = (*it).first;
if (comparison != card && comparison->types == card->types && comparison->controller() == card->controller()) if (comparison != card && comparison->types == card->types && comparison->controller() == card->controller())
if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer())) if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer()))
{
oldCards.push_back(comparison);
destroy = 1; destroy = 1;
game->LPWeffect = true;
}
} }
if (destroy) if (destroy)
{ {
vector<MTGAbility*>selection; vector<MTGAbility*>selection;
MTGCardInstance * myClone = NEW MTGCardInstance(card, card->controller()->game);
TargetChooserFactory tfL(game); MultiAbility * multi = NEW MultiAbility(game,game->mLayers->actionLayer()->getMaxId(), card, card, NULL);
tcP = tfL.createTargetChooser("planeswalker[share!types!]|mybattlefield",myClone); for(unsigned int i = 0;i < oldCards.size();i++)
tcP->targetter = NULL; {
tcP->maxtargets = 1; AAMover *a = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, oldCards[i],"ownergraveyard","Keep New");
PWrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), myClone, NULL,"ownergraveyard","Put in Graveyard"); a->oneShot = true;
PWrule->oneShot = true; multi->Add(a);
PWrule->canBeInterrupted = false; }
PWruleAbility = NEW GenericTargetAbility(game, "","",game->mLayers->actionLayer()->getMaxId(), myClone,tcP, PWrule->clone()); multi->oneShot = 1;
SAFE_DELETE(PWrule); MTGAbility * a1 = multi;
PWruleAbility->oneShot = true; selection.push_back(a1);
PWruleAbility->canBeInterrupted = false; AAMover *b = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, card,"ownergraveyard","Keep Old");
PWruleGeneric = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), myClone,NULL,PWruleAbility->clone()); b->oneShot = true;
SAFE_DELETE(PWruleAbility); MTGAbility * b1 = b;
PWruleGeneric->oneShot = true; selection.push_back(b1);
selection.push_back(PWruleGeneric->clone()); MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Planeswalker Rule");
SAFE_DELETE(PWruleGeneric);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Planeswalker Uniqueness Rule");
menuChoice->addToGame(); menuChoice->addToGame();
} }
return 1; return 1;
+12
View File
@@ -591,6 +591,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDcanProduceC = 1; cd->CDcanProduceC = 1;
} }
cd->mode = CardDescriptor::CD_OR;
} }
else if (attribute.find("manag") != string::npos) else if (attribute.find("manag") != string::npos)
{ {
@@ -602,6 +603,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDcanProduceG = 1; cd->CDcanProduceG = 1;
} }
cd->mode = CardDescriptor::CD_OR;
} }
else if (attribute.find("manau") != string::npos) else if (attribute.find("manau") != string::npos)
{ {
@@ -613,6 +615,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDcanProduceU = 1; cd->CDcanProduceU = 1;
} }
cd->mode = CardDescriptor::CD_OR;
} }
else if (attribute.find("manar") != string::npos) else if (attribute.find("manar") != string::npos)
{ {
@@ -624,6 +627,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDcanProduceR = 1; cd->CDcanProduceR = 1;
} }
cd->mode = CardDescriptor::CD_OR;
} }
else if (attribute.find("manab") != string::npos) else if (attribute.find("manab") != string::npos)
{ {
@@ -635,6 +639,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDcanProduceB = 1; cd->CDcanProduceB = 1;
} }
cd->mode = CardDescriptor::CD_OR;
} }
else if (attribute.find("manaw") != string::npos) else if (attribute.find("manaw") != string::npos)
{ {
@@ -646,6 +651,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDcanProduceW = 1; cd->CDcanProduceW = 1;
} }
cd->mode = CardDescriptor::CD_OR;
} }
else if (attribute.find("multicolor") != string::npos) else if (attribute.find("multicolor") != string::npos)
{ {
@@ -674,6 +680,12 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->setToughness(comparisonCriterion); cd->setToughness(comparisonCriterion);
cd->toughnessComparisonMode = comparisonMode; cd->toughnessComparisonMode = comparisonMode;
//zpos restrictions
}
else if (attribute.find("zpos") != string::npos)
{
cd->zposition = comparisonCriterion;
cd->zposComparisonMode = comparisonMode;
//Manacost restrictions //Manacost restrictions
} }
else if (attribute.find("manacost") != string::npos) else if (attribute.find("manacost") != string::npos)
+33
View File
@@ -236,11 +236,26 @@ WEventCardControllerChange::WEventCardControllerChange(MTGCardInstance * card) :
{ {
} }
WEventCardPhasesIn::WEventCardPhasesIn(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardFaceUp::WEventCardFaceUp(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardTransforms::WEventCardTransforms(MTGCardInstance * card) : WEventCardTransforms::WEventCardTransforms(MTGCardInstance * card) :
WEventCardUpdate(card) WEventCardUpdate(card)
{ {
} }
WEventCardCopiedACard::WEventCardCopiedACard(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCombatStepChange::WEventCombatStepChange(CombatStep step) : WEventCombatStepChange::WEventCombatStepChange(CombatStep step) :
WEvent(), step(step) WEvent(), step(step)
{ {
@@ -412,12 +427,30 @@ Targetable * WEventCardControllerChange::getTarget(int target)
return NULL; return NULL;
} }
Targetable * WEventCardPhasesIn::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardFaceUp::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardTransforms::getTarget(int target) Targetable * WEventCardTransforms::getTarget(int target)
{ {
if (target) return card; if (target) return card;
return NULL; return NULL;
} }
Targetable * WEventCardCopiedACard::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventplayerEnergized::getTarget(Player * player) Targetable * WEventplayerEnergized::getTarget(Player * player)
{ {
if (player) return player; if (player) return player;