zpos and zone display

added zone position (adjust dynamically), also inverts the display of
the zone so we always get the top/recent one... the library zpos is
inverted so if we choose to target the top 5 zpos like
target(*[zpos>=5|mylibrary), it will do from top to bottom... this is
only for AI so we can add alternate code for them since they cant use
reveal atm, we can make them target within allowed range...
Also this commit disabled the  new legend and planeswalker rule since it
conflicts with reveal ability, unless I/We figure it out, I recommend to
use the old one...
This commit is contained in:
Anthony Calosa
2017-02-14 22:30:50 +08:00
parent 2d383e237f
commit 01fdcfdfec
9 changed files with 104 additions and 19 deletions
+4 -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();
@@ -68,12 +70,12 @@ class CardDescriptor: public MTGCardInstance
int CDdamager; int CDdamager;
int CDgeared; int CDgeared;
int CDblocked; int CDblocked;
int CDcanProduceC; /*int CDcanProduceC;
int CDcanProduceG; int CDcanProduceG;
int CDcanProduceU; int CDcanProduceU;
int CDcanProduceR; int CDcanProduceR;
int CDcanProduceB; int CDcanProduceB;
int CDcanProduceW; int CDcanProduceW;*/
int CDnocolor; int CDnocolor;
}; };
+1
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;
+10 -4
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;
@@ -26,12 +28,12 @@ CardDescriptor::CardDescriptor()
CDdamager = 0; CDdamager = 0;
CDgeared = 0; CDgeared = 0;
CDblocked = 0; CDblocked = 0;
CDcanProduceC = 0; /*CDcanProduceC = 0;
CDcanProduceG = 0; CDcanProduceG = 0;
CDcanProduceU = 0; CDcanProduceU = 0;
CDcanProduceR = 0; CDcanProduceR = 0;
CDcanProduceB = 0; CDcanProduceB = 0;
CDcanProduceW = 0; CDcanProduceW = 0;*/
CDnocolor = 0; CDnocolor = 0;
} }
@@ -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;
@@ -256,7 +262,7 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
match = NULL; match = NULL;
} }
} }
/*
if ((CDcanProduceC == -1 && card->canproduceC == 1) || (CDcanProduceC == 1 && card->canproduceC == 0)) if ((CDcanProduceC == -1 && card->canproduceC == 1) || (CDcanProduceC == 1 && card->canproduceC == 0))
{ {
match = NULL; match = NULL;
@@ -286,7 +292,7 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
{ {
match = NULL; match = NULL;
} }
*/
if ((CDnocolor == -1 && card->getColor() == 0)) if ((CDnocolor == -1 && card->getColor() == 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);
+9 -2
View File
@@ -545,7 +545,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;
@@ -569,6 +569,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));
} }
@@ -732,7 +733,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());
} }
@@ -1509,6 +1510,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)
+10
View File
@@ -672,6 +672,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;
}
} }
+1
View File
@@ -237,6 +237,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;
+52 -3
View File
@@ -3257,14 +3257,17 @@ 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;
} }
}/*
if(destroy) if(destroy)
{ {
vector<MTGAbility*>selection; vector<MTGAbility*>selection;
@@ -3287,6 +3290,27 @@ int MTGLegendRule::added(MTGCardInstance * card)
SAFE_DELETE(LegendruleGeneric); SAFE_DELETE(LegendruleGeneric);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Legendary Rule"); MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Legendary Rule");
menuChoice->addToGame(); menuChoice->addToGame();
}*/
//reverted to old since this new code conflicts with reveal targetchooser
if(destroy)
{
vector<MTGAbility*>selection;
MultiAbility * multi = NEW MultiAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card, NULL);
for(unsigned int i = 0;i < oldCards.size();i++)
{
AAMover *a = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, oldCards[i],"ownergraveyard","Keep New");
a->oneShot = true;
multi->Add(a);
}
multi->oneShot = 1;
MTGAbility * a1 = multi;
selection.push_back(a1);
AAMover *b = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, card,"ownergraveyard","Keep Old");
b->oneShot = true;
MTGAbility * b1 = b;
selection.push_back(b1);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule");
menuChoice->addToGame();
} }
return 1; return 1;
} }
@@ -3342,8 +3366,11 @@ 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;
} }
}/*
if (destroy) if (destroy)
{ {
vector<MTGAbility*>selection; vector<MTGAbility*>selection;
@@ -3366,6 +3393,28 @@ int MTGPlaneWalkerRule::added(MTGCardInstance * card)
SAFE_DELETE(PWruleGeneric); SAFE_DELETE(PWruleGeneric);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Planeswalker Uniqueness Rule"); MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Planeswalker Uniqueness Rule");
menuChoice->addToGame(); menuChoice->addToGame();
}*/
//reverted to old since this new code conflicts with reveal targetchooser
if (destroy)
{
vector<MTGAbility*>selection;
MultiAbility * multi = NEW MultiAbility(game,game->mLayers->actionLayer()->getMaxId(), card, card, NULL);
for(unsigned int i = 0;i < oldCards.size();i++)
{
AAMover *a = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, oldCards[i],"ownergraveyard","Keep New");
a->oneShot = true;
multi->Add(a);
}
multi->oneShot = 1;
MTGAbility * a1 = multi;
selection.push_back(a1);
AAMover *b = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, card,"ownergraveyard","Keep Old");
b->oneShot = true;
MTGAbility * b1 = b;
selection.push_back(b1);
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Planeswalker Rule");
menuChoice->addToGame();
} }
return 1; return 1;
} }
+8 -2
View File
@@ -579,7 +579,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDdamager = 1; cd->CDdamager = 1;
} }
} }/*
//can produce mana //can produce mana
else if (attribute.find("cmana") != string::npos) else if (attribute.find("cmana") != string::npos)
{ {
@@ -646,7 +646,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
cd->CDcanProduceW = 1; cd->CDcanProduceW = 1;
} }
} }*/
else if (attribute.find("multicolor") != string::npos) else if (attribute.find("multicolor") != string::npos)
{ {
//card is multicolored? //card is multicolored?
@@ -674,6 +674,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)