Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auraward, unattach event and statebased action for protection from quality #631

Merged
merged 6 commits into from
Sep 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion projects/mtg/bin/Res/sets/primitives/mtg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9246,6 +9246,7 @@ type=Artifact
[/card]
[card]
name=Black Ward
abilities=auraward
target=creature
auto=protection from black
text=Enchant creature -- Enchanted creature has protection from black. This effect doesn't remove Black Ward.
Expand Down Expand Up @@ -10887,6 +10888,7 @@ type=Instant
[/card]
[card]
name=Blue Ward
abilities=auraward
target=creature
auto=protection from blue
text=Enchant creature -- Enchanted creature has protection from blue. This effect doesn't remove Blue Ward.
Expand Down Expand Up @@ -16532,6 +16534,7 @@ toughness=2
[/card]
[card]
name=Cho-Manno's Blessing
abilities=auraward
target=creature
abilities=flash
auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend
Expand Down Expand Up @@ -26107,7 +26110,7 @@ type=Sorcery
[/card]
[card]
name=Dragon Grip
other={2}{R} Name(cast anytime)
other={2}{R} name(cast anytime)
otherrestriction=type(creature[power>=4]|mybattlefield)~morethan~0
abilities=spellmastery
target=creature
Expand Down Expand Up @@ -35073,6 +35076,7 @@ toughness=2
[/card]
[card]
name=Flickering Ward
abilities=auraward
target=creature
auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend
auto={W}:moveTo(ownerhand)
Expand Down Expand Up @@ -35150,6 +35154,7 @@ toughness=2
[/card]
[card]
name=Floating Shield
abilities=auraward
target=creature
auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend
auto={S}:protection from white target(creature)
Expand Down Expand Up @@ -42027,6 +42032,7 @@ subtype=Aura
[/card]
[card]
name=Green Ward
abilities=auraward
target=creature
auto=protection from green
text=Enchant creature -- Enchanted creature has protection from green. This effect doesn't remove Green Ward.
Expand Down Expand Up @@ -71570,6 +71576,7 @@ toughness=3
[/card]
[card]
name=Pentarch Ward
abilities=auraward
target=creature
auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend
auto=draw:1
Expand Down Expand Up @@ -73677,6 +73684,7 @@ type=Sorcery
[/card]
[card]
name=Pledge of Loyalty
abilities=auraward
target=creature
auto=aslongas(*[red]|mybattlefield) protection from red
auto=aslongas(*[green]|mybattlefield) protection from green
Expand Down Expand Up @@ -78553,6 +78561,7 @@ type=Sorcery
[/card]
[card]
name=Red Ward
abilities=auraward
target=creature
auto=protection from red
text=Enchant creature -- Enchanted creature has protection from red. This effect doesn't remove Red Ward.
Expand Down Expand Up @@ -99792,6 +99801,7 @@ toughness=1
[/card]
[card]
name=Tattoo Ward
abilities=auraward
target=creature
auto=1/1
auto=protection from(enchantment)
Expand Down Expand Up @@ -112787,6 +112797,7 @@ type=Instant
[/card]
[card]
name=White Ward
abilities=auraward
target=creature
auto=protection from white
text=Enchant creature -- Enchanted creature has protection from white. This effect doesn't remove White Ward.
Expand Down
1 change: 1 addition & 0 deletions projects/mtg/bin/Res/test/_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ pillory_of_the_sleepless2_i188.txt
pillory_of_the_sleepless3_i188.txt
pillory_of_the_sleepless4_i188.txt
plague_rats.txt
pledge_protection.txt
plumes_of_peace_i260.txt
pouncing_jaguar_i425.txt
power_armor.txt
Expand Down
46 changes: 46 additions & 0 deletions projects/mtg/bin/Res/test/pledge_protection.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#Testing Protection
#702.16c A permanent or player with protection can’t be enchanted by Auras that have the stated
#quality. Such Auras attached to the permanent or player with protection will be put into their
#owners’ graveyards as a state-based action.
#
#702.16d A permanent with protection can’t be equipped by Equipment that have the stated quality
#or fortified by Fortifications that have the stated quality. Such Equipment or Fortifications
#become unattached from that permanent as a state-based action, but remain on the battlefield.
[INIT]
FIRSTMAIN
[PLAYER1]
hand:Pledge of Loyalty, Shuko, Holy Strength, Shifting Sky
inplay:Crimson Acolyte
manapool:{W}{W}{W}{W}{U}{U}{U}
[PLAYER2]
[DO]
Holy Strength
Crimson Acolyte
#crimson acolyte becomes 2/3
Shuko
Shuko
Crimson Acolyte
#crimson acolyte becomes 3/3
Pledge of Loyalty
Crimson Acolyte
#crimson acolyte becomes 2/1 since you have white permanents, pledge of loyalty grants protection from white
#holy strength is put into the graveyard as state based action :)
Shifting Sky
choice 0
choice 2
#after casting shifting sky, choose the color red, and all nonland permanents becomes red
#since shuko becomes red and crimson has protection from red, it will be unattached
#as state based action, pledge of loyalty stays on the creature :)
next
next
Crimson Acolyte
next
eot
[ASSERT]
UNTAP
[PLAYER1]
inplay:Crimson Acolyte, Pledge of Loyalty, Shuko, Shifting Sky
graveyard:Holy Strength
[PLAYER2]
life:19
[END]
3 changes: 2 additions & 1 deletion projects/mtg/include/MTGDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ class Constants
SPELLMASTERY = 111,
NOLIFEGAIN = 112,
NOLIFEGAINOPPONENT = 113,
NB_BASIC_ABILITIES = 114,
AURAWARD = 114,
NB_BASIC_ABILITIES = 115,


RARITY_S = 'S', //Special Rarity
Expand Down
6 changes: 6 additions & 0 deletions projects/mtg/include/WEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ struct WEventEmptyManaPool : public WEvent {
WEventEmptyManaPool(ManaPool * source);
};

//event when card-equipment unattached
struct WEventCardUnattached : public WEventCardUpdate {
WEventCardUnattached(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};

std::ostream& operator<<(std::ostream&, const WEvent&);

#endif
2 changes: 2 additions & 0 deletions projects/mtg/src/AllAbilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5428,6 +5428,8 @@ int AEquip::unequip()
game->removeObserver(currentAbilities[i]);
}
currentAbilities.clear();
WEvent * e = NEW WEventCardUnattached(source);
game->receiveEvent(e);
return 1;
}

Expand Down
20 changes: 20 additions & 0 deletions projects/mtg/src/GameObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,33 @@ void GameObserver::gameStateBasedEffects()
card->myPair->myPair = NULL;
card->myPair = NULL;
}
////////////////////////////////////////////////////
//Unattach Equipments that dont have valid targets//
////////////////////////////////////////////////////
if ((card->target) && card->hasType(Subtypes::TYPE_EQUIPMENT))
{
if(card->target && isInPlay(card->target) && (card->target)->protectedAgainst(card))//protection from quality
{
for (size_t i = 1; i < mLayers->actionLayer()->mObjects.size(); i++)
{
MTGAbility * a = ((MTGAbility *) mLayers->actionLayer()->mObjects[i]);
AEquip * eq = dynamic_cast<AEquip*> (a);
if (eq && eq->source == card)
{
((AEquip*)a)->unequip();
}
}
}
}
///////////////////////////////////////////////////////
//Remove auras that don't have a valid target anymore//
///////////////////////////////////////////////////////
if ((card->target||card->playerTarget) && !card->hasType(Subtypes::TYPE_EQUIPMENT))
{
if(card->target && !isInPlay(card->target))
players[i]->game->putInGraveyard(card);
if(card->target && isInPlay(card->target) && (card->target)->protectedAgainst(card) && !card->has(Constants::AURAWARD))//protection from quality except aura cards like flickering ward
players[i]->game->putInGraveyard(card);
}
card->enchanted = false;
if (card->target && isInPlay(card->target) && !card->hasType(Subtypes::TYPE_EQUIPMENT) && card->hasSubtype(Subtypes::TYPE_AURA))
Expand Down
2 changes: 2 additions & 0 deletions projects/mtg/src/GuiPlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ int GuiPlay::receiveEventPlus(WEvent * e)
}
else if (dynamic_cast<WEventCardChangeType*> (e))
Replace();
else if (dynamic_cast<WEventCardUnattached*> (e))
Replace();
Replace();
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion projects/mtg/src/MTGDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const char* Constants::MTGBasicAbilities[] = {
"evadebigger",
"spellmastery",
"nolifegain",
"nolifegainopponent"
"nolifegainopponent",
"auraward"
};

map<string,int> Constants::MTGBasicAbilitiesMap;
Expand Down
11 changes: 11 additions & 0 deletions projects/mtg/src/WEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ WEventEmptyManaPool::WEventEmptyManaPool(ManaPool * source) :
{
}

WEventCardUnattached::WEventCardUnattached(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}

WEventCombatStepChange::WEventCombatStepChange(CombatStep step) :
WEvent(), step(step)
{
Expand Down Expand Up @@ -305,6 +310,12 @@ Targetable * WEventcardDraw::getTarget(Player * player)
return NULL;
}

Targetable * WEventCardUnattached::getTarget(int target)
{
if (target) return card;
return NULL;
}

std::ostream& WEvent::toString(std::ostream& out) const
{
return out << "EVENT";
Expand Down