* Change inplay balance.
- Spells now stack three by three.
- Spells try to space a little more.
- Creatures and land stack to the left until they hit the big card,
  at which point they start displaying more compactly. At some point,
  they start using all the screen even if it's under the hand.
This commit is contained in:
jean.chalard
2009-10-11 05:47:31 +00:00
parent 9688d923a7
commit 38d7a96095
4 changed files with 73 additions and 42 deletions
+8 -9
View File
@@ -14,30 +14,29 @@ class GuiPlay : public GuiLayer
protected: protected:
class CardStack { class CardStack {
protected: protected:
unsigned total;
float baseX, baseY; float baseX, baseY;
float x, y; float x, y;
public: public:
void reset(float x, float y); void reset(unsigned total, float x, float y);
void Enstack(CardView*); void Enstack(CardView*);
void RenderSpell(MTGCardInstance*, iterator begin, iterator end, float x, float y); void RenderSpell(MTGCardInstance*, iterator begin, iterator end, float x, float y);
}; };
class HorzStack : public CardStack { class HorzStack : public CardStack {
protected:
const float maxWidth;
float maxHeight;
public: public:
HorzStack(float width = HORZWIDTH); HorzStack();
void reset(float x, float y); void reset(unsigned total, float x, float y);
void Render(CardView*, iterator begin, iterator end); void Render(CardView*, iterator begin, iterator end);
void Enstack(CardView*); void Enstack(CardView*);
}; };
class VertStack : public CardStack { class VertStack : public CardStack {
protected: protected:
float maxHeight; unsigned count;
public: public:
VertStack(float height = VERTHEIGHT); VertStack();
void reset(unsigned total, float x, float y);
void Render(CardView*, iterator begin, iterator end); void Render(CardView*, iterator begin, iterator end);
void Enstack(CardView*); void Enstack(CardView*);
inline float nextX(); inline float nextX();
@@ -56,7 +55,7 @@ class GuiPlay : public GuiLayer
void addAttacker(MTGCardInstance*); void addAttacker(MTGCardInstance*);
void removeAttacker(MTGCardInstance*); void removeAttacker(MTGCardInstance*);
void reset(float x, float y); void reset(float x, float y);
BattleField(float width = HORZWIDTH); BattleField();
void EnstackAttacker(CardView*); void EnstackAttacker(CardView*);
void EnstackBlocker(CardView*); void EnstackBlocker(CardView*);
void Update(float dt); void Update(float dt);
+1 -1
View File
@@ -184,7 +184,7 @@ void GuiHandSelf::Render()
mFont->DrawString("0",SCREEN_WIDTH - 10,backpos.actY); mFont->DrawString("0",SCREEN_WIDTH - 10,backpos.actY);
}else{ }else{
backpos.Render(back); backpos.Render(back);
mFont->DrawString("Empty",backpos.actX,backpos.actY); if (OptionHandDirection::HORIZONTAL == options[Options::HANDDIRECTION].number) mFont->DrawString("Empty",backpos.actX,backpos.actY);
} }
return; return;
} }
+55 -22
View File
@@ -8,8 +8,9 @@
const float GuiPlay::HORZWIDTH = 300.0f; const float GuiPlay::HORZWIDTH = 300.0f;
const float GuiPlay::VERTHEIGHT = 80.0f; const float GuiPlay::VERTHEIGHT = 80.0f;
void GuiPlay::CardStack::reset(float x, float y) void GuiPlay::CardStack::reset(unsigned total, float x, float y)
{ {
this->total = total;
this->x = 0; baseX = x; this->x = 0; baseX = x;
this->y = 0; baseY = y; this->y = 0; baseY = y;
} }
@@ -29,13 +30,19 @@ void GuiPlay::CardStack::RenderSpell(MTGCardInstance* card, iterator begin, iter
} }
} }
GuiPlay::HorzStack::HorzStack(float width) : maxWidth(width) {} GuiPlay::HorzStack::HorzStack() {}
GuiPlay::VertStack::VertStack(float height) : maxHeight(height) {} GuiPlay::VertStack::VertStack() {}
void GuiPlay::HorzStack::reset(float x, float y) void GuiPlay::HorzStack::reset(unsigned total, float x, float y)
{ {
GuiPlay::CardStack::reset(x, y); GuiPlay::CardStack::reset(total, x, y);
maxHeight = 0; }
void GuiPlay::VertStack::reset(unsigned total, float x, float y)
{
GuiPlay::CardStack::reset(total, x - CARD_WIDTH, y);
count = 0;
cout << "reset" << endl;
} }
void GuiPlay::HorzStack::Render(CardView* card, iterator begin, iterator end) void GuiPlay::HorzStack::Render(CardView* card, iterator begin, iterator end)
@@ -47,16 +54,18 @@ void GuiPlay::HorzStack::Render(CardView* card, iterator begin, iterator end)
void GuiPlay::HorzStack::Enstack(CardView* card) void GuiPlay::HorzStack::Enstack(CardView* card)
{ {
card->x = x + baseX; card->y = y + baseY; card->x = x + baseX; card->y = y + baseY;
x += CARD_WIDTH; if (total < 8) x += CARD_WIDTH;
if (maxHeight < card->mHeight) maxHeight = card->mHeight; else if (total < 16) x += (SCREEN_WIDTH - 200 - baseX) / total;
if (x > maxWidth) { x = 0; y += maxHeight + 2; maxHeight = 0; } else x += (SCREEN_WIDTH - 50 - baseX) / total;
} }
void GuiPlay::VertStack::Enstack(CardView* card) void GuiPlay::VertStack::Enstack(CardView* card)
{ {
if (y > maxHeight) x += CARD_WIDTH; if (0 == count % 3) { x += CARD_WIDTH; y = 0; }
card->x = x + baseX; card->y = y + baseY; card->x = x + baseX; card->y = y + baseY;
y += 8; y += 12;
if (++count == total-1 && y == 12) y += 12;
cerr << card->card->name << " " << card->x << "x" << card->y << " : " << nextX() << endl;
} }
void GuiPlay::VertStack::Render(CardView* card, iterator begin, iterator end) void GuiPlay::VertStack::Render(CardView* card, iterator begin, iterator end)
@@ -65,13 +74,13 @@ void GuiPlay::VertStack::Render(CardView* card, iterator begin, iterator end)
card->Render(); card->Render();
} }
inline float GuiPlay::VertStack::nextX() { return x + CARD_WIDTH; } inline float GuiPlay::VertStack::nextX() { if (0 == count) return x + CARD_WIDTH; else return x; }
GuiPlay::BattleField::BattleField(float width) : HorzStack(width), attackers(0), blockers(0), height(0.0), red(0), colorFlow(0) {} GuiPlay::BattleField::BattleField() : attackers(0), blockers(0), height(0.0), red(0), colorFlow(0) {}
const float GuiPlay::BattleField::HEIGHT = 80.0f; const float GuiPlay::BattleField::HEIGHT = 80.0f;
void GuiPlay::BattleField::addAttacker(MTGCardInstance*) { ++attackers; colorFlow = 1; } void GuiPlay::BattleField::addAttacker(MTGCardInstance*) { ++attackers; colorFlow = 1; }
void GuiPlay::BattleField::removeAttacker(MTGCardInstance*) { --attackers; } void GuiPlay::BattleField::removeAttacker(MTGCardInstance*) { --attackers; }
void GuiPlay::BattleField::reset(float x, float y) { HorzStack::reset(x, y); currentAttacker = 1; } void GuiPlay::BattleField::reset(float x, float y) { HorzStack::reset(0, x, y); currentAttacker = 1; }
void GuiPlay::BattleField::EnstackAttacker(CardView* card) void GuiPlay::BattleField::EnstackAttacker(CardView* card)
{ {
GameObserver* game = GameObserver::GetInstance(); GameObserver* game = GameObserver::GetInstance();
@@ -120,10 +129,36 @@ GuiPlay::~GuiPlay()
bool isSpell(CardView* c) { return c->card->isSpell(); } bool isSpell(CardView* c) { return c->card->isSpell(); }
void GuiPlay::Replace() void GuiPlay::Replace()
{ {
opponentSpells.reset(18, 80); unsigned opponentSpellsN = 0, selfSpellsN = 0, opponentLandsN = 0, opponentCreaturesN = 0,
selfSpells.reset(18, 200); battleFieldAttackersN = 0, battleFieldBlockersN = 0, selfCreaturesN = 0, selfLandsN = 0;
end_spells = stable_partition(cards.begin(), cards.end(), &isSpell); end_spells = stable_partition(cards.begin(), cards.end(), &isSpell);
for (iterator it = cards.begin(); it != end_spells; ++it)
if (!(*it)->card->target)
{
if (game->players[0] == (*it)->card->controller()) ++selfSpellsN;
else ++opponentSpellsN;
}
for (iterator it = end_spells; it != cards.end(); ++it)
{
if ((*it)->card->isCreature())
{
if ((*it)->card->isAttacker()) ++battleFieldAttackersN;
else if ((*it)->card->isDefenser()) ++battleFieldBlockersN;
else if (game->players[0] == (*it)->card->controller()) ++selfCreaturesN;
else ++opponentCreaturesN;
}
else if ((*it)->card->isLand())
{
if (game->players[0] == (*it)->card->controller()) ++selfLandsN;
else ++opponentLandsN;
}
}
opponentSpells.reset(opponentSpellsN, 18, 60);
selfSpells.reset(selfSpellsN, 18, 215);
for (iterator it = cards.begin(); it != end_spells; ++it) for (iterator it = cards.begin(); it != end_spells; ++it)
if (!(*it)->card->target) if (!(*it)->card->target)
{ {
@@ -132,11 +167,11 @@ void GuiPlay::Replace()
} }
float x = 24 + MAX(opponentSpells.nextX(), selfSpells.nextX()); float x = 24 + MAX(opponentSpells.nextX(), selfSpells.nextX());
opponentLands.reset(x, 50); opponentLands.reset(opponentLandsN, x, 50);
opponentCreatures.reset(x, 95); opponentCreatures.reset(opponentCreaturesN, x, 95);
battleField.reset(x, 145); battleField.reset(x, 145);
selfCreatures.reset(x, 195); selfCreatures.reset(selfCreaturesN, x, 195);
selfLands.reset(x, 240); selfLands.reset(selfLandsN, x, 240);
for (iterator it = end_spells; it != cards.end(); ++it) for (iterator it = end_spells; it != cards.end(); ++it)
{ {
@@ -229,9 +264,7 @@ int GuiPlay::receiveEventPlus(WEvent * e)
if (Constants::MTG_PHASE_COMBATEND == event->to->id) battleField.colorFlow = -1; if (Constants::MTG_PHASE_COMBATEND == event->to->id) battleField.colorFlow = -1;
} }
else if (dynamic_cast<WEventCardChangeType*>(e)) else if (dynamic_cast<WEventCardChangeType*>(e))
{
Replace(); Replace();
}
return 0; return 0;
} }
int GuiPlay::receiveEventMinus(WEvent * e) int GuiPlay::receiveEventMinus(WEvent * e)
-1
View File
@@ -135,7 +135,6 @@ void GuiGameZone::Render(){
mFont->DrawString(buffer, x0+1, actY+1); mFont->DrawString(buffer, x0+1, actY+1);
if (actA > 120) mAlpha = 255; if (actA > 120) mAlpha = 255;
mFont->SetColor(ARGB(mAlpha,255,255,255)); mFont->SetColor(ARGB(mAlpha,255,255,255));
fprintf(stderr, "%i\n", mAlpha);
mFont->DrawString(buffer, x0, actY); mFont->DrawString(buffer, x0, actY);