added poison support, guicounter, "infect" ability, poisonous ability.
This commit is contained in:
@@ -2196,7 +2196,36 @@ AADamager(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt *
|
|||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
//poison removel
|
||||||
|
class AARemovePoison:public ActivatedAbilityTP{
|
||||||
|
public:
|
||||||
|
int poison;
|
||||||
|
AARemovePoison(int _id, MTGCardInstance * _source, Targetable * _target,int poison, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),poison(poison){
|
||||||
|
}
|
||||||
|
|
||||||
|
int resolve(){
|
||||||
|
Damageable * _target = (Damageable *) getTarget();
|
||||||
|
if(_target){
|
||||||
|
_target->poisonCount -= poison;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * getMenuText(){
|
||||||
|
return "Remove Poison";
|
||||||
|
}
|
||||||
|
|
||||||
|
AARemovePoison * clone() const{
|
||||||
|
AARemovePoison * a = NEW AARemovePoison(*this);
|
||||||
|
a->isClone = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
~AARemovePoison(){
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
/* Standard Damager, can choose a NEW target each time the price is paid */
|
/* Standard Damager, can choose a NEW target each time the price is paid */
|
||||||
class TADamager:public TargetAbility{
|
class TADamager:public TargetAbility{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ class GameObserver;
|
|||||||
|
|
||||||
class Damageable:public Targetable {
|
class Damageable:public Targetable {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int life;
|
int life;
|
||||||
|
int poisonCount;
|
||||||
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;};
|
||||||
virtual int dealDamage(int damage){life-=damage;return life;};
|
virtual int dealDamage(int damage){life-=damage;return life;};
|
||||||
virtual int afterDamage(){return 0;}
|
virtual int afterDamage(){return 0;}
|
||||||
|
virtual int poisoned(){return 0;}
|
||||||
virtual JQuad * getIcon(){return NULL;};
|
virtual JQuad * getIcon(){return NULL;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ struct GuiAvatar : public GuiStatic{
|
|||||||
protected:
|
protected:
|
||||||
int avatarRed;
|
int avatarRed;
|
||||||
int currentLife;
|
int currentLife;
|
||||||
|
int currentpoisonCount;
|
||||||
Corner corner;
|
Corner corner;
|
||||||
public:
|
public:
|
||||||
Player * player;
|
Player * player;
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
|
|||||||
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
||||||
int nbOpponents();
|
int nbOpponents();
|
||||||
int stepPower(CombatStep step);
|
int stepPower(CombatStep step);
|
||||||
|
|
||||||
int afterDamage();
|
int afterDamage();
|
||||||
|
|
||||||
int has(int ability);
|
int has(int ability);
|
||||||
|
|||||||
@@ -103,8 +103,12 @@ class Constants
|
|||||||
HORSEMANSHIP = 45,
|
HORSEMANSHIP = 45,
|
||||||
CANTREGEN = 46,
|
CANTREGEN = 46,
|
||||||
ONEBLOCKER = 47,
|
ONEBLOCKER = 47,
|
||||||
|
INFECT = 48,
|
||||||
|
POISONDAMAGE = 49,
|
||||||
|
POISONTWODAMAGE = 50,
|
||||||
|
POISONTHREEDAMAGE = 51,
|
||||||
|
|
||||||
NB_BASIC_ABILITIES = 48,
|
NB_BASIC_ABILITIES = 52,
|
||||||
|
|
||||||
|
|
||||||
RARITY_S = 'S', //Special Rarity
|
RARITY_S = 'S', //Special Rarity
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class Player: public Damageable{
|
|||||||
int canPutLandsIntoPlay;
|
int canPutLandsIntoPlay;
|
||||||
MTGPlayerCards * game;
|
MTGPlayerCards * game;
|
||||||
int afterDamage();
|
int afterDamage();
|
||||||
|
int poisoned();
|
||||||
Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||||
virtual ~Player();
|
virtual ~Player();
|
||||||
void unTapPhase();
|
void unTapPhase();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class RulesPlayerData{
|
|||||||
public:
|
public:
|
||||||
vector <string> extraRules;
|
vector <string> extraRules;
|
||||||
int life;
|
int life;
|
||||||
|
int poisonCount;
|
||||||
string avatar;
|
string avatar;
|
||||||
ManaCost * manapool;
|
ManaCost * manapool;
|
||||||
RulesPlayerZone zones[5];
|
RulesPlayerZone zones[5];
|
||||||
|
|||||||
@@ -65,17 +65,52 @@ int Damage::resolve(){
|
|||||||
for (int i = 0; i < damage; i++){
|
for (int i = 0; i < damage; i++){
|
||||||
_target->counters->addCounter(-1, -1);
|
_target->counters->addCounter(-1, -1);
|
||||||
}
|
}
|
||||||
}else{ //Normal case
|
}else{//infect damage---------------------------------------
|
||||||
|
while(target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE && source->has(Constants::INFECT)){
|
||||||
|
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||||
|
for (int i = 0; i < damage; i++){
|
||||||
|
_target->counters->addCounter(-1, -1);
|
||||||
|
}return a;
|
||||||
|
}while(target->type_as_damageable == DAMAGEABLE_PLAYER && source->has(Constants::INFECT)){
|
||||||
|
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||||
|
for (int i = 0; i < damage; i++){
|
||||||
|
_target->poisonCount += 1;//this will be changed to poison counters.
|
||||||
|
}return a;
|
||||||
|
}//infect end--------------------------------------------------
|
||||||
|
//poison AND damage
|
||||||
|
while(target->type_as_damageable == DAMAGEABLE_PLAYER && source->has(Constants::POISONDAMAGE)){
|
||||||
|
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||||
|
for (int i = 0; i < damage; i++){
|
||||||
|
//this will be changed to poison counters.
|
||||||
|
a = target->dealDamage(1);
|
||||||
|
}
|
||||||
|
_target->poisonCount += 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
while(target->type_as_damageable == DAMAGEABLE_PLAYER && source->has(Constants::POISONTWODAMAGE)){
|
||||||
|
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||||
|
for (int i = 0; i < damage; i++){
|
||||||
|
//this will be changed to poison counters.
|
||||||
|
a = target->dealDamage(1);
|
||||||
|
}
|
||||||
|
_target->poisonCount += 2;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
while(target->type_as_damageable == DAMAGEABLE_PLAYER && source->has(Constants::POISONTHREEDAMAGE)){
|
||||||
|
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||||
|
for (int i = 0; i < damage; i++){
|
||||||
|
//this will be changed to poison counters.
|
||||||
|
a = target->dealDamage(1);
|
||||||
|
}
|
||||||
|
_target->poisonCount += 3;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
a = target->dealDamage(damage);
|
a = target->dealDamage(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send (Damage/Replaced effect) event to listeners
|
//Send (Damage/Replaced effect) event to listeners
|
||||||
|
|
||||||
g->receiveEvent(e);
|
g->receiveEvent(e);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Damage::Render(){
|
void Damage::Render(){
|
||||||
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
|
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
|
||||||
mFont->SetBase(0);
|
mFont->SetBase(0);
|
||||||
|
|||||||
@@ -301,6 +301,8 @@ void GameObserver::stateEffects()
|
|||||||
}
|
}
|
||||||
for (int i =0; i < 2; i++)
|
for (int i =0; i < 2; i++)
|
||||||
if (players[i]->life <= 0) gameOver = players[i];
|
if (players[i]->life <= 0) gameOver = players[i];
|
||||||
|
for (int i =0; i < 2; i++)
|
||||||
|
if (players[i]->poisonCount >= 10) gameOver = players[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ bool GuiStatic::Leaving(JButton key)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiAvatar::GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent) : GuiStatic(GuiAvatar::Height, x, y, hasFocus, parent), avatarRed(255), currentLife(player->life), corner(corner), player(player) {
|
GuiAvatar::GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent) : GuiStatic(GuiAvatar::Height, x, y, hasFocus, parent), avatarRed(255), currentLife(player->life),currentpoisonCount(player->poisonCount), corner(corner), player(player) {
|
||||||
type = GUI_AVATAR;
|
type = GUI_AVATAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ void GuiAvatar::Render()
|
|||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
JRenderer * r = JRenderer::GetInstance();
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
int life = player->life;
|
int life = player->life;
|
||||||
|
int poisonCount = player->poisonCount;
|
||||||
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
|
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
|
||||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||||
//Avatar
|
//Avatar
|
||||||
@@ -30,6 +31,12 @@ void GuiAvatar::Render()
|
|||||||
avatarRed = 192 + (3* 255 * lifeDiff) / currentLife / 4;
|
avatarRed = 192 + (3* 255 * lifeDiff) / currentLife / 4;
|
||||||
if (avatarRed < 0) avatarRed = 0;
|
if (avatarRed < 0) avatarRed = 0;
|
||||||
}
|
}
|
||||||
|
int poisonDiff = poisonCount - currentpoisonCount;
|
||||||
|
if (poisonDiff < 0 && currentpoisonCount > 0){
|
||||||
|
avatarRed = 192 + (3* 255 * poisonDiff) / currentpoisonCount / 4;
|
||||||
|
if (avatarRed < 0) avatarRed = 0;
|
||||||
|
}
|
||||||
|
currentpoisonCount = poisonCount;
|
||||||
currentLife = life;
|
currentLife = life;
|
||||||
|
|
||||||
r->FillRect(actX+2, actY+2, Width * actZ, Height *actZ, ARGB((int)(actA / 2), 0, 0, 0));
|
r->FillRect(actX+2, actY+2, Width * actZ, Height *actZ, ARGB((int)(actA / 2), 0, 0, 0));
|
||||||
@@ -88,7 +95,21 @@ void GuiAvatar::Render()
|
|||||||
mFont->SetColor(ARGB((int)actA, 255, 255, 255));
|
mFont->SetColor(ARGB((int)actA, 255, 255, 255));
|
||||||
mFont->DrawString(buffer, actX, actY-10, JGETEXT_RIGHT);
|
mFont->DrawString(buffer, actX, actY-10, JGETEXT_RIGHT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//poison
|
||||||
|
char poison[5];
|
||||||
|
sprintf(poison, "%i",poisonCount);
|
||||||
|
switch (corner)
|
||||||
|
{
|
||||||
|
case TOP_LEFT :
|
||||||
|
mFont->SetColor(ARGB((int)actA - 75, 0, 255, 0));
|
||||||
|
mFont->DrawString(poison, actX+2, actY+10);
|
||||||
|
break;
|
||||||
|
case BOTTOM_RIGHT :
|
||||||
|
mFont->SetColor(ARGB((int)actA - 75 ,0, 255, 0));
|
||||||
|
mFont->DrawString(poison, actX, actY-20, JGETEXT_RIGHT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
PlayGuiObject::Render();
|
PlayGuiObject::Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +117,7 @@ ostream& GuiAvatar::toString(ostream& out) const
|
|||||||
{
|
{
|
||||||
return out << "GuiAvatar ::: avatarRed : " << avatarRed
|
return out << "GuiAvatar ::: avatarRed : " << avatarRed
|
||||||
<< " ; currentLife : " << currentLife
|
<< " ; currentLife : " << currentLife
|
||||||
|
<< " ; currentpoisonCount : " << currentpoisonCount
|
||||||
<< " ; player : " << player;
|
<< " ; player : " << player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -793,7 +793,24 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
a->oneShot = 1;
|
a->oneShot = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
//remove poison
|
||||||
|
found = s.find("removepoison:");
|
||||||
|
if (found != string::npos){
|
||||||
|
size_t start = s.find(":",found);
|
||||||
|
size_t end = s.find(" ",start);
|
||||||
|
int poison;
|
||||||
|
if (end != string::npos){
|
||||||
|
poison = atoi(s.substr(start+1,end-start-1).c_str());
|
||||||
|
}else{
|
||||||
|
poison = atoi(s.substr(start+1).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
Targetable * t = NULL;
|
||||||
|
if (spell) t = spell->getNextPlayerTarget();
|
||||||
|
MTGAbility * a = NEW AARemovePoison (id, card, t,poison,NULL,0,who);
|
||||||
|
a->oneShot = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
//set life total
|
//set life total
|
||||||
found = s.find("lifeset");
|
found = s.find("lifeset");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ const char* Constants::MTGBasicAbilities[] = {
|
|||||||
"horsemanship",
|
"horsemanship",
|
||||||
"cantregen",
|
"cantregen",
|
||||||
"oneblocker",
|
"oneblocker",
|
||||||
|
"infect",
|
||||||
|
"poisondamage",
|
||||||
|
"poisontwodamage",
|
||||||
|
"poisonthreedamage",
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageabl
|
|||||||
game->setOwner(this);
|
game->setOwner(this);
|
||||||
manaPool = NEW ManaPool(this);
|
manaPool = NEW ManaPool(this);
|
||||||
canPutLandsIntoPlay = 1;
|
canPutLandsIntoPlay = 1;
|
||||||
|
poisonCount = 0;
|
||||||
mAvatar = NULL;
|
mAvatar = NULL;
|
||||||
mAvatarTex = NULL;
|
mAvatarTex = NULL;
|
||||||
type_as_damageable = DAMAGEABLE_PLAYER;
|
type_as_damageable = DAMAGEABLE_PLAYER;
|
||||||
@@ -83,7 +84,9 @@ ManaPool * Player::getManaPool(){
|
|||||||
int Player::afterDamage(){
|
int Player::afterDamage(){
|
||||||
return life;
|
return life;
|
||||||
}
|
}
|
||||||
|
int Player::poisoned(){
|
||||||
|
return poisonCount;
|
||||||
|
}
|
||||||
//Cleanup phase at the end of a turn
|
//Cleanup phase at the end of a turn
|
||||||
void Player::cleanupPhase(){
|
void Player::cleanupPhase(){
|
||||||
game->inPlay->cleanupPhase();
|
game->inPlay->cleanupPhase();
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ MTGCardInstance * Rules::getCardByMTGId(int mtgid){
|
|||||||
|
|
||||||
RulesPlayerData::RulesPlayerData(){
|
RulesPlayerData::RulesPlayerData(){
|
||||||
life = 20;
|
life = 20;
|
||||||
|
poisonCount = 0;
|
||||||
manapool = NEW ManaCost();
|
manapool = NEW ManaCost();
|
||||||
avatar = "";
|
avatar = "";
|
||||||
}
|
}
|
||||||
@@ -76,6 +77,9 @@ void RulesState::parsePlayerState(int playerId, string s){
|
|||||||
area = 3;
|
area = 3;
|
||||||
}else if(areaS.compare("life") == 0){
|
}else if(areaS.compare("life") == 0){
|
||||||
playerData[playerId].life = atoi((s.substr(limiter+1)).c_str());
|
playerData[playerId].life = atoi((s.substr(limiter+1)).c_str());
|
||||||
|
return;
|
||||||
|
}else if(areaS.compare("poisonCount") == 0){
|
||||||
|
playerData[playerId].poisonCount = 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);
|
||||||
@@ -273,6 +277,7 @@ void Rules::initGame(){
|
|||||||
for (int i = 0; i < 2; i++){
|
for (int i = 0; i < 2; i++){
|
||||||
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->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);
|
||||||
@@ -318,6 +323,7 @@ void RulesPlayerData::cleanup(){
|
|||||||
zones[i].cleanup();
|
zones[i].cleanup();
|
||||||
}
|
}
|
||||||
life=20;
|
life=20;
|
||||||
|
poisonCount=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RulesState::cleanup(){
|
void RulesState::cleanup(){
|
||||||
|
|||||||
Reference in New Issue
Block a user