|
|
|
|
@@ -1085,26 +1085,29 @@ HUDDisplay::~HUDDisplay(){
|
|
|
|
|
|
|
|
|
|
//putting cards with restricting effects inplay
|
|
|
|
|
MTGCantCasterstart::MTGCantCasterstart(int _id):MTGAbility(_id,NULL){};
|
|
|
|
|
|
|
|
|
|
int MTGCantCasterstart::receiveEvent(WEvent * event){
|
|
|
|
|
if (event->type == WEvent::CHANGE_ZONE){
|
|
|
|
|
WEventZoneChange * e = (WEventZoneChange *) event;
|
|
|
|
|
MTGCardInstance * card = e->card->previous;
|
|
|
|
|
if(card){
|
|
|
|
|
if (card->basicAbilities[Constants::BOTHCANTCAST] || card->basicAbilities[Constants::BOTHNOCREATURE] || card->basicAbilities[Constants::CANTCAST] || card->basicAbilities[Constants::CANTCASTCREATURE] || card->basicAbilities[Constants::CANTCASTTWO] || card->basicAbilities[Constants::ONLYONEBOTH] || card->basicAbilities[Constants::NOMAXHAND] ){
|
|
|
|
|
if(card){
|
|
|
|
|
if (card->basicAbilities[Constants::BOTHCANTCAST] || card->basicAbilities[Constants::BOTHNOCREATURE] || card->basicAbilities[Constants::CANTCAST] || card->basicAbilities[Constants::CANTCASTCREATURE] || card->basicAbilities[Constants::CANTCASTTWO] || card->basicAbilities[Constants::ONLYONEBOTH] || card->basicAbilities[Constants::NOMAXHAND] ){
|
|
|
|
|
int ok = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 2 ; i++){
|
|
|
|
|
Player * p = game->players[i];
|
|
|
|
|
if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile){ ok = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 2 ; i++){
|
|
|
|
|
Player * p = game->players[i];
|
|
|
|
|
if (e->to == p->game->inPlay){//this will trigger a check if opponent or player cast the card.
|
|
|
|
|
|
|
|
|
|
if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->to == p->game->inPlay || e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->from == p->game->inPlay ){ ok = 1;
|
|
|
|
|
//check happens----------
|
|
|
|
|
//reset restrictions if they exist and runs a check if these cards still exist.
|
|
|
|
|
p->nomaxhandsize = 0;
|
|
|
|
|
p->opponent()->nomaxhandsize = 0;
|
|
|
|
|
p->onlyonecast = 0;
|
|
|
|
|
p->opponent()->onlyonecast = 0;
|
|
|
|
|
p->castrestrictedspell = 0;//0 means no restrictions apply.
|
|
|
|
|
p->castrestrictedcreature = 0;
|
|
|
|
|
p->opponent()->castrestrictedspell = 0;
|
|
|
|
|
p->opponent()->castrestrictedcreature = 0;
|
|
|
|
|
/*--------------------------------------------------------------*/
|
|
|
|
|
for (int i = 0; i < 2 ; i++){
|
|
|
|
|
Player * p = game->players[i];
|
|
|
|
|
MTGGameZone * z = card->controller()->game->inPlay;
|
|
|
|
|
MTGGameZone * y = card->controller()->opponent()->game->inPlay;
|
|
|
|
|
int nbcards = z->nb_cards;
|
|
|
|
|
@@ -1113,122 +1116,66 @@ HUDDisplay::~HUDDisplay(){
|
|
|
|
|
//check my battlefield and opponents
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::NOMAXHAND)){
|
|
|
|
|
if (c->has(Constants::NOMAXHAND)){
|
|
|
|
|
card->controller()->nomaxhandsize = 1;
|
|
|
|
|
}
|
|
|
|
|
} //any on other side?
|
|
|
|
|
if (c->has(Constants::BOTHCANTCAST)){
|
|
|
|
|
card->controller()->castrestrictedspell = 1;
|
|
|
|
|
card->controller()->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
if (c->has(Constants::CANTCAST)){
|
|
|
|
|
card->controller()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
if (c->has(Constants::BOTHNOCREATURE)){
|
|
|
|
|
card->controller()->castrestrictedcreature += 1;
|
|
|
|
|
card->controller()->opponent()->castrestrictedcreature += 1;
|
|
|
|
|
}
|
|
|
|
|
if (c->has(Constants::CANTCASTCREATURE)){
|
|
|
|
|
card->controller()->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
if (c->has(Constants::ONLYONEBOTH)){
|
|
|
|
|
card->controller()->onlyonecast = 1;
|
|
|
|
|
card->controller()->opponent()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
if (c->has(Constants::CANTCASTTWO)){
|
|
|
|
|
card->controller()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//any on other side?
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::NOMAXHAND)){
|
|
|
|
|
card->controller()->opponent()->nomaxhandsize = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//--------------both cant cast-----------------
|
|
|
|
|
//check my battlefield and opponents
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHCANTCAST)){
|
|
|
|
|
if (c->has(Constants::BOTHCANTCAST)){
|
|
|
|
|
card->controller()->castrestrictedspell = 1;
|
|
|
|
|
card->controller()->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
} //any on other side?
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHCANTCAST)){
|
|
|
|
|
card->controller()->castrestrictedspell = 1;
|
|
|
|
|
card->controller()->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe one of us is still restricted, lets check...
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCAST)){
|
|
|
|
|
card->controller()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
} //any on other side?
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCAST)){
|
|
|
|
|
card->controller()->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---how about if we cant cast creatures---
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHNOCREATURE)){
|
|
|
|
|
card->controller()->castrestrictedcreature += 1;
|
|
|
|
|
card->controller()->opponent()->castrestrictedcreature += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHNOCREATURE)){
|
|
|
|
|
|
|
|
|
|
if (c->has(Constants::BOTHNOCREATURE)){
|
|
|
|
|
card->controller()->castrestrictedcreature = 1;
|
|
|
|
|
card->controller()->opponent()->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTCREATURE)){
|
|
|
|
|
card->controller()->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTCREATURE)){
|
|
|
|
|
if (c->has(Constants::CANTCASTCREATURE)){
|
|
|
|
|
card->controller()->opponent()->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---what if i can only cast 1?
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::ONLYONEBOTH)){
|
|
|
|
|
if (c->has(Constants::ONLYONEBOTH)){
|
|
|
|
|
card->controller()->onlyonecast = 1;
|
|
|
|
|
card->controller()->opponent()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::ONLYONEBOTH)){
|
|
|
|
|
card->controller()->onlyonecast = 1;
|
|
|
|
|
if (c->has(Constants::CANTCASTTWO)){
|
|
|
|
|
card->controller()->opponent()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTTWO)){
|
|
|
|
|
card->controller()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTTWO)){
|
|
|
|
|
card->controller()->opponent()->onlyonecast = 1;
|
|
|
|
|
if (c->has(Constants::CANTCAST)){
|
|
|
|
|
card->controller()->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//-----if a card with both*restrict* was found then the players are still restricted, if one player is still restricted he stays restricted.
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
ostream& MTGCantCasterstart::toString(ostream& out) const
|
|
|
|
|
@@ -1242,164 +1189,6 @@ HUDDisplay::~HUDDisplay(){
|
|
|
|
|
a->isClone = 1;
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//check if cast resristrictions are lifted when a card leaves play
|
|
|
|
|
MTGCantCastercheck::MTGCantCastercheck(int _id):MTGAbility(_id,NULL){};
|
|
|
|
|
|
|
|
|
|
int MTGCantCastercheck::receiveEvent(WEvent * event){
|
|
|
|
|
if (event->type == WEvent::CHANGE_ZONE){
|
|
|
|
|
WEventZoneChange * e = (WEventZoneChange *) event;
|
|
|
|
|
MTGCardInstance * card = e->card->previous;
|
|
|
|
|
if (card && (card->basicAbilities[Constants::BOTHCANTCAST] || card->basicAbilities[Constants::BOTHNOCREATURE] || card->basicAbilities[Constants::CANTCAST] || card->basicAbilities[Constants::CANTCASTCREATURE] || card->basicAbilities[Constants::CANTCASTTWO] || card->basicAbilities[Constants::ONLYONEBOTH]|| card->basicAbilities[Constants::NOMAXHAND])){
|
|
|
|
|
int ok = 0;
|
|
|
|
|
for (int i = 0; i < 2 ; i++){
|
|
|
|
|
Player * p = game->players[i];
|
|
|
|
|
if (e->from == p->game->inPlay) ok = 1;
|
|
|
|
|
}
|
|
|
|
|
if (!ok) return 0;
|
|
|
|
|
for (int i = 0; i < 2 ; i++){
|
|
|
|
|
Player * p = game->players[i];
|
|
|
|
|
if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile){//if it goes ANYWHERE but inplay.
|
|
|
|
|
//check happens----------
|
|
|
|
|
//reset restrictions
|
|
|
|
|
p->nomaxhandsize = 0;
|
|
|
|
|
p->opponent()->nomaxhandsize = 0;
|
|
|
|
|
p->onlyonecast = 0;
|
|
|
|
|
p->opponent()->onlyonecast = 0;
|
|
|
|
|
p->castrestrictedspell = 0;//0 means no restrictions apply.
|
|
|
|
|
p->castrestrictedcreature = 0;
|
|
|
|
|
p->opponent()->castrestrictedspell = 0;
|
|
|
|
|
p->opponent()->castrestrictedcreature = 0;
|
|
|
|
|
/*--------------------------------------------------------------*/
|
|
|
|
|
MTGGameZone * z = card->controller()->game->inPlay;
|
|
|
|
|
MTGGameZone * y = card->controller()->opponent()->game->inPlay;
|
|
|
|
|
int nbcards = z->nb_cards;
|
|
|
|
|
int onbcards = y->nb_cards;
|
|
|
|
|
|
|
|
|
|
//no max hand size
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::NOMAXHAND)){
|
|
|
|
|
p->nomaxhandsize = 1;
|
|
|
|
|
}
|
|
|
|
|
} //any on other side?
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::NOMAXHAND)){
|
|
|
|
|
p->opponent()->nomaxhandsize = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//check my battlefield and opponents
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHCANTCAST)){
|
|
|
|
|
p->castrestrictedspell = 1;
|
|
|
|
|
p->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
} //any on other side?
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHCANTCAST)){
|
|
|
|
|
p->castrestrictedspell = 1;
|
|
|
|
|
p->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe one of us is still restricted, lets check...
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCAST)){
|
|
|
|
|
p->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
} //any on other side?
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCAST)){
|
|
|
|
|
p->opponent()->castrestrictedspell = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---how about if we cant cast creatures---
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHNOCREATURE)){
|
|
|
|
|
p->castrestrictedcreature = 1;
|
|
|
|
|
p->opponent()->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::BOTHNOCREATURE)){
|
|
|
|
|
p->castrestrictedcreature = 1;
|
|
|
|
|
p->opponent()->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTCREATURE)){
|
|
|
|
|
p->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTCREATURE)){
|
|
|
|
|
p->opponent()->castrestrictedcreature = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---what if i can only cast 1?
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::ONLYONEBOTH)){
|
|
|
|
|
p->onlyonecast = 1;
|
|
|
|
|
p->opponent()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::ONLYONEBOTH)){
|
|
|
|
|
p->onlyonecast = 1;
|
|
|
|
|
p->opponent()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
for (int j = 0; j < nbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = z->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTTWO)){
|
|
|
|
|
p->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//maybe opponent has one....
|
|
|
|
|
for (int j = 0; j < onbcards; ++j){
|
|
|
|
|
MTGCardInstance * c = y->cards[j];
|
|
|
|
|
if (c->has(Constants::CANTCASTTWO)){
|
|
|
|
|
p->opponent()->onlyonecast = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//-----if a card with both*restrict* was found then the players are still restricted, if one player is still restricted he stays restricted.
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ostream& MTGCantCastercheck::toString(ostream& out) const
|
|
|
|
|
{
|
|
|
|
|
out << "MTGCantCastercheck ::: (";
|
|
|
|
|
return MTGAbility::toString(out) << ")";
|
|
|
|
|
}
|
|
|
|
|
int MTGCantCastercheck::testDestroy(){return 0;}
|
|
|
|
|
MTGCantCastercheck * MTGCantCastercheck::clone() const{
|
|
|
|
|
MTGCantCastercheck * a = NEW MTGCantCastercheck(*this);
|
|
|
|
|
a->isClone = 1;
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
//the end of this very complex code line.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|