Added commander mode achievement and improved its graphic resources, added fixed primitives, fixes RNA set file, added new keyword and events to code the ability of six-side die roll.

This commit is contained in:
valfieri
2020-12-14 19:20:05 +01:00
parent a753bb0c1b
commit bf3d35463f
22 changed files with 1224 additions and 189 deletions
+162 -2
View File
@@ -2670,7 +2670,7 @@ AASetTypeChosen::~AASetTypeChosen()
}
//
//choosing a type or color
//choosing flip coin
GenericFlipACoin::GenericFlipACoin(GameObserver* observer, int id, MTGCardInstance * source, Targetable *,string _toAdd, ManaCost * cost) :
ActivatedAbility(observer, id, source, cost, 0), baseAbility(_toAdd)
{
@@ -2717,7 +2717,7 @@ GenericFlipACoin::~GenericFlipACoin()
{
}
//set color choosen
//set coin result
AASetCoin::AASetCoin(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target,int _side , string toAlter):
InstantAbility(observer, id, source),side(_side), abilityToAlter(toAlter)
{
@@ -2810,6 +2810,166 @@ AASetCoin::~AASetCoin()
{
}
//
//rolling a 6 side die
GenericRollDie::GenericRollDie(GameObserver* observer, int id, MTGCardInstance * source, Targetable *, string _toAdd, ManaCost * cost, int userchoice) :
ActivatedAbility(observer, id, source, cost, 0), baseAbility(_toAdd), userchoice(userchoice)
{
this->GetId();
setDie = NULL;
}
int GenericRollDie::resolve()
{
if (!target)
return 0;
vector<MTGAbility*>selection;
if(userchoice > 0 && userchoice < 7){
setDie = NEW AASetDie(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, userchoice, baseAbility);
MTGAbility * set = setDie->clone();
set->oneShot = true;
game->mLayers->actionLayer()->currentActionCard = (MTGCardInstance *)target;
set->resolve();
SAFE_DELETE(setDie);
} else{
for (int i = 1; i < 7; ++i)
{
setDie = NEW AASetDie(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i, baseAbility);
MTGAbility * set = setDie->clone();
set->oneShot = true;
selection.push_back(set);
SAFE_DELETE(setDie);
}
}
if(selection.size() > 1)
{
MTGAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, false, selection);
game->mLayers->actionLayer()->currentActionCard = (MTGCardInstance *)target;
a1->resolve();
}
return 1;
}
const string GenericRollDie::getMenuText()
{
return "Roll a Die";
}
GenericRollDie * GenericRollDie::clone() const
{
GenericRollDie * a = NEW GenericRollDie(*this);
return a;
}
GenericRollDie::~GenericRollDie()
{
}
//set color choosen
AASetDie::AASetDie(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target, int _side, string toAlter):
InstantAbility(observer, id, source),side(_side), abilityToAlter(toAlter)
{
this->target = _target;
abilityAltered = NULL;
}
int AASetDie::resolve()
{
MTGCardInstance * _target = (MTGCardInstance *)target;
_target->dieSide = side;
int roll = 1 + game->getRandomGenerator()->random() % 6;
_target->lastRollResult = roll;
WEvent * e = NEW WEventCardRollDie(_target);
game->receiveEvent(e);
vector<string>Win = parseBetween(abilityToAlter,"winability "," winabilityend");
if(Win.size())
{
abilityWin = Win[1];
}
vector<string>Lose = parseBetween(abilityToAlter,"loseability "," loseabilityend");
if(Lose.size())
{
abilityLose = Lose[1];
}
if(abilityWin.size() && roll == side)
{
AbilityFactory af(game);
abilityAltered = af.parseMagicLine(abilityWin, 0, NULL, _target);
abilityAltered->canBeInterrupted = false;
if(abilityAltered->oneShot)
{
abilityAltered->resolve();
SAFE_DELETE(abilityAltered);
}
else
{
abilityAltered->addToGame();
}
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Won The Die Roll");
message->oneShot = true;
message->addToGame();
}
else if(abilityWin.size() && !abilityLose.size())
{
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Lost The Die Roll");
message->oneShot = true;
message->addToGame();
}
else if(abilityLose.size() && roll != side)
{
AbilityFactory af(game);
abilityAltered = af.parseMagicLine(abilityLose, 0, NULL, _target);
abilityAltered->canBeInterrupted = false;
if(abilityAltered->oneShot)
{
abilityAltered->resolve();
SAFE_DELETE(abilityAltered);
}
else
{
abilityAltered->addToGame();
}
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Lost The Die Roll");
message->oneShot = true;
message->addToGame();
}
else if(abilityLose.size())
{
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Won The Die Roll");
message->oneShot = true;
message->addToGame();
}
_target->skipDamageTestOnce = true;
return 1;
}
const string AASetDie::getMenuText()
{
if(side == 1)
return "Your choice is 1";
if(side == 2)
return "Your choice is 2";
if(side == 3)
return "Your choice is 3";
if(side == 4)
return "Your choice is 4";
if(side == 5)
return "Your choice is 5";
return "Your choice is 6";
}
AASetDie * AASetDie::clone() const
{
return NEW AASetDie(*this);
}
AASetDie::~AASetDie()
{
}
//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, bool asAlternate, ManaCost * cost) :
+15
View File
@@ -277,6 +277,12 @@ void Credits::compute(GameObserver* g, GameApp * _app)
goa = (GameOptionAward*) &options[Options::EVILTWIN_MODE_UNLOCKED];
goa->giveAward();
}
else if ((unlocked = isCommanderUnlocked()))
{
unlockedTextureName = "commander_unlocked.png";
goa = (GameOptionAward*) &options[Options::COMMANDER_MODE_UNLOCKED];
goa->giveAward();
}
else if ((unlocked = isRandomDeckUnlocked()))
{
unlockedTextureName = "randomdeck_unlocked.png";
@@ -669,6 +675,15 @@ int Credits::isEvilTwinUnlocked()
return 0;
}
int Credits::isCommanderUnlocked()
{
if (options[Options::COMMANDER_MODE_UNLOCKED].number)
return 0;
if (p1->life >= 40 && p2->game->graveyard->nb_cards && (p1->game->graveyard->nb_cards < p2->game->graveyard->nb_cards))
return 1;
return 0;
}
int Credits::isRandomDeckUnlocked()
{
if (0 == options[Options::DIFFICULTY].number)
+3
View File
@@ -61,6 +61,9 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f
case kRandomAIPlayerMenuID:
mImageFilename = "noavatar.jpg";
break;
case kCommanderMenuID:
mImageFilename = "noavatar.jpg";
break;
case kEvilTwinMenuID:
{
mImageFilename = "avatar.jpg";
+1
View File
@@ -74,6 +74,7 @@ const string Options::optionNames[] = {
"prx_eviltwin",
"prx_rnddeck",
"aw_collector",
"prx_commander",
};
+4
View File
@@ -91,6 +91,10 @@ void GameStateAwards::Start()
btn = NEW WGuiButton(aw, GUI_AWARD_BUTTON, Options::AWARD_COLLECTOR, this);
listview->Add(btn);
aw = NEW WGuiAward(Options::COMMANDER_MODE_UNLOCKED, "Commander Format", "Play a Commander Format game.");
btn = NEW WGuiButton(aw, GUI_AWARD_BUTTON, Options::COMMANDER_MODE_UNLOCKED, this);
listview->Add(btn);
wgh = NEW WGuiHeader("");
listview->Add(wgh);
+6
View File
@@ -222,6 +222,8 @@ void GameStateMenu::fillScroller()
scroller->Add(_("You haven't unlocked the random deck mode yet"));
if (!options[Options::EVILTWIN_MODE_UNLOCKED].number)
scroller->Add(_("You haven't unlocked the evil twin mode yet"));
if (!options[Options::COMMANDER_MODE_UNLOCKED].number)
scroller->Add(_("You haven't unlocked the commander format yet"));
//Unlocked sets
int nbunlocked = 0;
@@ -264,6 +266,10 @@ int GameStateMenu::gamePercentComplete() {
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
done++;
total++;
if (options[Options::COMMANDER_MODE_UNLOCKED].number)
done++;
//Unlocked sets
total+= setlist.size();
for (int i = 0; i < setlist.size(); i++)
+33 -6
View File
@@ -1216,23 +1216,33 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
//Card is mutated
if (TargetChooser * tc = parseSimpleTC(s, "mutated", card))
return NEW TrCardMutated(observer, id, card, tc,once,limitOnceATurn);
return NEW TrCardMutated(observer, id, card, tc, once, limitOnceATurn);
//Surveil has been performed from controller
if (TargetChooser * tc = parseSimpleTC(s, "surveiled", card))
return NEW TrCardSurveiled(observer, id, card, tc,once,limitOnceATurn);
return NEW TrCardSurveiled(observer, id, card, tc, once, limitOnceATurn);
//Roll die has been performed from a card
if (TargetChooser * tc = parseSimpleTC(s, "dierolled", card)){
int rollresult = 0;
vector<string>res = parseBetween(s, "result(",")");
if(res.size()){
rollresult = atoi(res[1].c_str());
}
return NEW TrCardRolledDie(observer, id, card, tc, once, limitOnceATurn, rollresult);
}
//Token has been created
if (TargetChooser * tc = parseSimpleTC(s, "tokencreated", card))
return NEW TrTokenCreated(observer, id, card, tc,once);
return NEW TrTokenCreated(observer, id, card, tc, once);
//Card is sacrificed
if (TargetChooser * tc = parseSimpleTC(s, "sacrificed", card))
return NEW TrCardSacrificed(observer, id, card, tc,once);
return NEW TrCardSacrificed(observer, id, card, tc ,once);
//Card is Discarded
if (TargetChooser * tc = parseSimpleTC(s, "discarded", card))
return NEW TrCardDiscarded(observer, id, card, tc,once);
return NEW TrCardDiscarded(observer, id, card, tc, once);
//Card is cycled
if (TargetChooser * tc = parseSimpleTC(s, "cycled", card))
@@ -2585,7 +2595,23 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (splitFlipCoin.size())
{
string a1 = splitFlipCoin[1];
MTGAbility * a = NEW GenericFlipACoin(observer, id, card, target,a1);
MTGAbility * a = NEW GenericFlipACoin(observer, id, card, target, a1);
a->oneShot = 1;
a->canBeInterrupted = false;
return a;
}
//roll a die
vector<string> splitRollDie = parseBetween(s, "rolladie ", " rollend");
if (splitRollDie.size())
{
string a1 = splitRollDie[1];
int userchoice = 0;
if(a1[0] >= 48 && a1[0] <= 57){
userchoice = a1[0] - 48;
a1 = a1.substr(2);
}
MTGAbility * a = NEW GenericRollDie(observer, id, card, target, a1, NULL, userchoice);
a->oneShot = 1;
a->canBeInterrupted = false;
return a;
@@ -2600,6 +2626,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
a->canBeInterrupted = false;
return a;
}
//Upkeep Cost
found = s.find("upcost");
if (found != string::npos)
+2
View File
@@ -262,6 +262,8 @@ void MTGCardInstance::initMTGCI()
chooseacolor = -1;
chooseasubtype = "";
coinSide = -1;
dieSide = 0;
lastRollResult = 0;
isAttacking = NULL;
storedCard = NULL;
storedSourceCard = NULL;
+11
View File
@@ -297,6 +297,11 @@ WEventCardSurveiled::WEventCardSurveiled(MTGCardInstance * card) :
{
}
WEventCardRollDie::WEventCardRollDie(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardMutated::WEventCardMutated(MTGCardInstance * card) :
WEventCardUpdate(card)
{
@@ -516,6 +521,12 @@ Targetable * WEventCardSurveiled::getTarget(int target)
return NULL;
}
Targetable * WEventCardRollDie::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventTokenCreated::getTarget(int target)
{
if (target) return card;