Files
wagic/projects/mtg/include/MTGCardInstance.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

213 lines
5.6 KiB
C++

#ifndef _MTG_CARD_INSTANCE_H_
#define _MTG_CARD_INSTANCE_H_
#include "MTGCard.h"
#include "CardPrimitive.h"
#include "MTGGameZones.h"
#include "MTGAbility.h"
#include "WResourceManager.h"
#include "ManaCost.h"
#include "Damage.h"
#include "Targetable.h"
class MTGCardInstance;
class MTGPlayerCards;
class MTGAbility;
class MTGCard;
class ManaCost;
class UntapBlockers;
class CardDescriptor;
class Counters;
struct Pos;
#include <list>
using namespace std;
class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable
#ifdef TRACK_OBJECT_USAGE
, public InstanceCounter<MTGCardInstance>
#endif
{
protected:
int untapping;
int nb_damages;
string sample;
int tapped;
int lifeOrig;
MTGPlayerCards * belongs_to;
MTGCardInstance * getNextPartner();
void initMTGCI();
int addBlocker(MTGCardInstance * c);
int removeBlocker(MTGCardInstance * c);
int init();
public:
int setAttacker(int value);
int setDefenser(MTGCardInstance * c);
MTGGameZone * currentZone;
Pos* view;
int X;
int alternateCostPaid[ManaCost::MANA_PAID_WITH_RETRACE + 1];
int paymenttype;
int castMethod; /* Tells if the card reached its current zone by being cast or not (brought into the zone by an effect). non 0 == cast, 0 == not cast */
int frozen;
int sunburst;
int equipment;
int auras;
bool wasDealtDamage;
bool damageToOpponent;
bool damageToController;
bool mPropertiesChangedSinceLastUpdate;
int reduxamount;
int flanked;
int regenerateTokens;
int isToken;
int origpower;
int origtoughness;
int isMultiColored;
int isLeveler;
bool enchanted;
int CDenchanted;
int CDdamaged;
bool blinked;
bool isExtraCostTarget;
bool morphed;
bool turningOver;
bool isMorphed;
bool isPhased;
int phasedTurn;
bool graveEffects;
bool exileEffects;
bool suspended;
int stillInUse();
int didattacked;
int didblocked;
int notblocked;
int fresh;
int MaxLevelUp;
int kicked;
Player * lastController;
MTGGameZone * getCurrentZone();
MTGGameZone * previousZone;
MTGCardInstance * previous;
MTGCardInstance * next;
int doDamageTest;
int summoningSickness;
ManaCost reducedCost;
ManaCost increasedCost;
ManaCost * getReducedManaCost();
ManaCost * getIncreasedManaCost();
bool matchesCastFilter(int castMethod);
// The recommended method to test for summoning Sickness !
int hasSummoningSickness();
MTGCardInstance * changeController(Player * newcontroller);
Player * owner;
Counters * counters;
int typeAsTarget(){return TARGET_CARD;}
const string getDisplayName() const;
MTGCardInstance * target;
vector<Targetable *> backupTargets;
//types
void addType(char * type_text);
virtual void addType(int id);
void setType(const char * type_text);
void setSubtype( string value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
//dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects.
int DangerRanking();
//Combat
bool blocked; //Blocked this turn or not?
MTGCardInstance * defenser;
list<MTGCardInstance *>blockers;
int attacker;
int toggleDefenser(MTGCardInstance * opponent);
int raiseBlockerRankOrder(MTGCardInstance * blocker);
//Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise
int getDefenserRank(MTGCardInstance * blocker);
int toggleAttacker();
MTGCardInstance * banding; // If belongs to a band when attacking
int canBlock();
int canBlock(MTGCardInstance * opponent);
int canAttack();
int isAttacker();
MTGCardInstance * isDefenser();
int initAttackersDefensers();
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
int nbOpponents();
int stepPower(CombatStep step);
int afterDamage();
int has(int ability);
int cleanup();
MTGCard * model;
MTGCardInstance();
MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to);
int regenerate();
int triggerRegenerate();
Player * controller();
virtual ~MTGCardInstance();
int bury();
int destroy();
int addToToughness(int value);
int setToughness(int value);
vector<TargetChooser *>protections;
int addProtection(TargetChooser * tc);
int removeProtection(TargetChooser *tc, int erase = 0);
int protectedAgainst(MTGCardInstance * card);
vector<TargetChooser *>canttarget;
int addCantBeTarget(TargetChooser * tc);
int removeCantBeTarget(TargetChooser *tc, int erase = 0);
int CantBeTargetby(MTGCardInstance * card);
vector<TargetChooser *>cantBeBlockedBys;
int addCantBeBlockedBy(TargetChooser * tc);
int removeCantBeBlockedBy(TargetChooser *tc, int erase = 0);
int cantBeBlockedBy(MTGCardInstance * card);
void copy(MTGCardInstance * card);
void setUntapping();
int isUntapping();
int isTapped();
void untap();
void tap();
void attemptUntap();
void eventattacked();
void eventattackedAlone();
void eventattackednotblocked();
void eventattackedblocked(MTGCardInstance * opponent);
void eventblocked(MTGCardInstance * opponent);
int isInPlay();
JSample * getSample();
JQuadPtr getIcon();
ostream& toString(ostream&) const;
static MTGCardInstance AnyCard;
static MTGCardInstance NoCard;
static MTGCardInstance ExtraRules[2];
};
ostream& operator<<(ostream&, const MTGCardInstance&);
#endif