- Added remove/add counters as a cost, patch by Salmelo, thanks man!. See primitives/mtg.txt -> Thallid to see how it works
- added test for i286 by salmelo
- added basic display for counters (this needs improvement) by salmelo
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-03-22 04:26:42 +00:00
parent 99db31fe9d
commit 22a35d2265
15 changed files with 334 additions and 20 deletions

View File

@@ -202,10 +202,11 @@ public:
//counters
class AACounter: public ActivatedAbility{
public:
string name;
int nb;
int power;
int toughness;
AACounter(int id, MTGCardInstance * source, MTGCardInstance * target, int power, int toughness, int nb, ManaCost * cost = NULL, int doTap = 0) : ActivatedAbility(id, source, cost, 0, doTap), nb(nb), power(power), toughness(toughness) {
AACounter(int id, MTGCardInstance * source, MTGCardInstance * target, const char * _name, int power, int toughness, int nb, ManaCost * cost = NULL, int doTap = 0) : ActivatedAbility(id, source, cost, 0, doTap), nb(nb), power(power), toughness(toughness), name(_name) {
this->target = target;
}
@@ -215,11 +216,11 @@ class AACounter: public ActivatedAbility{
MTGCardInstance * _target = (MTGCardInstance *)target;
if (nb>0){
for (int i=0; i < nb; i++){
_target->counters->addCounter(power, toughness);
_target->counters->addCounter(name.c_str(), power, toughness);
}
}else{
for (int i=0; i < -nb; i++){
_target->counters->removeCounter(power, toughness);
_target->counters->removeCounter(name.c_str(), power, toughness);
}
}
return nb;

View File

@@ -29,6 +29,7 @@ struct CardGui : public PlayGuiObject {
void RenderBig(const Pos&); //Tries to render the Big version of a card picture, backups to text version in case of failure
static void RenderBig(MTGCard * card, const Pos& pos);
void alternateRenderBig(const Pos&); //Renders Text Version of a card
void renderCountersBig(const Pos& pos);
virtual void Update(float dt);
static void alternateRender(MTGCard * card, const Pos& pos);
static JQuad * alternateThumbQuad(MTGCard * card);

View File

@@ -2,6 +2,7 @@
#define _EXTRACOST_H_
#include <vector>
#include "Counters.h"
using std::vector;
class TargetChooser;
@@ -13,9 +14,10 @@ public:
TargetChooser * tc;
MTGCardInstance * source;
ExtraCost(TargetChooser *_tc = NULL);
~ExtraCost();
virtual ~ExtraCost();
virtual int setPayment(MTGCardInstance * card) = 0;
virtual int isPaymentSet() = 0;
virtual int canPay() = 0;
virtual int doPay() = 0;
virtual void Render(){};
virtual int setSource(MTGCardInstance * _source);
@@ -32,6 +34,7 @@ public:
void Render();
int tryToSetPayment(MTGCardInstance * card);
int isPaymentSet();
int canPay();
int doPay();
int reset();
int setAction(MTGAbility * _action, MTGCardInstance * _source);
@@ -45,10 +48,27 @@ public:
SacrificeCost(TargetChooser *_tc = NULL);
virtual int setPayment(MTGCardInstance * card);
virtual int isPaymentSet();
virtual int canPay();
virtual int doPay();
virtual void Render();
virtual int setSource(MTGCardInstance * _source);
virtual SacrificeCost * clone() const;
};
class CounterCost: public ExtraCost{
public:
Counter * counter;
MTGCardInstance * target;
int hasCounters;
CounterCost(Counter * _counter,TargetChooser *_tc = NULL);
~CounterCost();
virtual int setPayment(MTGCardInstance * card);
virtual int isPaymentSet();
virtual int canPay();
virtual int doPay();
virtual void Render();
virtual int setSource(MTGCardInstance * _source);
virtual CounterCost * clone() const;
};
#endif

View File

@@ -252,10 +252,10 @@ class GenericTriggeredAbility:public TriggeredAbility{
class AbilityFactory{
private:
int countCards(TargetChooser * tc, Player * player = NULL, int option = 0);
int parsePowerToughness(string s, int *power, int *toughness);
TriggeredAbility * parseTrigger(string s, int id, Spell * spell, MTGCardInstance *card, Targetable * target);
int parseRestriction(string s);
public:
int parsePowerToughness(string s, int *power, int *toughness);
int getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0,MTGGameZone * dest = NULL);
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,MTGGameZone * dest = NULL);
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);

View File

@@ -46,11 +46,12 @@ class ManaCost{
int add(int color, int value);
//
// Extra Costs (sacrifice...)
// Extra Costs (sacrifice,counters...)
//
int addExtraCost(ExtraCost * _cost);
int setExtraCostsAction(MTGAbility * action, MTGCardInstance * card);
int isExtraPaymentSet();
int canPayExtra();
int doPayExtra();
int addHybrid(int c1, int v1, int c2, int v2);