Erwan
- Event System for MTGGuiPlay.cpp - THIS DOES NOT WORK
This commit is contained in:
@@ -50,6 +50,7 @@ class MTGGuiPlay: public PlayGuiObjectController {
|
|||||||
virtual void Render();
|
virtual void Render();
|
||||||
void forceUpdateCards();
|
void forceUpdateCards();
|
||||||
void updateCards();
|
void updateCards();
|
||||||
|
int receiveEvent(WEvent * e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,24 +46,19 @@ class MTGPersistRule:public MTGAbility{
|
|||||||
MTGPersistRule(int _id):MTGAbility(_id,NULL){};
|
MTGPersistRule(int _id):MTGAbility(_id,NULL){};
|
||||||
|
|
||||||
int receiveEvent(WEvent * event){
|
int receiveEvent(WEvent * event){
|
||||||
OutputDebugString("Receive1\n");
|
|
||||||
if (event->type == WEvent::CHANGE_ZONE){
|
if (event->type == WEvent::CHANGE_ZONE){
|
||||||
OutputDebugString("Receive2\n");
|
|
||||||
WEventZoneChange * e = (WEventZoneChange *) event;
|
WEventZoneChange * e = (WEventZoneChange *) event;
|
||||||
MTGCardInstance * card = e->card->previous;
|
MTGCardInstance * card = e->card->previous;
|
||||||
if (card && card->basicAbilities[Constants::PERSIST] && !card->counters->hasCounter(-1,-1)){
|
if (card && card->basicAbilities[Constants::PERSIST] && !card->counters->hasCounter(-1,-1)){
|
||||||
OutputDebugString("Receive3\n");
|
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
for (int i = 0; i < 2 ; i++){
|
for (int i = 0; i < 2 ; i++){
|
||||||
Player * p = game->players[i];
|
Player * p = game->players[i];
|
||||||
if (e->from == p->game->inPlay) ok = 1;
|
if (e->from == p->game->inPlay) ok = 1;
|
||||||
}
|
}
|
||||||
if (!ok) return 0;
|
if (!ok) return 0;
|
||||||
OutputDebugString("Receive4\n");
|
|
||||||
for (int i = 0; i < 2 ; i++){
|
for (int i = 0; i < 2 ; i++){
|
||||||
Player * p = game->players[i];
|
Player * p = game->players[i];
|
||||||
if (e->to == p->game->graveyard){
|
if (e->to == p->game->graveyard){
|
||||||
OutputDebugString("Receive5\n");
|
|
||||||
//p->game->putInZone(card, p->game->graveyard, card->owner->game->hand);
|
//p->game->putInZone(card, p->game->graveyard, card->owner->game->hand);
|
||||||
MTGCardInstance * copy = p->game->putInZone(e->card, p->game->graveyard, e->card->owner->game->stack);
|
MTGCardInstance * copy = p->game->putInZone(e->card, p->game->graveyard, e->card->owner->game->stack);
|
||||||
Spell * spell = NEW Spell(copy);
|
Spell * spell = NEW Spell(copy);
|
||||||
|
|||||||
@@ -199,6 +199,22 @@ void MTGGuiPlay::forceUpdateCards(){
|
|||||||
currentPlayer = game->currentPlayer;
|
currentPlayer = game->currentPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MTGGuiPlay::receiveEvent(WEvent *event){
|
||||||
|
return 0;
|
||||||
|
if (event->type == WEvent::CHANGE_ZONE){
|
||||||
|
WEventZoneChange * e = (WEventZoneChange *) event;
|
||||||
|
int ok = 0;
|
||||||
|
for (int i = 0; i < 2 ; i++){
|
||||||
|
Player * p = game->players[i];
|
||||||
|
if (e->from == p->game->inPlay || e->to == p->game->inPlay ) ok = 1;
|
||||||
|
}
|
||||||
|
if (!ok) return 0;
|
||||||
|
forceUpdateCards();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MTGGuiPlay::updateCards(){
|
void MTGGuiPlay::updateCards(){
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
Player * player = game->players[0];
|
Player * player = game->players[0];
|
||||||
@@ -213,9 +229,7 @@ void MTGGuiPlay::updateCards(){
|
|||||||
|
|
||||||
Player * opponent = game->players[1];
|
Player * opponent = game->players[1];
|
||||||
int opponent_cards = opponent ->game->inPlay->nb_cards;
|
int opponent_cards = opponent ->game->inPlay->nb_cards;
|
||||||
if (mCount - offset != (nb_cards+opponent_cards) || game->currentPlayer != currentPlayer ){ //if the number of cards has changed, then an update occured (is this test engouh ?)
|
|
||||||
forceUpdateCards();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//This is just so that we display the cards of the current player first, so that blockers are correctly positionned
|
//This is just so that we display the cards of the current player first, so that blockers are correctly positionned
|
||||||
|
|||||||
Reference in New Issue
Block a user