Merge pull request #949 from kevlahnota/master

Support for playing the top card of library
This commit is contained in:
Anthony Calosa
2017-03-03 22:57:37 +08:00
committed by GitHub
12 changed files with 319 additions and 123 deletions

View File

@@ -23031,6 +23031,18 @@ mana={1}{U}
type=Artifact
[/card]
[card]
name=Courser of Kruphix
abilities=showfromtoplibrary
auto=canplaylandlibrarytop
auto=@movedTo(land|mybattlefield):life:1
text=Play with the top card of your library revealed. -- You may play the top card of your library if it's a land card. -- Whenever a land enters the battlefield under your control, you gain 1 life.
mana={1}{G}{G}
type=Enchantment Creature
subtype=Centaur
power=2
toughness=4
[/card]
[card]
name=Coursers' Accord
auto=token(Centaur,Creature Centaur,3/3,green) && ability$! name(populate) clone notatarget(creature[token]|mybattlefield) !$ controller
text=Put a 3/3 green Centaur creature token onto the battlefield, then populate. (Put a token onto the battlefield that's a copy of a creature token you control.)
@@ -23980,6 +23992,15 @@ type=Enchantment
subtype=Aura
[/card]
[card]
name=Crown of Convergence
abilities=showfromtoplibrary
auto=lord(creature[zpos=1]|mylibrary) transforms((,newability[lord(creature[share!color!]|mybattlefield) 1/1]))
auto={G}{W}:bottomoflibrary all(*[zpos=1]|mylibrary)
text=Play with the top card of your library revealed. -- As long as the top card of your library is a creature card, creatures you control that share a color with that card get +1/+1. -- {G}{W}: Put the top card of your library on the bottom of your library.
mana={2}
type=Artifact
[/card]
[card]
name=Crown of Empires
auto={3}{t}:name(steal or tap) target(creature) if type(scepter of empires|mybattlefield)~morethan~0,type(Throne of Empires|mybattlefield)~morethan~0 then moveto(mybattlefield) and!(untap)! else tap
text={3}, {T}: Tap target creature. Gain control of that creature instead if you control artifacts named Scepter of Empires and Throne of Empires.
@@ -44084,6 +44105,14 @@ power=8
toughness=8
[/card]
[card]
name=Future Sight
abilities=showfromtoplibrary
auto=canplayfromlibrarytop
text=Play with the top card of your library revealed. -- You may play the top card of your library.
mana={2}{U}{U}{U}
type=Enchantment
[/card]
[card]
name=Fylamarid
abilities=flying
auto=cantbeblockedby(creature[blue])
@@ -44574,6 +44603,17 @@ power=3
toughness=2
[/card]
[card]
name=Garruk's Horde
abilities=trample,showfromtoplibrary
auto=canplaycreaturelibrarytop
text=Trample -- Play with the top card of your library revealed. -- You may cast the top card of your library if it's a creature card. (Do this only any time you could cast that creature card. You still pay the spell's costs.)
mana={5}{G}{G}
type=Creature
subtype=Beast
power=7
toughness=7
[/card]
[card]
name=Garruk's Packleader
auto=@movedTo(other creature[power>=3]|myBattlefield):may draw:1
text=Whenever another creature with power 3 or greater enters the battlefield under your control, you may draw a card.
@@ -48229,6 +48269,16 @@ power=2
toughness=2
[/card]
[card]
name=Goblin Spy
abilities=showfromtoplibrary
text=Play with the top card of your library revealed.
mana={R}
type=Creature
subtype=Goblin Rogue
power=1
toughness=1
[/card]
[card]
name=Goblin Spymaster
abilities=first strike
auto=@each opponent end:token(Goblin,Creature Goblin,1/1,red) and!( transforms((,newability[lord(creature|mybattlefield) mustattack])) forever )! opponent
@@ -65305,6 +65355,14 @@ power=1
toughness=1
[/card]
[card]
name=Lantern of Insight
abilities=showfromtoplibrary,showopponenttoplibrary
auto={T}{S}:target(player) shuffle
text=Each player plays with the top card of his or her library revealed. -- {T}, Sacrifice Lantern of Insight: Target player shuffles his or her library.
mana={1}
type=Artifact
[/card]
[card]
name=Lantern Scout
auto=choice all(creature|mybattlefield) lifelink ueot
auto=@movedTo(other ally|myBattlefield):all(creature|mybattlefield) lifelink ueot
@@ -69705,6 +69763,17 @@ power=2
toughness=4
[/card]
[card]
name=Magus of the Future
abilities=showfromtoplibrary
auto=canplayfromlibrarytop
text=Play with the top card of your library revealed. -- You may play the top card of your library.
mana={2}{U}{U}{U}
type=Creature
subtype=Human Wizard
power=2
toughness=3
[/card]
[card]
name=Magus of the Jar
auto={T}{S}:name(hand blink) all(*|hand) transforms((,newability[moveto(exile)],newability[phaseaction[endofturn once checkex] moveto(ownerhand)])) && ability$!draw:7 all(player) _ phaseaction[endofturn once] reject all(*|hand)!$ controller
text={T}, Sacrifice Magus of the Jar: Each player exiles all cards from his or her hand face down and draws seven cards. At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way.
@@ -72166,6 +72235,18 @@ type=Enchantment
subtype=Aura
[/card]
[card]
name=Melek, Izzet Paragon
abilities=showfromtoplibrary
auto=canplayinstantsorcerylibrarytop
auto=@movedto(instant,sorcery|mystack) from(mylibrary):all(trigger[to]) castcard(copied noevent)
text=Play with the top card of your library revealed. -- You may cast the top card of your library if it's an instant or sorcery card. -- Whenever you cast an instant or sorcery spell from your library, copy it. You may choose new targets for the copy.
mana={4}{U}{R}
type=Legendary Creature
subtype=Weird Wizard
power=2
toughness=4
[/card]
[card]
name=Melesse Spirit
abilities=flying,protection from black
text=Flying, protection from black
@@ -76754,6 +76835,22 @@ mana={R}
type=Sorcery
[/card]
[card]
name=Mul Daya Channelers
abilities=showfromtoplibrary
auto=aslongas(creature[zpos=1]|mylibrary) 3/3 >0
auto=aslongas(land[zpos=1]|mylibrary) {t}:add{G}{G} >0
auto=aslongas(land[zpos=1]|mylibrary) {t}:add{R}{R} >0
auto=aslongas(land[zpos=1]|mylibrary) {t}:add{U}{U} >0
auto=aslongas(land[zpos=1]|mylibrary) {t}:add{B}{B} >0
auto=aslongas(land[zpos=1]|mylibrary) {t}:add{W}{W} >0
text=Play with the top card of your library revealed. -- As long as the top card of your library is a creature card, Mul Daya Channelers gets +3/+3. -- As long as the top card of your library is a land card, Mul Daya Channelers has "{T}: Add two mana of any one color to your mana pool."
mana={1}{G}{G}
type=Creature
subtype=Elf Druid Shaman
power=2
toughness=2
[/card]
[card]
name=Mulch
aicode=activate target(<4>*[zpos<=4]|mylibrary) name(revealed card) moveto(myhand) name(revealed card) and!(if cantargetcard(*[-land]|*) then moveto(mygraveyard))!
auto=reveal:4 optionone name(Get land) target(<4>land|reveal) moveto(myhand) optiononeend optiontwo name(put in grave) all(*|reveal) moveto(mygraveyard) optiontwoend revealend
@@ -82431,6 +82528,18 @@ power=3
toughness=5
[/card]
[card]
name=Oracle of Mul Daya
abilities=showfromtoplibrary
auto=canplaylandlibrarytop
auto=maxPlay(land)+1
text=You may play an additional land on each of your turns. -- Play with the top card of your library revealed. -- You may play the top card of your library if it's a land card.
mana={3}{G}
type=Creature
subtype=Elf Shaman
power=2
toughness=2
[/card]
[card]
name=Oracle of Nectars
auto={X}{T}:life:X
text={X}, {T}: You gain X life.
@@ -118448,6 +118557,14 @@ power=1
toughness=1
[/card]
[card]
name=Temporal Aperture
aicode=activate choice all(*[zpos=1]) transforms((,canplayfromlibrarytop,zerocast)) forever
auto={5}{t}:shuffle && reveal:1 optionone name(choose card) target(<1>*|reveal) moveto(mylibrary) and!( transforms((,canplayfromlibrarytop,zerocast)) forever )! optiononeend revealend
text={5}, {T}: Shuffle your library, then reveal the top card. Until end of turn, for as long as that card remains on top of your library, play with the top card of your library revealed and you may play that card without paying its mana cost. (If it has X in its mana cost, X is 0.)
mana={2}
type=Artifact
[/card]
[card]
name=Temporal Cascade
other={7}{U}{U} name(Entwine)
auto=if paid(alternative) then moveto(ownerlibrary) and!(shuffle)! all(*|hand,graveyard) && draw:7 all(player)
@@ -126833,6 +126950,18 @@ power=3
toughness=2
[/card]
[card]
name=Vampire Nocturnus
abilities=showfromtoplibrary
auto=aslongas(*[black;zpos=1]|mylibrary) lord(creature) 2/1 >0
auto=aslongas(*[black;zpos=1]|mylibrary) lord(creature) flying >0
text=Play with the top card of your library revealed. -- As long as the top card of your library is black, Vampire Nocturnus and other Vampire creatures you control get +2/+1 and have flying.
mana={1}{B}{B}{B}
type=Creature
subtype=Vampire
power=3
toughness=3
[/card]
[card]
name=Vampire Outcasts
abilities=lifelink
auto=bloodthirst:2

View File

@@ -2866,15 +2866,6 @@ mana={4}{U}{U}
type=Instant
[/card]
[card]
name=Courser of Kruphix
text=Play with the top card of your library revealed. -- You may play the top card of your library if it's a land card. -- Whenever a land enters the battlefield under your control, you gain 1 life.
mana={1}{G}{G}
type=Enchantment Creature
subtype=Centaur
power=2
toughness=4
[/card]
[card]
name=Covenant of Minds
text=Reveal the top three cards of your library. Target opponent may choose to put those cards into your hand. If he or she doesn't, put those cards into your graveyard and draw five cards.
mana={4}{U}
@@ -2992,12 +2983,6 @@ mana={4}
type=Artifact
[/card]
[card]
name=Crown of Convergence
text=Play with the top card of your library revealed. -- As long as the top card of your library is a creature card, creatures you control that share a color with that card get +1/+1. -- {G}{W}: Put the top card of your library on the bottom of your library.
mana={2}
type=Artifact
[/card]
[card]
name=Crown of Doom
text=Whenever a creature attacks you or a planeswalker you control, it gets +2/+0 until end of turn. -- {2}: Target player other than Crown of Doom's owner gains control of it. Activate this ability only during your turn.
mana={3}
@@ -5455,12 +5440,6 @@ mana={1}{R}{R}{R}
type=Enchantment
[/card]
[card]
name=Future Sight
text=Play with the top card of your library revealed. -- You may play the top card of your library.
mana={2}{U}{U}{U}
type=Enchantment
[/card]
[card]
name=Gabriel Angelfire
text=At the beginning of your upkeep, choose flying, first strike, trample, or rampage 3. Gabriel Angelfire gains that ability until your next upkeep. (Whenever a creature with rampage 3 becomes blocked, it gets +3/+3 until end of turn for each creature blocking it beyond the first.)
mana={3}{G}{G}{W}{W}
@@ -5545,15 +5524,6 @@ mana={2}{R}
type=Instant
[/card]
[card]
name=Garruk's Horde
text=Trample -- Play with the top card of your library revealed. -- You may cast the top card of your library if it's a creature card. (Do this only any time you could cast that creature card. You still pay the spell's costs.)
mana={5}{G}{G}
type=Creature
subtype=Beast
power=7
toughness=7
[/card]
[card]
name=Garrulous Sycophant
text=At the beginning of your end step, if you're the monarch, each opponent loses 1 life and you gain 1 life.
mana={2}{B}
@@ -6072,15 +6042,6 @@ power=1
toughness=1
[/card]
[card]
name=Goblin Spy
text=Play with the top card of your library revealed.
mana={R}
type=Creature
subtype=Goblin Rogue
power=1
toughness=1
[/card]
[card]
name=Goblin Test Pilot
text=Flying -- {T}: Goblin Test Pilot deals 2 damage to target creature or player chosen at random.
mana={1}{U}{R}
@@ -8562,12 +8523,6 @@ mana={1}{R}{R}
type=World Enchantment
[/card]
[card]
name=Lantern of Insight
text=Each player plays with the top card of his or her library revealed. -- {T}, Sacrifice Lantern of Insight: Target player shuffles his or her library.
mana={1}
type=Artifact
[/card]
[card]
name=Laquatus's Disdain
text=Counter target spell cast from a graveyard. -- Draw a card.
mana={1}{U}
@@ -9152,15 +9107,6 @@ power=5
toughness=5
[/card]
[card]
name=Magus of the Future
text=Play with the top card of your library revealed. -- You may play the top card of your library.
mana={2}{U}{U}{U}
type=Creature
subtype=Human Wizard
power=2
toughness=3
[/card]
[card]
name=Magus of the Scroll
text={3}, {T}: Name a card. Reveal a card at random from your hand. If it's the named card, Magus of the Scroll deals 2 damage to target creature or player.
mana={R}
@@ -9504,15 +9450,6 @@ power=4
toughness=4
[/card]
[card]
name=Melek, Izzet Paragon
text=Play with the top card of your library revealed. -- You may cast the top card of your library if it's an instant or sorcery card. -- Whenever you cast an instant or sorcery spell from your library, copy it. You may choose new targets for the copy.
mana={4}{U}{R}
type=Legendary Creature
subtype=Weird Wizard
power=2
toughness=4
[/card]
[card]
name=Meletis Charlatan
text={2}{U}, {T}: The controller of target instant or sorcery spell copies it. That player may choose new targets for the copy.
mana={2}{U}
@@ -10056,15 +9993,6 @@ power=3
toughness=3
[/card]
[card]
name=Mul Daya Channelers
text=Play with the top card of your library revealed. -- As long as the top card of your library is a creature card, Mul Daya Channelers gets +3/+3. -- As long as the top card of your library is a land card, Mul Daya Channelers has "{T}: Add two mana of any one color to your mana pool."
mana={1}{G}{G}
type=Creature
subtype=Elf Druid Shaman
power=2
toughness=2
[/card]
[card]
name=Multani's Presence
text=Whenever a spell you've cast is countered, draw a card.
mana={G}
@@ -10956,15 +10884,6 @@ power=3
toughness=1
[/card]
[card]
name=Oracle of Mul Daya
text=You may play an additional land on each of your turns. -- Play with the top card of your library revealed. -- You may play the top card of your library if it's a land card.
mana={3}{G}
type=Creature
subtype=Elf Shaman
power=2
toughness=2
[/card]
[card]
name=Oracle's Attendants
text={T}: All damage that would be dealt to target creature this turn by a source of your choice is dealt to Oracle's Attendants instead.
mana={3}{W}
@@ -16080,12 +15999,6 @@ power=3
toughness=3
[/card]
[card]
name=Temporal Aperture
text={5}, {T}: Shuffle your library, then reveal the top card. Until end of turn, for as long as that card remains on top of your library, play with the top card of your library revealed and you may play that card without paying its mana cost. (If it has X in its mana cost, X is 0.)
mana={2}
type=Artifact
[/card]
[card]
name=Temporal Extortion
text=When you cast Temporal Extortion, any player may pay half his or her life, rounded up. If a player does, counter Temporal Extortion. -- Take an extra turn after this one.
mana={B}{B}{B}{B}
@@ -17127,15 +17040,6 @@ mana={W}
type=Instant
[/card]
[card]
name=Vampire Nocturnus
text=Play with the top card of your library revealed. -- As long as the top card of your library is black, Vampire Nocturnus and other Vampire creatures you control get +2/+1 and have flying.
mana={1}{B}{B}{B}
type=Creature
subtype=Vampire
power=3
toughness=3
[/card]
[card]
name=Vandalize
text=Choose one or both — -- • Destroy target artifact. -- • Destroy target land.
mana={4}{R}

View File

@@ -80,6 +80,7 @@ protected:
vector<CardView*> cards;
public:
int wave;
GuiPlay(DuelLayers*);
~GuiPlay();
virtual void Render();

View File

@@ -267,6 +267,7 @@ public:
bool discarded;
int copiedID;
int copiedSetID;
bool canPlayFromLibrary();
bool StackIsEmptyandSorcerySpeed();
bool isTargetted();
int cardistargetted;

View File

@@ -267,7 +267,14 @@ class Constants
ANYTYPEOFMANA = 145,
NECROED = 146,
CANTPWATTACK = 147,
NB_BASIC_ABILITIES = 148,
CANPLAYFROMLIBRARYTOP = 148,//all
CANPLAYLANDTOPLIBRARY = 149,//land
CANPLAYCREATURETOPLIBRARY = 150,//creature
CANPLAYARTIFACTTOPLIBRARY = 151,//artifact
CANPLAYINSTANTSORCERYTOPLIBRARY = 152,//instantorsorcery
SHOWFROMTOPLIBRARY = 153,
SHOWOPPONENTTOPLIBRARY = 154,
NB_BASIC_ABILITIES = 155,
RARITY_S = 'S', //Special Rarity
RARITY_M = 'M', //Mythics

View File

@@ -368,18 +368,21 @@ void CardGui::Render()
JQuadPtr ssMask = card->getObserver()->getResourceManager()->GetQuad("white");
//choose attacker mask
if(card->isInPlay(game) && card->isCreature()
&& ((!card->canAttack() || (card->attackCost > 0)) && (!card->canAttack(true) || (card->attackPlaneswalkerCost > 0)))
&& !card->isPhased && !card->didattacked )
if(game->currentPlayer->hasPossibleAttackers())
{
if(game->getCurrentGamePhase() > MTG_PHASE_FIRSTMAIN
&& game->getCurrentGamePhase() < MTG_PHASE_SECONDMAIN
&& card->controller() == game->currentPlayer )
if(card->isInPlay(game) && card->isCreature()
&& ((!card->canAttack() || (card->attackCost > 0)) && (!card->canAttack(true) || (card->attackPlaneswalkerCost > 0)))
&& !card->isPhased && !card->didattacked )
{
if(card->controller()->isHuman() && ssMask)
if(game->getCurrentGamePhase() > MTG_PHASE_FIRSTMAIN
&& game->getCurrentGamePhase() < MTG_PHASE_SECONDMAIN
&& card->controller() == game->currentPlayer )
{
ssMask->SetColor(ARGB(170,64,64,64));
renderer->RenderQuad(ssMask.get(), actX, actY, actT, (27 * actZ + 1) / 16, 40 * actZ / 16);
if(card->controller()->isHuman() && ssMask)
{
ssMask->SetColor(ARGB(170,64,64,64));
renderer->RenderQuad(ssMask.get(), actX, actY, actT, (27 * actZ + 1) / 16, 40 * actZ / 16);
}
}
}
}

View File

@@ -967,6 +967,21 @@ void GameObserver::gameStateBasedEffects()
p->nomaxhandsize = true;
else
p->nomaxhandsize = false;
//////////////////////////////////
//clear will attack player or pw//
//////////////////////////////////
if (mCurrentGamePhase == MTG_PHASE_COMBATBLOCKERS)
{
for (int l = z->nb_cards - 1; l >= 0; l--)
{
MTGCardInstance * c = z->cards[l];
if(c)
{
c->willattackplayer = 0;
c->willattackpw = 0;
}
}
}
/////////////////////////////////////////////////
//handle end of turn effects while we're at it.//
/////////////////////////////////////////////////

View File

@@ -178,6 +178,7 @@ void GuiPlay::BattleField::Render()
GuiPlay::GuiPlay(DuelLayers* view) :
GuiLayer(view)
{
wave = 0;
end_spells = cards.end();
}
@@ -298,6 +299,20 @@ void GuiPlay::Render()
for (iterator it = cards.begin(); it != cards.end(); ++it)
{
//draw line when attacking planeswalker
if((*it)->card && (*it)->card->isAttacker())
{
Damageable * dtarget = ((Damageable *)(*it)->card->isAttacking);
if(dtarget && dtarget->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
{
MTGCardInstance * ctarget = ((MTGCardInstance *)(*it)->card->isAttacking);
if(ctarget->hasType(Subtypes::TYPE_PLANESWALKER) && observer->isInPlay(ctarget) && observer->getCurrentGamePhase() < MTG_PHASE_COMBATEND)
{
JRenderer::GetInstance()->DrawLine((*it)->actX,(*it)->actY,ctarget->view->actX,ctarget->view->actY,0.5f,ARGB(128 - wave, 255, 20, 0));
}
}
}
if ((*it)->card->isLand())
{
if (mpDuelLayers->getRenderedPlayer() == (*it)->card->controller())
@@ -342,6 +357,7 @@ void GuiPlay::Update(float dt)
if((*it))
(*it)->Update(dt);
}
wave = (wave + 2 * (int) (100 * dt)) % 255;
}
int GuiPlay::receiveEventPlus(WEvent * e)

View File

@@ -197,12 +197,60 @@ void GuiGameZone::Render()
//Texture
JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
float scale = defaultHeight / quad->mHeight;
float modx = 0;
float mody = 0;
bool replaced = false;
bool showtop = (zone && zone->owner->game->battlefield->nb_cards && zone->owner->game->battlefield->hasAbility(Constants::SHOWFROMTOPLIBRARY))?true:false;
bool showopponenttop = (zone && zone->owner->opponent()->game->battlefield->nb_cards && zone->owner->opponent()->game->battlefield->hasAbility(Constants::SHOWOPPONENTTOPLIBRARY))?true:false;
quad->SetColor(ARGB((int)(actA),255,255,255));
if(type == GUI_EXILE)
{
quad->SetColor(ARGB((int)(actA),255,240,255));
}
JRenderer::GetInstance()->RenderQuad(quad.get(), actX, actY, 0.0, scale * actZ, scale * actZ);
if(type == GUI_LIBRARY && zone->nb_cards && !showCards)
{
int top = zone->nb_cards - 1;
if(zone->cards[top] && (zone->cards[top]->canPlayFromLibrary()||showtop||showopponenttop))
{
MTGCardInstance * card = zone->cards[top];
if(card && card->getObserver())
{
replaced = true;
/*TargetChooser * tc = card->getObserver()->getCurrentTargetChooser();
if(tc && tc->canTarget(card) && !tc->done)
replaced = false;
else
{*/
JQuadPtr kquad = WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB);
if(kquad)
{
kquad->SetColor(ARGB((int)(actA),255,255,255));
scale = defaultHeight / kquad->mHeight;
modx = (35/4)+1;
mody = (50/4)+1;
quad = kquad;
}
else
{
quad = CardGui::AlternateThumbQuad(card);
if(quad)
{
quad->SetColor(ARGB((int)(actA),255,255,255));
scale = defaultHeight / quad->mHeight;
modx = (35/4)+1;
mody = (50/4)+1;
}
}
//}
}
}
}
//render small card quad
if(quad)
JRenderer::GetInstance()->RenderQuad(quad.get(), actX+modx, actY+mody, 0.0, scale * actZ, scale * actZ);
float x0 = actX;
if (x0 < SCREEN_WIDTH / 2)
@@ -211,8 +259,11 @@ void GuiGameZone::Render()
}
if (mHasFocus)
JRenderer::GetInstance()->FillRect(actX, actY, quad->mWidth * scale * actZ, quad->mHeight * scale * actZ,
{
if(!replaced)
JRenderer::GetInstance()->FillRect(actX, actY, quad->mWidth * scale * actZ, quad->mHeight * scale * actZ,
ARGB(abs(128 - wave),255,255,255));
}
//Number of cards
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
@@ -236,10 +287,24 @@ void GuiGameZone::Render()
mFont->SetColor(ARGB(mAlpha,255,255,255));
mFont->DrawString(buffer, x0, actY);
//show top library - big card display
if(type == GUI_LIBRARY && mHasFocus && zone->nb_cards && !showCards && replaced)
{
int top = zone->nb_cards - 1;
if(zone->cards[top])
{
Pos pos = Pos(SCREEN_WIDTH - 35 - CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 15, 0.80f, 0.0, 220);
pos.actY = 165;
if (x < (CardGui::BigWidth / 2)) pos.actX = CardGui::BigWidth / 2;
CardGui::DrawCard(zone->cards[top], pos);
}
}
if (showCards)
cd->Render();
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
(*it)->Render();
PlayGuiObject::Render();
}
@@ -252,6 +317,26 @@ bool GuiGameZone::CheckUserInput(JButton key)
{
if (showCards)
return cd->CheckUserInput(key);
else if(type == GUI_LIBRARY && zone->nb_cards && !showCards && key == JGE_BTN_OK && mHasFocus)
{
bool activateclick = true;
int top = zone->nb_cards - 1;
MTGCardInstance * card = zone->cards[top];
GameObserver * game = card->getObserver();
if(game)
{
TargetChooser * tc = game->getCurrentTargetChooser();
if(tc && (tc->canTarget(card) || !tc->done || tc->Owner->isHuman()))
activateclick = false;
}
if(card && activateclick)
{
card->getObserver()->cardClick(card);
return true;
}
}
return false;
}

View File

@@ -903,6 +903,32 @@ int MTGCardInstance::canproduceMana(int color)
return 0;
}
//check can be played from library top
bool MTGCardInstance::canPlayFromLibrary()
{
int found = 0;
if(has(Constants::CANPLAYFROMLIBRARYTOP)
|| (controller()->game->inPlay->nb_cards && controller()->game->inPlay->hasAbility(Constants::CANPLAYFROMLIBRARYTOP)))
found++;
if(isLand() && (has(Constants::CANPLAYLANDTOPLIBRARY)
|| (controller()->game->inPlay->nb_cards && controller()->game->inPlay->hasAbility(Constants::CANPLAYLANDTOPLIBRARY))))
found++;
if(hasSubtype(Subtypes::TYPE_ARTIFACT) && (has(Constants::CANPLAYARTIFACTTOPLIBRARY)
|| (controller()->game->inPlay->nb_cards && controller()->game->inPlay->hasAbility(Constants::CANPLAYARTIFACTTOPLIBRARY))))
found++;
if(isCreature() && (has(Constants::CANPLAYCREATURETOPLIBRARY)
|| (controller()->game->inPlay->nb_cards && controller()->game->inPlay->hasAbility(Constants::CANPLAYCREATURETOPLIBRARY))))
found++;
if(isSorceryorInstant() && (has(Constants::CANPLAYINSTANTSORCERYTOPLIBRARY)
|| (controller()->game->inPlay->nb_cards && controller()->game->inPlay->hasAbility(Constants::CANPLAYINSTANTSORCERYTOPLIBRARY))))
found++;
if(found > 0)
return true;
return false;
}
//check stack
bool MTGCardInstance::StackIsEmptyandSorcerySpeed()
{

View File

@@ -178,7 +178,14 @@ const char* Constants::MTGBasicAbilities[] = {
"hiddenface",//test for hiding card
"anytypeofmana",
"necroed",//hide necored
"cantpwattack"
"cantpwattack",
"canplayfromlibrarytop",//all
"canplaylandlibrarytop",//land
"canplaycreaturelibrarytop",//creature
"canplayartifactlibrarytop",//artifact
"canplayinstantsorcerylibrarytop",//instant or sorcery
"showfromtoplibrary",
"showopponenttoplibrary"
};
map<string,int> Constants::MTGBasicAbilitiesMap;

View File

@@ -304,9 +304,9 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
int cardsinhand = game->players[0]->game->hand->nb_cards;
defaultPlayName = card->isLand()?"Play Land":"Cast Card Normally";
Player * player = game->currentlyActing();
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card))
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->library->hasCard(card))
return 0;
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
if ((player->game->library->hasCard(card) && !card->canPlayFromLibrary()) || (player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
return 0;
if ((game->turn < 1) && (cardsinhand != 0) && (card->basicAbilities[(int)Constants::LEYLINE])
&& game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
@@ -574,9 +574,9 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
if(OptionKicker::KICKER_ALWAYS == options[Options::KICKERPAYMENT].number)
return 0;
Player * player = game->currentlyActing();
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card))
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->library->hasCard(card))
return 0;
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
if ((player->game->library->hasCard(card) && !card->canPlayFromLibrary()) || (player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
return 0;
if(!allowedToCast(card,player))
return 0;
@@ -739,9 +739,9 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
{
alternateCost->extraCosts->costs[i]->setSource(card);
}
if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card))
if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card) && !game->currentlyActing()->game->library->hasCard(card))
return 0;
if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
if ((game->currentlyActing()->game->library->hasCard(card) && !card->canPlayFromLibrary()) || (game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
return 0;
return isReactingToClick( card, mana, alternateCost );
}
@@ -758,10 +758,12 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
alternativeName = "Pay Alternative Cost";
if(card->has(Constants::CANPLAYFROMGRAVEYARD))
if(card->has(Constants::CANPLAYFROMGRAVEYARD) && game->isInGrave(card))
alternativeName = "Alternate Cast From Graveyard";
else if(card->has(Constants::CANPLAYFROMEXILE))
else if(card->has(Constants::CANPLAYFROMEXILE) && game->isInExile(card))
alternativeName = "Alternate Cast From Exile";
else if(card->canPlayFromLibrary() && game->isInLibrary(card))
alternativeName = "Alternate Cast From Library";
else if(card->model->data->getManaCost()->getAlternative() && card->model->data->getManaCost()->getAlternative()->alternativeName.size())
alternativeName = card->model->data->getManaCost()->getAlternative()->alternativeName;
@@ -1330,9 +1332,9 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
Player * player = game->currentlyActing();
//Player * currentPlayer = game->currentPlayer;
if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
if (!player->game->library->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
return 0;
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
if ((!card->canPlayFromLibrary() && player->game->library->hasCard(card))||(!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
return 0;
if (!card->getManaCost()->getMorph())
return 0;
@@ -1468,12 +1470,12 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
if (!card->has(Constants::PAYZERO))
return 0;
Player * player = game->currentlyActing();
if (card->isLand() || (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card)))
if (card->isLand() || (!player->game->library->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card)))
{
//only allowed to pay zero for cards in library??? above is "if you dont have it in hand, grave, or exile"
return 0;
}
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card)) || (!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
if ((!card->canPlayFromLibrary() && player->game->library->hasCard(card))||(!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card)) || (!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
{
return 0;
}
@@ -1538,11 +1540,11 @@ int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
return 0;
}
Player * player = card->controller();
if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
if (!player->game->library->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
{
return 0;
}
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card)) || (!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
if ((!card->canPlayFromLibrary() && player->game->library->hasCard(card)) || (!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card)) || (!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
{
return 0;
}