first moved the def of handsize for a game into the rules.txt as discussed with wololo...
this update requires you to update your rules folder files!!! 2nd added 2 new vanguard game modes. Stone Hewer Basic - when ever a creature enters play, a random equipment with a converted mana cost less than or equal to that creature is put into play and attached to it. this mode is unlockable, requirement = win a match where 10 or more equipment were in the battlefeild at the moment you won. Hermit Druid basic- in this game mode, during each of the players upkeeps, a random land card from their deck is placed into the battlefield, these do not count against your 1 land per turn limit. to unlock this, win any match with less then 10 lands.
This commit is contained in:
@@ -185,6 +185,10 @@ public:
|
|||||||
{
|
{
|
||||||
intValue = target->getToughness();
|
intValue = target->getToughness();
|
||||||
}
|
}
|
||||||
|
else if (s == "handsize")
|
||||||
|
{
|
||||||
|
intValue = target->controller()->handsize;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
intValue = atoi(s.c_str());
|
intValue = atoi(s.c_str());
|
||||||
@@ -2982,6 +2986,21 @@ public:
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//set a players hand size
|
||||||
|
class AASetHand: public ActivatedAbilityTP
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int hand;
|
||||||
|
|
||||||
|
AASetHand(int _id, MTGCardInstance * _source, Targetable * _target, int hand, ManaCost * _cost = NULL,
|
||||||
|
int who = TargetChooser::UNSET);
|
||||||
|
int resolve();
|
||||||
|
const char * getMenuText();
|
||||||
|
AASetHand * clone() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
//lifeset
|
//lifeset
|
||||||
class AALifeSet: public ActivatedAbilityTP
|
class AALifeSet: public ActivatedAbilityTP
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ private:
|
|||||||
time_t gameLength;
|
time_t gameLength;
|
||||||
int isDifficultyUnlocked(DeckStats * stats);
|
int isDifficultyUnlocked(DeckStats * stats);
|
||||||
int isMomirUnlocked();
|
int isMomirUnlocked();
|
||||||
|
int isStoneHewerUnlocked();
|
||||||
|
int isHermitUnlocked();
|
||||||
int isEvilTwinUnlocked();
|
int isEvilTwinUnlocked();
|
||||||
int isRandomDeckUnlocked();
|
int isRandomDeckUnlocked();
|
||||||
int IsMoreAIDecksUnlocked(DeckStats * stats);
|
int IsMoreAIDecksUnlocked(DeckStats * stats);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class Damageable:public Targetable
|
|||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
int life;
|
int life;
|
||||||
|
int handsize;
|
||||||
int poisonCount;
|
int poisonCount;
|
||||||
int damageCount;
|
int damageCount;
|
||||||
int preventable;
|
int preventable;
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ enum
|
|||||||
GAME_TYPE_RANDOM2,
|
GAME_TYPE_RANDOM2,
|
||||||
GAME_TYPE_STORY,
|
GAME_TYPE_STORY,
|
||||||
GAME_TYPE_DEMO,
|
GAME_TYPE_DEMO,
|
||||||
|
GAME_TYPE_STONEHEWER,
|
||||||
|
GAME_TYPE_HERMIT,
|
||||||
|
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
GAME_TYPE_SLAVE,
|
GAME_TYPE_SLAVE,
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public:
|
|||||||
BEGIN_AWARDS, //Options after this use the GameOptionAward struct, which includes a timestamp.
|
BEGIN_AWARDS, //Options after this use the GameOptionAward struct, which includes a timestamp.
|
||||||
DIFFICULTY_MODE_UNLOCKED = BEGIN_AWARDS,
|
DIFFICULTY_MODE_UNLOCKED = BEGIN_AWARDS,
|
||||||
MOMIR_MODE_UNLOCKED,
|
MOMIR_MODE_UNLOCKED,
|
||||||
|
STONEHEWER_MODE_UNLOCKED,
|
||||||
|
HERMIT_MODE_UNLOCKED,
|
||||||
EVILTWIN_MODE_UNLOCKED,
|
EVILTWIN_MODE_UNLOCKED,
|
||||||
RANDOMDECK_MODE_UNLOCKED,
|
RANDOMDECK_MODE_UNLOCKED,
|
||||||
AWARD_COLLECTOR,
|
AWARD_COLLECTOR,
|
||||||
|
|||||||
@@ -342,6 +342,47 @@ public:
|
|||||||
virtual MTGMomirRule * clone() const;
|
virtual MTGMomirRule * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//stone hewer gaint avatar mode
|
||||||
|
class MTGStoneHewerRule: public MTGAbility
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int genRandomEquipId(int convertedCost);
|
||||||
|
static vector<int> pool[20];
|
||||||
|
static int initialized;
|
||||||
|
|
||||||
|
int textAlpha;
|
||||||
|
string text;
|
||||||
|
public:
|
||||||
|
|
||||||
|
int alreadyplayed;
|
||||||
|
MTGAllCards * collection;
|
||||||
|
MTGCardInstance * genEquip(int id);
|
||||||
|
int testDestroy();
|
||||||
|
void Update(float dt);
|
||||||
|
void Render();
|
||||||
|
MTGStoneHewerRule(int _id, MTGAllCards * _collection);
|
||||||
|
int receiveEvent(WEvent * event);
|
||||||
|
const char * getMenuText()
|
||||||
|
{
|
||||||
|
return "Stone Hewer";
|
||||||
|
}
|
||||||
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
virtual MTGStoneHewerRule * clone() const;
|
||||||
|
};
|
||||||
|
//Hermit Druid avatar mode
|
||||||
|
class MTGHermitRule: public MTGAbility
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int testDestroy();
|
||||||
|
MTGHermitRule(int _id);
|
||||||
|
int receiveEvent(WEvent * event);
|
||||||
|
const char * getMenuText()
|
||||||
|
{
|
||||||
|
return "Hermit";
|
||||||
|
}
|
||||||
|
virtual MTGHermitRule * clone() const;
|
||||||
|
};
|
||||||
|
//
|
||||||
/* LifeLink */
|
/* LifeLink */
|
||||||
class MTGLifelinkRule: public MTGAbility
|
class MTGLifelinkRule: public MTGAbility
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -927,13 +927,17 @@ int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCardInst
|
|||||||
if (!tc)
|
if (!tc)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (tc->source->controller() != this)
|
//Make sure we own the decision to choose the targets
|
||||||
{
|
assert(tc->source->controller() == this);
|
||||||
DebugTrace("AIPLAYER: Error, was asked to chose targets but I don't own the source of the targetController\n");
|
if (tc->source->controller() != this)
|
||||||
return 0;
|
{
|
||||||
}
|
gameObs->currentActionPlayer = tc->source->controller();
|
||||||
//Make sure we own the decision to choose the targets
|
//this is a hack, but if we hit this condition we are locked in a infinate loop
|
||||||
assert(tc->source->controller() == this);
|
//so lets give the tc to its owner
|
||||||
|
//todo:find the root cause of this.
|
||||||
|
DebugTrace("AIPLAYER: Error, was asked to chose targets but I don't own the source of the targetController\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
tc->initTargets(); //cleanup the targetchooser just in case.
|
tc->initTargets(); //cleanup the targetchooser just in case.
|
||||||
if (!(gameObs->currentlyActing() == this))
|
if (!(gameObs->currentlyActing() == this))
|
||||||
|
|||||||
@@ -1352,6 +1352,45 @@ AALifer * AALifer::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//players max hand size
|
||||||
|
AASetHand::AASetHand(int _id, MTGCardInstance * _source, Targetable * _target, int hand, ManaCost * _cost,
|
||||||
|
int who) :
|
||||||
|
ActivatedAbilityTP(_id, _source, _target, _cost, who), hand(hand)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int AASetHand::resolve()
|
||||||
|
{
|
||||||
|
Damageable * _target = (Damageable *) getTarget();
|
||||||
|
if (!_target)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Player * p = NULL;
|
||||||
|
if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||||
|
{
|
||||||
|
p = ((MTGCardInstance *) _target)->controller();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p = (Player*)_target;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->handsize = hand;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * AASetHand::getMenuText()
|
||||||
|
{
|
||||||
|
return "Set Hand Size";
|
||||||
|
}
|
||||||
|
|
||||||
|
AASetHand * AASetHand::clone() const
|
||||||
|
{
|
||||||
|
AASetHand * a = NEW AASetHand(*this);
|
||||||
|
a->isClone = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
//Lifeset
|
//Lifeset
|
||||||
AALifeSet::AALifeSet(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * life, ManaCost * _cost,
|
AALifeSet::AALifeSet(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * life, ManaCost * _cost,
|
||||||
|
|||||||
@@ -132,6 +132,20 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app)
|
|||||||
goa->giveAward();
|
goa->giveAward();
|
||||||
options.save();
|
options.save();
|
||||||
}
|
}
|
||||||
|
else if ((unlocked = isStoneHewerUnlocked()))
|
||||||
|
{
|
||||||
|
unlockedTextureName = "stonehewer_unlocked.png";
|
||||||
|
goa = (GameOptionAward*) &options[Options::STONEHEWER_MODE_UNLOCKED];
|
||||||
|
goa->giveAward();
|
||||||
|
options.save();
|
||||||
|
}
|
||||||
|
else if ((unlocked = isHermitUnlocked()))
|
||||||
|
{
|
||||||
|
unlockedTextureName = "hermit_unlocked.png";
|
||||||
|
goa = (GameOptionAward*) &options[Options::HERMIT_MODE_UNLOCKED];
|
||||||
|
goa->giveAward();
|
||||||
|
options.save();
|
||||||
|
}
|
||||||
else if ((unlocked = isEvilTwinUnlocked()))
|
else if ((unlocked = isEvilTwinUnlocked()))
|
||||||
{
|
{
|
||||||
unlockedTextureName = "eviltwin_unlocked.png";
|
unlockedTextureName = "eviltwin_unlocked.png";
|
||||||
@@ -338,6 +352,24 @@ int Credits::isMomirUnlocked()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Credits::isStoneHewerUnlocked()
|
||||||
|
{
|
||||||
|
if (options[Options::STONEHEWER_MODE_UNLOCKED].number)
|
||||||
|
return 0;
|
||||||
|
if (int(p1->game->inPlay->countByType("equipment") + p1->opponent()->game->inPlay->countByType("equipment")) > 10)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Credits::isHermitUnlocked()
|
||||||
|
{
|
||||||
|
if (options[Options::HERMIT_MODE_UNLOCKED].number)
|
||||||
|
return 0;
|
||||||
|
if (int(p1->game->inPlay->countByType("land")) < 10)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int Credits::isEvilTwinUnlocked()
|
int Credits::isEvilTwinUnlocked()
|
||||||
{
|
{
|
||||||
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
|
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ void GameObserver::nextGamePhase()
|
|||||||
if (currentGamePhase == Constants::MTG_PHASE_AFTER_EOT)
|
if (currentGamePhase == Constants::MTG_PHASE_AFTER_EOT)
|
||||||
{
|
{
|
||||||
//Auto Hand cleaning, in case the player didn't do it himself
|
//Auto Hand cleaning, in case the player didn't do it himself
|
||||||
while (currentPlayer->game->hand->nb_cards > 7 && currentPlayer->nomaxhandsize == false)
|
while (currentPlayer->game->hand->nb_cards > currentPlayer->handsize && currentPlayer->nomaxhandsize == false)
|
||||||
{
|
{
|
||||||
WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]);
|
WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]);
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
@@ -937,7 +937,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object)
|
|||||||
|
|
||||||
//Current player's hand
|
//Current player's hand
|
||||||
if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP
|
if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP
|
||||||
&& currentPlayer->game->hand->nb_cards > 7 && currentPlayer->nomaxhandsize == false)
|
&& currentPlayer->game->hand->nb_cards > currentPlayer->handsize && currentPlayer->nomaxhandsize == false)
|
||||||
{
|
{
|
||||||
WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]);
|
WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]);
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ const string Options::optionNames[] = {
|
|||||||
//Unlocked modes
|
//Unlocked modes
|
||||||
"prx_handler",
|
"prx_handler",
|
||||||
"prx_rimom",
|
"prx_rimom",
|
||||||
|
"prx_rewehenots",
|
||||||
|
"prx_timreh",
|
||||||
"prx_eviltwin",
|
"prx_eviltwin",
|
||||||
"prx_rnddeck",
|
"prx_rnddeck",
|
||||||
"aw_collector",
|
"aw_collector",
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ void GameStateAwards::Start()
|
|||||||
btn = NEW WGuiButton(aw, -103, Options::MOMIR_MODE_UNLOCKED, this);
|
btn = NEW WGuiButton(aw, -103, Options::MOMIR_MODE_UNLOCKED, this);
|
||||||
listview->Add(btn);
|
listview->Add(btn);
|
||||||
|
|
||||||
|
aw = NEW WGuiAward(Options::STONEHEWER_MODE_UNLOCKED, "Stone Hewer Mode", "Won with more than 10 equipments.");
|
||||||
|
btn = NEW WGuiButton(aw, -103, Options::STONEHEWER_MODE_UNLOCKED, this);
|
||||||
|
listview->Add(btn);
|
||||||
|
|
||||||
|
aw = NEW WGuiAward(Options::HERMIT_MODE_UNLOCKED, "Hermit Druid Mode", "Won with less than 10 lands.");
|
||||||
|
btn = NEW WGuiButton(aw, -103, Options::HERMIT_MODE_UNLOCKED, this);
|
||||||
|
listview->Add(btn);
|
||||||
|
|
||||||
aw = NEW WGuiAward(Options::EVILTWIN_MODE_UNLOCKED, "Evil Twin Mode", "Won with same army size.");
|
aw = NEW WGuiAward(Options::EVILTWIN_MODE_UNLOCKED, "Evil Twin Mode", "Won with same army size.");
|
||||||
btn = NEW WGuiButton(aw, -103, Options::EVILTWIN_MODE_UNLOCKED, this);
|
btn = NEW WGuiButton(aw, -103, Options::EVILTWIN_MODE_UNLOCKED, this);
|
||||||
listview->Add(btn);
|
listview->Add(btn);
|
||||||
|
|||||||
@@ -419,6 +419,14 @@ void GameStateDuel::Update(float dt)
|
|||||||
{
|
{
|
||||||
game->addObserver(NEW MTGMomirRule(-1, MTGCollection()));
|
game->addObserver(NEW MTGMomirRule(-1, MTGCollection()));
|
||||||
}
|
}
|
||||||
|
if (mParent->gameType == GAME_TYPE_STONEHEWER)
|
||||||
|
{
|
||||||
|
game->addObserver(NEW MTGStoneHewerRule(-1,MTGCollection()));
|
||||||
|
}
|
||||||
|
if (mParent->gameType == GAME_TYPE_HERMIT)
|
||||||
|
{
|
||||||
|
game->addObserver(NEW MTGHermitRule(-1));
|
||||||
|
}
|
||||||
|
|
||||||
//start of in game music code
|
//start of in game music code
|
||||||
musictrack = "";
|
musictrack = "";
|
||||||
@@ -611,7 +619,8 @@ void GameStateDuel::Render()
|
|||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
&& mParent->gameType != GAME_TYPE_SLAVE
|
&& mParent->gameType != GAME_TYPE_SLAVE
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
)
|
&& mParent->gameType != GAME_TYPE_STONEHEWER
|
||||||
|
&& mParent->gameType != GAME_TYPE_HERMIT)
|
||||||
mFont->DrawString(_("LOADING DECKS").c_str(), 0, SCREEN_HEIGHT / 2);
|
mFont->DrawString(_("LOADING DECKS").c_str(), 0, SCREEN_HEIGHT / 2);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ void GameStateMenu::fillScroller()
|
|||||||
scroller->Add(_("Unlock the difficult mode for more challenging duels!"));
|
scroller->Add(_("Unlock the difficult mode for more challenging duels!"));
|
||||||
if (!options[Options::MOMIR_MODE_UNLOCKED].number)
|
if (!options[Options::MOMIR_MODE_UNLOCKED].number)
|
||||||
scroller->Add(_("Interested in playing Momir Basic? You'll have to unlock it first :)"));
|
scroller->Add(_("Interested in playing Momir Basic? You'll have to unlock it first :)"));
|
||||||
|
if (!options[Options::STONEHEWER_MODE_UNLOCKED].number)
|
||||||
|
scroller->Add(_("Love Equipment and want a real challenge? Unlock Stone Hewer Basic:)"));
|
||||||
if (!options[Options::RANDOMDECK_MODE_UNLOCKED].number)
|
if (!options[Options::RANDOMDECK_MODE_UNLOCKED].number)
|
||||||
scroller->Add(_("You haven't unlocked the random deck mode yet"));
|
scroller->Add(_("You haven't unlocked the random deck mode yet"));
|
||||||
if (!options[Options::EVILTWIN_MODE_UNLOCKED].number)
|
if (!options[Options::EVILTWIN_MODE_UNLOCKED].number)
|
||||||
|
|||||||
@@ -1726,6 +1726,17 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set hand size
|
||||||
|
vector<string> splitSetHand = parseBetween(s, "sethand:", " ", false);
|
||||||
|
if (splitSetHand.size())
|
||||||
|
{
|
||||||
|
int hand = atoi(splitSetHand[1].c_str());
|
||||||
|
Damageable * t = spell ? spell->getNextDamageableTarget() : NULL;
|
||||||
|
MTGAbility * a = NEW AASetHand(id, card, t, hand, NULL, who);
|
||||||
|
a->oneShot = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
//set life total
|
//set life total
|
||||||
vector<string> splitLifeset = parseBetween(s, "lifeset:", " ", false);
|
vector<string> splitLifeset = parseBetween(s, "lifeset:", " ", false);
|
||||||
if (splitLifeset.size())
|
if (splitLifeset.size())
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Translate.h"
|
#include "Translate.h"
|
||||||
#include "Subtypes.h"
|
#include "Subtypes.h"
|
||||||
#include "Credits.h"
|
#include "Credits.h"
|
||||||
|
#include "AllAbilities.h"
|
||||||
|
|
||||||
MTGEventBonus::MTGEventBonus(int _id) :
|
MTGEventBonus::MTGEventBonus(int _id) :
|
||||||
MTGAbility(_id,NULL)
|
MTGAbility(_id,NULL)
|
||||||
@@ -1629,6 +1630,199 @@ MTGMomirRule * MTGMomirRule::clone() const
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//stone hewer game mode
|
||||||
|
//in stonehewer when ever a creature enters the battlefield
|
||||||
|
//it enters play with a equipment choosen at random with a converted manacost
|
||||||
|
//less than or equal to the creature.
|
||||||
|
//note this can kill your creature if the equipment contains negitive toughness
|
||||||
|
|
||||||
|
int MTGStoneHewerRule::initialized = 0;
|
||||||
|
vector<int> MTGStoneHewerRule::pool[20];
|
||||||
|
|
||||||
|
MTGStoneHewerRule::MTGStoneHewerRule(int _id, MTGAllCards * _collection) :
|
||||||
|
MTGAbility(_id, NULL)
|
||||||
|
{
|
||||||
|
collection = _collection;
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < collection->ids.size(); i++)
|
||||||
|
{
|
||||||
|
MTGCard * card = collection->collection[collection->ids[i]];
|
||||||
|
if (card->data->hasSubtype("equipment") && (card->getRarity() != Constants::RARITY_T) && //remove tokens
|
||||||
|
card->setId != MTGSets::INTERNAL_SET //remove cards that are defined in primitives. Those are workarounds (usually tokens) and should only be used internally
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int convertedCost = card->data->getManaCost()->getConvertedCost();
|
||||||
|
if (convertedCost > 20)
|
||||||
|
continue;
|
||||||
|
pool[convertedCost].push_back(card->getMTGId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initialized = 1;
|
||||||
|
}
|
||||||
|
alreadyplayed = 0;
|
||||||
|
textAlpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGStoneHewerRule::receiveEvent(WEvent * event)
|
||||||
|
{
|
||||||
|
WEventZoneChange * e = (WEventZoneChange *) event;
|
||||||
|
if (e->to == game->currentlyActing()->game->inPlay && e->card->isCreature())
|
||||||
|
{
|
||||||
|
int eId = genRandomEquipId(e->card->getManaCost()->getConvertedCost());
|
||||||
|
MTGCardInstance * card = genEquip(eId);
|
||||||
|
if(card)
|
||||||
|
{
|
||||||
|
game->currentlyActing()->game->temp->addCard(card);
|
||||||
|
Spell * spell = NEW Spell(card);
|
||||||
|
spell->resolve();
|
||||||
|
spell->source->isToken = 1;
|
||||||
|
|
||||||
|
GameObserver * g = g->GetInstance();
|
||||||
|
for (int i = 1; i < g->mLayers->actionLayer()->mCount; i++)
|
||||||
|
{
|
||||||
|
MTGAbility * a = ((MTGAbility *) g->mLayers->actionLayer()->mObjects[i]);
|
||||||
|
AEquip * eq = dynamic_cast<AEquip*> (a);
|
||||||
|
if (eq && eq->source == spell->source)
|
||||||
|
{
|
||||||
|
((AEquip*)a)->unequip();
|
||||||
|
((AEquip*)a)->equip(e->card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alreadyplayed = 1;
|
||||||
|
textAlpha = 255;
|
||||||
|
text = "equipment";//for some reason if i don't set this to something it runs the risk of a string based crash.
|
||||||
|
text = spell->source->name;
|
||||||
|
SAFE_DELETE(spell);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MTGCardInstance * MTGStoneHewerRule::genEquip(int id)
|
||||||
|
{
|
||||||
|
if (!id)
|
||||||
|
return NULL;
|
||||||
|
Player * p = game->currentlyActing();
|
||||||
|
MTGCard * card = collection->getCardById(id);
|
||||||
|
return NEW MTGCardInstance(card, p->game);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGStoneHewerRule::genRandomEquipId(int convertedCost)
|
||||||
|
{
|
||||||
|
if (convertedCost >= 20)
|
||||||
|
convertedCost = 19;
|
||||||
|
int total_cards = 0;
|
||||||
|
int i = (WRand() % int(convertedCost+1));//+1 becuase we want to generate a random "<=" the coverted.
|
||||||
|
while (!total_cards && i >= 0)
|
||||||
|
{
|
||||||
|
DebugTrace("Converted Cost in Stone Hewer: " << i);
|
||||||
|
total_cards = pool[i].size();
|
||||||
|
convertedCost = i;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
if (!total_cards)
|
||||||
|
return 0;
|
||||||
|
int start = (WRand() % total_cards);
|
||||||
|
return pool[convertedCost][start];
|
||||||
|
}
|
||||||
|
|
||||||
|
//The StoneHewer is never destroyed
|
||||||
|
int MTGStoneHewerRule::testDestroy()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MTGStoneHewerRule::Update(float dt)
|
||||||
|
{
|
||||||
|
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP)
|
||||||
|
{
|
||||||
|
alreadyplayed = 0;
|
||||||
|
}
|
||||||
|
if (textAlpha)
|
||||||
|
{
|
||||||
|
textAlpha -= static_cast<int> (200 * dt);
|
||||||
|
if (textAlpha < 0)
|
||||||
|
textAlpha = 0;
|
||||||
|
}
|
||||||
|
MTGAbility::Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MTGStoneHewerRule::Render()
|
||||||
|
{
|
||||||
|
if (!textAlpha)
|
||||||
|
return;
|
||||||
|
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT);
|
||||||
|
mFont->SetScale(2 - (float) textAlpha / 130);
|
||||||
|
mFont->SetColor(ARGB(textAlpha,255,255,255));
|
||||||
|
mFont->DrawString(text.c_str(), SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, JGETEXT_CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
ostream& MTGStoneHewerRule::toString(ostream& out) const
|
||||||
|
{
|
||||||
|
out << "MTGStoneHewerRule ::: pool : " << pool << " ; initialized : " << initialized << " ; textAlpha : " << textAlpha
|
||||||
|
<< " ; text " << text << " ; alreadyplayed : " << alreadyplayed
|
||||||
|
<< " ; collection : " << collection << "(";
|
||||||
|
return MTGAbility::toString(out) << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
MTGStoneHewerRule * MTGStoneHewerRule::clone() const
|
||||||
|
{
|
||||||
|
MTGStoneHewerRule * a = NEW MTGStoneHewerRule(*this);
|
||||||
|
a->isClone = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------
|
||||||
|
//Hermit druid mode places a random land from your deck into play during each of your upkeeps
|
||||||
|
MTGHermitRule::MTGHermitRule(int _id) :
|
||||||
|
MTGAbility(_id, NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGHermitRule::receiveEvent(WEvent * event)
|
||||||
|
{
|
||||||
|
WEventPhaseChange * e = dynamic_cast<WEventPhaseChange*>(event);
|
||||||
|
if (e && e->from->id == Constants::MTG_PHASE_UNTAP)
|
||||||
|
{
|
||||||
|
MTGCardInstance * lcard = NULL;
|
||||||
|
vector<MTGCardInstance*>lands = vector<MTGCardInstance*>();
|
||||||
|
for(int i = 0; i < game->currentPlayer->game->library->nb_cards-1; i++)
|
||||||
|
{
|
||||||
|
MTGCardInstance * temp = game->currentPlayer->game->library->cards[i];
|
||||||
|
if(temp && temp->isLand())
|
||||||
|
lands.push_back(temp);
|
||||||
|
}
|
||||||
|
if(lands.size())
|
||||||
|
lcard = lands[WRand() % lands.size()];
|
||||||
|
if(lcard)
|
||||||
|
{
|
||||||
|
MTGCardInstance * copy = game->currentPlayer->game->putInZone(lcard,game->currentPlayer->game->library, game->currentPlayer->game->temp);
|
||||||
|
Spell * spell = NEW Spell(copy);
|
||||||
|
spell->resolve();
|
||||||
|
delete spell;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//The hermit is never destroyed
|
||||||
|
int MTGHermitRule::testDestroy()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MTGHermitRule * MTGHermitRule::clone() const
|
||||||
|
{
|
||||||
|
MTGHermitRule * a = NEW MTGHermitRule(*this);
|
||||||
|
a->isClone = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
//--------------------
|
||||||
|
|
||||||
//HUDDisplay
|
//HUDDisplay
|
||||||
int HUDDisplay::testDestroy()
|
int HUDDisplay::testDestroy()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Damageable(20)
|
|||||||
game = NULL;
|
game = NULL;
|
||||||
deckFile = file;
|
deckFile = file;
|
||||||
deckFileSmall = fileSmall;
|
deckFileSmall = fileSmall;
|
||||||
|
handsize = 0;
|
||||||
manaPool = NEW ManaPool(this);
|
manaPool = NEW ManaPool(this);
|
||||||
nomaxhandsize = false;
|
nomaxhandsize = false;
|
||||||
poisonCount = 0;
|
poisonCount = 0;
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ Rules::Rules(string _bg)
|
|||||||
|
|
||||||
bool Rules::canChooseDeck()
|
bool Rules::canChooseDeck()
|
||||||
{
|
{
|
||||||
return (gamemode == GAME_TYPE_CLASSIC);
|
return (gamemode == GAME_TYPE_CLASSIC || gamemode == GAME_TYPE_STONEHEWER || gamemode == GAME_TYPE_HERMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Rules::load(string _filename)
|
int Rules::load(string _filename)
|
||||||
@@ -697,5 +697,7 @@ int Rules::strToGameMode(string s)
|
|||||||
if (s.compare("random1") == 0) return GAME_TYPE_RANDOM1;
|
if (s.compare("random1") == 0) return GAME_TYPE_RANDOM1;
|
||||||
if (s.compare("random2") == 0) return GAME_TYPE_RANDOM2;
|
if (s.compare("random2") == 0) return GAME_TYPE_RANDOM2;
|
||||||
if (s.compare("story") == 0) return GAME_TYPE_STORY;
|
if (s.compare("story") == 0) return GAME_TYPE_STORY;
|
||||||
|
if (s.compare("stonehewer") == 0) return GAME_TYPE_STONEHEWER;
|
||||||
|
if (s.compare("hermit") == 0) return GAME_TYPE_HERMIT;
|
||||||
return GAME_TYPE_CLASSIC;
|
return GAME_TYPE_CLASSIC;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -935,6 +935,7 @@ bool TypeTargetChooser::canTarget(Targetable * target,bool withoutProtections)
|
|||||||
MTGCardInstance * card = (MTGCardInstance *) target;
|
MTGCardInstance * card = (MTGCardInstance *) target;
|
||||||
for (int i = 0; i < nbtypes; i++)
|
for (int i = 0; i < nbtypes; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (card->hasSubtype(types[i])) return true;
|
if (card->hasSubtype(types[i])) return true;
|
||||||
if(card->getLCName().size())
|
if(card->getLCName().size())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user