Files
wagic/projects/mtg/src/WEvent.cpp
zethfoxster 6ee00c138c Pretty huge patch here(sorry old habits never die :( )
lots of changes, many bug fixes,
first
added auto=count(targetchooser)
and countedamount wparsed int
they work together for cards where it is difficult to get working without knowing in advance how many we had ie: exile blah creatures, for each creature you exiled do effect.
auto=count(creature|mybattlefield)
auto=moveto(exile)
auto=draw:countedamount
it takes into account token creatures, which our old methods did not.

second, added "freeze" which is a "frozen" that automatically taps your target for you, for use when nesting or whenever needed where it was difficult to nest the ability with tap included.

added devotion for "iroas"

added reveal:x and scry x
reveal contains optionone/optiononeend ; optiontwo/optiontwoend ; repeat; afterrevealed/afterrevealed end.

this ability has heavy use of targetListIsSet(<amount>) and upto:amount, you MUST be certain that all cards being revealed have an action that removes them from reveal either in the first, second, or 3rd ability.
there are over 300 examples in the new card code, the ability is VERY easy to understand.

scry contains automatic put on top, put on bottom, then scrycore/scrycoreend which is an ability to fire.
it also contains keywords, dontshow which is nested in scrycore, scry reveals, puts on top or bottom, then reveal AGAIN, and does an effect, dontshow eliminates the 2nd revealing.
is also contains "delayed" keyword, which delays the ability until AFTER the core fires.

added bestow. update rules mtg.txt!!!!
examples are in primitives, every bestow card was supported.

added a new lord based on varibles and restrictions
while(restriction{morbid})
while(varible:blah)
this simplifies and expands on this(, allowing you to even use while(cantarget together and check if a card is targetable by the variable. examples are in primitives

added token(by card name)
auto=token(Eldrazi Scion) 
will search primitives and card dats for this card and give it to you as a token.
valid card dat info is still required.

added variable delirium
added restriction madnessplayed to allow checking if the card was played with madness.

added restriction "geared" for checking if a card has equipment on it.

added abilities words
skulk

menace <--cant be blocked except by 2 or more, if you dont block it with 2 or more we automatically unassign the single blocker and the creature is considered not blocked.

nosolo <--cant attack alone

mustblock <---if you dont assign as a blocker, we assign automatically the first thing it can block legally.

changed iscolorless back to "colorless"

enjoy, cards coming soon, theyre coded but im debating on not alpha sorting, cards being added this patch 965 uniques.

there is a section of the commit which was just VS2016 normalizing line ends, sorry if it makes it a cluster mess.
2016-06-28 18:40:55 -04:00

418 lines
12 KiB
C++

#include "PrecompiledHeader.h"
#include "WEvent.h"
#include "MTGCardInstance.h"
#include "MTGGameZones.h"
#include "Damage.h"
#include "PhaseRing.h"
WEvent::WEvent(int type) :
type(type)
{
}
WEventZoneChange::WEventZoneChange(MTGCardInstance * card, MTGGameZone * from, MTGGameZone *to) :
WEvent(CHANGE_ZONE), card(card), from(from), to(to)
{
}
WEventDamage::WEventDamage(Damage *damage) :
WEvent(DAMAGE), damage(damage)
{
}
WEventLife::WEventLife(Player * player,int amount) :
WEvent(), player(player),amount(amount)
{
}
WEventDamageStackResolved::WEventDamageStackResolved() :
WEvent()
{
}
WEventCardUpdate::WEventCardUpdate(MTGCardInstance * card) :
WEvent(), card(card)
{
}
;
WEventCounters::WEventCounters(Counters *counter,string name,int power,int toughness,bool added,bool removed) :
WEvent(),counter(counter),name(name),power(power),toughness(toughness),added(added),removed(removed)
{
}
WEventPhaseChange::WEventPhaseChange(Phase * from, Phase * to) :
WEvent(CHANGE_PHASE), from(from), to(to)
{
}
WEventPhasePreChange::WEventPhasePreChange(Phase * from, Phase * to) :
WEvent(CHANGE_PHASE), from(from), to(to)
{
eventChanged = false;
}
WEventCardTap::WEventCardTap(MTGCardInstance * card, bool before, bool after) :
WEventCardUpdate(card), before(before), after(after)
{
}
WEventCardTappedForMana::WEventCardTappedForMana(MTGCardInstance * card, bool before, bool after) :
WEventCardUpdate(card), before(before), after(after)
{
}
WEventCardAttacked::WEventCardAttacked(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardAttackedAlone::WEventCardAttackedAlone(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardAttackedNotBlocked::WEventCardAttackedNotBlocked(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardAttackedBlocked::WEventCardAttackedBlocked(MTGCardInstance * card,MTGCardInstance * opponent) :
WEventCardUpdate(card),opponent(opponent)
{
}
WEventCardBlocked::WEventCardBlocked(MTGCardInstance * card,MTGCardInstance * opponent) :
WEventCardUpdate(card),opponent(opponent)
{
}
WEventcardDraw::WEventcardDraw(Player * player, int nb_cards) :
player(player), nb_cards(nb_cards)
{
}
WEventDraw::WEventDraw(Player * player, int nb_cards,MTGAbility * cardDraw) ://happens at the call for drawfromlibrary
player(player), nb_cards(nb_cards),drawAbility(cardDraw)
{
}
WEventCardSacrifice::WEventCardSacrifice(MTGCardInstance * card, MTGCardInstance * after) :
WEventCardUpdate(card),cardAfter(after)
{
}
WEventCardDiscard::WEventCardDiscard(MTGCardInstance * card) :
WEventCardUpdate(card)
{
card->discarded = true;
}
WEventCardCycle::WEventCardCycle(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventVampire::WEventVampire(MTGCardInstance * card,MTGCardInstance * source,MTGCardInstance * victem) :
WEventCardUpdate(card),source(source),victem(victem)
{
}
WEventTarget::WEventTarget(MTGCardInstance * card,MTGCardInstance * source) :
WEventCardUpdate(card),card(card),source(source)
{
card->cardistargetted = 1;
if(source)
source->cardistargetter = 1;
}
WEventCardChangeType::WEventCardChangeType(MTGCardInstance * card, int type, bool before, bool after) :
WEventCardUpdate(card), type(type), 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(from), after(to)
{
}
WEventCreatureBlockerRank::WEventCreatureBlockerRank(MTGCardInstance * card, MTGCardInstance * exchangeWith,
MTGCardInstance * attacker) :
WEventCardUpdate(card), exchangeWith(exchangeWith), attacker(attacker)
{
}
WEventEngageManaExtra::WEventEngageManaExtra(int color, MTGCardInstance* card, ManaPool * destination) :
WEvent(), color(color), card(card), destination(destination)
{//controller snow
if(color == 1 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaG += 1;
if(color == 2 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaU += 1;
if(color == 3 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaR += 1;
if(color == 4 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaB += 1;
if(color == 5 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaW += 1;
if((color == 0 || color == 6) && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaC += 1;
//opponent snow
if(color == 1 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaG += 1;
if(color == 2 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaU += 1;
if(color == 3 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaR += 1;
if(color == 4 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaB += 1;
if(color == 5 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaW += 1;
if((color == 0 || color == 6) && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaC += 1;
}
WEventEngageMana::WEventEngageMana(int color, MTGCardInstance* card, ManaPool * destination) :
WEvent(), color(color), card(card), destination(destination)
{//controller snow
if(color == 1 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaG += 1;
if(color == 2 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaU += 1;
if(color == 3 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaR += 1;
if(color == 4 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaB += 1;
if(color == 5 && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaW += 1;
if((color == 0 || color == 6) && card->controller()->getManaPool() == destination && card->hasType("snow"))
card->controller()->snowManaC += 1;
//opponent snow
if(color == 1 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaG += 1;
if(color == 2 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaU += 1;
if(color == 3 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaR += 1;
if(color == 4 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaB += 1;
if(color == 5 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaW += 1;
if((color == 0 || color == 6) && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
card->controller()->opponent()->snowManaC += 1;
}
WEventConsumeMana::WEventConsumeMana(int color, ManaPool * source) :
WEvent(), color(color), source(source)
{
}
WEventEmptyManaPool::WEventEmptyManaPool(ManaPool * source) :
WEvent(), source(source)
{
}
WEventCardUnattached::WEventCardUnattached(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardEquipped::WEventCardEquipped(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardControllerChange::WEventCardControllerChange(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCombatStepChange::WEventCombatStepChange(CombatStep step) :
WEvent(), step(step)
{
}
;
Targetable * WEventDamage::getTarget(int target)
{
switch (target)
{
case TARGET_TO:
return damage->target;
case TARGET_FROM:
return damage->source;
}
return NULL;
}
int WEventDamage::getValue()
{
return damage->damage;
}
Targetable * WEventLife::getTarget(int target)
{
if (target)
{
return player;
}
return NULL;
}
Targetable * WEventCounters::getTarget()
{
return targetCard;
}
Targetable * WEventVampire::getTarget(int target)
{
switch (target)
{
case TARGET_TO:
return victem->next;
case TARGET_FROM:
return source;
}
return NULL;
}
Targetable * WEventTarget::getTarget(int target)
{
switch (target)
{
case TARGET_TO:
return card;
case TARGET_FROM:
return source;
}
return NULL;
}
Targetable * WEventZoneChange::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardAttacked::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardAttackedAlone::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardSacrifice::getTarget(int target)
{
if (target)
{
return cardAfter;
}
return NULL;
}
Targetable * WEventCardDiscard::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardCycle::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardAttackedNotBlocked::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardAttackedBlocked::getTarget(int target)
{
switch (target)
{
case TARGET_TO:
return card;
case TARGET_FROM:
return opponent;
}
return NULL;
}
Targetable * WEventCardBlocked::getTarget(int target)
{
switch (target)
{
case TARGET_TO:
return card;
case TARGET_FROM:
return opponent;
}
return NULL;
}
Targetable * WEventCardTap::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardTappedForMana::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventcardDraw::getTarget(Player * player)
{
if (player) return player;
return NULL;
}
Targetable * WEventCardUnattached::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardEquipped::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardControllerChange::getTarget(int target)
{
if (target) return card;
return NULL;
}
std::ostream& WEvent::toString(std::ostream& out) const
{
return out << "EVENT";
}
std::ostream& WEventZoneChange::toString(std::ostream& out) const
{
return out << "ZONEEVENT " << *card << " : " << *from << " -> " << *to;
}
std::ostream& WEventDamage::toString(std::ostream& out) const
{
if (MTGCardInstance* m = dynamic_cast<MTGCardInstance*>(damage->target))
return out << "DAMAGEEVENT " << damage->damage << " >> " << *m;
else
return out << "DAMAGEEVENT " << damage->damage << " >> " << damage->target;
}
std::ostream& operator<<(std::ostream& out, const WEvent& m)
{
return m.toString(out);
}