Erwan
- tap/untap of a card now sends an event
This commit is contained in:
@@ -71,7 +71,7 @@ void AIPlayer::tapLandsForMana(ManaCost * potentialMana, ManaCost * cost){
|
||||
GameObserver * gameObs = GameObserver::GetInstance();
|
||||
CardDescriptor cd;
|
||||
cd.setColor(Constants::MTG_COLOR_LAND);
|
||||
cd.tapped = -1;
|
||||
cd.unsecureSetTapped(-1);
|
||||
|
||||
MTGCardInstance * card = NULL;
|
||||
while((card = cd.nextmatch(game->inPlay, card))){
|
||||
@@ -99,7 +99,7 @@ ManaCost * AIPlayer::getPotentialMana(){
|
||||
potentialMana = NEW ManaCost();
|
||||
CardDescriptor cd;
|
||||
cd.setColor(Constants::MTG_COLOR_LAND);
|
||||
cd.tapped = -1;
|
||||
cd.unsecureSetTapped(-1);
|
||||
MTGCardInstance * card = NULL;
|
||||
while((card = cd.nextmatch(game->inPlay, card))){
|
||||
|
||||
@@ -353,7 +353,7 @@ int AIPlayer::getCreaturesInfo(Player * player, int neededInfo , int untapMode,
|
||||
CardDescriptor cd;
|
||||
cd.init();
|
||||
cd.setType("Creature");
|
||||
cd.tapped = untapMode;
|
||||
cd.unsecureSetTapped(untapMode);
|
||||
MTGCardInstance * card = NULL;
|
||||
while((card = cd.nextmatch(player->game->inPlay, card))){
|
||||
if (!canAttack || card->canAttack()){
|
||||
@@ -414,7 +414,7 @@ int AIPlayer::chooseBlockers(){
|
||||
CardDescriptor cd;
|
||||
cd.init();
|
||||
cd.setType("Creature");
|
||||
cd.tapped = -1;
|
||||
cd.unsecureSetTapped(-1);
|
||||
MTGCardInstance * card = NULL;
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
MTGAbility * a = g->mLayers->actionLayer()->getAbility(MTGAbility::MTG_BLOCK_RULE);
|
||||
|
||||
@@ -13,6 +13,10 @@ int CardDescriptor::init(){
|
||||
return result;
|
||||
}
|
||||
|
||||
void CardDescriptor::unsecureSetTapped(int i){
|
||||
tapped = i;
|
||||
}
|
||||
|
||||
void CardDescriptor::setNegativeSubtype( string value){
|
||||
int id = Subtypes::subtypesList->Add(value);
|
||||
addType(-id);
|
||||
|
||||
@@ -34,7 +34,7 @@ int ConstraintResolver::untap(GameObserver * game, MTGCardInstance * card){
|
||||
|
||||
if (ok) {
|
||||
player->getManaPool()->pay(untapManaCost);
|
||||
card->untap();
|
||||
card->attemptUntap();
|
||||
}
|
||||
delete untapManaCost;
|
||||
return ok;
|
||||
|
||||
@@ -94,7 +94,7 @@ int AbilityFactory::TapAll(TargetChooser * tc){
|
||||
for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||
MTGCardInstance * current = g->players[i]->game->inPlay->cards[j];
|
||||
if (tc->canTarget(current)){
|
||||
current->tapped = 1;
|
||||
current->tap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ int AbilityFactory::UntapAll(TargetChooser * tc){
|
||||
for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||
MTGCardInstance * current = g->players[i]->game->inPlay->cards[j];
|
||||
if (tc->canTarget(current)){
|
||||
current->tapped = 0;
|
||||
current->untap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,7 +390,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
||||
if (cost){
|
||||
game->addObserver(NEW AUntapManaBlocker(id, card, cost));
|
||||
}else{
|
||||
target->tapped = 0;
|
||||
target->untap();
|
||||
}
|
||||
}
|
||||
result++;
|
||||
@@ -1011,7 +1011,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
||||
game->addObserver(NEW ATapper(id, card, cost, tc));
|
||||
}
|
||||
}else{
|
||||
target->tapped = 1;
|
||||
target->tap();
|
||||
}
|
||||
result++;
|
||||
continue;
|
||||
@@ -1447,7 +1447,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
|
||||
MTGInPlay * inplay = player->game->inPlay;
|
||||
for (int i = 0; i < inplay->nb_cards; i++){
|
||||
MTGCardInstance * current = inplay->cards[i];
|
||||
if (current->hasType("land")) current->tapped = 1;
|
||||
if (current->hasType("land")) current->tap();
|
||||
}
|
||||
player->getManaPool()->init();
|
||||
}
|
||||
@@ -1465,7 +1465,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
|
||||
{
|
||||
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4};
|
||||
game->addObserver(NEW AUntapManaBlocker(_id, card,card->target, NEW ManaCost(cost,1)));
|
||||
card->target->tapped = 1;
|
||||
card->target->tap();
|
||||
break;
|
||||
}
|
||||
case 1172: //Pestilence
|
||||
@@ -1784,7 +1784,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
|
||||
}
|
||||
case 1480: //Energy Tap
|
||||
{
|
||||
card->target->tapped = 1;
|
||||
card->target->tap();
|
||||
int mana = card->target->getManaCost()->getConvertedCost();
|
||||
game->currentlyActing()->getManaPool()->add(Constants::MTG_COLOR_ARTIFACT, mana);
|
||||
}
|
||||
@@ -2360,7 +2360,7 @@ int ActivatedAbility::reactToClick(MTGCardInstance * card){
|
||||
game->currentlyActing()->getManaPool()->pay(cost);
|
||||
cost->doPayExtra();
|
||||
}
|
||||
if (needsTapping) source->tapped = 1;
|
||||
if (needsTapping) source->tap();
|
||||
fireAbility();
|
||||
|
||||
return 1;
|
||||
@@ -2369,7 +2369,7 @@ int ActivatedAbility::reactToClick(MTGCardInstance * card){
|
||||
|
||||
int ActivatedAbility::reactToTargetClick(Targetable * object){
|
||||
if (!isReactingToTargetClick(object)) return 0;
|
||||
if (needsTapping) source->tapped = 1;
|
||||
if (needsTapping) source->tap();
|
||||
if (cost){
|
||||
if (object->typeAsTarget() == TARGET_CARD) cost->setExtraCostsAction(this, (MTGCardInstance *) object);
|
||||
OutputDebugString("React To click 2\n");
|
||||
@@ -2819,7 +2819,7 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
|
||||
GameObserver::GetInstance()->currentlyActing()->getManaPool()->pay(cost);
|
||||
cost->doPayExtra();
|
||||
}
|
||||
if (tap) source->tapped = 1;
|
||||
if (tap) source->tap();
|
||||
currentlyTapping++;
|
||||
|
||||
animation = 1.f;
|
||||
|
||||
@@ -172,9 +172,24 @@ int MTGCardInstance::has(int basicAbility){
|
||||
|
||||
//Taps the card
|
||||
void MTGCardInstance::tap(){
|
||||
if (tapped) return;
|
||||
tapped = 1;
|
||||
WEvent * e = NEW WEventCardTap(this, 0, 1);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
void MTGCardInstance::untap(){
|
||||
if (!tapped) return;
|
||||
tapped = 0;
|
||||
WEvent * e = NEW WEventCardTap(this, 1, 0);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
|
||||
void MTGCardInstance::setUntapping(){
|
||||
untapping = 1;
|
||||
}
|
||||
@@ -183,10 +198,10 @@ int MTGCardInstance::isUntapping(){
|
||||
return untapping;
|
||||
}
|
||||
|
||||
//Untaps the card
|
||||
void MTGCardInstance::untap(){
|
||||
//Tries to Untap the card
|
||||
void MTGCardInstance::attemptUntap(){
|
||||
if (untapping){
|
||||
tapped = 0;
|
||||
untap();
|
||||
untapping = 0;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +225,7 @@ int MTGCardInstance::regenerate(){
|
||||
int MTGCardInstance::triggerRegenerate(){
|
||||
if (! regenerateTokens) return 0;
|
||||
regenerateTokens--;
|
||||
tapped = 1;
|
||||
tap();
|
||||
life = toughness;
|
||||
initAttackersDefensers();
|
||||
return 1;
|
||||
@@ -269,7 +284,7 @@ MTGCardInstance * MTGCardInstance::changeController(Player * newController){
|
||||
//Reset the card parameters
|
||||
int MTGCardInstance::reset(){
|
||||
cleanup();
|
||||
tapped=0;
|
||||
untap();
|
||||
SAFE_DELETE(counters);
|
||||
counters = NEW Counters(this);
|
||||
return 1;
|
||||
@@ -383,7 +398,7 @@ int MTGCardInstance::toggleAttacker(){
|
||||
if (canAttack()){
|
||||
if (!attacker){
|
||||
attacker = 1;
|
||||
tapped = 1;
|
||||
tap();
|
||||
return 1;
|
||||
}else{
|
||||
MTGCardInstance * bandingPartner = getNextPartner();
|
||||
@@ -394,7 +409,7 @@ int MTGCardInstance::toggleAttacker(){
|
||||
return 1;
|
||||
}else{
|
||||
attacker = 0;
|
||||
tapped = 0;
|
||||
untap();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ void MTGInPlay::untapAll(){
|
||||
sprintf(buf, "Can untap %s\n", cards[i]->getName());
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
cards[i]->untap();
|
||||
cards[i]->attemptUntap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,19 +199,16 @@ void MTGGuiPlay::forceUpdateCards(){
|
||||
}
|
||||
|
||||
int MTGGuiPlay::receiveEvent(WEvent *event){
|
||||
if (event->type == WEvent::CHANGE_ZONE){
|
||||
WEventZoneChange * e = dynamic_cast<WEventZoneChange*>(event);
|
||||
if (!event) return 0;
|
||||
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;
|
||||
WEventZoneChange * e = dynamic_cast<WEventZoneChange*>(event);
|
||||
if (!e) return 0;
|
||||
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;
|
||||
}
|
||||
return 0;
|
||||
if (!ok) return 0;
|
||||
forceUpdateCards();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void MTGGuiPlay::updateCards(){
|
||||
|
||||
@@ -110,7 +110,7 @@ void MTGAttackRule::Update(float dt){
|
||||
int MTGAttackRule::reactToClick(MTGCardInstance * card){
|
||||
if (!isReactingToClick(card)) return 0;
|
||||
card->attacker = 1;
|
||||
if (!card->basicAbilities[Constants::VIGILANCE]) card->tapped = 1;
|
||||
if (!card->basicAbilities[Constants::VIGILANCE]) card->tap();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,9 +138,9 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
//Tapped, untapped
|
||||
}else if (attribute.find("tapped") != string::npos){
|
||||
if (minus){
|
||||
cd->tapped = -1;
|
||||
cd->unsecureSetTapped(-1);
|
||||
}else{
|
||||
cd->tapped = 1;
|
||||
cd->unsecureSetTapped(1);
|
||||
}
|
||||
}else{
|
||||
int attributefound = 0;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../include/Damage.h"
|
||||
#include "../include/PhaseRing.h"
|
||||
|
||||
|
||||
WEvent::WEvent(int _type){
|
||||
type=_type;
|
||||
}
|
||||
@@ -21,4 +22,10 @@ WEventDamage::WEventDamage(Damage *_damage):WEvent(DAMAGE){
|
||||
WEventPhaseChange::WEventPhaseChange(Phase * _from, Phase * _to):WEvent(CHANGE_PHASE){
|
||||
from = _from;
|
||||
to = _to;
|
||||
}
|
||||
|
||||
WEventCardTap::WEventCardTap(MTGCardInstance * _card, int _before, int _after):WEvent(){
|
||||
card = _card;
|
||||
before = _before;
|
||||
after = _after;
|
||||
}
|
||||
Reference in New Issue
Block a user