Merge branch 'master' into cmake
This commit is contained in:
@@ -650,8 +650,8 @@ MTGCardInstance * AIPlayerBaka::chooseCard(TargetChooser * tc, MTGCardInstance *
|
||||
}
|
||||
for(int players = 0; players < 2;++players)
|
||||
{
|
||||
MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack };
|
||||
for (int j = 0; j < 5; j++)
|
||||
MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile };
|
||||
for (int j = 0; j < 6; j++)
|
||||
{
|
||||
MTGGameZone * zone = zones[j];
|
||||
for (int k = 0; k < zone->nb_cards; k++)
|
||||
@@ -1214,7 +1214,7 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = observer->players[i];
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack };
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack,p->game->exile };
|
||||
if(a->getActionTc()->canTarget((Targetable*)p))
|
||||
{
|
||||
if(a->getActionTc()->maxtargets == 1)
|
||||
@@ -1225,7 +1225,7 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank
|
||||
else
|
||||
potentialTargets.push_back(p);
|
||||
}
|
||||
for (int j = 0; j < 5; j++)
|
||||
for (int j = 0; j < 6; j++)
|
||||
{
|
||||
MTGGameZone * zone = playerZones[j];
|
||||
for (int k = 0; k < zone->nb_cards; k++)
|
||||
@@ -1553,8 +1553,8 @@ int AIPlayerBaka::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCard
|
||||
}
|
||||
}
|
||||
MTGPlayerCards * playerZones = target->game;
|
||||
MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack };
|
||||
for (int j = 0; j < 5; j++)
|
||||
MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile };
|
||||
for (int j = 0; j < 6; j++)
|
||||
{
|
||||
MTGGameZone * zone = zones[j];
|
||||
for (int k = 0; k < zone->nb_cards; k++)
|
||||
|
||||
@@ -1146,9 +1146,9 @@ AASetCoin::~AASetCoin()
|
||||
|
||||
//paying for an ability as an effect but as a cost
|
||||
GenericPaidAbility::GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source,
|
||||
Targetable * target, string _newName, string _castRestriction, string mayCost, string _toAdd, ManaCost * cost) :
|
||||
Targetable * target, string _newName, string _castRestriction, string mayCost, string _toAdd, bool asAlternate, ManaCost * cost) :
|
||||
ActivatedAbility(observer, id, source, cost, 0),
|
||||
newName(_newName), restrictions(_castRestriction), baseCost(mayCost), baseAbilityStr(_toAdd)
|
||||
newName(_newName), restrictions(_castRestriction), baseCost(mayCost), baseAbilityStr(_toAdd), asAlternate(asAlternate)
|
||||
{
|
||||
this->GetId();
|
||||
baseAbility = NULL;
|
||||
@@ -1172,6 +1172,8 @@ int GenericPaidAbility::resolve()
|
||||
AbilityFactory Af(game);
|
||||
vector<string> baseAbilityStrSplit = split(baseAbilityStr,'?');
|
||||
vector<MTGAbility*> selection;
|
||||
MTGAbility * nomenuAbility = NULL;
|
||||
bool nomenu = false;
|
||||
if (baseAbilityStrSplit.size() > 1)
|
||||
{
|
||||
baseAbility = Af.parseMagicLine(baseAbilityStrSplit[0], this->GetId(), NULL, source);
|
||||
@@ -1200,10 +1202,12 @@ int GenericPaidAbility::resolve()
|
||||
}
|
||||
else
|
||||
{
|
||||
nomenu = true;
|
||||
baseAbility = Af.parseMagicLine(baseAbilityStrSplit[0], this->GetId(), NULL, source);
|
||||
baseAbility->target = target;
|
||||
optionalCost = ManaCost::parseManaCost(baseCost, NULL, source);
|
||||
MTGAbility * set = baseAbility->clone();
|
||||
nomenuAbility = baseAbility->clone();
|
||||
set->oneShot = true;
|
||||
selection.push_back(set);
|
||||
}
|
||||
@@ -1211,10 +1215,37 @@ int GenericPaidAbility::resolve()
|
||||
if (selection.size())
|
||||
{
|
||||
bool must = baseAbilityStrSplit.size() > 1 ? true : false;
|
||||
MenuAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, must, selection, NULL, newName);
|
||||
a1->optionalCosts.push_back(NEW ManaCost(optionalCost));
|
||||
game->mLayers->actionLayer()->currentActionCard = (MTGCardInstance *)target;
|
||||
a1->resolve();
|
||||
//todo get increased - reduced cost if asAlternate cost to cast using castcard
|
||||
if(asAlternate)
|
||||
{
|
||||
must = true;
|
||||
//cost increase - reduce + trinisphere effect ability todo...
|
||||
if(((MTGCardInstance *)target)->getIncreasedManaCost()->getConvertedCost())
|
||||
optionalCost->add(((MTGCardInstance *)target)->getIncreasedManaCost());
|
||||
if(((MTGCardInstance *)target)->getReducedManaCost()->getConvertedCost())
|
||||
optionalCost->remove(((MTGCardInstance *)target)->getReducedManaCost());
|
||||
//trinisphere effect must be hardcoded...here..
|
||||
/*if(((MTGCardInstance *)target)->has(Constants::TRINISPHERE))
|
||||
{
|
||||
if(optionalCost->getConvertedCost() == 2)
|
||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
else if(optionalCost->getConvertedCost() == 1)
|
||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 2);
|
||||
else if(optionalCost->getConvertedCost() < 1)
|
||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 3);
|
||||
}*/
|
||||
}
|
||||
if(asAlternate && nomenu && optionalCost->getConvertedCost() < 1)
|
||||
{
|
||||
nomenuAbility->resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, must, selection, NULL, newName);
|
||||
a1->optionalCosts.push_back(NEW ManaCost(optionalCost));
|
||||
game->mLayers->actionLayer()->currentActionCard = (MTGCardInstance *)target;
|
||||
a1->resolve();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -2470,6 +2501,49 @@ AALifer * AALifer::clone() const
|
||||
return NEW AALifer(*this);
|
||||
}
|
||||
|
||||
//players modify hand size
|
||||
AModifyHand::AModifyHand(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, string hand, int who) :
|
||||
AbilityTP(observer, _id, _source, _target, who), hand(hand)
|
||||
{
|
||||
}
|
||||
|
||||
int AModifyHand::addToGame()
|
||||
{
|
||||
Damageable * _target = (Damageable *) getTarget();
|
||||
Player * p = getPlayerFromDamageable(_target);
|
||||
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
WParsedInt handmodifier(hand, NULL, source);
|
||||
p->handmodifier += handmodifier.getValue();
|
||||
|
||||
return MTGAbility::addToGame();
|
||||
}
|
||||
|
||||
int AModifyHand::destroy()
|
||||
{
|
||||
Damageable * _target = (Damageable *) getTarget();
|
||||
Player * p = getPlayerFromDamageable(_target);
|
||||
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
WParsedInt handmodifier(hand, NULL, source);
|
||||
p->handmodifier -= handmodifier.getValue();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const string AModifyHand::getMenuText()
|
||||
{
|
||||
return "Modify Hand Size";
|
||||
}
|
||||
|
||||
AModifyHand * AModifyHand::clone() const
|
||||
{
|
||||
return NEW AModifyHand(*this);
|
||||
}
|
||||
|
||||
//players max hand size
|
||||
AASetHand::AASetHand(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int hand, ManaCost * _cost,
|
||||
@@ -5092,8 +5166,8 @@ AUpkeep::~AUpkeep()
|
||||
}
|
||||
|
||||
//A Phase based Action
|
||||
APhaseAction::APhaseAction(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance *, string sAbility, int, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once) :
|
||||
MTGAbility(observer, _id, card),sAbility(sAbility), phase(_phase),forcedestroy(forcedestroy),next(next),myturn(myturn),opponentturn(opponentturn),once(once)
|
||||
APhaseAction::APhaseAction(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance *, string sAbility, int, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once, bool checkexile) :
|
||||
MTGAbility(observer, _id, card),sAbility(sAbility), phase(_phase),forcedestroy(forcedestroy),next(next),myturn(myturn),opponentturn(opponentturn),once(once),checkexile(checkexile)
|
||||
{
|
||||
abilityId = _id;
|
||||
abilityOwner = card->controller();
|
||||
@@ -5110,6 +5184,14 @@ MTGAbility(observer, _id, card),sAbility(sAbility), phase(_phase),forcedestroy(f
|
||||
|
||||
void APhaseAction::Update(float dt)
|
||||
{
|
||||
if(checkexile)
|
||||
{
|
||||
if(((MTGCardInstance *)target)->next->getCurrentZone() != ((MTGCardInstance *)target)->owner->game->exile)
|
||||
{
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (newPhase != currentPhase)
|
||||
{
|
||||
if((myturn && game->currentPlayer == source->controller())||
|
||||
@@ -5186,11 +5268,11 @@ APhaseAction::~APhaseAction()
|
||||
}
|
||||
|
||||
// the main ability
|
||||
APhaseActionGeneric::APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once) :
|
||||
APhaseActionGeneric::APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once, bool checkexile) :
|
||||
InstantAbility(observer, _id, card, target)
|
||||
{
|
||||
MTGCardInstance * _target = target;
|
||||
ability = NEW APhaseAction(game, _id, card,_target, sAbility, restrictions, _phase,forcedestroy,next,myturn,opponentturn,once);
|
||||
ability = NEW APhaseAction(game, _id, card,_target, sAbility, restrictions, _phase,forcedestroy,next,myturn,opponentturn,once,checkexile);
|
||||
}
|
||||
|
||||
int APhaseActionGeneric::resolve()
|
||||
@@ -5238,10 +5320,13 @@ void ABlink::Update(float dt)
|
||||
|
||||
if ((blinkueot && currentPhase == MTG_PHASE_ENDOFTURN) || (blinkForSource && !source->isInPlay(game)))
|
||||
{
|
||||
if (Blinked == NULL)
|
||||
MTGAbility::Update(dt);
|
||||
MTGCardInstance * _target = Blinked;
|
||||
returnCardIntoPlay(_target);
|
||||
if(Blinked->blinked)
|
||||
{
|
||||
if (Blinked == NULL)
|
||||
MTGAbility::Update(dt);
|
||||
MTGCardInstance * _target = Blinked;
|
||||
returnCardIntoPlay(_target);
|
||||
}
|
||||
}
|
||||
MTGAbility::Update(dt);
|
||||
}
|
||||
@@ -5272,6 +5357,7 @@ void ABlink::resolveBlink()
|
||||
return;
|
||||
}
|
||||
_target = _target->next;
|
||||
_target->blinked = true;
|
||||
Blinked = _target;
|
||||
if(!blinkueot && !blinkForSource)
|
||||
{
|
||||
@@ -5282,6 +5368,11 @@ void ABlink::resolveBlink()
|
||||
|
||||
void ABlink::returnCardIntoPlay(MTGCardInstance* _target) {
|
||||
MTGCardInstance * Blinker = NULL;
|
||||
if(!_target->blinked)
|
||||
{
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
if (!blinkhand)
|
||||
Blinker = _target->controller()->game->putInZone(
|
||||
_target,
|
||||
@@ -5611,6 +5702,8 @@ int AEquip::equip(MTGCardInstance * equipped)
|
||||
//we equip...
|
||||
a->addToGame();
|
||||
}
|
||||
WEvent * e = NEW WEventCardEquipped(source);
|
||||
game->receiveEvent(e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -5708,16 +5801,28 @@ void AACastCard::Update(float dt)
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
if(!toCheck->hasType(Subtypes::TYPE_INSTANT) && !(game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
|
||||
/*if(!toCheck->hasType(Subtypes::TYPE_INSTANT) && !(game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
|
||||
{
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
MTGCardInstance * toCheck = (MTGCardInstance*)target;
|
||||
if(theNamedCard)
|
||||
toCheck = theNamedCard;
|
||||
if(toCheck && toCheck->spellTargetType.size())
|
||||
{
|
||||
TargetChooserFactory tcf(game);
|
||||
TargetChooser * stc = tcf.createTargetChooser(toCheck->spellTargetType,toCheck);
|
||||
if (!stc->validTargetsExist()||toCheck->isToken)
|
||||
{
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
SAFE_DELETE(stc);
|
||||
}
|
||||
MTGCardInstance * toCheck = (MTGCardInstance*)target;
|
||||
if(theNamedCard)
|
||||
toCheck = theNamedCard;
|
||||
if (Spell * checkSpell = dynamic_cast<Spell*>(target))
|
||||
{
|
||||
toCheck = checkSpell->source;
|
||||
|
||||
@@ -129,7 +129,7 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card)
|
||||
return NULL;
|
||||
if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness))
|
||||
return NULL;
|
||||
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost))
|
||||
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost))
|
||||
return NULL;
|
||||
if (nameComparisonMode && compareName != card->name)
|
||||
return NULL;
|
||||
@@ -170,7 +170,7 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card)
|
||||
match = NULL;
|
||||
if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness))
|
||||
match = NULL;
|
||||
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost))
|
||||
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost))
|
||||
match = NULL;
|
||||
if(nameComparisonMode && compareName != card->name)
|
||||
match = NULL;
|
||||
|
||||
+240
-123
@@ -225,8 +225,12 @@ void GameObserver::nextGamePhase()
|
||||
|
||||
if (mCurrentGamePhase == MTG_PHASE_AFTER_EOT)
|
||||
{
|
||||
int handmodified = 0;
|
||||
handmodified = currentPlayer->handsize+currentPlayer->handmodifier;
|
||||
//Auto Hand cleaning, in case the player didn't do it himself
|
||||
while (currentPlayer->game->hand->nb_cards > currentPlayer->handsize && currentPlayer->nomaxhandsize == false)
|
||||
if(handmodified < 0)
|
||||
handmodified = 0;
|
||||
while (currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false)
|
||||
{
|
||||
WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]);
|
||||
receiveEvent(e);
|
||||
@@ -518,12 +522,13 @@ bool GameObserver::operator==(const GameObserver& aGame)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
MTGGameZone * aZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
|
||||
MTGGameZone * aZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile };
|
||||
MTGGameZone * thisZones[] = { players[i]->game->graveyard,
|
||||
players[i]->game->library,
|
||||
players[i]->game->hand,
|
||||
players[i]->game->inPlay };
|
||||
for (int j = 0; j < 4; j++)
|
||||
players[i]->game->inPlay,
|
||||
players[i]->game->exile };
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
MTGGameZone * zone = aZones[j];
|
||||
if (zone->nb_cards != thisZones[j]->nb_cards)
|
||||
@@ -595,16 +600,16 @@ void GameObserver::gameStateBasedEffects()
|
||||
/////////////////////////////////////
|
||||
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 * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library, players[d]->game->exile };
|
||||
for (int k = 0; k < 5; 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;
|
||||
zone->cards[c]->cardistargetted = 0;
|
||||
zone->cards[c]->cardistargetter = 0;
|
||||
}
|
||||
}
|
||||
}//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue
|
||||
@@ -877,8 +882,12 @@ void GameObserver::gameStateBasedEffects()
|
||||
enchantmentStatus();
|
||||
/////////////////////////////
|
||||
// Check affinity on a card//
|
||||
// plus modify costs //
|
||||
/////////////////////////////
|
||||
Affinity();
|
||||
//trinisphere? buggy...
|
||||
//ComputeTrinisphere();
|
||||
//end trinisphere
|
||||
/////////////////////////////////////
|
||||
// Check colored statuses on cards //
|
||||
/////////////////////////////////////
|
||||
@@ -953,46 +962,142 @@ void GameObserver::enchantmentStatus()
|
||||
|
||||
void GameObserver::Affinity()
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int dd = 0; dd < 2; dd++)
|
||||
{
|
||||
MTGGameZone * zone = players[i]->game->hand;
|
||||
for (int k = zone->nb_cards - 1; k >= 0; k--)
|
||||
MTGGameZone * dzones[] = { players[dd]->game->graveyard, players[dd]->game->hand, players[dd]->game->library, players[dd]->game->exile };
|
||||
for (int kk = 0; kk < 4; kk++)
|
||||
{
|
||||
MTGCardInstance * card = zone->cards[k];
|
||||
if (!card)
|
||||
continue;
|
||||
MTGGameZone * zone = dzones[kk];
|
||||
for (int cc = zone->nb_cards - 1; cc >= 0; cc--)
|
||||
{//start
|
||||
MTGCardInstance * card = zone->cards[cc];
|
||||
if (!card)
|
||||
continue;
|
||||
|
||||
int color = 0;
|
||||
string type = "";
|
||||
//only do any of the following if a card with the stated ability is in your hand.
|
||||
ManaCost * original = NEW ManaCost();
|
||||
original->copy(card->model->data->getManaCost());
|
||||
//have to run alter cost before affinity or the 2 cancel each other out.
|
||||
if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost())
|
||||
{
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
original->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
original->remove(card->getReducedManaCost());
|
||||
card->getManaCost()->copy(original);
|
||||
if(card->getManaCost()->extraCosts)
|
||||
int color = 0;
|
||||
string type = "";
|
||||
//only do any of the following if a card with the stated ability is in your hand.
|
||||
ManaCost * original = NEW ManaCost();
|
||||
ManaCost * alternate = NEW ManaCost();
|
||||
original->copy(card->model->data->getManaCost());
|
||||
alternate->copy(card->model->data->getManaCost()->getAlternative());
|
||||
if (card->has(Constants::PAYZERO))
|
||||
original = ManaCost::parseManaCost("{0}",NULL,card);//can't figure out 2 or more alternative...
|
||||
//have to run alter cost before affinity or the 2 cancel each other out.
|
||||
if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost())
|
||||
{
|
||||
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
{
|
||||
card->getManaCost()->extraCosts->costs[i]->setSource(card);
|
||||
original->add(card->getIncreasedManaCost());
|
||||
for(int kc = Constants::MTG_COLOR_ARTIFACT; kc < Constants::NB_Colors;kc++)
|
||||
{
|
||||
if (card->getManaCost()->getAlternative())
|
||||
{
|
||||
alternate->add(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
{
|
||||
original->remove(card->getReducedManaCost());
|
||||
for(int kc = Constants::MTG_COLOR_ARTIFACT; kc < Constants::NB_Colors;kc++)
|
||||
{
|
||||
if (card->getManaCost()->getAlternative())
|
||||
{
|
||||
alternate->remove(kc,card->getReducedManaCost()->getCost(kc));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(card->getManaCost())
|
||||
card->getManaCost()->copy(original);
|
||||
if(card->getManaCost()->getAlternative())
|
||||
card->getManaCost()->setAlternative(alternate);
|
||||
if(card->getManaCost()->extraCosts)
|
||||
{
|
||||
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
|
||||
{
|
||||
card->getManaCost()->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int reducem = 0;
|
||||
bool resetCost = false;
|
||||
for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
|
||||
{
|
||||
ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
|
||||
if(newAff)
|
||||
int reducem = 0;
|
||||
bool resetCost = false;
|
||||
for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
|
||||
{
|
||||
if(!resetCost)
|
||||
ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
|
||||
if(newAff)
|
||||
{
|
||||
resetCost = true;
|
||||
if(!resetCost)
|
||||
{
|
||||
resetCost = true;
|
||||
card->getManaCost()->copy(original);
|
||||
if(card->getManaCost()->extraCosts)
|
||||
{
|
||||
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
|
||||
{
|
||||
card->getManaCost()->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
TargetChooserFactory tf(this);
|
||||
TargetChooser * tcn = tf.createTargetChooser(newAff->tcString,card,NULL);
|
||||
|
||||
for (int w = 0; w < 2; ++w)
|
||||
{
|
||||
Player *p = this->players[w];
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
MTGGameZone * z = zones[k];
|
||||
if (tcn->targetsZone(z))
|
||||
{
|
||||
reducem += z->countByCanTarget(tcn);
|
||||
}
|
||||
}
|
||||
}
|
||||
SAFE_DELETE(tcn);
|
||||
ManaCost * removingCost = ManaCost::parseManaCost(newAff->manaString);
|
||||
for(int j = 0; j < reducem; j++)
|
||||
card->getManaCost()->remove(removingCost);
|
||||
SAFE_DELETE(removingCost);
|
||||
}
|
||||
}
|
||||
if(card->has(Constants::AFFINITYARTIFACTS)||
|
||||
card->has(Constants::AFFINITYFOREST)||
|
||||
card->has(Constants::AFFINITYGREENCREATURES)||
|
||||
card->has(Constants::AFFINITYISLAND)||
|
||||
card->has(Constants::AFFINITYMOUNTAIN)||
|
||||
card->has(Constants::AFFINITYPLAINS)||
|
||||
card->has(Constants::AFFINITYSWAMP)){
|
||||
if (card->has(Constants::AFFINITYARTIFACTS))
|
||||
{
|
||||
type = "artifact";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYSWAMP))
|
||||
{
|
||||
type = "swamp";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYMOUNTAIN))
|
||||
{
|
||||
type = "mountain";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYPLAINS))
|
||||
{
|
||||
type = "plains";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYISLAND))
|
||||
{
|
||||
type = "island";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYFOREST))
|
||||
{
|
||||
type = "forest";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
color = 1;
|
||||
type = "creature";
|
||||
}
|
||||
card->getManaCost()->copy(original);
|
||||
if(card->getManaCost()->extraCosts)
|
||||
{
|
||||
@@ -1001,97 +1106,103 @@ void GameObserver::Affinity()
|
||||
card->getManaCost()->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
TargetChooserFactory tf(this);
|
||||
TargetChooser * tcn = tf.createTargetChooser(newAff->tcString,card,NULL);
|
||||
|
||||
for (int w = 0; w < 2; ++w)
|
||||
{
|
||||
Player *p = this->players[w];
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
|
||||
for (int k = 0; k < 6; k++)
|
||||
int reduce = 0;
|
||||
if(card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
MTGGameZone * z = zones[k];
|
||||
if (tcn->targetsZone(z))
|
||||
{
|
||||
reducem += z->countByCanTarget(tcn);
|
||||
}
|
||||
TargetChooserFactory tf(this);
|
||||
TargetChooser * tc = tf.createTargetChooser("creature[green]",NULL);
|
||||
reduce = card->controller()->game->battlefield->countByCanTarget(tc);
|
||||
SAFE_DELETE(tc);
|
||||
}
|
||||
else
|
||||
{
|
||||
reduce = card->controller()->game->battlefield->countByType(type);
|
||||
}
|
||||
for(int i = 0; i < reduce;i++)
|
||||
{
|
||||
if(card->getManaCost()->getCost(color) > 0)
|
||||
card->getManaCost()->remove(color,1);
|
||||
}
|
||||
|
||||
}
|
||||
SAFE_DELETE(original);
|
||||
}//end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameObserver::ComputeTrinisphere()
|
||||
{
|
||||
for (int td = 0; td < 2; td++)
|
||||
{
|
||||
MTGGameZone * dzones[] = { players[td]->game->graveyard, players[td]->game->hand, players[td]->game->library, players[td]->game->exile };
|
||||
for (int tk = 0; tk < 4; tk++)
|
||||
{
|
||||
MTGGameZone * zone = dzones[tk];
|
||||
for (int ct = zone->nb_cards - 1; ct >= 0; ct--)
|
||||
{
|
||||
if(zone->cards[ct]->has(Constants::TRINISPHERE))
|
||||
{
|
||||
if(zone->cards[ct]->getManaCost()->getConvertedCost() == 2)
|
||||
{
|
||||
zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
zone->cards[ct]->tmodifier = 1;
|
||||
}
|
||||
else if(zone->cards[ct]->getManaCost()->getConvertedCost() == 1)
|
||||
{
|
||||
zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 2);
|
||||
zone->cards[ct]->tmodifier = 2;
|
||||
}
|
||||
else if(zone->cards[ct]->getManaCost()->getConvertedCost() < 1)
|
||||
{
|
||||
zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 3);
|
||||
zone->cards[ct]->tmodifier = 3;
|
||||
}
|
||||
if(zone->cards[ct]->getManaCost()->getAlternative())
|
||||
{
|
||||
ManaCost * currentAlternate = NEW ManaCost();
|
||||
currentAlternate->copy(zone->cards[ct]->getManaCost()->getAlternative());
|
||||
if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 2)
|
||||
zone->cards[ct]->tmodifierb = 1;
|
||||
else if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 1)
|
||||
zone->cards[ct]->tmodifierb = 2;
|
||||
else if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() < 1)
|
||||
zone->cards[ct]->tmodifierb = 3;
|
||||
currentAlternate->add(Constants::MTG_COLOR_ARTIFACT, zone->cards[ct]->tmodifierb);
|
||||
zone->cards[ct]->getManaCost()->setAlternative(currentAlternate);
|
||||
}
|
||||
}
|
||||
else
|
||||
RemoveTrinisphere(zone->cards[ct]);
|
||||
if(zone->cards[ct]->getManaCost()->extraCosts)
|
||||
{
|
||||
for(unsigned int i = 0; i < zone->cards[ct]->getManaCost()->extraCosts->costs.size();i++)
|
||||
{
|
||||
zone->cards[ct]->getManaCost()->extraCosts->costs[i]->setSource(zone->cards[ct]);
|
||||
}
|
||||
SAFE_DELETE(tcn);
|
||||
ManaCost * removingCost = ManaCost::parseManaCost(newAff->manaString);
|
||||
for(int j = 0; j < reducem; j++)
|
||||
card->getManaCost()->remove(removingCost);
|
||||
SAFE_DELETE(removingCost);
|
||||
}
|
||||
}
|
||||
if(card->has(Constants::AFFINITYARTIFACTS)||
|
||||
card->has(Constants::AFFINITYFOREST)||
|
||||
card->has(Constants::AFFINITYGREENCREATURES)||
|
||||
card->has(Constants::AFFINITYISLAND)||
|
||||
card->has(Constants::AFFINITYMOUNTAIN)||
|
||||
card->has(Constants::AFFINITYPLAINS)||
|
||||
card->has(Constants::AFFINITYSWAMP)){
|
||||
if (card->has(Constants::AFFINITYARTIFACTS))
|
||||
{
|
||||
type = "artifact";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYSWAMP))
|
||||
{
|
||||
type = "swamp";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYMOUNTAIN))
|
||||
{
|
||||
type = "mountain";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYPLAINS))
|
||||
{
|
||||
type = "plains";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYISLAND))
|
||||
{
|
||||
type = "island";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYFOREST))
|
||||
{
|
||||
type = "forest";
|
||||
}
|
||||
else if (card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
color = 1;
|
||||
type = "creature";
|
||||
}
|
||||
card->getManaCost()->copy(original);
|
||||
if(card->getManaCost()->extraCosts)
|
||||
{
|
||||
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
|
||||
{
|
||||
card->getManaCost()->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
}
|
||||
int reduce = 0;
|
||||
if(card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
TargetChooserFactory tf(this);
|
||||
TargetChooser * tc = tf.createTargetChooser("creature[green]",NULL);
|
||||
reduce = card->controller()->game->battlefield->countByCanTarget(tc);
|
||||
SAFE_DELETE(tc);
|
||||
}
|
||||
else
|
||||
{
|
||||
reduce = card->controller()->game->battlefield->countByType(type);
|
||||
}
|
||||
for(int i = 0; i < reduce;i++)
|
||||
{
|
||||
if(card->getManaCost()->getCost(color) > 0)
|
||||
card->getManaCost()->remove(color,1);
|
||||
}
|
||||
|
||||
}
|
||||
SAFE_DELETE(original);
|
||||
}
|
||||
}
|
||||
}
|
||||
void GameObserver::RemoveTrinisphere(MTGCardInstance * card)
|
||||
{
|
||||
if(card->has(Constants::TRINISPHERE))
|
||||
return;
|
||||
if(card->tmodifier)
|
||||
{
|
||||
card->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, card->tmodifier);
|
||||
card->tmodifier = 0;
|
||||
}
|
||||
if(card->getManaCost()->getAlternative() && card->tmodifierb)
|
||||
{
|
||||
ManaCost * newalternate = NEW ManaCost();
|
||||
newalternate->copy(card->getManaCost()->getAlternative());
|
||||
newalternate->remove(Constants::MTG_COLOR_ARTIFACT, card->tmodifierb);
|
||||
card->getManaCost()->setAlternative(newalternate);
|
||||
card->tmodifierb = 0;
|
||||
}
|
||||
}
|
||||
void GameObserver::Render()
|
||||
{
|
||||
if(mLayers)
|
||||
@@ -1134,6 +1245,8 @@ void GameObserver::ButtonPressed(PlayGuiObject * target)
|
||||
}
|
||||
else if (GuiGraveyard* graveyard = dynamic_cast<GuiGraveyard*>(target))
|
||||
graveyard->toggleDisplay();
|
||||
else if (GuiExile* exile = dynamic_cast<GuiExile*>(target))
|
||||
exile->toggleDisplay();
|
||||
//opponenthand
|
||||
else if (GuiOpponentHand* opponentHand = dynamic_cast<GuiOpponentHand*>(target))
|
||||
if (opponentHand->showCards)
|
||||
@@ -1255,6 +1368,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object, bool lo
|
||||
{
|
||||
Player * clickedPlayer = NULL;
|
||||
int toReturn = 0;
|
||||
int handmodified = 0;
|
||||
MTGGameZone* zone = NULL;
|
||||
size_t index = 0;
|
||||
MTGCardInstance* backup = NULL;
|
||||
@@ -1372,8 +1486,11 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object, bool lo
|
||||
}
|
||||
|
||||
//Current player's hand
|
||||
handmodified = currentPlayer->handsize+currentPlayer->handmodifier;
|
||||
if(handmodified < 0)
|
||||
handmodified = 0;
|
||||
if (currentPlayer->game->hand->hasCard(card) && mCurrentGamePhase == MTG_PHASE_CLEANUP
|
||||
&& currentPlayer->game->hand->nb_cards > currentPlayer->handsize && currentPlayer->nomaxhandsize == false)
|
||||
&& currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false)
|
||||
{
|
||||
WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]);
|
||||
receiveEvent(e);
|
||||
|
||||
@@ -14,26 +14,34 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) :
|
||||
self->zoom = 0.9f;
|
||||
Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 1, false, mpDuelLayers->getRenderedPlayer(), this));
|
||||
Add(selfLibrary = NEW GuiLibrary(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 5 + GuiGameZone::Height + 5, false, mpDuelLayers->getRenderedPlayer(), this));
|
||||
//myexile
|
||||
Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 30, false, mpDuelLayers->getRenderedPlayer(), this));
|
||||
|
||||
Add(opponent = NEW GuiAvatar(0, 0, false, mpDuelLayers->getRenderedPlayerOpponent(), GuiAvatar::TOP_LEFT, this));
|
||||
opponent->zoom = 0.9f;
|
||||
//opponenthandveiw button
|
||||
Add(opponentHand = NEW GuiOpponentHand(-30 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10,
|
||||
//opponentExile
|
||||
Add(opponentExile = NEW GuiExile(-30 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10,
|
||||
false, mpDuelLayers->getRenderedPlayerOpponent(), this));
|
||||
//opponenthandveiwends
|
||||
//opponentGraveyard
|
||||
Add(opponentGraveyard = NEW GuiGraveyard(5 + GuiAvatar::Width * 1.4 - GuiGameZone::Width / 2, 5, false,
|
||||
mpDuelLayers->getRenderedPlayerOpponent(), this));
|
||||
//opponentHand
|
||||
Add(opponentHand = NEW GuiOpponentHand(-15 + GuiAvatar::Width * 1.4 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10, false,
|
||||
mpDuelLayers->getRenderedPlayerOpponent(), this));
|
||||
//opponentLibrary
|
||||
Add(opponentLibrary = NEW GuiLibrary(5 + GuiAvatar::Width * 1.4 - GuiGameZone::Width / 2, 5 + GuiGameZone::Height + 5, false,
|
||||
mpDuelLayers->getRenderedPlayerOpponent(), this));
|
||||
|
||||
observer->getCardSelector()->Add(self);
|
||||
observer->getCardSelector()->Add(selfGraveyard);
|
||||
observer->getCardSelector()->Add(selfExile);
|
||||
observer->getCardSelector()->Add(selfLibrary);
|
||||
observer->getCardSelector()->Add(opponent);
|
||||
observer->getCardSelector()->Add(opponentGraveyard);
|
||||
observer->getCardSelector()->Add(opponentExile);
|
||||
observer->getCardSelector()->Add(opponentLibrary);
|
||||
observer->getCardSelector()->Add(opponentHand);
|
||||
selfGraveyard->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
|
||||
selfGraveyard->alpha = selfExile->alpha = opponentExile->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
|
||||
}
|
||||
|
||||
float GuiAvatars::LeftBoundarySelf()
|
||||
@@ -50,15 +58,15 @@ void GuiAvatars::Activate(PlayGuiObject* c)
|
||||
c->zoom = 1.2f;
|
||||
c->mHasFocus = true;
|
||||
|
||||
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c) || (opponentHand == c))
|
||||
if ((opponentGraveyard == c) || (opponentExile == c) || (opponentLibrary == c) || (opponent == c) || (opponentHand == c))
|
||||
{
|
||||
opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 128.0f;
|
||||
opponentGraveyard->alpha = opponentExile->alpha = opponentLibrary->alpha = opponentHand->alpha = 128.0f;
|
||||
active = opponent;
|
||||
opponent->zoom = 1.2f;
|
||||
}
|
||||
else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c))
|
||||
else if ((selfGraveyard == c) || (selfExile == c) || (selfLibrary == c) || (self == c))
|
||||
{
|
||||
selfGraveyard->alpha = selfLibrary->alpha = 128.0f;
|
||||
selfGraveyard->alpha = selfExile->alpha = selfLibrary->alpha = 128.0f;
|
||||
self->zoom = 1.0f;
|
||||
active = self;
|
||||
}
|
||||
@@ -69,15 +77,15 @@ void GuiAvatars::Deactivate(PlayGuiObject* c)
|
||||
{
|
||||
c->zoom = 1.0;
|
||||
c->mHasFocus = false;
|
||||
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponentHand == c) || (opponent == c))
|
||||
if ((opponentGraveyard == c) || (opponentExile == c) || (opponentLibrary == c) || (opponentHand == c) || (opponent == c))
|
||||
{
|
||||
opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
|
||||
opponentGraveyard->alpha = opponentExile->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
|
||||
opponent->zoom = 0.9f;
|
||||
active = NULL;
|
||||
}
|
||||
else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c))
|
||||
else if ((selfGraveyard == c) || (selfExile == c) || (selfLibrary == c) || (self == c))
|
||||
{
|
||||
selfGraveyard->alpha = selfLibrary->alpha = 0;
|
||||
selfGraveyard->alpha = selfExile->alpha = selfLibrary->alpha = 0;
|
||||
self->zoom = 0.5f;
|
||||
active = NULL;
|
||||
}
|
||||
@@ -85,13 +93,15 @@ void GuiAvatars::Deactivate(PlayGuiObject* c)
|
||||
|
||||
int GuiAvatars::receiveEventPlus(WEvent* e)
|
||||
{
|
||||
return selfGraveyard->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e);
|
||||
return selfGraveyard->receiveEventPlus(e) | selfExile->receiveEventPlus(e) | opponentExile->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e);
|
||||
}
|
||||
|
||||
int GuiAvatars::receiveEventMinus(WEvent* e)
|
||||
{
|
||||
selfGraveyard->receiveEventMinus(e);
|
||||
selfExile->receiveEventMinus(e);
|
||||
opponentGraveyard->receiveEventMinus(e);
|
||||
opponentExile->receiveEventMinus(e);
|
||||
opponentHand->receiveEventMinus(e);
|
||||
return 1;
|
||||
}
|
||||
@@ -104,8 +114,12 @@ bool GuiAvatars::CheckUserInput(JButton key)
|
||||
return true;
|
||||
if (selfGraveyard->CheckUserInput(key))
|
||||
return true;
|
||||
if (selfExile->CheckUserInput(key))
|
||||
return true;
|
||||
if (opponentGraveyard->CheckUserInput(key))
|
||||
return true;
|
||||
if (opponentExile->CheckUserInput(key))
|
||||
return true;
|
||||
if (opponentHand->CheckUserInput(key))
|
||||
return true;
|
||||
if (selfLibrary->CheckUserInput(key))
|
||||
@@ -120,8 +134,10 @@ void GuiAvatars::Update(float dt)
|
||||
self->Update(dt);
|
||||
opponent->Update(dt);
|
||||
selfGraveyard->Update(dt);
|
||||
selfExile->Update(dt);
|
||||
opponentHand->Update(dt);
|
||||
opponentGraveyard->Update(dt);
|
||||
opponentExile->Update(dt);
|
||||
selfLibrary->Update(dt);
|
||||
opponentLibrary->Update(dt);
|
||||
}
|
||||
@@ -133,10 +149,12 @@ void GuiAvatars::Render()
|
||||
float h = 54;
|
||||
if (opponent == active)
|
||||
{
|
||||
r->FillRect(opponent->actX, opponent->actY, 40 * opponent->actZ, h+20 * opponent->actZ, ARGB(200,0,0,0));
|
||||
r->FillRect(opponent->actX, opponent->actY, w * opponent->actZ, h * opponent->actZ, ARGB(200,0,0,0));
|
||||
}
|
||||
else if (self == active)
|
||||
{
|
||||
r->FillRect(self->actX - w * self->actZ - 4.5f, self->actY - h-28 * self->actZ, 24 * self->actZ, h+28 * self->actZ, ARGB(200,0,0,0));
|
||||
r->FillRect(self->actX - w * self->actZ - 4.5f, self->actY - h * self->actZ, w * self->actZ, h * self->actZ, ARGB(200,0,0,0));
|
||||
}
|
||||
GuiLayer::Render();
|
||||
|
||||
@@ -412,6 +412,8 @@ int GuiPlay::receiveEventPlus(WEvent * e)
|
||||
Replace();
|
||||
else if (dynamic_cast<WEventCardUnattached*> (e))
|
||||
Replace();
|
||||
else if (dynamic_cast<WEventCardEquipped*> (e))
|
||||
Replace();
|
||||
else if (dynamic_cast<WEventCardControllerChange*> (e))
|
||||
Replace();
|
||||
Replace();
|
||||
|
||||
@@ -164,7 +164,10 @@ void GuiGameZone::Render()
|
||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||
float scale = defaultHeight / quad->mHeight;
|
||||
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);
|
||||
|
||||
float x0 = actX;
|
||||
@@ -182,7 +185,16 @@ void GuiGameZone::Render()
|
||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||
char buffer[11];
|
||||
int mAlpha = (int) (actA);
|
||||
sprintf(buffer, "%i", zone->nb_cards);
|
||||
/*if(type == GUI_GRAVEYARD)
|
||||
sprintf(buffer, "%i\ng", zone->nb_cards);
|
||||
else if(type == GUI_LIBRARY)
|
||||
sprintf(buffer, "%i\nl", zone->nb_cards);
|
||||
else if(type == GUI_OPPONENTHAND)
|
||||
sprintf(buffer, "%i\nh", zone->nb_cards);
|
||||
else if(type == GUI_EXILE)
|
||||
sprintf(buffer, "%i\ne", zone->nb_cards);
|
||||
else*/
|
||||
sprintf(buffer, "%i", zone->nb_cards);
|
||||
mFont->SetColor(ARGB(mAlpha,0,0,0));
|
||||
mFont->DrawString(buffer, x0 + 1, actY + 1);
|
||||
if (actA > 120)
|
||||
@@ -298,6 +310,52 @@ ostream& GuiGraveyard::toString(ostream& out) const
|
||||
return out << "GuiGraveyard :::";
|
||||
}
|
||||
|
||||
GuiExile::GuiExile(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) :
|
||||
GuiGameZone(x, y, hasFocus, player->game->exile, parent), player(player)
|
||||
{
|
||||
type = GUI_EXILE;
|
||||
}
|
||||
|
||||
int GuiExile::receiveEventPlus(WEvent* e)
|
||||
{
|
||||
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||
if (event->to == zone)
|
||||
{
|
||||
CardView* t;
|
||||
if (event->card->view)
|
||||
t = NEW CardView(CardView::nullZone, event->card, *(event->card->view));
|
||||
else
|
||||
t = NEW CardView(CardView::nullZone, event->card, x, y);
|
||||
t->x = x + Width / 2;
|
||||
t->y = y + Height / 2;
|
||||
t->zoom = 0.6f;
|
||||
t->alpha = 0;
|
||||
cards.push_back(t);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GuiExile::receiveEventMinus(WEvent* e)
|
||||
{
|
||||
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||
if (event->from == zone)
|
||||
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||
if (event->card->previous == (*it)->card)
|
||||
{
|
||||
CardView* cv = *it;
|
||||
cards.erase(it);
|
||||
zone->owner->getObserver()->mTrash->trash(cv);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ostream& GuiExile::toString(ostream& out) const
|
||||
{
|
||||
return out << "GuiExile :::";
|
||||
}
|
||||
|
||||
//opponenthand begins
|
||||
GuiOpponentHand::GuiOpponentHand(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) :
|
||||
GuiGameZone(x, y, hasFocus, player->game->hand, parent), player(player)
|
||||
|
||||
@@ -310,6 +310,21 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
check = restriction[i].find("rebound");
|
||||
if(check != string::npos)
|
||||
{
|
||||
int count = 0;
|
||||
for(unsigned int k = 0; k < player->game->stack->cardsSeenThisTurn.size(); k++)
|
||||
{
|
||||
MTGCardInstance * stackCard = player->game->stack->cardsSeenThisTurn[k];
|
||||
if(stackCard->next && stackCard->next == card && card->previousZone == card->controller()->game->hand)
|
||||
count++;
|
||||
if(stackCard == card && card->previousZone == card->controller()->game->hand)
|
||||
count++;
|
||||
}
|
||||
if(!count)
|
||||
return 0;
|
||||
}
|
||||
check = restriction[i].find("morbid");
|
||||
if(check != string::npos)
|
||||
{
|
||||
@@ -558,8 +573,8 @@ int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option)
|
||||
{
|
||||
if (player && player != observer->players[i])
|
||||
continue;
|
||||
MTGGameZone * zones[] = { observer->players[i]->game->inPlay, observer->players[i]->game->graveyard, observer->players[i]->game->hand };
|
||||
for (int k = 0; k < 3; k++)
|
||||
MTGGameZone * zones[] = { observer->players[i]->game->inPlay, observer->players[i]->game->graveyard, observer->players[i]->game->hand, observer->players[i]->game->exile };
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
for (int j = zones[k]->nb_cards - 1; j >= 0; j--)
|
||||
{
|
||||
@@ -1064,6 +1079,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
MTGGameZone * dest)
|
||||
{
|
||||
size_t found;
|
||||
bool asAlternate = false;
|
||||
trim(s);
|
||||
//TODO This block redundant with calling function
|
||||
if (!card && spell)
|
||||
@@ -1073,7 +1089,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
MTGCardInstance * target = card->target;
|
||||
if (!target)
|
||||
target = card;
|
||||
|
||||
//pay and castcard?
|
||||
if(s.find("castcard(restricted") != string::npos && (s.find("pay(") != string::npos || s.find("pay[[") != string::npos))
|
||||
asAlternate = true;
|
||||
//MTG Specific rules
|
||||
//adds the bonus credit system
|
||||
found = s.find("bonusrule");
|
||||
@@ -1571,7 +1589,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
vector<string> splitMayPay = parseBetween(s, "pay(", ")", true);
|
||||
if(splitMayPay.size())
|
||||
{
|
||||
GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPay[1],storedPayString);
|
||||
GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPay[1],storedPayString,asAlternate);
|
||||
a->oneShot = 1;
|
||||
a->canBeInterrupted = false;
|
||||
return a;
|
||||
@@ -2076,7 +2094,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
vector<string> splitMayPaysub = parseBetween(s, "pay[[","]]", true);
|
||||
if (splitMayPaysub.size())
|
||||
{
|
||||
GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPaysub[1],storedPayString);
|
||||
GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPaysub[1],storedPayString,asAlternate);
|
||||
a->oneShot = 1;
|
||||
a->canBeInterrupted = false;
|
||||
return a;
|
||||
@@ -2565,6 +2583,15 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
}
|
||||
|
||||
//modify hand size - reduce maximum or increase
|
||||
vector<string> splitHandMod = parseBetween(s, "hmodifer:", " ", false);
|
||||
if (splitHandMod.size())
|
||||
{
|
||||
Damageable * t = spell ? spell->getNextDamageableTarget() : NULL;
|
||||
MTGAbility * a = NEW AModifyHand(observer, id, card, t, splitHandMod[1], who);
|
||||
return a;
|
||||
}
|
||||
|
||||
//set hand size
|
||||
vector<string> splitSetHand = parseBetween(s, "sethand:", " ", false);
|
||||
if (splitSetHand.size())
|
||||
@@ -3412,6 +3439,7 @@ MTGAbility * AbilityFactory::parsePhaseActionAbility(string s,MTGCardInstance *
|
||||
bool opponentturn = (s1.find("my") == string::npos);
|
||||
bool myturn = (s1.find("opponent") == string::npos);
|
||||
bool sourceinPlay = (s1.find("sourceinplay") != string::npos);
|
||||
bool checkexile = (s1.find("checkex") != string::npos);
|
||||
bool next = (s1.find("next") == string::npos); //Why is this one the opposite of the two others? That's completely inconsistent
|
||||
bool once = (s1.find("once") != string::npos);
|
||||
|
||||
@@ -3420,7 +3448,7 @@ MTGAbility * AbilityFactory::parsePhaseActionAbility(string s,MTGCardInstance *
|
||||
_target = spell->getNextCardTarget();
|
||||
if(!_target)
|
||||
_target = target;
|
||||
return NEW APhaseActionGeneric(observer, id, card,_target, trim(splitActions[2]), restrictions, phase,sourceinPlay,next,myturn,opponentturn,once);
|
||||
return NEW APhaseActionGeneric(observer, id, card,_target, trim(splitActions[2]), restrictions, phase,sourceinPlay,next,myturn,opponentturn,once,checkexile);
|
||||
}
|
||||
|
||||
MTGAbility * AbilityFactory::parseChooseActionAbility(string s,MTGCardInstance * card,Spell *,MTGCardInstance * target, int, int id)
|
||||
@@ -5257,8 +5285,8 @@ void ListMaintainerAbility::updateTargets()
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = game->players[i];
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack };
|
||||
for (int k = 0; k < 5; k++)
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
MTGGameZone * zone = zones[k];
|
||||
if (canTarget(zone))
|
||||
@@ -5329,8 +5357,8 @@ void ListMaintainerAbility::checkTargets()
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = game->players[i];
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack };
|
||||
for (int k = 0; k < 5; k++)
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
MTGGameZone * zone = zones[k];
|
||||
if (canTarget(zone))
|
||||
|
||||
@@ -65,6 +65,9 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
||||
LKItoughness = toughness;
|
||||
cardistargetted = 0;
|
||||
cardistargetter = 0;
|
||||
tmodifier = 0;
|
||||
tmodifierb = 0;
|
||||
myconvertedcost = getManaCost()->getConvertedCost();
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGCardInstance::createSnapShot()
|
||||
|
||||
@@ -147,7 +147,9 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"madness",
|
||||
"protectionfromcoloredspells",
|
||||
"mygcreatureexiler",
|
||||
"oppgcreatureexiler"
|
||||
"oppgcreatureexiler",
|
||||
"payzero",
|
||||
"trinisphere"
|
||||
};
|
||||
|
||||
map<string,int> Constants::MTGBasicAbilitiesMap;
|
||||
|
||||
@@ -1289,6 +1289,10 @@ ostream& operator<<(ostream& out, const MTGPlayerCards& z)
|
||||
out << "hand=";
|
||||
out << *(z.hand) << endl;
|
||||
}
|
||||
if(z.removedFromGame->cards.size()) {
|
||||
out << "exile=";
|
||||
out << *(z.hand) << endl;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -1321,6 +1325,11 @@ bool MTGPlayerCards::parseLine(const string& s)
|
||||
battlefield->parseLine(s.substr(limiter+1));
|
||||
return true;
|
||||
}
|
||||
else if (areaS.compare("removedfromgame") == 0 || areaS.compare("exile") == 0)
|
||||
{
|
||||
removedFromGame->parseLine(s.substr(limiter+1));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -35,6 +35,7 @@ Player::Player(GameObserver *observer, string file, string fileSmall, MTGDeck *
|
||||
drawCounter = 0;
|
||||
epic = 0;
|
||||
raidcount = 0;
|
||||
handmodifier = 0;
|
||||
prowledTypes.clear();
|
||||
doesntEmpty = NEW ManaCost();
|
||||
poolDoesntEmpty = NEW ManaCost();
|
||||
|
||||
@@ -79,8 +79,8 @@ MTGCardInstance * Rules::getCardByMTGId(GameObserver* g, int mtgid)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = g->players[i];
|
||||
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard };
|
||||
for (int j = 0; j < 4; j++)
|
||||
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->exile };
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
MTGGameZone * zone = zones[j];
|
||||
for (int k = 0; k < zone->nb_cards; k++)
|
||||
@@ -340,9 +340,10 @@ MTGDeck * Rules::buildDeck(int playerId)
|
||||
MTGGameZone * loadedPlayerZones[] = { initState.playerData[playerId].player->game->graveyard,
|
||||
initState.playerData[playerId].player->game->library,
|
||||
initState.playerData[playerId].player->game->hand,
|
||||
initState.playerData[playerId].player->game->inPlay };
|
||||
initState.playerData[playerId].player->game->inPlay,
|
||||
initState.playerData[playerId].player->game->exile };
|
||||
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
|
||||
{
|
||||
@@ -412,12 +413,13 @@ void Rules::initGame(GameObserver *g, bool currentPlayerSet)
|
||||
{
|
||||
p->mAvatarName = initState.playerData[i].player->mAvatarName;
|
||||
}
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile };
|
||||
MTGGameZone * loadedPlayerZones[] = { initState.playerData[i].player->game->graveyard,
|
||||
initState.playerData[i].player->game->library,
|
||||
initState.playerData[i].player->game->hand,
|
||||
initState.playerData[i].player->game->inPlay };
|
||||
for (int j = 0; j < 4; j++)
|
||||
initState.playerData[i].player->game->inPlay,
|
||||
initState.playerData[i].player->game->exile };
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
MTGGameZone * zone = playerZones[j];
|
||||
for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
|
||||
|
||||
@@ -739,6 +739,10 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
return NEW CardTargetChooser(observer, card->storedSourceCard, card, zones, nbzones);
|
||||
}
|
||||
else if (typeName.compare("abilitycontroller") == 0)
|
||||
{
|
||||
return NEW PlayerTargetChooser(observer, card, 1, card->storedSourceCard->controller());
|
||||
}
|
||||
else
|
||||
{
|
||||
tc = NEW TypeTargetChooser(observer, typeName.c_str(), zones, nbzones, card, maxtargets, other, targetMin);
|
||||
|
||||
@@ -50,8 +50,8 @@ MTGCardInstance * TestSuiteAI::getCard(string action)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = observer->players[i];
|
||||
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard };
|
||||
for (int j = 0; j < 4; j++)
|
||||
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->removedFromGame };
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
MTGGameZone * zone = zones[j];
|
||||
for (int k = 0; k < zone->nb_cards; k++)
|
||||
@@ -398,12 +398,13 @@ void TestSuiteGame::assertGame()
|
||||
error++;
|
||||
|
||||
}
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->removedFromGame };
|
||||
MTGGameZone * endstateZones[] = { endState.players[i]->game->graveyard,
|
||||
endState.players[i]->game->library,
|
||||
endState.players[i]->game->hand,
|
||||
endState.players[i]->game->inPlay };
|
||||
for (int j = 0; j < 4; j++)
|
||||
endState.players[i]->game->inPlay,
|
||||
endState.players[i]->game->removedFromGame };
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
MTGGameZone * zone = playerZones[j];
|
||||
if (zone->nb_cards != endstateZones[j]->nb_cards)
|
||||
@@ -857,12 +858,13 @@ void TestSuiteGame::initGame()
|
||||
stringstream stream;
|
||||
initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream);
|
||||
p->getRandomGenerator()->loadRandValues(stream.str());
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
|
||||
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->removedFromGame };
|
||||
MTGGameZone * loadedPlayerZones[] = { initState.players[i]->game->graveyard,
|
||||
initState.players[i]->game->library,
|
||||
initState.players[i]->game->hand,
|
||||
initState.players[i]->game->inPlay };
|
||||
for (int j = 0; j < 4; j++)
|
||||
initState.players[i]->game->inPlay,
|
||||
initState.players[i]->game->removedFromGame };
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
MTGGameZone * zone = playerZones[j];
|
||||
for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
|
||||
@@ -914,9 +916,10 @@ MTGPlayerCards * TestSuiteGame::buildDeck(Player* player, int playerId)
|
||||
MTGGameZone * loadedPlayerZones[] = { initState.players[playerId]->game->graveyard,
|
||||
initState.players[playerId]->game->library,
|
||||
initState.players[playerId]->game->hand,
|
||||
initState.players[playerId]->game->removedFromGame,
|
||||
initState.players[playerId]->game->inPlay };
|
||||
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
|
||||
{
|
||||
|
||||
@@ -165,6 +165,11 @@ WEventCardUnattached::WEventCardUnattached(MTGCardInstance * card) :
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardEquipped::WEventCardEquipped(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardControllerChange::WEventCardControllerChange(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
@@ -324,6 +329,12 @@ Targetable * WEventCardUnattached::getTarget(int target)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardEquipped::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardControllerChange::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
|
||||
Reference in New Issue
Block a user