added bloodthirst:number ability

This commit is contained in:
omegablast2002@yahoo.com
2010-08-26 16:05:48 +00:00
parent 3b9b79bb6e
commit aef30e6e0d
12 changed files with 63 additions and 7 deletions

View File

@@ -53,12 +53,14 @@ public:
intValue = target->getManaCost()->getConvertedCost();
}else if (s == "lifetotal"){
intValue = target->controller()->life;
}else if (s == "odcount"){
intValue = target->controller()->opponent()->damageCount;
}else if (s == "opponentlifetotal"){
intValue = target->controller()->opponent()->life;
}else if (s == "p"){
intValue = target->power;
}else if (s == "t"){
intValue = target->toughness;
}else if (s == "p" || s == "power"){
intValue = target->getPower();
}else if (s == "t" || s == "toughness"){
intValue = target->getToughness();
}else{
intValue = atoi(s.c_str());
}
@@ -2491,7 +2493,27 @@ public:
~AResetCost(){
}
};
//bloodthirst ability------------------------------------------
class ABloodThirst:public MTGAbility{
public:
int amount;
ABloodThirst(int id, MTGCardInstance * source, MTGCardInstance * target,int amount):MTGAbility(id,source,target),amount(amount){
MTGCardInstance * _target = (MTGCardInstance *)target;}
int addToGame(){
MTGCardInstance * _target = (MTGCardInstance *)target;
amount;
for(int i = 0;i < amount;i++){
if(_target->controller()->opponent()->damaged() > 0){
_target->counters->addCounter(1,1);}
}
return 1;}
ABloodThirst * clone() const{
ABloodThirst * a = NEW ABloodThirst(*this);
a->isClone = 1;
return a;
}
~ABloodThirst(){}
};
//reduce or increase manacost of target by color:amount------------------------------------------
class AManaRedux:public MTGAbility{
public:

View File

@@ -22,6 +22,7 @@ class Damageable:public Targetable {
public:
int life;
int poisonCount;
int damageCount;
int type_as_damageable;
Damageable(int _life){life=_life;};
int getLife(){return life;};

View File

@@ -107,8 +107,9 @@ class Constants
POISONDAMAGE = 49,
POISONTWODAMAGE = 50,
POISONTHREEDAMAGE = 51,
POWERBLOCKER = 52,
NB_BASIC_ABILITIES = 52,
NB_BASIC_ABILITIES = 53,
RARITY_S = 'S', //Special Rarity

View File

@@ -25,6 +25,7 @@ class Player: public Damageable{
MTGPlayerCards * game;
int afterDamage();
int poisoned();
int damaged();
Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
virtual ~Player();
void unTapPhase();

View File

@@ -26,6 +26,7 @@ class RulesPlayerData{
vector <string> extraRules;
int life;
int poisonCount;
int damageCount;
string avatar;
ManaCost * manapool;
RulesPlayerZone zones[5];

View File

@@ -82,7 +82,8 @@ int Damage::resolve(){
MTGCardInstance * _target = (MTGCardInstance *)target;
for (int i = 0; i < damage; i++){
//this will be changed to poison counters.
a = target->dealDamage(1);
a = target->dealDamage(1);
target->damageCount += 1;
}
_target->poisonCount += 1;
return a;
@@ -92,6 +93,7 @@ int Damage::resolve(){
for (int i = 0; i < damage; i++){
//this will be changed to poison counters.
a = target->dealDamage(1);
target->damageCount += 1;
}
_target->poisonCount += 2;
return a;
@@ -101,11 +103,13 @@ int Damage::resolve(){
for (int i = 0; i < damage; i++){
//this will be changed to poison counters.
a = target->dealDamage(1);
target->damageCount += 1;
}
_target->poisonCount += 3;
return a;
}
a = target->dealDamage(damage);
target->damageCount += 1;
}
//Send (Damage/Replaced effect) event to listeners
g->receiveEvent(e);

View File

@@ -97,6 +97,7 @@ void GameObserver::nextGamePhase(){
if (currentGamePhase == Constants::MTG_PHASE_BEFORE_BEGIN){
cleanupPhase();
currentPlayer->canPutLandsIntoPlay = 1;
currentPlayer->damageCount = 0;
mLayers->actionLayer()->cleanGarbage(); //clean abilities history for this turn;
mLayers->stackLayer()->garbageCollect(); //clean stack history for this turn;
mLayers->actionLayer()->Update(0);

View File

@@ -988,6 +988,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
ab = NEW ABecomes(id,card,target,stypes,pt,sabilities);
}return ab;
}
//bloodthirst
found = s.find("bloodthirst:");
if (found != string::npos){
size_t start = s.find(":",found);
size_t end = s.find(" ",start);
int amount;
if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());}
else{amount = atoi(s.substr(start+1).c_str());}
MTGAbility * a = NEW ABloodThirst(id,card,target,amount);
return a;}
//ManaRedux
found = s.find("colorless:");

View File

@@ -343,6 +343,7 @@ int MTGCardInstance::canBlock(MTGCardInstance * opponent){
if (!opponent->isAttacker()) return 0;
// Comprehensive rule 502.7f : If a creature with protection attacks, it can't be blocked by creatures that have the stated quality.
if (opponent->protectedAgainst(this)) return 0;
if (opponent->power > !(defenser->power) && opponent->has(basicAbilities[Constants::POWERBLOCKER])) return 0;
if (opponent->cantBeBlockedBy(this)) return 0;
if (opponent->basicAbilities[Constants::UNBLOCKABLE]) return 0;
if (opponent->basicAbilities[Constants::ONEBLOCKER] && opponent->blocked) return 0;

View File

@@ -60,6 +60,7 @@ const char* Constants::MTGBasicAbilities[] = {
"poisondamage",
"poisontwodamage",
"poisonthreedamage",
"powerblocker"
};

View File

@@ -13,6 +13,7 @@ Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageabl
manaPool = NEW ManaPool(this);
canPutLandsIntoPlay = 1;
poisonCount = 0;
damageCount = 0;
mAvatar = NULL;
mAvatarTex = NULL;
type_as_damageable = DAMAGEABLE_PLAYER;
@@ -87,10 +88,16 @@ int Player::afterDamage(){
int Player::poisoned(){
return poisonCount;
}
int Player::damaged(){
return damageCount;
}
//Cleanup phase at the end of a turn
void Player::cleanupPhase(){
Player *p;
game->inPlay->cleanupPhase();
game->graveyard->cleanupPhase();
}
ostream& operator<<(ostream& out, const Player& p)

View File

@@ -40,6 +40,7 @@ MTGCardInstance * Rules::getCardByMTGId(int mtgid){
RulesPlayerData::RulesPlayerData(){
life = 20;
poisonCount = 0;
damageCount = 0;
manapool = NEW ManaCost();
avatar = "";
}
@@ -80,6 +81,9 @@ void RulesState::parsePlayerState(int playerId, string s){
return;
}else if(areaS.compare("poisonCount") == 0){
playerData[playerId].poisonCount = atoi((s.substr(limiter+1)).c_str());
return;
}else if(areaS.compare("damageCount") == 0){
playerData[playerId].damageCount = atoi((s.substr(limiter+1)).c_str());
return;
}else if(areaS.compare("avatar") == 0){
playerData[playerId].avatar = s.substr(limiter+1);
@@ -278,6 +282,7 @@ void Rules::initGame(){
Player * p = g->players[i];
p->life = initState.playerData[i].life;
p->poisonCount = initState.playerData[i].poisonCount;
p->damageCount = initState.playerData[i].damageCount;
p->getManaPool()->copy(initState.playerData[i].manapool);
if (initState.playerData[i].avatar.size()) {
p->loadAvatar(initState.playerData[i].avatar);
@@ -324,6 +329,7 @@ void RulesPlayerData::cleanup(){
}
life=20;
poisonCount=0;
damageCount=0;
}
void RulesState::cleanup(){