Erwan
- fix issue 94 (enchant enchantments)
This commit is contained in:
@@ -38,6 +38,7 @@ class GuiPlay : public GuiLayer
|
|||||||
float maxHeight;
|
float maxHeight;
|
||||||
public:
|
public:
|
||||||
VertStack(float height = VERTHEIGHT);
|
VertStack(float height = VERTHEIGHT);
|
||||||
|
void Render(CardView*, iterator begin, iterator end);
|
||||||
void Enstack(CardView*);
|
void Enstack(CardView*);
|
||||||
inline float nextX();
|
inline float nextX();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,10 +63,18 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
|||||||
int typeAsTarget(){return TARGET_CARD;}
|
int typeAsTarget(){return TARGET_CARD;}
|
||||||
const string getDisplayName() const;
|
const string getDisplayName() const;
|
||||||
MTGCardInstance * target;
|
MTGCardInstance * target;
|
||||||
void addType(int type);
|
|
||||||
bool blocked; //Blocked this turn or not?
|
|
||||||
|
//types
|
||||||
|
void addType(char * type_text);
|
||||||
|
virtual void addType(int id);
|
||||||
|
void setType(const char * type_text);
|
||||||
|
void setSubtype( string value);
|
||||||
|
int removeType(string value, int removeAll = 0);
|
||||||
|
int removeType(int value, int removeAll = 0);
|
||||||
|
|
||||||
//Combat
|
//Combat
|
||||||
|
bool blocked; //Blocked this turn or not?
|
||||||
MTGCardInstance * defenser;
|
MTGCardInstance * defenser;
|
||||||
list<MTGCardInstance *>blockers;
|
list<MTGCardInstance *>blockers;
|
||||||
int attacker;
|
int attacker;
|
||||||
|
|||||||
@@ -54,6 +54,14 @@ struct WEventCardUpdate : public WEvent {
|
|||||||
WEventCardUpdate(MTGCardInstance * card);
|
WEventCardUpdate(MTGCardInstance * card);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Event when a card gains/looses types
|
||||||
|
struct WEventCardChangeType : public WEventCardUpdate {
|
||||||
|
int type;
|
||||||
|
bool before;
|
||||||
|
bool after;
|
||||||
|
WEventCardChangeType(MTGCardInstance * card, int type, bool before, bool after);
|
||||||
|
};
|
||||||
|
|
||||||
//Event when a card is tapped/untapped
|
//Event when a card is tapped/untapped
|
||||||
struct WEventCardTap : public WEventCardUpdate {
|
struct WEventCardTap : public WEventCardUpdate {
|
||||||
bool before;
|
bool before;
|
||||||
|
|||||||
@@ -59,6 +59,12 @@ void GuiPlay::VertStack::Enstack(CardView* card)
|
|||||||
y += 8;
|
y += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiPlay::VertStack::Render(CardView* card, iterator begin, iterator end)
|
||||||
|
{
|
||||||
|
RenderSpell(card->card, begin, end, card->x + 5, card->y - 10);
|
||||||
|
card->Render();
|
||||||
|
}
|
||||||
|
|
||||||
inline float GuiPlay::VertStack::nextX() { return x + CARD_WIDTH; }
|
inline float GuiPlay::VertStack::nextX() { return x + CARD_WIDTH; }
|
||||||
|
|
||||||
GuiPlay::BattleField::BattleField(float width) : HorzStack(width), attackers(0), blockers(0), height(0.0), red(0), colorFlow(0) {}
|
GuiPlay::BattleField::BattleField(float width) : HorzStack(width), attackers(0), blockers(0), height(0.0), red(0), colorFlow(0) {}
|
||||||
@@ -152,20 +158,25 @@ void GuiPlay::Replace()
|
|||||||
void GuiPlay::Render()
|
void GuiPlay::Render()
|
||||||
{
|
{
|
||||||
battleField.Render();
|
battleField.Render();
|
||||||
for (iterator it = cards.begin(); it != end_spells; ++it)
|
|
||||||
if (!(*it)->card->target)
|
for (iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
(*it)->Render();
|
if ((*it)->card->isLand())
|
||||||
for (iterator it = end_spells; it != cards.end(); ++it)
|
|
||||||
if ((*it)->card->isCreature())
|
|
||||||
{
|
|
||||||
if (game->players[0] == (*it)->card->controller()) selfCreatures.Render(*it, cards.begin(), end_spells);
|
|
||||||
else opponentCreatures.Render(*it, cards.begin(), end_spells);
|
|
||||||
}
|
|
||||||
else if ((*it)->card->isLand())
|
|
||||||
{
|
{
|
||||||
if (game->players[0] == (*it)->card->controller()) selfLands.Render(*it, cards.begin(), end_spells);
|
if (game->players[0] == (*it)->card->controller()) selfLands.Render(*it, cards.begin(), end_spells);
|
||||||
else opponentLands.Render(*it, cards.begin(), end_spells);
|
else opponentLands.Render(*it, cards.begin(), end_spells);
|
||||||
}
|
}
|
||||||
|
else if ((*it)->card->isCreature())
|
||||||
|
{
|
||||||
|
if (game->players[0] == (*it)->card->controller()) selfCreatures.Render(*it, cards.begin(), end_spells);
|
||||||
|
else opponentCreatures.Render(*it, cards.begin(), end_spells);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (!(*it)->card->target) {
|
||||||
|
if (game->players[0] == (*it)->card->controller()) selfSpells.Render(*it, cards.begin(), end_spells);
|
||||||
|
else opponentSpells.Render(*it, cards.begin(), end_spells);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void GuiPlay::Update(float dt)
|
void GuiPlay::Update(float dt)
|
||||||
{
|
{
|
||||||
@@ -217,6 +228,10 @@ 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))
|
||||||
|
{
|
||||||
|
Replace();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int GuiPlay::receiveEventMinus(WEvent * e)
|
int GuiPlay::receiveEventMinus(WEvent * e)
|
||||||
|
|||||||
@@ -217,7 +217,6 @@ void MTGCard::addType(char * _type_text){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MTGCard::setSubtype( string value){
|
void MTGCard::setSubtype( string value){
|
||||||
|
|
||||||
int id = Subtypes::subtypesList->Add(value);
|
int id = Subtypes::subtypesList->Add(value);
|
||||||
addType(id);
|
addType(id);
|
||||||
}
|
}
|
||||||
@@ -228,6 +227,7 @@ void MTGCard::addType(int id){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO Definitely move some of these functions to MTGCardInstance. There is no reason to remove a type from an MTGCard since they represent the Database
|
||||||
//Removes a type from the types of a given card
|
//Removes a type from the types of a given card
|
||||||
//If removeAll is true, removes all occurences of this type, otherwise only removes the first occurence
|
//If removeAll is true, removes all occurences of this type, otherwise only removes the first occurence
|
||||||
int MTGCard::removeType(string value, int removeAll){
|
int MTGCard::removeType(string value, int removeAll){
|
||||||
|
|||||||
@@ -114,8 +114,36 @@ const string MTGCardInstance::getDisplayName() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MTGCardInstance::addType(int type){
|
void MTGCardInstance::addType(int type){
|
||||||
types[nb_types] = type;
|
bool before = hasType(type);
|
||||||
nb_types++;
|
MTGCard::addType(type);
|
||||||
|
WEvent * e = NEW WEventCardChangeType(this,type,before,true);
|
||||||
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MTGCardInstance::addType(char * type_text){
|
||||||
|
setSubtype(type_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MTGCardInstance::setType(const char * type_text){
|
||||||
|
setSubtype(type_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MTGCardInstance::setSubtype(string value){
|
||||||
|
int id = Subtypes::subtypesList->Add(value);
|
||||||
|
addType(id);
|
||||||
|
}
|
||||||
|
int MTGCardInstance::removeType(string value,int removeAll){
|
||||||
|
int id = Subtypes::subtypesList->Add(value);
|
||||||
|
return removeType(id,removeAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGCardInstance::removeType(int id, int removeAll){
|
||||||
|
bool before = hasType(id);
|
||||||
|
int result = MTGCard::removeType(id,removeAll);
|
||||||
|
bool after = hasType(id);
|
||||||
|
WEvent * e = NEW WEventCardChangeType(this,id,before,after);
|
||||||
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
UntapBlockers * MTGCardInstance::getUntapBlockers(){
|
UntapBlockers * MTGCardInstance::getUntapBlockers(){
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ WEventPhaseChange::WEventPhaseChange(Phase * from, Phase * to) : WEvent(CHANGE_P
|
|||||||
|
|
||||||
WEventCardTap::WEventCardTap(MTGCardInstance * card, bool before, bool after) : WEventCardUpdate(card), before(before), after(after){}
|
WEventCardTap::WEventCardTap(MTGCardInstance * card, bool before, bool after) : WEventCardUpdate(card), before(before), after(after){}
|
||||||
|
|
||||||
|
WEventCardChangeType::WEventCardChangeType(MTGCardInstance * card, int type, bool before, bool after) : WEventCardUpdate(card), type(type), before(before), after(after){}
|
||||||
|
|
||||||
WEventCreatureAttacker::WEventCreatureAttacker(MTGCardInstance * card, Targetable * before, Targetable * after) : WEventCardUpdate(card), before(before), after(after){}
|
WEventCreatureAttacker::WEventCreatureAttacker(MTGCardInstance * card, Targetable * before, Targetable * after) : WEventCardUpdate(card), before(before), after(after){}
|
||||||
|
|
||||||
WEventCreatureBlocker::WEventCreatureBlocker(MTGCardInstance * card, MTGCardInstance * from,MTGCardInstance * to) : WEventCardUpdate(card), before(from), after(to){}
|
WEventCreatureBlocker::WEventCreatureBlocker(MTGCardInstance * card, MTGCardInstance * from,MTGCardInstance * to) : WEventCardUpdate(card), before(from), after(to){}
|
||||||
|
|||||||
Reference in New Issue
Block a user