Files
wagic/projects/mtg/include/WEvent.h
omegablast2002@yahoo.com 6399917d25 changes:
added abilities:
proliferate
ProliferateChooser:new targetchooser for cards with counter and poison counters "proliferation".

MenuAbility:new internal ability to create custom menus of abilities which can be activated in sequence one after another.

multikicker, syntax kicker=multi{b}
works with variable word "kicked", the amount of times it was kicked.

target=<number>tc,target=<upto:>tc,target=<anyamount>tc,target(<number>tc),target(<upto:>tc),target(<anynumber>tc);
multitarget is now supported with the exception of "devided any way you choose" which can not be supported becuase we allow detoggling of targeted cards with a "second" click....so you can not click the same card 2 times to add it to the targets list twice for example.
this is minor, as the bulk of multitarget is not "devided"
removed 's' parsing for multitarget, added a limit of 1000 to "unlimited" for easier handling; we currently can't handle activation of an ability on a 1000 cards very well on any platform(infact i don't suggest it)

Countershroud(counterstring), this MTGAbility allows you to denote that a card can not have counters of the type "counterstring" put on it.
"any" is for no counters allowed at all. this is a replacement effect. cards state that they can still be the targets of counter effects, however on resolve nothing is placed on them instead.

@counteradded(counterstring) from(target):,@counterremoved(counterstring) from(target):: these are triggers for cards which state "whenever you add a counter of "counterstring" to "target"; added counterEvents struct; 

other changes:
added support for ai handling of multitargeted spells.

changed a few of delete( into SAFE_DELETE(, safed up a couple areas where they did not seem safe to me;

added better handling of menus presented to ai, it will try to select the best based on eff returns.

added varible lastactioncontroller for ai use, it keeps it truely from ever tripping over itself and brings ai more inline with MTG rules.

converted TC into a protected member.
added "abilitybelongsto" string to tc, and set "owner" of the tc. a tc should never belong to "no one" it should always have a owner.
abilitybelongs to string is solely for easier debugging, i found it was a pain to never know what ability created a tc while i coded multitarget. the owner of the tc is the only one that should be using it, if an ability needs to declare the opponent as the owner (choose discard which is currently unsupported for example) this will allow us to better handle that situation by setting the tc owner in the ability which called it.

rewrote the logic of "checkonly" in ai choose targets, the only time it is "checkonly" is when it is trying to see if it had a target for a spell before it cast it, i now set this in the actual function call instead, the old method was far to error prone.

wrote logic for ai checking of menu objects presented to it,
ai will now make better choices when a menu is presented to it based on what it already knows. this changes it from it's old method of "just click the first option".

taught ai how to use multi-mana producers such as birds and duel lands by adding a method for it to find it's mana for a payment. it can effectively use cards like birds of paradise and sol ring(without locking up). It's primary method of pMana searching was maintain for performance(no need to deep search if we have it in pMana).

added a vector to actionlayer to store mana abilities for pMana. this provides us with a dramatic improvement when mana lords are present by reducing the amount of objects that need checking when ai checks pMana.
with 80 mana objects and a ton of lords one instance i checked went from 8000ish checks down to 80<===big difference.

added "tapped" green coloring(sorry i missed that!)...added red coloring to current actionLayers current action card (usually the source).

changed "type(" restrictions second amount from atoi into wparsedint for more flexiable coding.

add "&" parsing to CD targetchooser, removed "iscolorandcolor" variables and functions becuase they were a hack the real fix was this.
cretaure[dragon&black&blue] a creature that is a dragon, and black and also blue.

changed some of the ai computeactions and
removed unneeded gaurds in ai chooseblockers, they did more harm then good.
2011-09-01 20:03:26 +00:00

256 lines
7.1 KiB
C++

#ifndef _WEVENT_H_
#define _WEVENT_H_
#include <iostream>
#include "PhaseRing.h"
class MTGCardInstance;
class MTGGameZone;
class Damage;
class Phase;
class Targetable;
class ManaPool;
class AACounter;
class Counters;
class WEvent {
public:
enum {
NOT_SPECIFIED = 0,
CHANGE_ZONE = 1,
DAMAGE = 2,
CHANGE_PHASE = 3,
};
//for getTargets, in case event has more than one possible "target", like with damage events.
enum {
TARGET_NONE = 0,
TARGET_TO,
TARGET_FROM,
};
int type; //Deprecated, use dynamic casting instead
WEvent(int type = NOT_SPECIFIED);
virtual ~WEvent() {};
virtual std::ostream& toString(std::ostream& out) const;
virtual int getValue() {return 0;};
virtual Targetable * getTarget(int target) {return 0;};
};
struct WEventZoneChange : public WEvent {
MTGCardInstance * card;
MTGGameZone * from;
MTGGameZone * to;
WEventZoneChange(MTGCardInstance * card, MTGGameZone * from, MTGGameZone *to);
virtual ~WEventZoneChange() {};
virtual std::ostream& toString(std::ostream& out) const;
virtual Targetable * getTarget(int target);
};
struct WEventDamage : public WEvent {
Damage * damage;
WEventDamage(Damage * damage);
virtual std::ostream& toString(std::ostream& out) const;
virtual int getValue();
virtual Targetable * getTarget(int target);
};
struct WEventCounters : public WEvent {
MTGCardInstance * targetCard;
Counters * counter;
string name;
int power;
int toughness;
bool added;
bool removed;
WEventCounters(Counters *counter,string name,int power, int toughness,bool added = false, bool removed = false);
virtual Targetable * getTarget();
};
struct WEventLife : public WEvent {
Player * player;
int amount;
WEventLife(Player * player,int amount);
virtual Targetable * getTarget(int target);
};
struct WEventDamageStackResolved : public WEvent {
WEventDamageStackResolved();
};
struct WEventPhaseChange : public WEvent {
Phase * from;
Phase * to;
WEventPhaseChange(Phase * from, Phase * to);
};
//Abstract class of event when a card's status changes
struct WEventCardUpdate : public WEvent {
MTGCardInstance * card;
WEventCardUpdate(MTGCardInstance * card);
};
//creature damaged was killed, triggers effects targetter
struct WEventVampire : public WEventCardUpdate {
MTGCardInstance * card;
MTGCardInstance * source;
MTGCardInstance * victem;
WEventVampire(MTGCardInstance * card,MTGCardInstance * source,MTGCardInstance * victem);
virtual Targetable * getTarget(int target);
};
//creature became the target of a spell or ability
struct WEventTarget : public WEventCardUpdate {
MTGCardInstance * card;
MTGCardInstance * source;
WEventTarget(MTGCardInstance * card,MTGCardInstance * source);
virtual Targetable * getTarget(int target);
};
//Event when a card gains/looses types
struct WEventCardChangeType : public WEventCardUpdate {
int type;
bool before;
bool after;
WEventCardChangeType(MTGCardInstance * card, int type, bool before, bool after);
};
//Event when a card is tapped/untapped
struct WEventCardTap : public WEventCardUpdate {
bool before;
bool after;
WEventCardTap(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target);
};
struct WEventCardTappedForMana : public WEventCardUpdate {
bool before;
bool after;
WEventCardTappedForMana(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target);
};
//Event when a card's "attacker" status changes
//before:Player/Planeswalker that card was attacking previously
//after: Player/Planeswalker that card is attacking now
struct WEventCreatureAttacker : public WEventCardUpdate {
Targetable * before;
Targetable * after;
WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to);
};
//event when card attacks.
struct WEventCardAttacked : public WEventCardUpdate {
WEventCardAttacked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card attacks alone.
struct WEventCardAttackedAlone : public WEventCardUpdate {
WEventCardAttackedAlone(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card attacks but is not blocked.
struct WEventCardAttackedNotBlocked : public WEventCardUpdate {
WEventCardAttackedNotBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card attacks but is blocked.
struct WEventCardAttackedBlocked : public WEventCardUpdate {
WEventCardAttackedBlocked(MTGCardInstance * card,MTGCardInstance * opponent);
MTGCardInstance * opponent;
virtual Targetable * getTarget(int target);
};
//event when card blocked.
struct WEventCardBlocked : public WEventCardUpdate {
WEventCardBlocked(MTGCardInstance * card,MTGCardInstance * opponent);
MTGCardInstance * opponent;
virtual Targetable * getTarget(int target);
};
//event when card is sacrificed.
struct WEventCardSacrifice : public WEventCardUpdate {
WEventCardSacrifice(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card is discarded.
struct WEventCardDiscard : public WEventCardUpdate {
WEventCardDiscard(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//Event when a card's "defenser" status changes
//before : attacker that card was blocking previously
//after: attacker that card is blocking now
struct WEventCreatureBlocker : public WEventCardUpdate {
MTGCardInstance * before;
MTGCardInstance * after;
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
};
//Event sent when attackers have been chosen and they
//cannot be changed any more.
struct WEventAttackersChosen : public WEvent {
};
//Event sent when blockers have been chosen and they
//cannot be changed any more.
struct WEventBlockersChosen : public WEvent {
};
struct WEventcardDraw : public WEvent {
WEventcardDraw(Player * player,int nb_cards);
Player * player;
int nb_cards;
virtual Targetable * getTarget(Player * player);
};
//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.
struct WEventCreatureBlockerRank : public WEventCardUpdate {
MTGCardInstance * exchangeWith;
MTGCardInstance * attacker;
WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker);
};
//Event when a combat phase step ends
struct WEventCombatStepChange : public WEvent
{
CombatStep step;
WEventCombatStepChange(CombatStep);
};
//Event when a mana is engaged
//color : color
struct WEventEngageMana : public WEvent {
int color;
MTGCardInstance* card;
ManaPool * destination;
WEventEngageMana(int color, MTGCardInstance* card, ManaPool * destination);
};
//Event when a mana is consumed
//color : color
struct WEventConsumeMana : public WEvent {
int color;
ManaPool * source;
WEventConsumeMana(int color, ManaPool * source);
};
//Event when a manapool is emptied
//color : color
struct WEventEmptyManaPool : public WEvent {
ManaPool * source;
WEventEmptyManaPool(ManaPool * source);
};
std::ostream& operator<<(std::ostream&, const WEvent&);
#endif