Erwan
- reduced requirements for ai decks unlocks - attempt to fix a Quad issue when unlocking something
This commit is contained in:
@@ -30,14 +30,14 @@ private:
|
|||||||
int isEvilTwinUnlocked();
|
int isEvilTwinUnlocked();
|
||||||
int isRandomDeckUnlocked();
|
int isRandomDeckUnlocked();
|
||||||
int IsMoreAIDecksUnlocked(DeckStats * stats);
|
int IsMoreAIDecksUnlocked(DeckStats * stats);
|
||||||
|
string unlockedTextureName;
|
||||||
|
JQuad * GetUnlockedQuad(string texturename);
|
||||||
public:
|
public:
|
||||||
int value;
|
int value;
|
||||||
Player * p1, *p2;
|
Player * p1, *p2;
|
||||||
GameApp * app;
|
GameApp * app;
|
||||||
int showMsg;
|
int showMsg;
|
||||||
int unlocked;
|
int unlocked;
|
||||||
JQuad * unlockedQuad;
|
|
||||||
JTexture * unlockedTex;
|
|
||||||
string unlockedString;
|
string unlockedString;
|
||||||
vector<CreditBonus *> bonus;
|
vector<CreditBonus *> bonus;
|
||||||
Credits();
|
Credits();
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ void CreditBonus::Render(float x, float y, WFont * font)
|
|||||||
|
|
||||||
Credits::Credits()
|
Credits::Credits()
|
||||||
{
|
{
|
||||||
unlockedTex = NULL;
|
|
||||||
unlockedQuad = NULL;
|
|
||||||
unlocked = -1;
|
unlocked = -1;
|
||||||
p1 = NULL;
|
p1 = NULL;
|
||||||
p2 = NULL;
|
p2 = NULL;
|
||||||
@@ -36,7 +34,6 @@ Credits::Credits()
|
|||||||
|
|
||||||
Credits::~Credits()
|
Credits::~Credits()
|
||||||
{
|
{
|
||||||
resources.Release(unlockedTex);
|
|
||||||
for (unsigned int i = 0; i < bonus.size(); ++i)
|
for (unsigned int i = 0; i < bonus.size(); ++i)
|
||||||
if (bonus[i])
|
if (bonus[i])
|
||||||
delete bonus[i];
|
delete bonus[i];
|
||||||
@@ -124,40 +121,35 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app)
|
|||||||
unlocked = isDifficultyUnlocked(stats);
|
unlocked = isDifficultyUnlocked(stats);
|
||||||
if (unlocked)
|
if (unlocked)
|
||||||
{
|
{
|
||||||
unlockedTex = resources.RetrieveTexture("unlocked.png");
|
unlockedTextureName = "unlocked.png";
|
||||||
unlockedQuad = resources.RetrieveQuad("unlocked.png", 2, 2, 396, 96);
|
|
||||||
goa = (GameOptionAward*) &options[Options::DIFFICULTY_MODE_UNLOCKED];
|
goa = (GameOptionAward*) &options[Options::DIFFICULTY_MODE_UNLOCKED];
|
||||||
goa->giveAward();
|
goa->giveAward();
|
||||||
options.save();
|
options.save();
|
||||||
}
|
}
|
||||||
else if ((unlocked = isMomirUnlocked()))
|
else if ((unlocked = isMomirUnlocked()))
|
||||||
{
|
{
|
||||||
unlockedTex = resources.RetrieveTexture("momir_unlocked.png");
|
unlockedTextureName = "momir_unlocked.png";
|
||||||
unlockedQuad = resources.RetrieveQuad("momir_unlocked.png", 2, 2, 396, 96);
|
|
||||||
goa = (GameOptionAward*) &options[Options::MOMIR_MODE_UNLOCKED];
|
goa = (GameOptionAward*) &options[Options::MOMIR_MODE_UNLOCKED];
|
||||||
goa->giveAward();
|
goa->giveAward();
|
||||||
options.save();
|
options.save();
|
||||||
}
|
}
|
||||||
else if ((unlocked = isEvilTwinUnlocked()))
|
else if ((unlocked = isEvilTwinUnlocked()))
|
||||||
{
|
{
|
||||||
unlockedTex = resources.RetrieveTexture("eviltwin_unlocked.png");
|
unlockedTextureName = "eviltwin_unlocked.png";
|
||||||
unlockedQuad = resources.RetrieveQuad("eviltwin_unlocked.png", 2, 2, 396, 96);
|
|
||||||
goa = (GameOptionAward*) &options[Options::EVILTWIN_MODE_UNLOCKED];
|
goa = (GameOptionAward*) &options[Options::EVILTWIN_MODE_UNLOCKED];
|
||||||
goa->giveAward();
|
goa->giveAward();
|
||||||
options.save();
|
options.save();
|
||||||
}
|
}
|
||||||
else if ((unlocked = isRandomDeckUnlocked()))
|
else if ((unlocked = isRandomDeckUnlocked()))
|
||||||
{
|
{
|
||||||
unlockedTex = resources.RetrieveTexture("randomdeck_unlocked.png");
|
unlockedTextureName = "randomdeck_unlocked.png";
|
||||||
unlockedQuad = resources.RetrieveQuad("randomdeck_unlocked.png", 2, 2, 396, 96);
|
|
||||||
goa = (GameOptionAward*) &options[Options::RANDOMDECK_MODE_UNLOCKED];
|
goa = (GameOptionAward*) &options[Options::RANDOMDECK_MODE_UNLOCKED];
|
||||||
goa->giveAward();
|
goa->giveAward();
|
||||||
options.save();
|
options.save();
|
||||||
}
|
}
|
||||||
else if ((unlocked = unlockRandomSet()))
|
else if ((unlocked = unlockRandomSet()))
|
||||||
{
|
{
|
||||||
unlockedTex = resources.RetrieveTexture("set_unlocked.png");
|
unlockedTextureName = "set_unlocked.png";
|
||||||
unlockedQuad = resources.RetrieveQuad("set_unlocked.png", 2, 2, 396, 96);
|
|
||||||
MTGSetInfo * si = setlist.getInfo(unlocked - 1);
|
MTGSetInfo * si = setlist.getInfo(unlocked - 1);
|
||||||
if (si)
|
if (si)
|
||||||
unlockedString = si->getName(); //Show the set's pretty name for unlocks.
|
unlockedString = si->getName(); //Show the set's pretty name for unlocks.
|
||||||
@@ -166,8 +158,7 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app)
|
|||||||
{
|
{
|
||||||
options[Options::AIDECKS_UNLOCKED].number += 10;
|
options[Options::AIDECKS_UNLOCKED].number += 10;
|
||||||
options.save();
|
options.save();
|
||||||
unlockedTex = resources.RetrieveTexture("ai_unlocked.png");
|
unlockedTextureName = "ai_unlocked.png";
|
||||||
unlockedQuad = resources.RetrieveQuad("ai_unlocked.png", 2, 2, 396, 96);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlocked && options[Options::SFXVOLUME].number > 0)
|
if (unlocked && options[Options::SFXVOLUME].number > 0)
|
||||||
@@ -210,6 +201,17 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app)
|
|||||||
SAFE_DELETE(playerdata);
|
SAFE_DELETE(playerdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JQuad * Credits::GetUnlockedQuad(string textureName)
|
||||||
|
{
|
||||||
|
if (!textureName.size()) return NULL;
|
||||||
|
|
||||||
|
JTexture * unlockedTex = resources.RetrieveTexture(textureName);
|
||||||
|
if (!unlockedTex) return NULL;
|
||||||
|
|
||||||
|
return resources.RetrieveQuad(unlockedTextureName, 2, 2, unlockedTex->mWidth - 4, unlockedTex->mHeight - 4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Credits::Render()
|
void Credits::Render()
|
||||||
{
|
{
|
||||||
if (!p1)
|
if (!p1)
|
||||||
@@ -237,6 +239,7 @@ void Credits::Render()
|
|||||||
if (g->gameOver != p1)
|
if (g->gameOver != p1)
|
||||||
{
|
{
|
||||||
sprintf(buffer, _("Congratulations! You earn %i credits").c_str(), value);
|
sprintf(buffer, _("Congratulations! You earn %i credits").c_str(), value);
|
||||||
|
JQuad * unlockedQuad = GetUnlockedQuad(unlockedTextureName);
|
||||||
if (unlockedQuad)
|
if (unlockedQuad)
|
||||||
{
|
{
|
||||||
showMsg = 0;
|
showMsg = 0;
|
||||||
@@ -434,9 +437,9 @@ int Credits::unlockRandomSet(bool force)
|
|||||||
int Credits::IsMoreAIDecksUnlocked(DeckStats * stats) {
|
int Credits::IsMoreAIDecksUnlocked(DeckStats * stats) {
|
||||||
int currentlyUnlocked = options[Options::AIDECKS_UNLOCKED].number;
|
int currentlyUnlocked = options[Options::AIDECKS_UNLOCKED].number;
|
||||||
|
|
||||||
// Random rule: having played at least twice as much games as
|
// Random rule: having played at least 1.2 times as much games as
|
||||||
// the number of currently unlocked decks in order to go through.
|
// the number of currently unlocked decks in order to go through.
|
||||||
if (stats->nbGames() < currentlyUnlocked * 2) return 0;
|
if (stats->nbGames() < currentlyUnlocked * 1.2) return 0;
|
||||||
|
|
||||||
int nbdecks = 0;
|
int nbdecks = 0;
|
||||||
int found = 1;
|
int found = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user