added bloodthirst:number ability
This commit is contained in:
@@ -53,12 +53,14 @@ public:
|
|||||||
intValue = target->getManaCost()->getConvertedCost();
|
intValue = target->getManaCost()->getConvertedCost();
|
||||||
}else if (s == "lifetotal"){
|
}else if (s == "lifetotal"){
|
||||||
intValue = target->controller()->life;
|
intValue = target->controller()->life;
|
||||||
|
}else if (s == "odcount"){
|
||||||
|
intValue = target->controller()->opponent()->damageCount;
|
||||||
}else if (s == "opponentlifetotal"){
|
}else if (s == "opponentlifetotal"){
|
||||||
intValue = target->controller()->opponent()->life;
|
intValue = target->controller()->opponent()->life;
|
||||||
}else if (s == "p"){
|
}else if (s == "p" || s == "power"){
|
||||||
intValue = target->power;
|
intValue = target->getPower();
|
||||||
}else if (s == "t"){
|
}else if (s == "t" || s == "toughness"){
|
||||||
intValue = target->toughness;
|
intValue = target->getToughness();
|
||||||
}else{
|
}else{
|
||||||
intValue = atoi(s.c_str());
|
intValue = atoi(s.c_str());
|
||||||
}
|
}
|
||||||
@@ -2491,7 +2493,27 @@ public:
|
|||||||
~AResetCost(){
|
~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------------------------------------------
|
//reduce or increase manacost of target by color:amount------------------------------------------
|
||||||
class AManaRedux:public MTGAbility{
|
class AManaRedux:public MTGAbility{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class Damageable:public Targetable {
|
|||||||
public:
|
public:
|
||||||
int life;
|
int life;
|
||||||
int poisonCount;
|
int poisonCount;
|
||||||
|
int damageCount;
|
||||||
int type_as_damageable;
|
int type_as_damageable;
|
||||||
Damageable(int _life){life=_life;};
|
Damageable(int _life){life=_life;};
|
||||||
int getLife(){return life;};
|
int getLife(){return life;};
|
||||||
|
|||||||
@@ -107,8 +107,9 @@ class Constants
|
|||||||
POISONDAMAGE = 49,
|
POISONDAMAGE = 49,
|
||||||
POISONTWODAMAGE = 50,
|
POISONTWODAMAGE = 50,
|
||||||
POISONTHREEDAMAGE = 51,
|
POISONTHREEDAMAGE = 51,
|
||||||
|
POWERBLOCKER = 52,
|
||||||
|
|
||||||
NB_BASIC_ABILITIES = 52,
|
NB_BASIC_ABILITIES = 53,
|
||||||
|
|
||||||
|
|
||||||
RARITY_S = 'S', //Special Rarity
|
RARITY_S = 'S', //Special Rarity
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Player: public Damageable{
|
|||||||
MTGPlayerCards * game;
|
MTGPlayerCards * game;
|
||||||
int afterDamage();
|
int afterDamage();
|
||||||
int poisoned();
|
int poisoned();
|
||||||
|
int damaged();
|
||||||
Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||||
virtual ~Player();
|
virtual ~Player();
|
||||||
void unTapPhase();
|
void unTapPhase();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class RulesPlayerData{
|
|||||||
vector <string> extraRules;
|
vector <string> extraRules;
|
||||||
int life;
|
int life;
|
||||||
int poisonCount;
|
int poisonCount;
|
||||||
|
int damageCount;
|
||||||
string avatar;
|
string avatar;
|
||||||
ManaCost * manapool;
|
ManaCost * manapool;
|
||||||
RulesPlayerZone zones[5];
|
RulesPlayerZone zones[5];
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ int Damage::resolve(){
|
|||||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||||
for (int i = 0; i < damage; i++){
|
for (int i = 0; i < damage; i++){
|
||||||
//this will be changed to poison counters.
|
//this will be changed to poison counters.
|
||||||
a = target->dealDamage(1);
|
a = target->dealDamage(1);
|
||||||
|
target->damageCount += 1;
|
||||||
}
|
}
|
||||||
_target->poisonCount += 1;
|
_target->poisonCount += 1;
|
||||||
return a;
|
return a;
|
||||||
@@ -92,6 +93,7 @@ int Damage::resolve(){
|
|||||||
for (int i = 0; i < damage; i++){
|
for (int i = 0; i < damage; i++){
|
||||||
//this will be changed to poison counters.
|
//this will be changed to poison counters.
|
||||||
a = target->dealDamage(1);
|
a = target->dealDamage(1);
|
||||||
|
target->damageCount += 1;
|
||||||
}
|
}
|
||||||
_target->poisonCount += 2;
|
_target->poisonCount += 2;
|
||||||
return a;
|
return a;
|
||||||
@@ -101,11 +103,13 @@ int Damage::resolve(){
|
|||||||
for (int i = 0; i < damage; i++){
|
for (int i = 0; i < damage; i++){
|
||||||
//this will be changed to poison counters.
|
//this will be changed to poison counters.
|
||||||
a = target->dealDamage(1);
|
a = target->dealDamage(1);
|
||||||
|
target->damageCount += 1;
|
||||||
}
|
}
|
||||||
_target->poisonCount += 3;
|
_target->poisonCount += 3;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
a = target->dealDamage(damage);
|
a = target->dealDamage(damage);
|
||||||
|
target->damageCount += 1;
|
||||||
}
|
}
|
||||||
//Send (Damage/Replaced effect) event to listeners
|
//Send (Damage/Replaced effect) event to listeners
|
||||||
g->receiveEvent(e);
|
g->receiveEvent(e);
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ void GameObserver::nextGamePhase(){
|
|||||||
if (currentGamePhase == Constants::MTG_PHASE_BEFORE_BEGIN){
|
if (currentGamePhase == Constants::MTG_PHASE_BEFORE_BEGIN){
|
||||||
cleanupPhase();
|
cleanupPhase();
|
||||||
currentPlayer->canPutLandsIntoPlay = 1;
|
currentPlayer->canPutLandsIntoPlay = 1;
|
||||||
|
currentPlayer->damageCount = 0;
|
||||||
mLayers->actionLayer()->cleanGarbage(); //clean abilities history for this turn;
|
mLayers->actionLayer()->cleanGarbage(); //clean abilities history for this turn;
|
||||||
mLayers->stackLayer()->garbageCollect(); //clean stack history for this turn;
|
mLayers->stackLayer()->garbageCollect(); //clean stack history for this turn;
|
||||||
mLayers->actionLayer()->Update(0);
|
mLayers->actionLayer()->Update(0);
|
||||||
|
|||||||
@@ -988,6 +988,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
ab = NEW ABecomes(id,card,target,stypes,pt,sabilities);
|
ab = NEW ABecomes(id,card,target,stypes,pt,sabilities);
|
||||||
}return ab;
|
}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
|
//ManaRedux
|
||||||
found = s.find("colorless:");
|
found = s.find("colorless:");
|
||||||
|
|||||||
@@ -343,6 +343,7 @@ int MTGCardInstance::canBlock(MTGCardInstance * opponent){
|
|||||||
if (!opponent->isAttacker()) return 0;
|
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.
|
// 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->protectedAgainst(this)) return 0;
|
||||||
|
if (opponent->power > !(defenser->power) && opponent->has(basicAbilities[Constants::POWERBLOCKER])) return 0;
|
||||||
if (opponent->cantBeBlockedBy(this)) return 0;
|
if (opponent->cantBeBlockedBy(this)) return 0;
|
||||||
if (opponent->basicAbilities[Constants::UNBLOCKABLE]) return 0;
|
if (opponent->basicAbilities[Constants::UNBLOCKABLE]) return 0;
|
||||||
if (opponent->basicAbilities[Constants::ONEBLOCKER] && opponent->blocked) return 0;
|
if (opponent->basicAbilities[Constants::ONEBLOCKER] && opponent->blocked) return 0;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ const char* Constants::MTGBasicAbilities[] = {
|
|||||||
"poisondamage",
|
"poisondamage",
|
||||||
"poisontwodamage",
|
"poisontwodamage",
|
||||||
"poisonthreedamage",
|
"poisonthreedamage",
|
||||||
|
"powerblocker"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageabl
|
|||||||
manaPool = NEW ManaPool(this);
|
manaPool = NEW ManaPool(this);
|
||||||
canPutLandsIntoPlay = 1;
|
canPutLandsIntoPlay = 1;
|
||||||
poisonCount = 0;
|
poisonCount = 0;
|
||||||
|
damageCount = 0;
|
||||||
mAvatar = NULL;
|
mAvatar = NULL;
|
||||||
mAvatarTex = NULL;
|
mAvatarTex = NULL;
|
||||||
type_as_damageable = DAMAGEABLE_PLAYER;
|
type_as_damageable = DAMAGEABLE_PLAYER;
|
||||||
@@ -87,10 +88,16 @@ int Player::afterDamage(){
|
|||||||
int Player::poisoned(){
|
int Player::poisoned(){
|
||||||
return poisonCount;
|
return poisonCount;
|
||||||
}
|
}
|
||||||
|
int Player::damaged(){
|
||||||
|
return damageCount;
|
||||||
|
}
|
||||||
//Cleanup phase at the end of a turn
|
//Cleanup phase at the end of a turn
|
||||||
void Player::cleanupPhase(){
|
void Player::cleanupPhase(){
|
||||||
|
Player *p;
|
||||||
game->inPlay->cleanupPhase();
|
game->inPlay->cleanupPhase();
|
||||||
game->graveyard->cleanupPhase();
|
game->graveyard->cleanupPhase();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& operator<<(ostream& out, const Player& p)
|
ostream& operator<<(ostream& out, const Player& p)
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ MTGCardInstance * Rules::getCardByMTGId(int mtgid){
|
|||||||
RulesPlayerData::RulesPlayerData(){
|
RulesPlayerData::RulesPlayerData(){
|
||||||
life = 20;
|
life = 20;
|
||||||
poisonCount = 0;
|
poisonCount = 0;
|
||||||
|
damageCount = 0;
|
||||||
manapool = NEW ManaCost();
|
manapool = NEW ManaCost();
|
||||||
avatar = "";
|
avatar = "";
|
||||||
}
|
}
|
||||||
@@ -80,6 +81,9 @@ void RulesState::parsePlayerState(int playerId, string s){
|
|||||||
return;
|
return;
|
||||||
}else if(areaS.compare("poisonCount") == 0){
|
}else if(areaS.compare("poisonCount") == 0){
|
||||||
playerData[playerId].poisonCount = atoi((s.substr(limiter+1)).c_str());
|
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;
|
return;
|
||||||
}else if(areaS.compare("avatar") == 0){
|
}else if(areaS.compare("avatar") == 0){
|
||||||
playerData[playerId].avatar = s.substr(limiter+1);
|
playerData[playerId].avatar = s.substr(limiter+1);
|
||||||
@@ -278,6 +282,7 @@ void Rules::initGame(){
|
|||||||
Player * p = g->players[i];
|
Player * p = g->players[i];
|
||||||
p->life = initState.playerData[i].life;
|
p->life = initState.playerData[i].life;
|
||||||
p->poisonCount = initState.playerData[i].poisonCount;
|
p->poisonCount = initState.playerData[i].poisonCount;
|
||||||
|
p->damageCount = initState.playerData[i].damageCount;
|
||||||
p->getManaPool()->copy(initState.playerData[i].manapool);
|
p->getManaPool()->copy(initState.playerData[i].manapool);
|
||||||
if (initState.playerData[i].avatar.size()) {
|
if (initState.playerData[i].avatar.size()) {
|
||||||
p->loadAvatar(initState.playerData[i].avatar);
|
p->loadAvatar(initState.playerData[i].avatar);
|
||||||
@@ -324,6 +329,7 @@ void RulesPlayerData::cleanup(){
|
|||||||
}
|
}
|
||||||
life=20;
|
life=20;
|
||||||
poisonCount=0;
|
poisonCount=0;
|
||||||
|
damageCount=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RulesState::cleanup(){
|
void RulesState::cleanup(){
|
||||||
|
|||||||
Reference in New Issue
Block a user