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

163 lines
4.8 KiB
C++

#ifndef _MANACOST_H_
#define _MANACOST_H_
#include "utils.h"
#include "MTGDefinitions.h"
#include "ObjectAnalytics.h"
class ManaCostHybrid;
class ExtraCosts;
class ExtraCost;
class MTGAbility;
class MTGCardInstance;
class Player;
class ManaCost
#ifdef TRACK_OBJECT_USAGE
: public InstanceCounter<ManaCost>
#endif
{
friend std::ostream& operator<<(std::ostream& out, ManaCost& m);
friend std::ostream& operator<<(std::ostream& out, ManaCost* m);
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
protected:
std::vector<int16_t> cost;
std::vector<ManaCostHybrid> hybrids;
virtual void init();
ManaCost * suspend;
ManaCost * manaUsedToCast;
ManaCost * morph;
ManaCost * Retrace;
ManaCost * Bestow;
ManaCost * FlashBack;
ManaCost * BuyBack;
ManaCost * kicker;
ManaCost * alternative;
public:
enum
{
MANA_UNPAID = 0,
MANA_PAID = 1,
MANA_PAID_WITH_KICKER = 2,
MANA_PAID_WITH_ALTERNATIVE = 3,
MANA_PAID_WITH_BUYBACK = 4,
MANA_PAID_WITH_FLASHBACK = 5,
MANA_PAID_WITH_RETRACE = 6,
MANA_PAID_WITH_MORPH = 7,
MANA_PAID_WITH_SUSPEND = 8,
MANA_PAID_WITH_OVERLOAD = 9,
MANA_PAID_WITH_BESTOW = 10,
MANA_PAID_WITH_OTHERCOST = 11
};
ExtraCosts * extraCosts;
ManaCost * getAlternative(){ return alternative; };
void setAlternative(ManaCost * aMana){ SAFE_DELETE(alternative); alternative = aMana;};
ManaCost * getKicker(){ return kicker; };
void setKicker(ManaCost * aMana){ SAFE_DELETE(kicker); kicker = aMana;};
ManaCost * getBuyback(){ return BuyBack; };
void setBuyback(ManaCost * aMana){ SAFE_DELETE(BuyBack); BuyBack = aMana;};
ManaCost * getFlashback(){ return FlashBack; };
void setFlashback(ManaCost * aMana){ SAFE_DELETE(FlashBack); FlashBack = aMana;};
ManaCost * getRetrace(){ return Retrace; };
void setRetrace(ManaCost * aMana){ SAFE_DELETE(Retrace); Retrace = aMana;};
ManaCost * getMorph(){ return morph; };
void setMorph(ManaCost * aMana){ SAFE_DELETE(morph); morph = aMana;};
ManaCost * getSuspend(){ return suspend; };
void setSuspend(ManaCost * aMana){ SAFE_DELETE(suspend); suspend = aMana;};
ManaCost * getBestow() { return Bestow; };
void setBestow(ManaCost * aMana) { SAFE_DELETE(Bestow); Bestow = aMana; };
ManaCost * getManaUsedToCast(){ return manaUsedToCast; };
void setManaUsedToCast(ManaCost * aMana){ SAFE_DELETE(manaUsedToCast); manaUsedToCast = aMana;};
string alternativeName;
bool isMulti;
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
static int parseManaSymbol(char symbol);
virtual void resetCosts();
void x();
int hasX();
void specificX(int color = 0);
int hasSpecificX();
int xColor;
int hasAnotherCost();
ManaCost(std::vector<int16_t>& _cost, int nb_elems = 1);
ManaCost();
virtual ~ManaCost();
ManaCost(ManaCost * _manaCost);
ManaCost(const ManaCost& manaCost);
ManaCost& operator= (const ManaCost& manaCost);
void copy(ManaCost * _manaCost);
int isNull();
int getConvertedCost();
string toString();
int getCost(int color);
int getManaSymbols(int color);
int getManaSymbolsHybridMerged(int color);
int countHybridsNoPhyrexian();
//Returns NULL if i is greater than nbhybrids
ManaCostHybrid * getHybridCost(unsigned int i);
int hasColor(int color);
int remove(int color, int value);
int add(int color, int value);
//
// Extra Costs (sacrifice,counters...)
//
int addExtraCost(ExtraCost * _cost);
int addExtraCosts(ExtraCosts *_cost);
int setExtraCostsAction(MTGAbility * action, MTGCardInstance * card);
int isExtraPaymentSet();
int canPayExtra();
int doPayExtra();
ExtraCost * getExtraCost(unsigned int i);
int addHybrid(int c1, int v1, int c2, int v2);
int tryToPayHybrids(const std::vector<ManaCostHybrid> &_hybrids, int _nbhybrids, std::vector<int16_t>& diff);
void randomDiffHybrids(ManaCost * _cost, std::vector<int16_t>& diff);
int add(ManaCost * _cost);
int remove(ManaCost * _cost);
int removeAll(int color);
int pay (ManaCost * _cost);
//return 1 if _cost can be paid with current data, 0 otherwise
int canAfford(ManaCost * _cost);
int isPositive();
ManaCost * Diff(ManaCost * _cost);
#ifdef WIN32
void Dump();
#endif
};
class ManaPool:public ManaCost{
protected:
Player * player;
public:
void Empty();
ManaPool(Player * player);
ManaPool(ManaCost * _manaCost, Player * player);
int remove (int color, int value);
int add(int color, int value, MTGCardInstance * source = NULL, bool extra = false);
int add(ManaCost * _cost, MTGCardInstance * source = NULL);
int pay (ManaCost * _cost);
};
#endif