Merge branch 'master' into cmake

This commit is contained in:
xawotihs
2015-10-25 00:22:57 +02:00
60 changed files with 1588 additions and 694 deletions
+42 -17
View File
@@ -93,9 +93,27 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string
WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
mFont->SetColor(ARGB(255,255,255,255));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT);
JRenderer * renderer = JRenderer::GetInstance();
if (!targetQuad)
{
/*if(source->controller()->isHuman() && source->controller()->opponent()->isAI() && !alt2.size() && _(action).c_str() == source->name)
mFont->DrawString("You play ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);
else if(source->controller()->isAI() && source->controller()->opponent()->isHuman() && !alt2.size() && _(action).c_str() == source->name)
mFont->DrawString("Opponent plays ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);*/
mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT);
}
else
{
renderer->FillRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(235,10,10,10));
/*if(source->controller()->isHuman() && source->controller()->opponent()->isAI())
renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,0,255,0));
else
renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,255,0,0));*/
mFont->DrawString(">", x + 32, y + GetVerticalTextOffset(), JGETEXT_LEFT);
mFont->DrawString(_(action).c_str(), x + 75, y + GetVerticalTextOffset(), JGETEXT_LEFT);
}
JQuadPtr quad = observer->getResourceManager()->RetrieveCard(source, CACHE_THUMB);
if (!quad.get())
quad = CardGui::AlternateThumbQuad(source);
@@ -123,12 +141,12 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string
targetQuad->SetColor(ARGB(255,255,255,255));
targetQuad->SetHotSpot(targetQuad->mWidth / 2, targetQuad->mHeight / 2);
float scale = mHeight / targetQuad->mHeight;
renderer->RenderQuad(targetQuad, x + 150, y + ((mHeight - targetQuad->mHeight) / 2) + targetQuad->mHotSpotY, 0, scale, scale);
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 + 120, y + GetVerticalTextOffset());
mFont->DrawString(_(alt2).c_str(), x + 35, y+15 + GetVerticalTextOffset());
}
}
@@ -1219,10 +1237,17 @@ void ActionStack::Render()
mFont->SetColor(ARGB(255,255,255,255));
JRenderer * renderer = JRenderer::GetInstance();
renderer->FillRoundRect(x0 + 16, y0 + 16, width + 2, height + 2, 10, ARGB(128,0,0,0));
renderer->FillRoundRect(x0 - 5, y0, width + 2, height + 2, 10, ARGB(200,0,0,0));
renderer->DrawRoundRect(x0 - 5, y0, width + 2, height + 2, 10, ARGB(255,255,255,255));
//stack shadow
//renderer->FillRoundRect(x0 - 7, y0+2, width + 17, height + 2, 9.0f, ARGB(128,0,0,0));
//stack fill
renderer->FillRect(x0 - 7, y0+2, width + 17, height + 14, ARGB(225,5,5,5));
//stack highlight
renderer->FillRect(x0 - 6, y0+3, width + 15, 30, ARGB(255,89,89,89));
//another border
renderer->DrawRect(x0 - 6, y0+33, width + 15, height - 18, ARGB(255,89,89,89));
//stack border
renderer->DrawRect(x0 - 7, y0+2, width + 17, height + 14, ARGB(255,240,240,240));
std::ostringstream stream;
// WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down
// seconds if the user disables auto progressing interrupts by setting the seconds
@@ -1235,11 +1260,11 @@ void ActionStack::Render()
else
stream << _(kInterruptMessageString) << " " << static_cast<int>(timer);
mFont->DrawString(stream.str(), x0 + 5, currenty);
mFont->DrawString(stream.str(), x0 + 5, currenty - 2);
// static const float kIconVerticalOffset = 24;
static const float kIconHorizontalOffset = 9;
static const float kBeforeIconSpace = 10;
static const float kIconHorizontalOffset = 10;
static const float kBeforeIconSpace = 12;
//Render "interrupt?" text + possible actions
{
@@ -1248,25 +1273,25 @@ void ActionStack::Render()
if (gModRules.game.canInterrupt())
{
renderer->RenderQuad(pspIcons[7].get(), currentx, kIconVerticalOffset, 0, kGamepadIconSize, kGamepadIconSize);
renderer->RenderQuad(pspIcons[7].get(), currentx, kIconVerticalOffset - 2, 0, kGamepadIconSize, kGamepadIconSize);
currentx+= kIconHorizontalOffset;
mFont->DrawString(_(kInterruptString), currentx, kIconVerticalOffset - 6);
mFont->DrawString(_(kInterruptString), currentx, kIconVerticalOffset - 8);
currentx+= mFont->GetStringWidth(_(kInterruptString).c_str()) + kBeforeIconSpace;
}
noBtnXOffset = static_cast<int>(currentx);
renderer->RenderQuad(pspIcons[4].get(), currentx, kIconVerticalOffset, 0, kGamepadIconSize, kGamepadIconSize);
renderer->RenderQuad(pspIcons[4].get(), currentx, kIconVerticalOffset - 2, 0, kGamepadIconSize, kGamepadIconSize);
currentx+= kIconHorizontalOffset;
mFont->DrawString(_(kNoString), currentx, kIconVerticalOffset - 6);
mFont->DrawString(_(kNoString), currentx, kIconVerticalOffset - 8);
currentx+= mFont->GetStringWidth(_(kNoString).c_str()) + kBeforeIconSpace;
noToAllBtnXOffset = static_cast<int>(currentx);
if (mObjects.size() > 1)
{
renderer->RenderQuad(pspIcons[6].get(), currentx, kIconVerticalOffset, 0, kGamepadIconSize, kGamepadIconSize);
renderer->RenderQuad(pspIcons[6].get(), currentx, kIconVerticalOffset - 2, 0, kGamepadIconSize, kGamepadIconSize);
currentx+= kIconHorizontalOffset;
mFont->DrawString(_(kNoToAllString), currentx, kIconVerticalOffset - 6);
mFont->DrawString(_(kNoToAllString), currentx, kIconVerticalOffset - 8);
currentx+= mFont->GetStringWidth(_(kNoToAllString).c_str()) + kBeforeIconSpace;
}
+163 -21
View File
@@ -390,8 +390,26 @@ int AACopier::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
source->copy(_target);
MTGCard* clone = MTGCollection()->getCardById(_target->copiedID);
MTGCardInstance * myClone = NEW MTGCardInstance(clone, source->controller()->game);
source->copy(myClone);
source->isACopier = true;
source->copiedID = _target->copiedID;
source->modifiedbAbi = _target->modifiedbAbi;
source->origbasicAbilities = _target->origbasicAbilities;
if(_target->isMorphed)
{
source->power = 2;
source->life = 2;
source->toughness = 2;
source->setColor(0,1);
source->name = "Morph";
source->types.clear();
string cre = "Creature";
source->setType(cre.c_str());
source->basicAbilities.reset();
source->getManaCost()->resetCosts();
}
return 1;
}
return 0;
@@ -1160,14 +1178,14 @@ int GenericPaidAbility::resolve()
baseAbility->target = target;
optionalCost = ManaCost::parseManaCost(baseCost, NULL, source);
// hacky way to produce better MenuText
/*// hacky way to produce better MenuText
AAFakeAbility* isFake = dynamic_cast< AAFakeAbility* >( baseAbility );
size_t findPayN = isFake->named.find(" {value} mana");
if (isFake && findPayN != string::npos) {
stringstream parseN;
parseN << optionalCost->getCost(Constants::MTG_COLOR_ARTIFACT);
isFake->named.replace(findPayN + 1, 7, parseN.str());
}
}//commented out, it crashes cards with recover ability*/
MTGAbility * set = baseAbility->clone();
set->oneShot = true;
@@ -1721,8 +1739,8 @@ AAFrozen * AAFrozen::clone() const
}
// chose a new target for an aura or enchantment and equip it note: VERY basic right now.
AANewTarget::AANewTarget(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,bool retarget, ManaCost * _cost) :
ActivatedAbility(observer, id, card, _cost, 0),retarget(retarget)
AANewTarget::AANewTarget(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,bool retarget, ManaCost * _cost, bool reequip, bool newhook) :
ActivatedAbility(observer, id, card, _cost, 0),retarget(retarget),reequip(reequip),newhook(newhook)
{
target = _target;
}
@@ -1735,7 +1753,7 @@ int AANewTarget::resolve()
_target = source;
source = (MTGCardInstance *) target;
}
if (_target)
if (_target && !reequip)
{
while (_target->next)
_target = _target->next;
@@ -1772,6 +1790,37 @@ int AANewTarget::resolve()
}
}
if (_target && _target->currentZone == _target->controller()->game->battlefield && reequip)
{
if(!newhook)
{
_target = source;
source = (MTGCardInstance *) target;
}
else
{
while (_target->next)
_target = _target->next;
}
if(_target->hasSubtype(Subtypes::TYPE_EQUIPMENT))
{
for (size_t i = 1; i < game->mLayers->actionLayer()->mObjects.size(); i++)
{
MTGAbility * a = ((MTGAbility *) game->mLayers->actionLayer()->mObjects[i]);
AEquip * eq = dynamic_cast<AEquip*> (a);
if (eq && eq->source == _target)
{
((AEquip*)a)->unequip();
((AEquip*)a)->equip(source);
}
}
}
if(!newhook)
{
target = source;
source = _target;
}
}
return 1;
}
@@ -2069,16 +2118,16 @@ int AADynamic::resolve()
switch(type)
{
case DYNAMIC_ABILITY_TYPE_POWER:
sourceamount = ((MTGCardInstance *) source)->power;
targetamount = ((MTGCardInstance *) _target)->power;
sourceamount = ((MTGCardInstance *) source)->getCurrentPower();
targetamount = ((MTGCardInstance *) _target)->getCurrentPower();
if(eachother )
sourceamount = ((MTGCardInstance *) source)->power;
sourceamount = ((MTGCardInstance *) source)->getCurrentPower();
break;
case DYNAMIC_ABILITY_TYPE_TOUGHNESS:
sourceamount = ((MTGCardInstance *) source)->toughness;
targetamount = ((MTGCardInstance *) _target)->toughness;
sourceamount = ((MTGCardInstance *) source)->getCurrentToughness();
targetamount = ((MTGCardInstance *) _target)->getCurrentToughness();
if(eachother )
sourceamount = ((MTGCardInstance *) source)->toughness;
sourceamount = ((MTGCardInstance *) source)->getCurrentToughness();
break;
case DYNAMIC_ABILITY_TYPE_MANACOST:
if(amountsource == 1)
@@ -2520,6 +2569,10 @@ int AACloner::resolve()
// Use id of the card to have the same image as the original
MTGCard* clone = (_target->isToken ? _target: MTGCollection()->getCardById(_target->getId()));
// If its a copier then copy what it is
if(_target->isACopier)
clone = _target;
Player * targetPlayer = who == 1 ? source->controller()->opponent() : source->controller();
int tokenize = 1;//tokenizer support for cloning
@@ -2550,7 +2603,7 @@ int AACloner::resolve()
if(_target->pbonus > 0)
spell->source->power = _target->power - _target->pbonus;
else
spell->source->power = _target->power + _target->pbonus;
spell->source->power = _target->power + abs(_target->pbonus);
if(_target->tbonus > 0)
{
spell->source->toughness = _target->toughness - _target->tbonus;
@@ -2558,8 +2611,8 @@ int AACloner::resolve()
}
else
{
spell->source->toughness = _target->toughness + _target->tbonus;
spell->source->life = _target->toughness + _target->tbonus;
spell->source->toughness = _target->toughness + abs(_target->tbonus);
spell->source->life = _target->toughness + abs(_target->tbonus);
}
}
list<int>::iterator it;
@@ -2575,6 +2628,8 @@ int AACloner::resolve()
{
spell->source->addType(*it);
}
spell->source->modifiedbAbi = _target->modifiedbAbi;
spell->source->origbasicAbilities = _target->origbasicAbilities;
delete spell;
}
return 1;
@@ -2710,8 +2765,8 @@ AInstantCastRestrictionUEOT::~AInstantCastRestrictionUEOT()
//AAMover
AAMover::AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string newName, ManaCost * _cost) :
ActivatedAbility(observer, _id, _source, _cost, 0), destination(dest),named(newName)
AAMover::AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string newName, ManaCost * _cost, bool undying, bool persist) :
ActivatedAbility(observer, _id, _source, _cost, 0), destination(dest),named(newName),undying(undying),persist(persist)
{
if (_target)
target = _target;
@@ -2758,6 +2813,10 @@ int AAMover::resolve()
andAbilityClone->addToGame();
}
}
if(persist)
spell->source->counters->addCounter(-1,-1);
if(undying)
spell->source->counters->addCounter(1,1);
delete spell;
return 1;
}
@@ -4157,6 +4216,7 @@ for (it = types.begin(); it != types.end(); it++)
for (it = abilities.begin(); it != abilities.end(); it++)
{
_target->basicAbilities.set(*it);
_target->modifiedbAbi += 1;
}
if(newAbilityFound)
@@ -4305,6 +4365,7 @@ int ATransformer::destroy()
for (it = abilities.begin(); it != abilities.end(); it++)
{
_target->basicAbilities.reset(*it);
_target->modifiedbAbi -= 1;
}
for (it = oldcolors.begin(); it != oldcolors.end(); it++)
@@ -4851,6 +4912,78 @@ AVanishing::~AVanishing()
{
}
//Produce Mana
AProduceMana::AProduceMana(GameObserver* observer, int _id, MTGCardInstance * _source, string ManaDescription) :
MTGAbility(observer, _id, source),ManaDescription(ManaDescription)
{
source = _source;
mana[0] = "{g}"; mana[1] = "{u}"; mana[2] = "{r}"; mana[3] = "{b}"; mana[4] = "{w}";
}
int AProduceMana::receiveEvent(WEvent * event)
{
if(WEventCardTappedForMana * isTappedForMana = dynamic_cast<WEventCardTappedForMana *> (event))
{
if ((isTappedForMana->card == source)||(isTappedForMana->card == source->target && ManaDescription == "selectmana"))
produce();
}
return 1;
}
int AProduceMana::produce()
{
if(ManaDescription == "selectmana")
{//I tried menu ability and vector<MTGAbility*abi> to have a shorter code but it crashes wagic at end of turn...
//The may ability on otherhand works but the ability is cumulative...
//This must be wrapped on menuability so we can use it on successions...
AManaProducer *ap0 = NEW AManaProducer(game, game->mLayers->actionLayer()->getMaxId(), source, source->controller(), ManaCost::parseManaCost(mana[0],NULL,source), NULL, 0,"",false);
MayAbility *mw0 = NEW MayAbility(game, game->mLayers->actionLayer()->getMaxId(), ap0, source,true);
MTGAbility *ga0 = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), source,NULL,mw0);
AManaProducer *ap1 = NEW AManaProducer(game, game->mLayers->actionLayer()->getMaxId(), source, source->controller(), ManaCost::parseManaCost(mana[1],NULL,source), NULL, 0,"",false);
MayAbility *mw1 = NEW MayAbility(game, game->mLayers->actionLayer()->getMaxId(), ap1, source,true);
MTGAbility *ga1 = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), source,NULL,mw1);
AManaProducer *ap2 = NEW AManaProducer(game, game->mLayers->actionLayer()->getMaxId(), source, source->controller(), ManaCost::parseManaCost(mana[2],NULL,source), NULL, 0,"",false);
MayAbility *mw2 = NEW MayAbility(game, game->mLayers->actionLayer()->getMaxId(), ap2, source,true);
MTGAbility *ga2 = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), source,NULL,mw2);
AManaProducer *ap3 = NEW AManaProducer(game, game->mLayers->actionLayer()->getMaxId(), source, source->controller(), ManaCost::parseManaCost(mana[3],NULL,source), NULL, 0,"",false);
MayAbility *mw3 = NEW MayAbility(game, game->mLayers->actionLayer()->getMaxId(), ap3, source,true);
MTGAbility *ga3 = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), source,NULL,mw3);
AManaProducer *ap4 = NEW AManaProducer(game, game->mLayers->actionLayer()->getMaxId(), source, source->controller(), ManaCost::parseManaCost(mana[4],NULL,source), NULL, 0,"",false);
MayAbility *mw4 = NEW MayAbility(game, game->mLayers->actionLayer()->getMaxId(), ap4, source,true);
MTGAbility *ga4 = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), source,NULL,mw4);
ga0->resolve();
ga1->resolve();
ga2->resolve();
ga3->resolve();
ga4->resolve();
}
else
{
AManaProducer *amp = NEW AManaProducer(game, game->mLayers->actionLayer()->getMaxId(), source, source->controller(), ManaCost::parseManaCost(ManaDescription,NULL,source), NULL, 0,"",false);
amp->resolve();
}
return 1;
}
const string AProduceMana::getMenuText()
{
return "Produce Mana";
}
AProduceMana * AProduceMana::clone() const
{
return NEW AProduceMana(*this);
}
AProduceMana::~AProduceMana()
{
}
//AUpkeep
AUpkeep::AUpkeep(GameObserver* observer, int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, int restrictions, int _phase,
int _once,bool Cumulative) :
@@ -5179,7 +5312,7 @@ void ABlink::returnCardIntoPlay(MTGCardInstance* _target) {
return;
}
MTGGameZone * inplay = spell->source->owner->game->inPlay;
/*MTGGameZone * inplay = spell->source->owner->game->inPlay;
spell->source->target = NULL;
for (int i = game->getRandomGenerator()->random()%inplay->nb_cards;;i = game->getRandomGenerator()->random()%inplay->nb_cards)
{
@@ -5193,7 +5326,16 @@ void ABlink::returnCardIntoPlay(MTGCardInstance* _target) {
this->forceDestroy = 1;
return;
}
}
}*/
//replaced with castcard(putinplay)
MTGAbility *a = NEW AACastCard(game, game->mLayers->actionLayer()->getMaxId(), Blinker, Blinker,false,false,false,"","Return to Play",false,true);
a->oneShot = false;
a->canBeInterrupted = false;
a->addToGame();
SAFE_DELETE(spell);
SAFE_DELETE(tc);
this->forceDestroy = 1;
return;
}
spell->source->power = spell->source->origpower;
spell->source->toughness = spell->source->origtoughness;
@@ -5541,7 +5683,7 @@ void AACastCard::Update(float dt)
toCheck->bypassTC = true;
TargetChooserFactory tcf(game);
TargetChooser * atc = tcf.createTargetChooser(toCheck->spellTargetType,toCheck);
if (toCheck->hasType(Subtypes::TYPE_AURA) && !atc->validTargetsExist())
if ((toCheck->hasType(Subtypes::TYPE_AURA) && !atc->validTargetsExist())||toCheck->isToken)
{
processed = true;
this->forceDestroy = 1;
@@ -5724,7 +5866,7 @@ const string AACastCard::getMenuText()
return nameThis.c_str();
if(putinplay)
return "Put Into Play";
return "Cast For Free";
return "Cast Card";
}
AACastCard * AACastCard::clone() const
+1 -1
View File
@@ -267,7 +267,7 @@ void CardDisplay::Render()
int drawMode = DrawMode::kNormal;
if (observer)
{
pos.actY = 150;
pos.actY = 145;
if (x < (CardGui::BigWidth / 2)) pos.actX = SCREEN_WIDTH - 10 - CardGui::BigWidth / 2;
drawMode = observer->getCardSelector()->GetDrawMode();
}
+88 -9
View File
@@ -111,17 +111,17 @@ void CardGui::Update(float dt)
PlayGuiObject::Update(dt);
}
void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb)
void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb, bool noborder)
{
DrawCard(card, inPosition, inMode, thumb);
DrawCard(card, inPosition, inMode, thumb, noborder);
}
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb)
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb, bool noborder)
{
switch (inMode)
{
case DrawMode::kNormal:
RenderBig(inCard, inPosition, thumb);
RenderBig(inCard, inPosition, thumb, noborder);
break;
case DrawMode::kText:
AlternateRender(inCard, inPosition);
@@ -237,6 +237,31 @@ void CardGui::Render()
if (quad)
{
quad->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
//fake border...
JQuadPtr fakeborder;
JQuadPtr highlightborder;
fakeborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
if(fakeborder)
{
fakeborder->SetColor(ARGB((int)(actA),15,15,15));
renderer->RenderQuad(fakeborder.get(), actX, actY, actT, (29 * actZ + 1) / 16, 42 * actZ / 16);
}
//draw border for highlighting
if (game)
{
if (card && card->isTargetted() && highlightborder)
{
highlightborder->SetColor(ARGB(95,255,0,0));
renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16);
}
if (card && card->isTargetter() && highlightborder)
{
highlightborder->SetColor(ARGB(95,0,245,0));
renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16);
}
}
//draw the card image
renderer->RenderQuad(quad.get(), actX, actY, actT, scale, scale);
}
@@ -267,7 +292,7 @@ void CardGui::Render()
}
JQuadPtr mor;
if(card->isMorphed && !alternate)
if((card->isMorphed||(card->name == "Morph" && card->isACopier)) && !alternate)
{
mor = card->getObserver()->getResourceManager()->RetrieveTempQuad("morph.jpg");
if (mor && mor->mTex) {
@@ -277,14 +302,45 @@ void CardGui::Render()
}
}
//draw line
if (game)
{
if (card && card->isTargetted())
{
if(card->isTapped())
{
if(mHasFocus)
renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-10,actY - (scale * quad->mHeight / 2)+6.5f, (scale * quad->mHeight)-0.02f, (scale * quad->mWidth)-0.02f, 1.8f,ARGB(250,255,0,0));
else
renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-8,actY - (scale * quad->mHeight / 2)+4, (scale * quad->mHeight)-0.02f, (scale * quad->mWidth)-0.02f, 1.8f,ARGB(250,255,0,0));
}
else
renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-2,actY - (scale * quad->mHeight / 2)-2, (scale * quad->mWidth)-0.02f, (scale * quad->mHeight)-0.02f, 1.8f,ARGB(250,255,0,0));
}
if (card && card->isTargetter())
{
if(card->isTapped())
{
if(mHasFocus)
renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-10,actY - (scale * quad->mHeight / 2)+6.5f, (scale * quad->mHeight)-0.02f, (scale * quad->mWidth)-0.02f, 1.8f,ARGB(250,0,255,0));
else
renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-8,actY - (scale * quad->mHeight / 2)+4, (scale * quad->mHeight)-0.02f, (scale * quad->mWidth)-0.02f, 1.8f,ARGB(250,0,255,0));
}
else
renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-2,actY - (scale * quad->mHeight / 2)-2, (scale * quad->mWidth)-0.02f, (scale * quad->mHeight)-0.02f, 1.8f,ARGB(250,0,255,0));
}
}
//draws the numbers power/toughness
if (card->isCreature())
{
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200];
sprintf(buffer, "%i/%i", card->power, card->life);
renderer->FillRect(actX - (12 * actZ), actY + 6 * actZ, 25 * actZ, 12 * actZ,
renderer->FillRect(actX - (13 * actZ), actY + 4 * actZ, 25.5f * actZ, 14 * actZ,
ARGB(((static_cast<unsigned char>(actA))/2),0,0,0));
renderer->DrawRect(actX - (13 * actZ), actY + 4 * actZ, 25.5f * actZ, 14 * actZ,
ARGB(((static_cast<unsigned char>(actA))),20,20,20));
//damaged or buffed or powered down
if(card->wasDealtDamage && card->life <= 2)
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,0,0));//red critical and damaged
@@ -298,7 +354,7 @@ void CardGui::Render()
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));//white default
mFont->SetScale(actZ);
mFont->SetScale(actZ);
mFont->DrawString(buffer, actX - 10 * actZ, actY + 8 * actZ);
mFont->DrawString(buffer, actX - 10 * actZ, actY + 7 * actZ);
mFont->SetScale(1);
}
@@ -988,7 +1044,7 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad)
}
//Renders a big card on screen. Defaults to the "alternate" rendering if no image is found
void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb)
void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder)
{
JRenderer * renderer = JRenderer::GetInstance();
//GameObserver * game = GameObserver::GetInstance();
@@ -1013,7 +1069,30 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb)
}
quad->SetColor(ARGB(255,255,255,255));
float scale = pos.actZ * 250.f / quad->mHeight;
renderer->RenderQuad(quad.get(), x, pos.actY, pos.actT, scale, scale);
//init setname
string cardsetname = setlist[card->setId].c_str();
if(!noborder)
{
if(cardsetname == "2ED"||cardsetname == "RV"||cardsetname == "4ED"||cardsetname == "5ED"||cardsetname == "6ED"||cardsetname == "7ED"||cardsetname == "8ED"||cardsetname == "9ED"||cardsetname == "CHR")
{
//like white border
renderer->FillRoundRect(x-92,pos.actY-130, (scale * quad->mWidth)-10, (scale * quad->mHeight)-11, 9.0f,ARGB(255,248,248,255));
//black thin line to simulate card edge
renderer->DrawRoundRect(x-92,pos.actY-130, (scale * quad->mWidth)-10, (scale * quad->mHeight)-11, 9.0f,ARGB(150,20,20,20));
}
else
{
//like black border
renderer->FillRoundRect(x-92,pos.actY-130, (scale * quad->mWidth)-10, (scale * quad->mHeight)-11, 9.0f,ARGB(255,10,10,10));
//white thin line to simulate card edge
renderer->DrawRoundRect(x-92,pos.actY-130, (scale * quad->mWidth)-10, (scale * quad->mHeight)-11, 9.0f,ARGB(50,240,240,240));
}
//render card image
renderer->RenderQuad(quad.get(), x, pos.actY-2, pos.actT, scale-0.02f, scale-0.02f);
}
else
renderer->RenderQuad(quad.get(), x, pos.actY, pos.actT, scale, scale);
RenderCountersBig(card, pos);
return;
}
+3
View File
@@ -41,6 +41,8 @@ CardPrimitive::CardPrimitive(CardPrimitive * source)
if(!source)
return;
basicAbilities = source->basicAbilities;
origbasicAbilities = source->basicAbilities;
LKIbasicAbilities = source->basicAbilities;
for (size_t i = 0; i < source->types.size(); ++i)
types.push_back(source->types[i]);
@@ -76,6 +78,7 @@ CardPrimitive::~CardPrimitive()
int CardPrimitive::init()
{
basicAbilities.reset();
origbasicAbilities.reset();
types.clear();
+2 -2
View File
@@ -176,7 +176,7 @@ bool CardSelector::CheckUserInput(JButton key)
return true;
}
Target* oldactive = active;
timer = 250;
timer = 800;
int x,y;
JGE* jge = observer->getInput();
if(!jge) return false;
@@ -306,7 +306,7 @@ switch_active:
}
else
{
timer = 250;
timer = 800;
}
return true;
}
+5
View File
@@ -78,6 +78,11 @@ int Damage::resolve()
damage = 0;
//rulings = 10/4/2004 The damage prevention ability works even if it has no counters, as long as some effect keeps its toughness above zero.
//these creature are essentially immune to damage. however 0/-1 effects applied through lords or counters can kill them.
if ((_target)->has(Constants::PROTECTIONFROMCOLOREDSPELLS))
{//damage is prevented as long as the damage source is a spell on the stack...
if((source->currentZone == source->controller()->opponent()->game->stack||source->currentZone == source->controller()->game->stack) && (source->hasColor(1)||source->hasColor(2)||source->hasColor(3)||source->hasColor(4)||source->hasColor(5)))
damage = 0;
}
if ((_target)->has(Constants::PHANTOM))
{
damage = 0;
+2
View File
@@ -276,6 +276,8 @@ void DeckMenu::Render()
JQuadPtr quad = WResourceManager::Instance()->RetrieveTempQuad(currentAvatarImageName, TEXTURE_SUB_AVATAR);
if(quad.get())
{
quad->mWidth = 35.f;
quad->mHeight = 50.f;
if (currentMenuItem->getText() == "Evil Twin")
{
JQuad * evil = quad.get();
+5 -4
View File
@@ -133,13 +133,13 @@ void DeckView::renderCard(int index, int alpha, bool asThumbnail)
else
{
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
CardGui::DrawCard(cardPosition.card, pos, asThumbnail);
CardGui::DrawCard(cardPosition.card, pos, asThumbnail, true);
}
}
else
{
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
CardGui::DrawCard(cardPosition.card, pos, DrawMode::kText, asThumbnail);
CardGui::DrawCard(cardPosition.card, pos, DrawMode::kText, asThumbnail, true);
}
}
else
@@ -147,9 +147,10 @@ void DeckView::renderCard(int index, int alpha, bool asThumbnail)
int mode = !options[Options::DISABLECARDS].number ? DrawMode::kNormal : DrawMode::kText;
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
CardGui::DrawCard(cardPosition.card, pos, mode, asThumbnail);
CardGui::DrawCard(cardPosition.card, pos, mode, asThumbnail, true);
}
//the three DrawCard function above, I intentionally disabled the rendered border when in Deck Editor since the border must be dynamically resized
//we can pass variables so the DrawCard method knows what to do to the border but... there must be a better way to do it...
int quadAlpha = alpha;
if (!deck()->count(cardPosition.card)) quadAlpha /= 2;
quadAlpha = 255 - quadAlpha;
+4
View File
@@ -39,6 +39,7 @@ bool GameApp::HasMusic = true;
JMusic * GameApp::music = NULL;
string GameApp::currentMusicFile = "";
string GameApp::systemError = "";
char GameApp::mynbcardsStr[512] = {0};
vector<JQuadPtr > manaIcons;
@@ -173,6 +174,9 @@ void GameApp::Create()
LOG("Loading Textures");
LOG("--Loading menuicons.png");
WResourceManager::Instance()->RetrieveTexture("menuicons.png", RETRIEVE_MANAGE);
#if !defined (PSP)
WResourceManager::Instance()->RetrieveTexture("miconslarge.png", RETRIEVE_MANAGE);
#endif
LOG("---Gettings menuicons.png quads");
//Load all icons from gModRules and save in manaIcons -> todo. Change the icons positions on menuicons.png to avoid use item->mColorId
+30 -1
View File
@@ -204,6 +204,8 @@ void GameObserver::nextGamePhase()
cleanupPhase();
currentPlayer->damageCount = 0;
currentPlayer->drawCounter = 0;
currentPlayer->raidcount = 0;
currentPlayer->opponent()->raidcount = 0;
currentPlayer->prowledTypes.clear();
currentPlayer->opponent()->damageCount = 0; //added to clear odcount
currentPlayer->preventable = 0;
@@ -590,6 +592,25 @@ void GameObserver::gameStateBasedEffects()
{
if(getCurrentTargetChooser() && int(getCurrentTargetChooser()->getNbTargets()) == getCurrentTargetChooser()->maxtargets)
getCurrentTargetChooser()->done = true;
/////////////////////////////////////
for (int d = 0; d < 2; d++)
{
MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library };
for (int k = 0; k < 4; k++)
{
MTGGameZone * zone = dzones[k];
if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
{
for (int c = zone->nb_cards - 1; c >= 0; c--)
{
zone->cards[c]->cardistargetted = 0;
zone->cards[c]->cardistargetter = 0;
}
}
}//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue
players[d]->DeadLifeState();
}
////////////////////////////////////
if (mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0)
return;
@@ -608,6 +629,9 @@ void GameObserver::gameStateBasedEffects()
for (int j = zone->nb_cards - 1; j >= 0; j--)
{
MTGCardInstance * card = zone->cards[j];
card->LKIpower = card->power;
card->LKItoughness = card->toughness;
card->LKIbasicAbilities = card->basicAbilities;
card->afterDamage();
card->mPropertiesChangedSinceLastUpdate = false;
if(card->hasType(Subtypes::TYPE_PLANESWALKER) && (!card->counters||!card->counters->hasCounter("loyalty",0,0)))
@@ -761,7 +785,7 @@ void GameObserver::gameStateBasedEffects()
///////////////////////////////////////////////////////////
//life checks/poison checks also checks cant win or lose.//
///////////////////////////////////////////////////////////
players[i]->DeadLifeState();//refactored
players[i]->DeadLifeState(true);//refactored
}
//////////////////////////////////////////////////////
//-------------card based states effects------------//
@@ -824,6 +848,11 @@ void GameObserver::gameStateBasedEffects()
}
}
if(c->modifiedbAbi > 0)
{
c->modifiedbAbi = 0;
c->basicAbilities = c->origbasicAbilities;
}
if(nbcards > z->nb_cards)
{
t = 0;
+18 -10
View File
@@ -85,10 +85,19 @@ void GameStateMenu::Create()
{
for (int j = 0; j < 2; j++)
{
#if defined (PSP)
sprintf(buf, "menuicons%d%d", i, j);
mIcons[n] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + i * 36.0f, 2.0f + j * 36.0f, 32.0f, 32.0f, buf);
#else
sprintf(buf, "miconslarge%d%d", i, j);
mIcons[n] = WResourceManager::Instance()->RetrieveQuad("miconslarge.png", 4 + i * 72.0f, 4.0f + j * 72.0f, 72.0f, 72.0f, buf);
#endif
if (mIcons[n])
{
mIcons[n]->mHeight = 36.f;
mIcons[n]->mWidth = 36.f;
mIcons[n]->SetHotSpot(16, 16);
}
n++;
}
}
@@ -141,10 +150,10 @@ void GameStateMenu::Start()
WResourceManager::Instance()->ClearUnlocked();
bgTexture = WResourceManager::Instance()->RetrieveTexture("menutitle.png", RETRIEVE_LOCK);
mBg = WResourceManager::Instance()->RetrieveQuad("menutitle.png", 0, 0, 256, 166); // Create background quad for rendering.
mBg = WResourceManager::Instance()->RetrieveQuad("menutitle.png", 0, 0, 0, 0); // Create background quad for rendering.
if (mBg)
mBg->SetHotSpot(128, 50);
mBg->SetHotSpot(0, 0);
if (MENU_STATE_MAJOR_MAINMENU == currentState)
currentState = currentState | MENU_STATE_MINOR_FADEIN;
@@ -160,22 +169,22 @@ void GameStateMenu::genNbCardsStr()
PlayerData * playerdata = NEW PlayerData(MTGCollection());
size_t totalUnique = MTGCollection()->primitives.size();
size_t totalPrints = MTGCollection()->totalCards();
if (totalUnique != totalPrints)
{
if (playerdata && !options[Options::ACTIVE_PROFILE].isDefault())
sprintf(nbcardsStr, _("%s: %i cards (%i) (%i unique)").c_str(), options[Options::ACTIVE_PROFILE].str.c_str(),
sprintf(GameApp::mynbcardsStr, _("%s: %i cards (%i) (%i unique)").c_str(), options[Options::ACTIVE_PROFILE].str.c_str(),
playerdata->collection->totalCards(), totalPrints,totalUnique);
else
sprintf(nbcardsStr, _("%i cards (%i unique)").c_str(),totalPrints,totalUnique);
sprintf(GameApp::mynbcardsStr, _("%i cards (%i unique)").c_str(),totalPrints,totalUnique);
}
else
{
if (playerdata && !options[Options::ACTIVE_PROFILE].isDefault())
sprintf(nbcardsStr, _("%s: %i cards (%i)").c_str(), options[Options::ACTIVE_PROFILE].str.c_str(),
sprintf(GameApp::mynbcardsStr, _("%s: %i cards (%i)").c_str(), options[Options::ACTIVE_PROFILE].str.c_str(),
playerdata->collection->totalCards(), totalPrints);
else
sprintf(nbcardsStr, _("%i cards").c_str(),totalPrints);
sprintf(GameApp::mynbcardsStr, _("%i cards").c_str(),totalPrints);
}
SAFE_DELETE(playerdata);
@@ -726,7 +735,7 @@ void GameStateMenu::RenderTopMenu()
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(128,255,255,255));
mFont->DrawString(GAME_VERSION, rightTextPos, 5, JGETEXT_RIGHT);
mFont->DrawString(nbcardsStr, leftTextPos, 5);
mFont->DrawString(GameApp::mynbcardsStr, leftTextPos, 5);
renderer->FillRect(leftTextPos, 26, 104, 8, ARGB(255, 100, 90, 60));
renderer->FillRect(leftTextPos + 2, 28, (float)(gamePercentComplete()), 4, ARGB(255,220,200, 125));
char buf[512];
@@ -790,7 +799,7 @@ void GameStateMenu::Render()
scroller->Render();
if (mBg.get())
renderer->RenderQuad(mBg.get(), SCREEN_WIDTH / 2, 50);
renderer->RenderQuad(mBg.get(), (SCREEN_WIDTH/4)-6, 2, 0, 256 / mBg->mWidth, 166 / mBg->mHeight);
RenderTopMenu();
@@ -960,7 +969,6 @@ ostream& GameStateMenu::toString(ostream& out) const
<< " ; mCreditsYPos : " << mCreditsYPos
<< " ; currentState : " << currentState
<< " ; mVolume : " << mVolume
<< " ; nbcardsStr : " << nbcardsStr
<< " ; mCurrentSetName : " << mCurrentSetName
<< " ; mCurrentSetFileName : " << mCurrentSetFileName
<< " ; mReadConf : " << mReadConf
+2
View File
@@ -1,6 +1,7 @@
#include "PrecompiledHeader.h"
#include "GameStateOptions.h"
#include "GameStateMenu.h"
#include "GameApp.h"
#include "OptionItem.h"
#include "SimpleMenu.h"
@@ -167,6 +168,7 @@ void GameStateOptions::Update(float dt)
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
mState = SHOW_OPTIONS;
GameStateMenu::genNbCardsStr();
break;
case WGuiBase::CONFIRM_NEED:
optionsTabs->yieldFocus();
+2
View File
@@ -5,6 +5,7 @@
#include <JRenderer.h>
#include "GameStateShop.h"
#include "GameStateMenu.h"
#include "GameApp.h"
#include "MTGDeck.h"
#include "MTGPack.h"
@@ -840,6 +841,7 @@ void GameStateShop::ButtonPressed(int controllerId, int controlId)
mStage = STAGE_SHOP_SHOP;
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
save();
GameStateMenu::genNbCardsStr();
break;
case 14:
mStage = STAGE_SHOP_TASKS;
+3 -1
View File
@@ -30,6 +30,8 @@ void GuiBackground::Render()
}
if (quad.get())
{
renderer->RenderQuad(quad.get(), 0, 18);
quad->mWidth = 480.f;
quad->mHeight = 272.f;
renderer->RenderQuad(quad.get(), 0, 0);
}
}
+3 -1
View File
@@ -483,6 +483,8 @@ void GuiCombat::Render()
}
else
{
observer->opponent()->getIcon()->mHeight = 50.f;
observer->opponent()->getIcon()->mWidth = 35.f;
observer->opponent()->getIcon()->SetHotSpot(18, 25);
enemy_avatar.Render(observer->opponent()->getIcon().get());
}
@@ -502,7 +504,7 @@ void GuiCombat::Render()
ok_quad->SetHotSpot(28, 22);
ok.Render(ok_quad.get());
}
renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0));
renderer->DrawLine(0, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT / 2, ARGB(255, 255, 64, 0));
if (FIRST_STRIKE == step)
{
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
+19 -15
View File
@@ -6,16 +6,20 @@
GuiFrame::GuiFrame(GameObserver* observer)
: GuiLayer(observer)
{
if (observer->getResourceManager())
{
if (observer->getResourceManager()->GetTexture("wood.png"))
wood = observer->getResourceManager()->RetrieveQuad("wood.png", 0, 0, SCREEN_WIDTH, 28);
//if (observer->getResourceManager())
//{
/*if (observer->getResourceManager()->GetTexture("wood.png"))
{
wood = observer->getResourceManager()->RetrieveQuad("wood.png", 0, 0, 0, 0);
wood->mHeight = 32.f;
wood->mWidth = 480.f;
}
else
{
GameApp::systemError += "Can't load wood texture : " __FILE__ "\n";
}
}*/
if (observer->getResourceManager()->GetTexture("gold.png"))
/*if (observer->getResourceManager()->GetTexture("gold.png"))
{
gold1 = observer->getResourceManager()->RetrieveQuad("gold.png", 0, 0, SCREEN_WIDTH, 6, "gold1");
gold2 = observer->getResourceManager()->RetrieveQuad("gold.png", 0, 6, SCREEN_WIDTH, 6, "gold2");
@@ -26,9 +30,9 @@ GuiFrame::GuiFrame(GameObserver* observer)
gold2->SetColor(ARGB(127, 255, 255, 255));
gold2->SetHFlip(true);
}
}
}
step = 0.0;
}*/
//}
//step = 0.0;
}
@@ -38,12 +42,12 @@ GuiFrame::~GuiFrame()
void GuiFrame::Render()
{
JRenderer* renderer = JRenderer::GetInstance();
/*JRenderer* renderer = JRenderer::GetInstance();
float sized = step / 4;
if (sized > SCREEN_WIDTH)
sized -= SCREEN_WIDTH;
renderer->RenderQuad(wood.get(), 0, 0);
if (gold1.get())
renderer->RenderQuad(wood.get(), 0, 0);*/
/*if (gold1.get())
{
renderer->RenderQuad(gold1.get(), -sized, 16);
renderer->RenderQuad(gold1.get(), -sized + 479, 16);
@@ -60,12 +64,12 @@ void GuiFrame::Render()
renderer->RenderQuad(gold2.get(), step / 2, 16);
renderer->RenderQuad(gold2.get(), step / 2 - 479, 16);
}
}
}*/
}
void GuiFrame::Update(float dt)
{
step += dt * 5;
/*step += dt * 5;
if (step > 2 * SCREEN_WIDTH)
step -= 2 * SCREEN_WIDTH;
step -= 2 * SCREEN_WIDTH;*/
}
+4 -4
View File
@@ -262,7 +262,7 @@ void GuiMana::RenderStatic()
float x0 = x - 20 * totalColors;
x0 = max(40.f, x0);
float xEnd = x0 + 20 * totalColors;
r->FillRoundRect(x0, y - 5, static_cast<float> (20 * totalColors + 5), 20, 2, ARGB(128,0,0,0));
r->FillRoundRect(x0, y - 8, static_cast<float> (20 * totalColors + 5), 20, 2, ARGB(128,0,0,0));
int offset = 0;
for (int i = 0; i < Constants::NB_Colors; ++i)
@@ -270,10 +270,10 @@ void GuiMana::RenderStatic()
if (values[i])
{
offset -= 20;
r->RenderQuad(manaIcons[i].get(), xEnd + 15 + offset, y + 5, 0, 0.7f, 0.7f);
r->RenderQuad(manaIcons[i].get(), xEnd + 15 + offset, y + 3, 0, 0.65f, 0.65f);
}
}
r->FillRoundRect(x0, y, static_cast<float> (20 * totalColors + 5), 8, 2, ARGB(100,0,0,0));
//r->DrawRoundRect(x0, y - 8, static_cast<float> (20 * totalColors + 5), 20, 2, ARGB(128,255,255,255));
offset = 0;
for (int i = 0; i < Constants::NB_Colors; ++i)
{
@@ -283,7 +283,7 @@ void GuiMana::RenderStatic()
char buf[4];
sprintf(buf, "%i", values[i]);
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(buf, xEnd + offset + 9, y);
mFont->DrawString(buf, xEnd + offset + 18, y + 5);
}
}
}
+7 -4
View File
@@ -24,7 +24,7 @@
};
*/
const float GuiPhaseBar::zoom_big = (float)(1.5 * 1.4);
const float GuiPhaseBar::zoom_big = (float)(1.5 * 1.25);
const float GuiPhaseBar::zoom_small = 1.5;
const float GuiPhaseBar::step = M_PI/6.0f;
@@ -36,9 +36,9 @@ namespace
const unsigned kPhases = NB_MTG_PHASES - 2; //there are two phases we do not show
}
void GuiPhaseBar::DrawGlyph(JQuad *inQuad, int phaseId, float x, float y, float scale)
void GuiPhaseBar::DrawGlyph(JQuad *inQuad, int phaseId, float x, float y, float scale, float z)
{
inQuad->SetTextureRect(phaseId * (kWidth + 1), 0, kWidth, kHeight);
inQuad->SetTextureRect(phaseId * (kWidth + 1), z, kWidth, kHeight);
JRenderer::GetInstance()->RenderQuad(inQuad, x, y - scale * kWidth/2, 0.0f, scale, scale);
}
@@ -110,7 +110,10 @@ void GuiPhaseBar::Render()
//hint: sin(circPos + PI/2) = cos(circPos)
const float glyphScale = float(zoomFactor * cosf(circPos) * 0.5f);
DrawGlyph(quad.get(), (displayedPhaseId - 2 + i + kPhases) % kPhases, 0, glyphY, glyphScale);
if (observer->currentPlayer && observer->currentPlayer->isAI() && !observer->currentPlayer->opponent()->isAI())
DrawGlyph(quad.get(), (displayedPhaseId - 2 + i + kPhases) % kPhases, 0, glyphY, glyphScale, 29);
else
DrawGlyph(quad.get(), (displayedPhaseId - 2 + i + kPhases) % kPhases, 0, glyphY, glyphScale, 0);
}
//print phase name
+9 -3
View File
@@ -106,7 +106,7 @@ GuiPlay::BattleField::BattleField() :
attackers(0), height(0.0), red(0), colorFlow(0)
{
}
const float GuiPlay::BattleField::HEIGHT = 80.0f;
const float GuiPlay::BattleField::HEIGHT = 146.0f;
void GuiPlay::BattleField::addAttacker(MTGCardInstance*)
{
++attackers;
@@ -160,7 +160,11 @@ void GuiPlay::BattleField::Update(float dt)
void GuiPlay::BattleField::Render()
{
if (height > 3)
JRenderer::GetInstance()->FillRect(44, SCREEN_HEIGHT / 2 + 10 - height / 2, 318, height, ARGB(127, red, 0, 0));
{
JRenderer::GetInstance()->FillRect(0, SCREEN_HEIGHT / 2 + 8.5f - height / 2, 480, height, ARGB(127, red, 0, 0));
if(red > 1)
JRenderer::GetInstance()->DrawRect(-2, SCREEN_HEIGHT / 2 + 8.5f - height / 2, 484, height, ARGB(255, 255, 165, 0));
}
}
GuiPlay::GuiPlay(DuelLayers* view) :
@@ -270,7 +274,7 @@ void GuiPlay::Replace()
//rerun the iter reattaching planes walkers to the back of the lands.
for (iterator it = end_spells; it != cards.end(); ++it)
{
if ((*it)->card->hasType(Subtypes::TYPE_PLANESWALKER))
if ((*it)->card->hasType(Subtypes::TYPE_PLANESWALKER) && !(*it)->card->isCreature())
{
if (mpDuelLayers->getRenderedPlayer() == (*it)->card->controller())
selfLands.Enstack(*it);
@@ -408,6 +412,8 @@ int GuiPlay::receiveEventPlus(WEvent * e)
Replace();
else if (dynamic_cast<WEventCardUnattached*> (e))
Replace();
else if (dynamic_cast<WEventCardControllerChange*> (e))
Replace();
Replace();
return 0;
}
+19 -8
View File
@@ -60,8 +60,8 @@ void GuiAvatar::Render()
{
if (corner == BOTTOM_RIGHT)
{
x0 -= player->getIcon()->mWidth * actZ;
y0 -= player->getIcon()->mHeight * actZ;
x0 -= Width * actZ;
y0 -= Height * actZ;
}
switch (corner)
{
@@ -69,14 +69,14 @@ void GuiAvatar::Render()
player->getIcon()->SetHotSpot(0, 0);
break;
case BOTTOM_RIGHT:
player->getIcon()->SetHotSpot(35, 50);
player->getIcon()->SetHotSpot(player->getIcon()->mWidth, player->getIcon()->mHeight);
break;
}
player->getIcon()->SetColor(ARGB((int)actA, 255, avatarRed, avatarRed));
r->RenderQuad(player->getIcon().get(), actX, actY, actT, actZ, actZ);
r->RenderQuad(player->getIcon().get(), actX, actY, actT, Width/player->getIcon()->mWidth*actZ, Height/player->getIcon()->mHeight*actZ);
if (mHasFocus)
{
r->FillRect(x0, x0, player->getIcon()->mWidth * actZ, player->getIcon()->mHeight * actZ, ARGB(abs(128 - wave),255,255,255));
r->FillRect(x0, x0, Width/player->getIcon()->mWidth * actZ, Height/player->getIcon()->mHeight * actZ, ARGB(abs(128 - wave),255,255,255));
}
}
@@ -96,18 +96,29 @@ void GuiAvatar::Render()
//Life
char buffer[10];
int lx = 255, ly = 255, lz = 255;
if(life > 24) { lx = 127; ly = 255; lz = 212; }
if(life > 16 && life < 24) { lx = 255; ly = 255; lz = 255; }
if(life > 12 && life < 17) { lx = 255; ly = 255; lz = 105; }
if(life > 8 && life < 13) { lx = 255; ly = 255; lz = 13; }
if(life > 4 && life < 9) { lx = 255; ly = 166; lz = 0; }
if(life < 5) { lx = 255; ly = 40; lz = 0; }
sprintf(buffer, "%i", life);
switch (corner)
{
case TOP_LEFT:
mFont->SetColor(ARGB((int)actA / 4, 0, 0, 0));
mFont->DrawString(buffer, actX + 2, actY + 2);
mFont->SetColor(ARGB((int)actA, 255, 255, 255));
mFont->SetScale(1.3f);
mFont->SetColor(ARGB((int)actA, lx, ly, lz));
mFont->DrawString(buffer, actX + 1, actY + 1);
mFont->SetScale(1);
break;
case BOTTOM_RIGHT:
mFont->SetColor(ARGB((int)actA, 255, 255, 255));
mFont->DrawString(buffer, actX, actY - 10, JGETEXT_RIGHT);
mFont->SetScale(1.3f);
mFont->SetColor(ARGB((int)actA, lx, ly, lz));
mFont->DrawString(buffer, actX, actY - 14, JGETEXT_RIGHT);
mFont->SetScale(1);
break;
}
//poison
+132 -32
View File
@@ -411,6 +411,20 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
}
}
check = restriction[i].find("discarded");
if(check != string::npos)
{
if(!card->discarded)
return 0;
}
check = restriction[i].find("raid");
if(check != string::npos)
{
if(card->controller()->raidcount < 1)
return 0;
}
check = restriction[i].find("ownerscontrol");
if(check != string::npos)
{
@@ -811,7 +825,16 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
attackingTrigger,attackedAloneTrigger,notBlockedTrigger,attackBlockedTrigger,blockingTrigger);
}
//Card card is drawn
//drawn player - controller of card - dynamic version drawof(player) -> returns current controller even with exchange of card controller
if (TargetChooser * tc = parseSimpleTC(s, "drawof", card))
return NEW TrcardDrawn(observer, id, card, tc,once,true,false);
//drawn player - opponent of card controller - dynamic version drawfoeof(player) -> returns current opponent even with exchange of card controller
if (TargetChooser * tc = parseSimpleTC(s, "drawfoeof", card))
return NEW TrcardDrawn(observer, id, card, tc,once,false,true);
//Card card is drawn - static version - drawn(player) - any player; drawn(controller) - owner forever; drawn(opponent) - opponent forever
if (TargetChooser * tc = parseSimpleTC(s, "drawn", card))
return NEW TrcardDrawn(observer, id, card, tc,once);
@@ -827,35 +850,105 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
if (TargetChooser * tc = parseSimpleTC(s, "cycled", card))
return NEW TrCardDiscarded(observer, id, card, tc,once,true);
//Card Damaging non combat
//Card Damaging non combat current controller
if (TargetChooser * tc = parseSimpleTC(s, "noncombatdamageof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 2,false,false,once,true,false);
}
//Card Damaging non combat current opponent
if (TargetChooser * tc = parseSimpleTC(s, "noncombatdamagefoeof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 2,false,false,once,false,true);
}
//Card Damaging non combat static
if (TargetChooser * tc = parseSimpleTC(s, "noncombatdamaged", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 2,once);
}
//Card Damaging combat
//Card Damaging combat current controller
if (TargetChooser * tc = parseSimpleTC(s, "combatdamageof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 1,sourceUntapped,limitOnceATurn,once,true,false);
}
//Card Damaging combat current opponent
if (TargetChooser * tc = parseSimpleTC(s, "combatdamagefoeof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 1,sourceUntapped,limitOnceATurn,once,false,true);
}
//Card Damaging combat static
if (TargetChooser * tc = parseSimpleTC(s, "combatdamaged", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 1,sourceUntapped,limitOnceATurn,once);
}
//Card Damaging
//Card Damaging current controller
if (TargetChooser * tc = parseSimpleTC(s, "damageof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 0,sourceUntapped,limitOnceATurn,once,true,false);
}
//Card Damaging current opponent
if (TargetChooser * tc = parseSimpleTC(s, "damagefoeof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 0,sourceUntapped,limitOnceATurn,once,false,true);
}
//Card Damaging static
if (TargetChooser * tc = parseSimpleTC(s, "damaged", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrDamaged(observer, id, card, tc, fromTc, 0,sourceUntapped,limitOnceATurn,once);
}
//Lifed
//Lifed current controller
if (TargetChooser * tc = parseSimpleTC(s, "lifeof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrLifeGained(observer, id, card, tc, fromTc, 0,sourceUntapped,once,true,false);
}
//Lifed current opponent
if (TargetChooser * tc = parseSimpleTC(s, "lifefoeof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrLifeGained(observer, id, card, tc, fromTc, 0,sourceUntapped,once,false,true);
}
//Lifed static
if (TargetChooser * tc = parseSimpleTC(s, "lifed", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrLifeGained(observer, id, card, tc, fromTc, 0,sourceUntapped,once);
}
//Life Loss
//Life Loss current player
if (TargetChooser * tc = parseSimpleTC(s, "lifelostof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrLifeGained(observer, id, card, tc, fromTc,1,sourceUntapped,once,true,false);
}
//Life Loss current opponent
if (TargetChooser * tc = parseSimpleTC(s, "lifelostfoeof", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
return NEW TrLifeGained(observer, id, card, tc, fromTc,1,sourceUntapped,once,false,true);
}
//Life Loss static
if (TargetChooser * tc = parseSimpleTC(s, "lifeloss", card))
{
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
@@ -2652,6 +2745,24 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return NEW AEvolveAbility(observer, id, card);
}
//produce additional mana when tapped for mana
if (s.find("produceextra:") != string::npos)
{
return NEW AProduceMana(observer, id, card,s.substr(13));
}
//produce additional mana when a mana is engaged
if (s.find("producecolor:") != string::npos)
{
return NEW AEngagedManaAbility(observer, id, card,s.substr(13));
}
//reducelife to specific value
if (s.find("reduceto:") != string::npos)
{
return NEW AReduceToAbility(observer, id, card,s.substr(9));
}
//flanking
if (s.find("flanker") != string::npos)
{
@@ -3083,7 +3194,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a;
}
//get a new target
//get a new target - retarget and newtarget makes the card refreshed - from exile to play...
if ((s.find("retarget") != string::npos) || s.find("newtarget") != string::npos)
{
MTGAbility * a = NEW AANewTarget(observer, id, card,target, (s.find("retarget") != string::npos));
@@ -3091,6 +3202,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a;
}
//get a new target for puresteel paladin...etc for equipments inplay only.. newhook & rehook supports stone hewer basic... the card is reequipped
if ((s.find("rehook") != string::npos) || s.find("newhook") != string::npos)
{
MTGAbility * a = NEW AANewTarget(observer, id, card,target, false,NULL,true,(s.find("newhook") != string::npos));
a->oneShot = 1;
return a;
}
//morph
found = s.find("morph");
if (found != string::npos)
@@ -3542,6 +3661,9 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
badAbilities[(int)Constants::WEAK] = true;
badAbilities[(int)Constants::NOLIFEGAIN] = true;
badAbilities[(int)Constants::NOLIFEGAINOPPONENT] = true;
badAbilities[(int)Constants::CANTLOSE] = false;
badAbilities[(int)Constants::CANTLIFELOSE] = false;
badAbilities[(int)Constants::CANTMILLLOSE] = false;
if (AInstantBasicAbilityModifierUntilEOT * abi = dynamic_cast<AInstantBasicAbilityModifierUntilEOT *>(a))
{
@@ -4249,7 +4371,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
if (current->hasType(Subtypes::TYPE_CREATURE))
{
card->controller()->game->putInGraveyard(current);
damage += current->power;
damage += current->getCurrentPower();
}
}
observer->mLayers->stackLayer()->addDamage(card, target, damage);
@@ -4578,6 +4700,8 @@ int ActivatedAbility::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
return 0;
if (cPhase != MTG_PHASE_FIRSTMAIN && cPhase != MTG_PHASE_SECONDMAIN)
return 0;
if (player->opponent()->getObserver()->mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0||game->mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0||player->getObserver()->mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0)
return 0;
break;
}
if (restrictions >= MY_BEFORE_BEGIN && restrictions <= MY_AFTER_EOT)
@@ -5000,30 +5124,6 @@ int TriggeredAbility::receiveEvent(WEvent * e)
resolve();
return 1;
}
if(dynamic_cast<WEventLife*>(e))
{
//check life state on life triger
WEventLife * lifecheck = dynamic_cast<WEventLife*>(e);
if (lifecheck->player->DeadLifeState())
{
return 0;
}
fireAbility();
return 1;
}
if(dynamic_cast<WEventDamage*>(e))
{
//check life state on damage trigger
WEventDamage * lifecheck = dynamic_cast<WEventDamage*>(e);
if (lifecheck->damage->target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
{
Player * triggerPlayer = (Player *) lifecheck->damage->target;
if(triggerPlayer->DeadLifeState())
return 0;
}
fireAbility();
return 1;
}
WEventZoneChange * stackCheck = dynamic_cast<WEventZoneChange*>(e);
if(stackCheck && (stackCheck->to == game->currentPlayer->game->stack||stackCheck->to == game->currentPlayer->opponent()->game->stack))
{
+90 -1
View File
@@ -58,6 +58,13 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
isSwitchedPT = false;
isACopier = false;
bypassTC = false;
discarded = false;
copiedID = getId();
modifiedbAbi = 0;
LKIpower = power;
LKItoughness = toughness;
cardistargetted = 0;
cardistargetter = 0;
}
MTGCardInstance * MTGCardInstance::createSnapShot()
@@ -75,6 +82,8 @@ void MTGCardInstance::copy(MTGCardInstance * card)
CardPrimitive * data = source->data;
basicAbilities = card->basicAbilities;
origbasicAbilities = card->origbasicAbilities;
modifiedbAbi = card->modifiedbAbi;
for (size_t i = 0; i < data->types.size(); i++)
{
types.push_back(data->types[i]);
@@ -574,11 +583,13 @@ Player * MTGCardInstance::controller()
int MTGCardInstance::canAttack()
{
if (basicAbilities[(int)Constants::CANTATTACK])
return 0;
if (tapped)
return 0;
if (hasSummoningSickness())
return 0;
if ((basicAbilities[(int)Constants::DEFENSER] || basicAbilities[(int)Constants::CANTATTACK]) && !basicAbilities[(int)Constants::CANATTACK])
if (basicAbilities[(int)Constants::DEFENSER] && !basicAbilities[(int)Constants::CANATTACK])
return 0;
if (!isCreature())
return 0;
@@ -718,6 +729,84 @@ void MTGCardInstance::switchPT(bool apply)
}
}
int MTGCardInstance::getCurrentPower()
{
if(!isInPlay(observer))
return LKIpower;
return power;
}
int MTGCardInstance::getCurrentToughness()
{
if(!isInPlay(observer))
return LKItoughness;
return toughness;
}
//check stack
bool MTGCardInstance::StackIsEmptyandSorcerySpeed()
{
if((getObserver()->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) &&
(getObserver()->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN ||
getObserver()->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN) &&
controller() == getObserver()->currentPlayer &&
!getObserver()->isInterrupting)
{
return true;
}
return false;
}
//check targetted?
bool MTGCardInstance::isTargetted()
{
if(getObserver()->mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0)
{
ActionStack * stack = observer->mLayers->stackLayer();
for (int i = stack->mObjects.size() - 1; i >= 0; i--)
{
Interruptible * current = ((Interruptible *) stack->mObjects[i]);
if ((current->type == ACTION_SPELL || current->type == ACTION_ABILITY) && current->state == NOT_RESOLVED)
{
if(current->type == ACTION_SPELL)
{
Spell * spell = (Spell *) current;
if(spell->getNextTarget() && spell->getNextTarget() == (Targetable*)this)
return true;
}
}
}
}
if(cardistargetted)
return true;
return false;
}
//check targetter?
bool MTGCardInstance::isTargetter()
{
if(getObserver()->mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0)
{
ActionStack * stack = observer->mLayers->stackLayer();
for (int i = stack->mObjects.size() - 1; i >= 0; i--)
{
Interruptible * current = ((Interruptible *) stack->mObjects[i]);
if ((current->type == ACTION_SPELL || current->type == ACTION_ABILITY) && current->state == NOT_RESOLVED)
{
if(current->type == ACTION_SPELL)
{
Spell * spell = (Spell *) current;
if(spell && spell->source == this)
return true;
}
}
}
}
if(cardistargetter)
return true;
return false;
}
int MTGCardInstance::canBlock()
{
if (tapped)
+5 -1
View File
@@ -143,7 +143,11 @@ const char* Constants::MTGBasicAbilities[] = {
"spellmastery",
"nolifegain",
"nolifegainopponent",
"auraward"
"auraward",
"madness",
"protectionfromcoloredspells",
"mygcreatureexiler",
"oppgcreatureexiler"
};
map<string,int> Constants::MTGBasicAbilitiesMap;
+38
View File
@@ -322,9 +322,19 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
int doCopy = 1;
bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH];
bool inplaytoinplay = false;
bool ripToken = false;
if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace"))
ripToken = true;
//Madness or Put in Play...
for(int i = 0; i < 2; ++i)
{
if (card->discarded && (to == g->players[i]->game->graveyard) && (from == g->players[i]->game->hand))
{
if(card->basicAbilities[(int)Constants::MADNESS])
to = g->players[i]->game->exile;
}
}
//Darksteel Colossus, Legacy Weapon ... top priority since we replace destination directly automatically...
for(int i = 0; i < 2; ++i)
{
@@ -339,6 +349,8 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
for(int i = 0; i < 2; ++i)
{
if ((to == g->players[i]->game->graveyard) && (
(g->players[i]->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER) && card->isCreature()) ||
(g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && card->isCreature())||
g->players[i]->game->battlefield->hasAbility(Constants::MYGRAVEEXILER) ||
g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)))
{
@@ -353,6 +365,8 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
== g->players[1]->game->inPlay))
{
doCopy = 0;
asCopy = true;//don't send zone change event so it will not destroy the GUI when multiple switching of control...
inplaytoinplay = true;//try sending different event...
}
if (!(copy = from->removeCard(card, doCopy)))
@@ -361,6 +375,13 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
{
copy->miracle = true;
}
if (card->discarded)
{//set discarded for madness...
if(from == g->players[0]->game->hand || from == g->players[1]->game->hand)
copy->discarded = true;
else//turn off discarded if its previous zone is not in hand...
copy->discarded = false;
}
if (options[Options::SFXVOLUME].number > 0)
{
if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard)
@@ -417,6 +438,11 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
WEvent * e = NEW WEventZoneChange(copy, from, to);
g->receiveEvent(e);
}
if(inplaytoinplay)
{
WEvent * ep = NEW WEventCardControllerChange(copy);
g->receiveEvent(ep);
}
return ret;
}
@@ -748,6 +774,18 @@ bool MTGGameZone::hasAbility(int ability)
return false;
}
bool MTGGameZone::hasAlias(int alias)
{
for (int i = 0; i < (nb_cards); i++)
{
if (cards[i]->alias == alias)
{
return true;
}
}
return false;
}
int MTGGameZone::seenThisTurn(TargetChooser * tc, int castMethod, bool lastTurn)
{
//The following 2 lines modify the passed TargetChooser. Call this function with care :/
+37 -44
View File
@@ -284,7 +284,6 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
{
int cardsinhand = game->players[0]->game->hand->nb_cards;
Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer;
if (!player->game->hand->hasCard(card))
return 0;
if ((game->turn < 1) && (cardsinhand != 0) && (card->basicAbilities[(int)Constants::LEYLINE])
@@ -310,18 +309,12 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
{
if (game->currentActionPlayer->game->playRestrictions->canPutIntoZone(card, game->currentActionPlayer->game->inPlay) == PlayRestriction::CANT_PLAY)
return 0;
if (player == currentPlayer
&& (game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN)
)
{
if (card->StackIsEmptyandSorcerySpeed())
return 1;
}
else
return 0;
}
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH)
|| (player == card->controller() && !game->isInterrupting
&& (game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|| game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
)
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH) || (card->StackIsEmptyandSorcerySpeed()))
{
if(card->controller()->epic)
return 0;
@@ -631,7 +624,6 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *, ManaCost *alternateManaCost)
{
Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer;
if (!alternateManaCost)
return 0;
@@ -645,17 +637,12 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
{
if (game->currentActionPlayer->game->playRestrictions->canPutIntoZone(card, game->currentActionPlayer->game->inPlay) == PlayRestriction::CANT_PLAY)
return 0;
if (player == currentPlayer
&& (game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|| game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN)
)
if (card->StackIsEmptyandSorcerySpeed())
return 1;
else
return 0;
}
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH) || card->has(Constants::SPELLMASTERY) || card->has(Constants::OFFERING)
|| (player == card->controller() && !game->isInterrupting
&& (game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|| game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
)
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH) || card->has(Constants::SPELLMASTERY) || card->has(Constants::OFFERING) || (card->StackIsEmptyandSorcerySpeed()))
{
if(card->controller()->epic)
return 0;
@@ -1042,11 +1029,7 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
if(card->controller()->epic)//zoetic cavern... morph is casted for a cost...
return 0;
//note lands can morph too, this is different from other cost types.
if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH) || (player == card->controller()
&& !game->isInterrupting
&& (game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|| game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
)
if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH) || (card->StackIsEmptyandSorcerySpeed()))
{
if (card->controller()->game->playRestrictions->canPutIntoZone(card, card->controller()->game->stack) == PlayRestriction::CANT_PLAY)
return 0;
@@ -1415,6 +1398,7 @@ int MTGCombatTriggersRule::receiveEvent(WEvent *e)
if (card && card->isAttacker())
{
card->eventattacked();
card->controller()->raidcount += 1;
}
}
}
@@ -2293,6 +2277,10 @@ int MTGPersistRule::receiveEvent(WEvent * event)
if (e->from == p->game->inPlay)
ok = 1;
}
if (card->owner->game->battlefield->hasAbility(Constants::MYGRAVEEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER))
ok = 0;
if ((card->owner->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER))&&(card->isCreature()))
ok = 0;
if (!ok)
return 0;
@@ -2301,19 +2289,28 @@ int MTGPersistRule::receiveEvent(WEvent * event)
Player * p = game->players[i];
if (e->to == p->game->graveyard)
{
MTGCardInstance * copy = p->game->putInZone(e->card, p->game->graveyard, e->card->owner->game->temp);
MTGCardInstance * copy = e->card;
if (!copy)
{
DebugTrace("MTGRULES: couldn't move card for persist/undying");
return 0;
}
Spell * spell = NEW Spell(game, copy);
spell->resolve();
string code = "";
bool persist = false;
bool undying = false;
if(card->basicAbilities[(int)Constants::PERSIST])
spell->source->counters->addCounter(-1, -1);
{
code = "Persist";
persist = true;
}
else
spell->source->counters->addCounter(1,1);
delete spell;
{
code = "Undying";
undying = true;
}
AAMover *putinplay = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), copy, copy,"ownerbattlefield",code,NULL,undying,persist);
putinplay->oneShot = true;
putinplay->fireAbility();
return 1;
}
}
@@ -2535,20 +2532,18 @@ int MTGLegendRule::added(MTGCardInstance * card)
MultiAbility * multi = NEW MultiAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card, NULL);
for(unsigned int i = 0;i < oldCards.size();i++)
{
AABuryCard *a = NEW AABuryCard(game, game->mLayers->actionLayer()->getMaxId(), card, oldCards[i]);
a->menu = "Keep New";
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);
AABuryCard *b = NEW AABuryCard(game, game->mLayers->actionLayer()->getMaxId(), card, card);
b->menu = "Keep Old";
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(),"Choose Legend");
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule");
menuChoice->addToGame();
}
return 1;
@@ -2612,20 +2607,18 @@ int MTGPlaneWalkerRule::added(MTGCardInstance * card)
MultiAbility * multi = NEW MultiAbility(game,game->mLayers->actionLayer()->getMaxId(), card, card, NULL);
for(unsigned int i = 0;i < oldCards.size();i++)
{
AABuryCard *a = NEW AABuryCard(game, game->mLayers->actionLayer()->getMaxId(), card, oldCards[i]);
a->menu = "Keep New";
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);
AABuryCard *b = NEW AABuryCard(game, game->mLayers->actionLayer()->getMaxId(), card, card);
b->menu = "Keep Old";
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(),"Choose Planeswalker");
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Planeswalker Rule");
menuChoice->addToGame();
}
return 1;
@@ -2707,7 +2700,7 @@ int MTGLifelinkRule::receiveEvent(WEvent * event)
WEventDamage * e = (WEventDamage *) event;
Damage * d = e->damage;
MTGCardInstance * card = d->source;
if (d->damage > 0 && card && card->basicAbilities[(int)Constants::LIFELINK])
if (d->damage > 0 && card && (card->basicAbilities[(int)Constants::LIFELINK]||card->LKIbasicAbilities[(int)Constants::LIFELINK]))
{
card->controller()->gainLife(d->damage);
return 1;
@@ -2751,7 +2744,7 @@ int MTGDeathtouchRule::receiveEvent(WEvent * event)
return 0;
MTGCardInstance * _target = (MTGCardInstance *) (d->target);
if (card->basicAbilities[(int)Constants::DEATHTOUCH])
if (card->basicAbilities[(int)Constants::DEATHTOUCH]||card->LKIbasicAbilities[(int)Constants::DEATHTOUCH])
{
_target->destroy();
return 1;
+18 -3
View File
@@ -34,6 +34,7 @@ Player::Player(GameObserver *observer, string file, string fileSmall, MTGDeck *
extraTurn = 0;
drawCounter = 0;
epic = 0;
raidcount = 0;
prowledTypes.clear();
doesntEmpty = NEW ManaCost();
poolDoesntEmpty = NEW ManaCost();
@@ -89,7 +90,7 @@ bool Player::loadAvatar(string file, string resName)
}
mAvatarTex = rm->RetrieveTexture(file, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR);
if (mAvatarTex) {
mAvatar = rm->RetrieveQuad(file, 0, 0, 35, 50, resName, RETRIEVE_NORMAL, TEXTURE_SUB_AVATAR);
mAvatar = rm->RetrieveQuad(file, 0, 0, 0, 0, resName, RETRIEVE_NORMAL, TEXTURE_SUB_AVATAR);
return true;
}
@@ -236,7 +237,7 @@ void Player::serumMulligan()
//Draw hand no penalty
}
bool Player::DeadLifeState()
bool Player::DeadLifeState(bool check)
{
if ((life <= 0)||(poisonCount >= 10))
{
@@ -263,7 +264,21 @@ bool Player::DeadLifeState()
}
if (cantlosers < 1)
{
getObserver()->setLoser(this);
if(!check)
{
ActionStack * stack = getObserver()->mLayers->stackLayer();
for (int i = stack->mObjects.size() - 1; i >= 0; i--)
{
Interruptible * current = ((Interruptible *) stack->mObjects[i]);
Spell * spell = (Spell *) current;
if (current->type == ACTION_SPELL)
spell->source->controller()->game->putInGraveyard(spell->source);
current->state = RESOLVED_NOK;
}
}
if(check)
game->owner->getObserver()->setLoser(this);
return true;
}
}
+5
View File
@@ -859,6 +859,11 @@ bool TargetChooser::canTarget(Targetable * target, bool withoutProtections)
if (card->protectedAgainst(targetter)) return targetter->bypassTC;
if (card->CantBeTargetby(targetter)) return targetter->bypassTC;
if ((targetter->controller() != card->controller()) && card->has(Constants::OPPONENTSHROUD)) return targetter->bypassTC;
if (card->has(Constants::PROTECTIONFROMCOLOREDSPELLS))
{//a spell that has no target=criteria means it's not targetted unless its a workaround card...
if((targetter->spellTargetType.size()) && (targetter->hasColor(1)||targetter->hasColor(2)||targetter->hasColor(3)||targetter->hasColor(4)||targetter->hasColor(5)))
return targetter->bypassTC;
}
}
return true;
}
+14
View File
@@ -106,6 +106,7 @@ WEventCardSacrifice::WEventCardSacrifice(MTGCardInstance * card, MTGCardInstance
WEventCardDiscard::WEventCardDiscard(MTGCardInstance * card) :
WEventCardUpdate(card)
{
card->discarded = true;
}
WEventCardCycle::WEventCardCycle(MTGCardInstance * card) :
@@ -121,6 +122,8 @@ WEventVampire::WEventVampire(MTGCardInstance * card,MTGCardInstance * source,MTG
WEventTarget::WEventTarget(MTGCardInstance * card,MTGCardInstance * source) :
WEventCardUpdate(card),card(card),source(source)
{
card->cardistargetted = 1;
source->cardistargetter = 1;
}
WEventCardChangeType::WEventCardChangeType(MTGCardInstance * card, int type, bool before, bool after) :
@@ -162,6 +165,11 @@ WEventCardUnattached::WEventCardUnattached(MTGCardInstance * card) :
{
}
WEventCardControllerChange::WEventCardControllerChange(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCombatStepChange::WEventCombatStepChange(CombatStep step) :
WEvent(), step(step)
{
@@ -316,6 +324,12 @@ Targetable * WEventCardUnattached::getTarget(int target)
return NULL;
}
Targetable * WEventCardControllerChange::getTarget(int target)
{
if (target) return card;
return NULL;
}
std::ostream& WEvent::toString(std::ostream& out) const
{
return out << "EVENT";