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.
259 lines
8.4 KiB
C++
259 lines
8.4 KiB
C++
#ifndef _TARGETCHOOSER_H_
|
|
#define _TARGETCHOOSER_H_
|
|
|
|
#define TARGET_NOK 0
|
|
#define TARGET_OK 1
|
|
#define TARGET_OK_FULL 2
|
|
#define TARGET_OK_NOT_READY 3
|
|
|
|
#include <JGE.h>
|
|
#include "TargetsList.h"
|
|
#include "ActionStack.h"
|
|
|
|
#include <string>
|
|
using std::string;
|
|
|
|
class MTGCardInstance;
|
|
class MTGGameZone;
|
|
class Player;
|
|
class Damageable;
|
|
class Targetable;
|
|
class CardDescriptor;
|
|
|
|
class TargetChooser: public TargetsList
|
|
{
|
|
protected:
|
|
int forceTargetListReady;
|
|
public:
|
|
const static int UNLITMITED_TARGETS = 1000;
|
|
enum
|
|
{
|
|
UNSET = 0,
|
|
OPPONENT = -1,
|
|
CONTROLLER = 1,
|
|
TARGET_CONTROLLER = 2,
|
|
OWNER = 3
|
|
};
|
|
bool other;
|
|
bool withoutProtections;
|
|
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = UNLITMITED_TARGETS, bool other = false, bool targetMin = false);
|
|
Player * Owner;
|
|
MTGCardInstance * source;
|
|
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
|
|
int maxtargets;
|
|
bool done;
|
|
bool targetMin;
|
|
bool validTargetsExist(int maxTarget = 1);
|
|
int attemptsToFill;
|
|
string belongsToAbility;
|
|
int countValidTargets();
|
|
virtual int setAllZones()
|
|
{
|
|
return 0;
|
|
}
|
|
virtual bool targetsZone(MTGGameZone * z)
|
|
{
|
|
return false;
|
|
}
|
|
virtual bool targetsZone(MTGGameZone * z,MTGCardInstance * mSource)
|
|
{
|
|
return false;
|
|
}
|
|
;
|
|
int ForceTargetListReady();
|
|
int targetsReadyCheck();
|
|
virtual int addTarget(Targetable * target);
|
|
virtual bool canTarget(Targetable * _target,bool withoutProtections = false);
|
|
|
|
//returns true if tc is equivalent to this TargetChooser
|
|
//Two targetchoosers are equivalent if they target exactly the same cards
|
|
virtual bool equals(TargetChooser * tc);
|
|
|
|
virtual int full()
|
|
{
|
|
if ( (maxtargets != UNLITMITED_TARGETS && (int(targets.size())) >= maxtargets) || done)
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
;
|
|
virtual int ready()
|
|
{
|
|
return (int) (targets.size());
|
|
}
|
|
;
|
|
virtual ~TargetChooser()
|
|
{
|
|
}
|
|
;
|
|
int targetListSet();
|
|
virtual TargetChooser* clone() const = 0;
|
|
};
|
|
|
|
class TargetChooserFactory
|
|
{
|
|
public:
|
|
TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL);
|
|
TargetChooser * createTargetChooser(MTGCardInstance * card);
|
|
};
|
|
|
|
class TargetZoneChooser: public TargetChooser
|
|
{
|
|
public:
|
|
int zones[15];
|
|
int nbzones;
|
|
int init(int * _zones, int _nbzones);
|
|
bool targetsZone(MTGGameZone * z);
|
|
bool targetsZone(MTGGameZone * z,MTGCardInstance * mSource);
|
|
bool withoutProtections;
|
|
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
|
|
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
|
|
virtual bool canTarget(Targetable * _card,bool withoutProtections = false);
|
|
int setAllZones();
|
|
virtual TargetZoneChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class CardTargetChooser: public TargetZoneChooser
|
|
{
|
|
protected:
|
|
MTGCardInstance * validTarget;
|
|
public:
|
|
bool withoutProtections;
|
|
CardTargetChooser(MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0);
|
|
virtual bool canTarget(Targetable * target,bool withoutProtections = false);
|
|
virtual CardTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class TypeTargetChooser: public TargetZoneChooser
|
|
{
|
|
public:
|
|
int nbtypes;
|
|
int types[10];
|
|
bool withoutProtections;
|
|
TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
|
|
TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
|
|
void addType(int type);
|
|
void addType(const char * type);
|
|
virtual bool canTarget(Targetable * target,bool withoutProtections = false);
|
|
virtual TypeTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class DamageableTargetChooser: public TypeTargetChooser
|
|
{
|
|
public:
|
|
bool withoutProtections;
|
|
DamageableTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
|
|
TypeTargetChooser("creature",_zones, _nbzones, card, _maxtargets, other, targetMin)
|
|
{
|
|
}
|
|
;
|
|
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
|
|
TypeTargetChooser("creature", card, _maxtargets, other, targetMin)
|
|
{
|
|
}
|
|
;
|
|
virtual bool canTarget(Targetable * target,bool withoutProtections = false);
|
|
virtual DamageableTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class PlayerTargetChooser: public TargetChooser
|
|
{
|
|
protected:
|
|
Player * p; //In Case we can only target a specific player
|
|
public:
|
|
bool withoutProtections;
|
|
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
|
|
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
|
|
virtual PlayerTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class DescriptorTargetChooser: public TargetZoneChooser
|
|
{
|
|
public:
|
|
CardDescriptor * cd;
|
|
bool withoutProtections;
|
|
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false);
|
|
DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false);
|
|
virtual bool canTarget(Targetable * target,bool withoutProtections = false);
|
|
~DescriptorTargetChooser();
|
|
virtual DescriptorTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class SpellTargetChooser: public TargetChooser
|
|
{
|
|
public:
|
|
int color;
|
|
bool withoutProtections;
|
|
SpellTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false, bool targetMin = false);
|
|
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
|
|
virtual SpellTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class SpellOrPermanentTargetChooser: public TargetZoneChooser
|
|
{
|
|
public:
|
|
int color;
|
|
bool withoutProtections;
|
|
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false, bool targetMin = false);
|
|
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
|
|
virtual SpellOrPermanentTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class DamageTargetChooser: public TargetChooser
|
|
{
|
|
public:
|
|
int color;
|
|
int state;
|
|
bool withoutProtections;
|
|
DamageTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, int state = NOT_RESOLVED);
|
|
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
|
|
virtual DamageTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
//Should only be used for triggered abilities.
|
|
class TriggerTargetChooser: public TargetChooser
|
|
{
|
|
public:
|
|
Targetable * target;
|
|
int triggerTarget;
|
|
bool withoutProtections;
|
|
TriggerTargetChooser(int _triggerTarget);
|
|
virtual bool targetsZone(MTGGameZone * z);
|
|
virtual bool canTarget(Targetable * _target, bool withoutProtections = false);
|
|
virtual TriggerTargetChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
|
|
class ProliferateChooser: public TypeTargetChooser
|
|
{
|
|
public:
|
|
bool withoutProtections;
|
|
ProliferateChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
|
|
TypeTargetChooser("*",_zones, _nbzones, card, _maxtargets, other, targetMin)
|
|
{
|
|
}
|
|
;
|
|
ProliferateChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false) :
|
|
TypeTargetChooser("*", card, _maxtargets, other,targetMin)
|
|
{
|
|
}
|
|
;
|
|
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
|
|
virtual ProliferateChooser * clone() const;
|
|
virtual bool equals(TargetChooser * tc);
|
|
};
|
|
#endif
|