From ab445c9758f587189188143fe56e99d782255c35 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Sun, 12 Jul 2009 12:27:55 +0000 Subject: [PATCH] Erwan - Added a few cards - Creature attacks, blocks, is re-ordered in blocking list events --- projects/mtg/bin/Res/sets/ALA/_cards.dat | 9 +++ projects/mtg/bin/Res/sets/ALA/todo.dat | 9 +-- projects/mtg/bin/Res/sets/EVE/_cards.dat | 12 +++ projects/mtg/bin/Res/sets/LRW/_cards.dat | 12 +++ projects/mtg/bin/Res/sets/LRW/todo.dat | 12 +-- projects/mtg/bin/Res/sets/POR/_cards.dat | 91 ++++++++++++++++++++++ projects/mtg/bin/Res/sets/POR/todo.dat | 90 +++------------------ projects/mtg/bin/Res/test/_tests.txt | 3 +- projects/mtg/bin/Res/test/necrogenesis.txt | 19 +++++ projects/mtg/include/AllAbilities.h | 9 ++- projects/mtg/include/MTGCardInstance.h | 2 + projects/mtg/include/WEvent.h | 47 ++++++++++- projects/mtg/src/CardDescriptor.cpp | 4 +- projects/mtg/src/MTGCardInstance.cpp | 87 ++++++++++++--------- projects/mtg/src/MTGRules.cpp | 3 +- projects/mtg/src/Player.cpp | 1 + projects/mtg/src/TestSuiteAI.cpp | 2 +- projects/mtg/src/Token.cpp | 4 +- projects/mtg/src/WEvent.cpp | 12 ++- 19 files changed, 280 insertions(+), 148 deletions(-) create mode 100644 projects/mtg/bin/Res/test/necrogenesis.txt diff --git a/projects/mtg/bin/Res/sets/ALA/_cards.dat b/projects/mtg/bin/Res/sets/ALA/_cards.dat index 18d6c6f16..b22d04e2c 100644 --- a/projects/mtg/bin/Res/sets/ALA/_cards.dat +++ b/projects/mtg/bin/Res/sets/ALA/_cards.dat @@ -597,6 +597,15 @@ subtype=Human Shaman toughness=2 [/card] [card] +text={2}: Remove target creature card in a graveyard from the game. Put a 1/1 green Saproling creature token into play. +auto={2}:moveTo(exile) target(creature|graveyard) && token(Saproling,creature saproling, 1/1,green) +id=175023 +name=Necrogenesis +rarity=U +type=Enchantment +mana={B}{G} +[/card] +[card] text={T}: Add {G}, {W}, or {U} to your mana pool. auto={T}:Add{G} auto={T}:Add{W} diff --git a/projects/mtg/bin/Res/sets/ALA/todo.dat b/projects/mtg/bin/Res/sets/ALA/todo.dat index bfb359614..55ae99cfc 100644 --- a/projects/mtg/bin/Res/sets/ALA/todo.dat +++ b/projects/mtg/bin/Res/sets/ALA/todo.dat @@ -865,14 +865,7 @@ name=Naya Panorama rarity=C type=Land [/card] -[card] -text={2}: Remove target creature card in a graveyard from the game. Put a 1/1 green Saproling creature token into play. -id=175023 -name=Necrogenesis -rarity=U -type=Enchantment -mana={B}{G} -[/card] + [card] text=When Oblivion Ring comes into play, remove another target nonland permanent from the game. When Oblivion Ring leaves play, return the removed card to play under its owner's control. id=174909 diff --git a/projects/mtg/bin/Res/sets/EVE/_cards.dat b/projects/mtg/bin/Res/sets/EVE/_cards.dat index 2ce7cfbed..6454dddd0 100644 --- a/projects/mtg/bin/Res/sets/EVE/_cards.dat +++ b/projects/mtg/bin/Res/sets/EVE/_cards.dat @@ -42,6 +42,18 @@ type=Instant mana={1}{WB} [/card] [card] +text={BG}{BG}: Remove target card in a graveyard from the game. You gain 1 life. +auto={BG}{BG}:moveTo(exile) target(*|graveyard) && life:1 +id=157206 +name=Creakwood Ghoul +rarity=U +type=Creature +mana={4}{B} +power=3 +subtype=Plant Zombie +toughness=3 +[/card] +[card] text=Target creature gains double strike until end of turn. (It deals both first-strike and regular combat damage.) target=creature auto=double strike diff --git a/projects/mtg/bin/Res/sets/LRW/_cards.dat b/projects/mtg/bin/Res/sets/LRW/_cards.dat index 422b3c4d7..2f6bc2f0d 100644 --- a/projects/mtg/bin/Res/sets/LRW/_cards.dat +++ b/projects/mtg/bin/Res/sets/LRW/_cards.dat @@ -21,6 +21,18 @@ mana={2}{W} subtype=Aura [/card] [card] +text={2}{B}: Regenerate target Treefolk. +auto={2}{B}:regenerate target(treefolk) +id=139454 +name=Black Poplar Shaman +rarity=C +type=Creature +mana={2}{B} +power=1 +subtype=Treefolk Shaman +toughness=3 +[/card] +[card] text=Blind-Spot Giant can't attack or block unless you control another Giant. id=146597 name=Blind-Spot Giant diff --git a/projects/mtg/bin/Res/sets/LRW/todo.dat b/projects/mtg/bin/Res/sets/LRW/todo.dat index df098af75..b7773bc41 100644 --- a/projects/mtg/bin/Res/sets/LRW/todo.dat +++ b/projects/mtg/bin/Res/sets/LRW/todo.dat @@ -137,17 +137,7 @@ power=5 subtype=Elemental toughness=5 [/card] -[card] -text={2}{B}: Regenerate target Treefolk. -id=139454 -name=Black Poplar Shaman -rarity=C -type=Creature -mana={2}{B} -power=1 -subtype=Treefolk Shaman -toughness=3 -[/card] + [card] text=Changeling (This card is every creature type at all times.) Up to two target creatures each get +2/+0 and gain all creature types until end of turn. id=139480 diff --git a/projects/mtg/bin/Res/sets/POR/_cards.dat b/projects/mtg/bin/Res/sets/POR/_cards.dat index d7f2d40b3..5d7edc7af 100644 --- a/projects/mtg/bin/Res/sets/POR/_cards.dat +++ b/projects/mtg/bin/Res/sets/POR/_cards.dat @@ -91,6 +91,15 @@ mana={1}{B} type=Instant [/card] [card] +text=Target opponent reveals his or her hand. You draw a card for each Mountain and red card in it. +auto=foreach(*[land,red]|opponenthand) draw:1 +id=4249 +name=Baleful Stare +rarity=U +type=Sorcery +mana={2}{U} +[/card] +[card] text=Bee Sting deals 2 damage to target creature or player. id=4289 target=creature,player @@ -101,6 +110,24 @@ mana={3}{G} type=Sorcery [/card] [card] +text=You gain 3 life for each creature attacking you. +auto=foreach(creature[attacking]|opponentinplay) life:3 +id=4375 +name=Blessed Reversal +rarity=R +type=Instant +mana={1}{W} +[/card] +[card] +text=Tap all nonwhite creatures. +auto=tap all(creature[-white]) +id=4376 +name=Blinding Light +rarity=R +type=Sorcery +mana={2}{W} +[/card] +[card] text=Flying id=4209 name=Bog Imp @@ -282,6 +309,19 @@ subtype=Human Knight toughness=2 [/card] [card] +text=Deep-Sea Serpent can't attack unless defending player controls an Island. +abilities=cantattack +auto=aslongas(island|opponentinplay) -cantattack +id=4258 +name=Deep-Sea Serpent +rarity=U +type=Creature +mana={4}{U}{U} +power=5 +subtype=Serpent +toughness=5 +[/card] +[card] text=Play Defiant Stand only during the declare attackers step and only if you are the defending player. Target creature gets +1/+3 until the end of the turn. If that creature is tapped, untap it. target=creature auto=untap @@ -798,6 +838,15 @@ power=2 toughness=3 [/card] [card] +text=Untap all creatures you control. +auto=untap all(creature|myinplay) +id=4303 +name=Mobilize +rarity=C +type=Sorcery +mana={G} +[/card] +[card] text=Target creature gets +4/+4 until end of turn. id=4304 target=creature @@ -1145,6 +1194,18 @@ mana={R} type=Sorcery [/card] [card] +text=When Serpent Assassin comes into play, you may destroy target nonblack creature. +auto=may destroy target(creature[-black]) +id=4237 +name=Serpent Assassin +rarity=R +type=Creature +mana={3}{B}{B} +power=2 +subtype=Snake Assassin +toughness=2 +[/card] +[card] text=When Serpent Warrior comes into play, you lose 3 life. auto=life:-3 id=4238 @@ -1354,6 +1415,18 @@ type=Sorcery mana={2}{U} [/card] [card] +text=Haste (This creature can attack the turn it comes under your control.) When Thundermare comes into play, tap all other creatures. +auto=tap all(creature) other +id=4364 +name=Thundermare +rarity=R +type=Creature +mana={5}{R} +power=5 +subtype=Elemental Horse +toughness=5 +[/card] +[card] text=Put target creature on top of its owner's library. target=creature auto=moveTo(ownerLibrary) @@ -1373,6 +1446,24 @@ mana={3}{U} type=Sorcery [/card] [card] +text=White creatures get +2/+0 until end of turn. +auto=lord(creature[white] 2/0 +id=4402 +name=Valorous Charge +rarity=U +type=Sorcery +mana={1}{W}{W} +[/card] +[card] +text=Creatures you control get +1/+1 until end of turn. +auto=lord(creature|myinplay) 1/1 +id=4406 +name=Warrior's Charge +rarity=C +type=Sorcery +mana={2}{W} +[/card] +[card] text=Search your library for a basic land card and put that card into play. Then shuffle your library. target=land[basic]|myLibrary auto=moveTo(myInplay) diff --git a/projects/mtg/bin/Res/sets/POR/todo.dat b/projects/mtg/bin/Res/sets/POR/todo.dat index 5f97de0c8..267cfb7fb 100644 --- a/projects/mtg/bin/Res/sets/POR/todo.dat +++ b/projects/mtg/bin/Res/sets/POR/todo.dat @@ -33,14 +33,7 @@ rarity=R type=Sorcery mana={3}{U}{U} [/card] -[card] -text=Target opponent reveals his or her hand. You draw a card for each Mountain and red card in it. -id=4249 -name=Baleful Stare -rarity=U -type=Sorcery -mana={2}{U} -[/card] + [card] text=Blaze deals X damage to target creature or player. id=4329 @@ -49,22 +42,8 @@ rarity=U type=Sorcery mana={X}{R} [/card] -[card] -text=You gain 3 life for each creature attacking you. -id=4375 -name=Blessed Reversal -rarity=R -type=Instant -mana={1}{W} -[/card] -[card] -text=Tap all nonwhite creatures. -id=4376 -name=Blinding Light -rarity=R -type=Sorcery -mana={2}{W} -[/card] + + [card] text=Whenever Charging Bandits attacks, it gets +2/+0 until end of turn. id=4212 @@ -140,17 +119,7 @@ rarity=U type=Instant mana={1}{G} [/card] -[card] -text=Deep-Sea Serpent can't attack unless defending player controls an Island. -id=4258 -name=Deep-Sea Serpent -rarity=U -type=Creature -mana={4}{U}{U} -power=5 -subtype=Serpent -toughness=5 -[/card] + [card] text=Until end of turn, black creatures you control can be blocked only by black creatures. id=4216 @@ -314,14 +283,7 @@ power=4 subtype=Human Mercenary Knight toughness=4 [/card] -[card] -text=Untap all creatures you control. -id=4303 -name=Mobilize -rarity=C -type=Sorcery -mana={G} -[/card] + [card] text=As an additional cost to play Natural Order, sacrifice a green creature. Search your library for a green creature card and put it into play. Then shuffle your library. id=4307 @@ -433,17 +395,7 @@ power=2 subtype=Human Soldier toughness=2 [/card] -[card] -text=When Serpent Assassin comes into play, you may destroy target nonblack creature. -id=4237 -name=Serpent Assassin -rarity=R -type=Creature -mana={3}{B}{B} -power=2 -subtype=Snake Assassin -toughness=2 -[/card] + [card] text=Look at target opponent's hand. Draw a card. id=4275 @@ -517,17 +469,7 @@ power=4 subtype=Wurm toughness=4 [/card] -[card] -text=Haste (This creature can attack the turn it comes under your control.) When Thundermare comes into play, tap all other creatures. -id=4364 -name=Thundermare -rarity=R -type=Creature -mana={5}{R} -power=5 -subtype=Elemental Horse -toughness=5 -[/card] + [card] text=Tap up to three target creatures without flying. id=4281 @@ -556,22 +498,8 @@ subtype=Beast toughness=2 [/card] -[card] -text=White creatures get +2/+0 until end of turn. -id=4402 -name=Valorous Charge -rarity=U -type=Sorcery -mana={1}{W}{W} -[/card] -[card] -text=Creatures you control get +1/+1 until end of turn. -id=4406 -name=Warrior's Charge -rarity=C -type=Sorcery -mana={2}{W} -[/card] + + [card] text=Destroy two target nonblack creatures. You lose 5 life. id=4246 diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index b152a31a6..148f25497 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -104,6 +104,7 @@ master_of_etherium.txt millstone.txt mind_rot.txt nantuko_husk.txt +necrogenesis.txt Nevinyrrals_Disk.txt Nevinyrrals_Disk2.txt nightmare.txt @@ -149,4 +150,4 @@ zombify.txt #Momir Basic Tests ######################## momir/keldon_warlord.txt -momir/overcost.txt \ No newline at end of file +momir/overcost.txt diff --git a/projects/mtg/bin/Res/test/necrogenesis.txt b/projects/mtg/bin/Res/test/necrogenesis.txt new file mode 100644 index 000000000..a330a02d0 --- /dev/null +++ b/projects/mtg/bin/Res/test/necrogenesis.txt @@ -0,0 +1,19 @@ +#Testing && symbol +#necrogensis: text={2}: Remove target creature card in a graveyard from the game. Put a 1/1 green Saproling creature token into play. +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:necrogenesis +manapool:{B}{B} +[PLAYER2] +graveyard:1250 +[DO] +necrogenesis +1250 +[ASSERT] +FIRSTMAIN +[PLAYER1] +inplay:necrogenesis,* +manapool:{0} +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 68af2be3f..3951347a3 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -140,6 +140,7 @@ public: int resolve(){ vector::size_type sz = abilities.size(); for (unsigned int i = 0; i < sz; i++){ + if (target && target!= source && abilities[i]->target == abilities[i]->source) abilities[i]->target = target; abilities[i]->resolve(); } return 1; @@ -1734,8 +1735,7 @@ class AStrongLandLinkCreature: public MTGAbility{ void Update(float dt){ if (source->isAttacker()){ if (!game->opponent()->game->inPlay->hasType(land)){ - source->attacker=0; - source->untap(); + source->toggleAttacker(); //TODO Improve, there can be race conditions here } } @@ -2337,7 +2337,8 @@ class AEbonyHorse:public TargetAbility{ } int resolve(){ - tc->getNextCardTarget()->attacker = 0; + MTGCardInstance * _target = tc->getNextCardTarget(); + if (_target->isAttacker()) _target->toggleAttacker(); return 1; } @@ -3382,7 +3383,7 @@ class AIslandSanctuary:public MTGAbility{ MTGGameZone * zone = game->currentPlayer->game->inPlay; for (int i = 0; i < zone->nb_cards; i++){ MTGCardInstance * card = zone->cards[i]; - if (card->isAttacker() && !card->basicAbilities[Constants::FLYING] && !card->basicAbilities[Constants::ISLANDWALK]) card->attacker=0; + if (card->isAttacker() && !card->basicAbilities[Constants::FLYING] && !card->basicAbilities[Constants::ISLANDWALK]) source->toggleAttacker(); } } } diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 50b2653f9..50257cfca 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -38,6 +38,8 @@ class MTGCardInstance: public MTGCard, public Damageable { void unband(); MTGCardInstance * getNextPartner(); void initMTGCI(); + int setDefenser(MTGCardInstance * c); + int setAttacker(int value); public: int regenerateTokens; bool isToken; diff --git a/projects/mtg/include/WEvent.h b/projects/mtg/include/WEvent.h index c9d9e6db7..0f6b9de91 100644 --- a/projects/mtg/include/WEvent.h +++ b/projects/mtg/include/WEvent.h @@ -5,6 +5,7 @@ class MTGCardInstance; class MTGGameZone; class Damage; class Phase; +class Targetable; class WEvent{ public: @@ -14,7 +15,7 @@ public: DAMAGE = 2, CHANGE_PHASE = 3, }; - int type; + int type; //Deprecated, use dynamic casting instead WEvent(int _type = NOT_SPECIFIED); virtual ~WEvent() {}; }; @@ -42,12 +43,54 @@ public: WEventPhaseChange(Phase * _from, Phase * _to); }; -class WEventCardTap: public WEvent{ + +//Abstract class of event when a card's status changes +class WEventCardUpdate: public WEvent{ public: MTGCardInstance * card; + WEventCardUpdate(MTGCardInstance * card):WEvent(),card(card){}; +}; + +//Event when a card is tapped/untapped +class WEventCardTap: public WEventCardUpdate{ +public: bool before; bool after; WEventCardTap(MTGCardInstance * card, bool before, bool after); }; +//Event when a card's "attacker" status changes +//before:Player/Planeswalker that card was attacking previously +//after: Player/Planeswalker that card is attacking now +class WEventCreatureAttacker: public WEventCardUpdate{ +public: + Targetable * before; + Targetable * after; + WEventCreatureAttacker(MTGCardInstance * card,Targetable * from, Targetable * to); + +}; + +//Event when a card's "defenser" status changes +//before : attacker that card was blocking previously +//after: attacker that card is blocking now +class WEventCreatureBlocker: public WEventCardUpdate{ +public: + MTGCardInstance * before; + MTGCardInstance * after; + WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to); + +}; + +//Event when a blocker is reordered +//exchangeWith: exchange card's position with exchangeWith's position +//attacker:both card and exchangeWith *should* be in attacker's "blockers" list. +class WEventCreatureBlockerRank: public WEventCardUpdate{ +public: + MTGCardInstance * exchangeWith; + MTGCardInstance * attacker; + WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker); + +}; + + #endif diff --git a/projects/mtg/src/CardDescriptor.cpp b/projects/mtg/src/CardDescriptor.cpp index 4a5421c77..87562c5d7 100644 --- a/projects/mtg/src/CardDescriptor.cpp +++ b/projects/mtg/src/CardDescriptor.cpp @@ -9,7 +9,9 @@ CardDescriptor::CardDescriptor(): MTGCardInstance(){ int CardDescriptor::init(){ int result = MTGCardInstance::init(); - initAttackersDefensers(); + attacker = 0; + defenser = NULL; + banding = NULL; return result; } diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 0244e680b..7c044ed9d 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -27,7 +27,8 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to): owner = NULL; if (_belongs_to) owner = _belongs_to->library->owner; lastController = owner; - initAttackersDefensers(); + defenser = NULL; + banding = NULL; life=toughness; LOG("==Creating MTGCardInstance Successful=="); @@ -242,8 +243,8 @@ int MTGCardInstance::triggerRegenerate(){ int MTGCardInstance::initAttackersDefensers(){ - attacker = 0; - defenser = NULL; + setAttacker(0); + setDefenser(NULL); banding = NULL; blockers.clear(); return 1; @@ -403,26 +404,38 @@ void MTGCardInstance::unband(){ return ; } +int MTGCardInstance::setAttacker(int value){ + Targetable * previousTarget = NULL; + Targetable * target = NULL; + Player * p = controller()->opponent(); + if (value) target = p; + if (attacker) previousTarget = p; + attacker = value; + WEvent * e = NEW WEventCreatureAttacker(this,previousTarget, target); + GameObserver::GetInstance()->receiveEvent(e); + delete e; + return 1; +} + int MTGCardInstance::toggleAttacker(){ - //TODO more controls ? - if (canAttack()){ - if (!attacker){ - attacker = 1; - tap(); + GameObserver * g = GameObserver::GetInstance(); + if (!attacker){ + if (!basicAbilities[Constants::VIGILANCE]) tap(); + setAttacker(1); + return 1; + }else{ + //Banding needs to be debugged... + /*MTGCardInstance * bandingPartner = getNextPartner(); + if (bandingPartner){ + if (banding) unband(); + if (!bandingPartner->banding) bandingPartner->banding = bandingPartner; + banding = bandingPartner->banding; return 1; - }else{ - MTGCardInstance * bandingPartner = getNextPartner(); - if (bandingPartner){ - if (banding) unband(); - if (!bandingPartner->banding) bandingPartner->banding = bandingPartner; - banding = bandingPartner->banding; - return 1; - }else{ - attacker = 0; - untap(); - return 1; - } - } + }else{*/ + untap(); + setAttacker(0); + return 1; + //} } return 0; } @@ -465,14 +478,9 @@ int MTGCardInstance::moveBlockerInRow(MTGCardInstance * blocker){ if (it2 == blockers.end()) it2 = blockers.begin(); blockers.splice( it2, blockers, it1 ); // move a before b, invalidates a - char buffer[512]; - OutputDebugString("===Outputing blockers\n"); - for (it1 = blockers.begin(); it1 != blockers.end(); it1++){ - MTGCardInstance * c = *it1; - sprintf(buffer, "%p-", c); - OutputDebugString(buffer); - } - OutputDebugString("\n===End Outputing blockers\n"); + WEvent* e = NEW WEventCreatureBlockerRank(blocker,*it2,this); + GameObserver::GetInstance()->receiveEvent(e); + delete(e); return 1; } @@ -510,15 +518,24 @@ MTGCardInstance * MTGCardInstance::getNextOpponent(MTGCardInstance * previous){ return NULL; } +int MTGCardInstance::setDefenser(MTGCardInstance * opponent){ + GameObserver * g = GameObserver::GetInstance(); + if (defenser) defenser->blockers.remove(this); + WEvent * e = NEW WEventCreatureBlocker(this, defenser, opponent); + defenser = opponent; + if (defenser){ + defenser->blockers.push_back(this); + } + g->blockersSorted = false; + g->receiveEvent(e); + delete e; + return 1; +} + int MTGCardInstance::toggleDefenser(MTGCardInstance * opponent){ if (canBlock()){ if (canBlock(opponent)){ - if (defenser) defenser->blockers.remove(this); - defenser = opponent; - if (defenser){ - defenser->blockers.push_back(this); - } - GameObserver::GetInstance()->blockersSorted = false; + setDefenser(opponent); return 1; } } diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 466965cda..2f530268b 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -116,8 +116,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->tap(); + card->toggleAttacker(); return 1; } diff --git a/projects/mtg/src/Player.cpp b/projects/mtg/src/Player.cpp index 091370130..008210890 100644 --- a/projects/mtg/src/Player.cpp +++ b/projects/mtg/src/Player.cpp @@ -50,6 +50,7 @@ JQuad * Player::getIcon(){ Player * Player::opponent(){ GameObserver * game = GameObserver::GetInstance(); + if (!game) return NULL; for (int i= 0; i < 2; i++){ if (game->players[i] != this) return game->players[i]; } diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index c88cfd43e..01c17deb5 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -354,7 +354,7 @@ int TestSuite::assertGame(){ for (int j = 0; j < 4; j++){ MTGGameZone * zone = playerZones[j]; if (zone->nb_cards != endState.playerData[i].zones[j].nbitems){ - sprintf(result, "==Card number not the same in %i==
",j); + sprintf(result, "==Card number not the same in %i==, expected %i, got %i
",j, endState.playerData[i].zones[j].nbitems, zone->nb_cards); Log(result); error++; return 0; diff --git a/projects/mtg/src/Token.cpp b/projects/mtg/src/Token.cpp index c0dd69efc..0e83caf72 100644 --- a/projects/mtg/src/Token.cpp +++ b/projects/mtg/src/Token.cpp @@ -13,7 +13,9 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness) model = this; owner = source->owner; belongs_to=source->controller()->game; - initAttackersDefensers(); + attacker = 0; + defenser = NULL; + banding = NULL; mCache = source->mCache; } \ No newline at end of file diff --git a/projects/mtg/src/WEvent.cpp b/projects/mtg/src/WEvent.cpp index f94d29672..341f1320f 100644 --- a/projects/mtg/src/WEvent.cpp +++ b/projects/mtg/src/WEvent.cpp @@ -24,4 +24,14 @@ WEventPhaseChange::WEventPhaseChange(Phase * _from, Phase * _to):WEvent(CHANGE_P to = _to; } -WEventCardTap::WEventCardTap(MTGCardInstance * card, bool before, bool after):WEvent(), card(card),before(before), after(after){} \ No newline at end of file +WEventCardTap::WEventCardTap(MTGCardInstance * card, bool before, bool 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(before), after(after){} + +WEventCreatureBlockerRank::WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker) + :WEventCardUpdate(card), exchangeWith(exchangeWith), attacker(attacker){} \ No newline at end of file