Added object analytics around ExtraCost & ManaCost; some formatting style cleanup.
This commit is contained in:
@@ -3,13 +3,19 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Counters.h"
|
#include "Counters.h"
|
||||||
|
#include "ObjectAnalytics.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
class TargetChooser;
|
class TargetChooser;
|
||||||
class MTGCardInstance;
|
class MTGCardInstance;
|
||||||
class MTGAbility;
|
class MTGAbility;
|
||||||
|
|
||||||
class ExtraCost{
|
class ExtraCost
|
||||||
|
#ifdef TRACK_OBJECT_USAGE
|
||||||
|
: public InstanceCounter<ExtraCost>
|
||||||
|
#endif
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
TargetChooser * tc;
|
TargetChooser * tc;
|
||||||
MTGCardInstance * source;
|
MTGCardInstance * source;
|
||||||
@@ -18,8 +24,13 @@ public:
|
|||||||
|
|
||||||
ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc = NULL);
|
ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc = NULL);
|
||||||
virtual ~ExtraCost();
|
virtual ~ExtraCost();
|
||||||
|
|
||||||
virtual int setPayment(MTGCardInstance * card);
|
virtual int setPayment(MTGCardInstance * card);
|
||||||
virtual int isPaymentSet() { return (target != NULL); }
|
virtual int isPaymentSet()
|
||||||
|
{
|
||||||
|
return (target != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
virtual int canPay() { return 1; }
|
virtual int canPay() { return 1; }
|
||||||
virtual int doPay() = 0;
|
virtual int doPay() = 0;
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
@@ -27,11 +38,13 @@ public:
|
|||||||
virtual ExtraCost* clone() const = 0;
|
virtual ExtraCost* clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExtraCosts{
|
class ExtraCosts
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
vector<ExtraCost *>costs;
|
vector<ExtraCost *>costs;
|
||||||
MTGCardInstance * source;
|
MTGCardInstance * source;
|
||||||
MTGAbility * action;
|
MTGAbility * action;
|
||||||
|
|
||||||
ExtraCosts();
|
ExtraCosts();
|
||||||
~ExtraCosts();
|
~ExtraCosts();
|
||||||
void Render();
|
void Render();
|
||||||
@@ -45,7 +58,8 @@ public:
|
|||||||
ExtraCosts * clone() const;
|
ExtraCosts * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SacrificeCost: public ExtraCost{
|
class SacrificeCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
SacrificeCost(TargetChooser *_tc = NULL);
|
SacrificeCost(TargetChooser *_tc = NULL);
|
||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
@@ -53,15 +67,18 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//life cost
|
//life cost
|
||||||
class LifeCost: public ExtraCost{
|
class LifeCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
LifeCost(TargetChooser *_tc = NULL);
|
LifeCost(TargetChooser *_tc = NULL);
|
||||||
virtual int canPay();
|
virtual int canPay();
|
||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
virtual LifeCost * clone() const;
|
virtual LifeCost * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//pyrhaixa mana
|
//pyrhaixa mana
|
||||||
class LifeorManaCost: public ExtraCost{
|
class LifeorManaCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
LifeorManaCost(TargetChooser *_tc = NULL,string manaType = "");
|
LifeorManaCost(TargetChooser *_tc = NULL,string manaType = "");
|
||||||
string manaType;
|
string manaType;
|
||||||
@@ -69,8 +86,10 @@ public:
|
|||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
virtual LifeorManaCost * clone() const;
|
virtual LifeorManaCost * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Discard a random card cost
|
//Discard a random card cost
|
||||||
class DiscardRandomCost: public ExtraCost{
|
class DiscardRandomCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
DiscardRandomCost(TargetChooser *_tc = NULL);
|
DiscardRandomCost(TargetChooser *_tc = NULL);
|
||||||
virtual int canPay();
|
virtual int canPay();
|
||||||
@@ -79,7 +98,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//a choosen discard
|
//a choosen discard
|
||||||
class DiscardCost: public ExtraCost{
|
class DiscardCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
DiscardCost(TargetChooser *_tc = NULL);
|
DiscardCost(TargetChooser *_tc = NULL);
|
||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
@@ -87,7 +107,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//tolibrary cost
|
//tolibrary cost
|
||||||
class ToLibraryCost: public ExtraCost{
|
class ToLibraryCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
ToLibraryCost(TargetChooser *_tc = NULL);
|
ToLibraryCost(TargetChooser *_tc = NULL);
|
||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
@@ -95,7 +116,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Millyourself cost
|
//Millyourself cost
|
||||||
class MillCost: public ExtraCost{
|
class MillCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
MillCost(TargetChooser *_tc = NULL);
|
MillCost(TargetChooser *_tc = NULL);
|
||||||
virtual int canPay();
|
virtual int canPay();
|
||||||
@@ -104,13 +126,16 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Mill to exile yourself cost
|
//Mill to exile yourself cost
|
||||||
class MillExileCost: public MillCost{
|
class MillExileCost : public MillCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
MillExileCost(TargetChooser *_tc = NULL);
|
MillExileCost(TargetChooser *_tc = NULL);
|
||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
};
|
};
|
||||||
|
|
||||||
//tap cost
|
//tap cost
|
||||||
class TapCost: public ExtraCost{
|
class TapCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
TapCost();
|
TapCost();
|
||||||
virtual int isPaymentSet();
|
virtual int isPaymentSet();
|
||||||
@@ -118,8 +143,10 @@ public:
|
|||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
virtual TapCost * clone() const;
|
virtual TapCost * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//untap cost
|
//untap cost
|
||||||
class UnTapCost: public ExtraCost{
|
class UnTapCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
UnTapCost();
|
UnTapCost();
|
||||||
virtual int isPaymentSet();
|
virtual int isPaymentSet();
|
||||||
@@ -127,8 +154,10 @@ public:
|
|||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
virtual UnTapCost * clone() const;
|
virtual UnTapCost * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//tap other cost
|
//tap other cost
|
||||||
class TapTargetCost: public ExtraCost{
|
class TapTargetCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
TapTargetCost(TargetChooser *_tc = NULL);
|
TapTargetCost(TargetChooser *_tc = NULL);
|
||||||
virtual int isPaymentSet();
|
virtual int isPaymentSet();
|
||||||
@@ -137,7 +166,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//exile as cost
|
//exile as cost
|
||||||
class ExileTargetCost: public ExtraCost{
|
class ExileTargetCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
ExileTargetCost(TargetChooser *_tc = NULL);
|
ExileTargetCost(TargetChooser *_tc = NULL);
|
||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
@@ -145,7 +175,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//bounce cost
|
//bounce cost
|
||||||
class BounceTargetCost: public ExtraCost{
|
class BounceTargetCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
BounceTargetCost(TargetChooser *_tc = NULL);
|
BounceTargetCost(TargetChooser *_tc = NULL);
|
||||||
virtual int doPay();
|
virtual int doPay();
|
||||||
@@ -153,7 +184,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//bounce cost
|
//bounce cost
|
||||||
class Ninja: public ExtraCost{
|
class Ninja : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Ninja(TargetChooser *_tc = NULL);
|
Ninja(TargetChooser *_tc = NULL);
|
||||||
virtual int isPaymentSet();
|
virtual int isPaymentSet();
|
||||||
@@ -161,7 +193,8 @@ public:
|
|||||||
virtual Ninja * clone() const;
|
virtual Ninja * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CounterCost: public ExtraCost{
|
class CounterCost : public ExtraCost
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Counter * counter;
|
Counter * counter;
|
||||||
int hasCounters;
|
int hasCounters;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "MTGDefinitions.h"
|
#include "MTGDefinitions.h"
|
||||||
|
#include "ObjectAnalytics.h"
|
||||||
|
|
||||||
class ManaCostHybrid;
|
class ManaCostHybrid;
|
||||||
class ExtraCosts;
|
class ExtraCosts;
|
||||||
@@ -12,7 +12,11 @@ class MTGAbility;
|
|||||||
class MTGCardInstance;
|
class MTGCardInstance;
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
class ManaCost{
|
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);
|
friend std::ostream& operator<<(std::ostream& out, ManaCost* m);
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "Counters.h"
|
#include "Counters.h"
|
||||||
|
|
||||||
ExtraCost::ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc) :
|
SUPPORT_OBJECT_ANALYTICS(ExtraCost)
|
||||||
tc(_tc), source(NULL), target(NULL), mCostRenderString(inCostRenderString)
|
|
||||||
|
ExtraCost::ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc)
|
||||||
|
: tc(_tc), source(NULL), target(NULL), mCostRenderString(inCostRenderString)
|
||||||
{
|
{
|
||||||
if (tc)
|
if (tc)
|
||||||
tc->targetter = NULL;
|
tc->targetter = NULL;
|
||||||
@@ -25,7 +27,7 @@ int ExtraCost::setSource(MTGCardInstance * _source)
|
|||||||
if (tc)
|
if (tc)
|
||||||
{
|
{
|
||||||
tc->source = _source;
|
tc->source = _source;
|
||||||
// "extra cost is not targetting, protections do not apply" this is not cryptic at all :) make an ability you will understand it then. this keeps the target chooser from being unable to select a creature with shroud/protections.
|
// this keeps the target chooser from being unable to select a creature with shroud/protections.
|
||||||
tc->targetter = NULL;
|
tc->targetter = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -69,8 +71,8 @@ LifeCost * LifeCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
LifeCost::LifeCost(TargetChooser *_tc) :
|
LifeCost::LifeCost(TargetChooser *_tc)
|
||||||
ExtraCost("Life", _tc)
|
: ExtraCost("Life", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ int LifeCost::doPay()
|
|||||||
tc->initTargets();
|
tc->initTargets();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//life or Mana cost
|
//life or Mana cost
|
||||||
LifeorManaCost * LifeorManaCost::clone() const
|
LifeorManaCost * LifeorManaCost::clone() const
|
||||||
{
|
{
|
||||||
@@ -106,8 +109,8 @@ LifeorManaCost * LifeorManaCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
LifeorManaCost::LifeorManaCost(TargetChooser *_tc,string manaType) :
|
LifeorManaCost::LifeorManaCost(TargetChooser *_tc,string manaType)
|
||||||
ExtraCost("Phyrexian Mana", _tc),manaType(manaType)
|
: ExtraCost("Phyrexian Mana", _tc), manaType(manaType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +164,8 @@ DiscardRandomCost * DiscardRandomCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscardRandomCost::DiscardRandomCost(TargetChooser *_tc) :
|
DiscardRandomCost::DiscardRandomCost(TargetChooser *_tc)
|
||||||
ExtraCost("Discard Random", _tc)
|
: ExtraCost("Discard Random", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,8 +234,8 @@ ToLibraryCost * ToLibraryCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToLibraryCost::ToLibraryCost(TargetChooser *_tc) :
|
ToLibraryCost::ToLibraryCost(TargetChooser *_tc)
|
||||||
ExtraCost("Put a card on top of Library", _tc)
|
: ExtraCost("Put a card on top of Library", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,8 +262,8 @@ MillCost * MillCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
MillCost::MillCost(TargetChooser *_tc) :
|
MillCost::MillCost(TargetChooser *_tc)
|
||||||
ExtraCost("Deplete", _tc)
|
: ExtraCost("Deplete", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,8 +292,8 @@ int MillCost::doPay()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MillExileCost::MillExileCost(TargetChooser *_tc) :
|
MillExileCost::MillExileCost(TargetChooser *_tc)
|
||||||
MillCost(_tc)
|
: MillCost(_tc)
|
||||||
{
|
{
|
||||||
// override the base string here
|
// override the base string here
|
||||||
mCostRenderString = "Deplete To Exile";
|
mCostRenderString = "Deplete To Exile";
|
||||||
@@ -319,8 +322,8 @@ TapCost * TapCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
TapCost::TapCost() :
|
TapCost::TapCost()
|
||||||
ExtraCost("Tap")
|
: ExtraCost("Tap")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,8 +397,8 @@ TapTargetCost * TapTargetCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
TapTargetCost::TapTargetCost(TargetChooser *_tc) :
|
TapTargetCost::TapTargetCost(TargetChooser *_tc)
|
||||||
ExtraCost("Tap Target", _tc)
|
: ExtraCost("Tap Target", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,8 +439,8 @@ ExileTargetCost * ExileTargetCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExileTargetCost::ExileTargetCost(TargetChooser *_tc) :
|
ExileTargetCost::ExileTargetCost(TargetChooser *_tc)
|
||||||
ExtraCost("Exile Target", _tc)
|
: ExtraCost("Exile Target", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,8 +467,8 @@ BounceTargetCost * BounceTargetCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
BounceTargetCost::BounceTargetCost(TargetChooser *_tc) :
|
BounceTargetCost::BounceTargetCost(TargetChooser *_tc)
|
||||||
ExtraCost("Return Target to Hand", _tc)
|
: ExtraCost("Return Target to Hand", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +518,6 @@ int Ninja::isPaymentSet()
|
|||||||
|
|
||||||
int Ninja::doPay()
|
int Ninja::doPay()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
target->controller()->game->putInHand(target);
|
target->controller()->game->putInHand(target);
|
||||||
@@ -538,8 +540,8 @@ SacrificeCost * SacrificeCost::clone() const
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
SacrificeCost::SacrificeCost(TargetChooser *_tc) :
|
SacrificeCost::SacrificeCost(TargetChooser *_tc)
|
||||||
ExtraCost("Sacrifice", _tc)
|
: ExtraCost("Sacrifice", _tc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "WEvent.h"
|
#include "WEvent.h"
|
||||||
#include "MTGAbility.h"
|
#include "MTGAbility.h"
|
||||||
|
|
||||||
|
SUPPORT_OBJECT_ANALYTICS(ManaCost)
|
||||||
|
|
||||||
ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstance * c)
|
ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstance * c)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "CardPrimitive.h"
|
#include "CardPrimitive.h"
|
||||||
#include "DebugRoutines.h"
|
#include "DebugRoutines.h"
|
||||||
|
#include "ExtraCost.h"
|
||||||
|
#include "ManaCost.h"
|
||||||
#include "MTGCard.h"
|
#include "MTGCard.h"
|
||||||
#include "MTGCardInstance.h"
|
#include "MTGCardInstance.h"
|
||||||
|
|
||||||
@@ -30,6 +32,16 @@ namespace ObjectAnalytics
|
|||||||
DebugTrace("MTGCardInstance max count: " << InstanceCounter<MTGCardInstance>::GetMaximumObjectCount());
|
DebugTrace("MTGCardInstance max count: " << InstanceCounter<MTGCardInstance>::GetMaximumObjectCount());
|
||||||
DebugTrace("MTGCardInstance max byte usage: " << InstanceCounter<MTGCardInstance>::GetMaximumByteCount() << std::endl);
|
DebugTrace("MTGCardInstance max byte usage: " << InstanceCounter<MTGCardInstance>::GetMaximumByteCount() << std::endl);
|
||||||
|
|
||||||
|
DebugTrace("ManaCost current count: " << InstanceCounter<ManaCost>::GetCurrentObjectCount());
|
||||||
|
DebugTrace("ManaCost current byte usage: " << InstanceCounter<ManaCost>::GetCurrentByteCount());
|
||||||
|
DebugTrace("ManaCost max count: " << InstanceCounter<ManaCost>::GetMaximumObjectCount());
|
||||||
|
DebugTrace("ManaCost max byte usage: " << InstanceCounter<ManaCost>::GetMaximumByteCount() << std::endl);
|
||||||
|
|
||||||
|
DebugTrace("ExtraCost current count: " << InstanceCounter<ExtraCost>::GetCurrentObjectCount());
|
||||||
|
DebugTrace("ExtraCost current byte usage: " << InstanceCounter<ExtraCost>::GetCurrentByteCount());
|
||||||
|
DebugTrace("ExtraCost max count: " << InstanceCounter<ExtraCost>::GetMaximumObjectCount());
|
||||||
|
DebugTrace("ExtraCost max byte usage: " << InstanceCounter<ExtraCost>::GetMaximumByteCount() << std::endl);
|
||||||
|
|
||||||
DebugTrace("-----------------------------------------------------------");
|
DebugTrace("-----------------------------------------------------------");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user