Erwan
- Added Tokens (needs testing !!!) - Added a few cards that create tokens
This commit is contained in:
@@ -106,7 +106,7 @@ void Spell::Render(){
|
||||
mFont->SetBase(0);
|
||||
mFont->SetScale(0.75);
|
||||
char buffer[200];
|
||||
sprintf(buffer, "%s", source->model->getName());
|
||||
sprintf(buffer, "%s", source->getName());
|
||||
mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT);
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
JQuad * quad = source->getThumb();
|
||||
|
||||
@@ -216,7 +216,8 @@ void CardGui::RenderBig(float xpos, float ypos, int alternate){
|
||||
quad = card->getQuad();
|
||||
if (quad){
|
||||
quad->SetColor(ARGB(220,255,255,255));
|
||||
renderer->RenderQuad(quad, xpos , ypos , 0.0f,0.9f,0.9f);
|
||||
float scale = 257.f / quad->mHeight;
|
||||
renderer->RenderQuad(quad, xpos , ypos , 0.0f,scale,scale);
|
||||
}else{
|
||||
quad = card->getThumb();
|
||||
alternate = 1;
|
||||
|
||||
@@ -61,6 +61,24 @@ int AbilityFactory::putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone
|
||||
}
|
||||
|
||||
|
||||
int AbilityFactory::parsePowerToughness(string s, int *power, int *toughness){
|
||||
int found = s.find("/");
|
||||
if (found != string::npos){
|
||||
unsigned int start = s.find(":");
|
||||
if (start == string::npos) start = s.find(" ");
|
||||
if (start == string::npos) start = -1;
|
||||
*power = atoi(s.substr(start+1,s.size()-found).c_str());
|
||||
unsigned int end = s.find(" ",start);
|
||||
if (end != string::npos){
|
||||
*toughness = atoi(s.substr(found+1,end-found-1).c_str());
|
||||
}else{
|
||||
*toughness = atoi(s.substr(found+1).c_str());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Trigger * AbilityFactory::parseTrigger(string magicText){
|
||||
size_t found = magicText.find("@");
|
||||
if (found == string::npos) return NULL;
|
||||
@@ -210,6 +228,40 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//Token creator. Name, type, p/t, abilities
|
||||
found = s.find("token(");
|
||||
if (found != string::npos){
|
||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
||||
int end = s.find(",", found);
|
||||
string sname = s.substr(found + 6,end - found - 6);
|
||||
int previous = end+1;
|
||||
end = s.find(",",previous);
|
||||
string stypes = s.substr(previous,end - previous);
|
||||
previous = end+1;
|
||||
end = s.find(",",previous);
|
||||
string spt = s.substr(previous,end - previous);
|
||||
int power, toughness;
|
||||
int havePowertoughness = parsePowerToughness(spt,&power, &toughness);
|
||||
string sabilities = s.substr(end+1);
|
||||
ManaCost * cost = ManaCost::parseManaCost(s);
|
||||
int multiplier = 1;
|
||||
found = s.find("*");
|
||||
if (found != string::npos)multiplier = atoi(s.substr(found+1).c_str());
|
||||
if(cost->getConvertedCost() || doTap){
|
||||
game->addObserver(NEW ATokenCreator(id,card,cost,sname,stypes,power,toughness,sabilities,doTap));
|
||||
}else{
|
||||
delete cost;
|
||||
cost = NULL;
|
||||
ATokenCreator * tok = NEW ATokenCreator(id,card,cost,sname,stypes,power,toughness,sabilities,doTap);
|
||||
for (int i=0; i < multiplier; i++){
|
||||
tok->resolve();
|
||||
}
|
||||
delete tok;
|
||||
}
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
//MoveTo Move a card from a zone to another
|
||||
found = s.find("moveto(");
|
||||
if (found != string::npos){
|
||||
@@ -389,19 +441,8 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
||||
}
|
||||
|
||||
//Change Power/Toughness
|
||||
found = s.find("/");
|
||||
if (found != string::npos){
|
||||
unsigned int start = s.find(":");
|
||||
if (start == string::npos) start = s.find(" ");
|
||||
if (start == string::npos) start = -1;
|
||||
int power = atoi(s.substr(start+1,size-found).c_str());
|
||||
unsigned int end = s.find(" ",start);
|
||||
int toughness;
|
||||
if (end != string::npos){
|
||||
toughness = atoi(s.substr(found+1,end-found-1).c_str());
|
||||
}else{
|
||||
toughness = atoi(s.substr(found+1).c_str());
|
||||
}
|
||||
int power, toughness;
|
||||
if ( parsePowerToughness(s,&power, &toughness)){
|
||||
if (dryMode){
|
||||
if (power >=0 && toughness >= 0 ) return BAKA_EFFECT_GOOD;
|
||||
return BAKA_EFFECT_BAD;
|
||||
@@ -533,7 +574,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
|
||||
|
||||
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
int id = card->model->getId();
|
||||
int id = card->getId();
|
||||
if (card->alias) id = card->alias;
|
||||
switch (id){
|
||||
case 1092: //Aladdin's lamp
|
||||
|
||||
@@ -148,7 +148,14 @@ const char * MTGCard::colorToString(){
|
||||
|
||||
void MTGCard::setMTGId(int id){
|
||||
mtgid = id;
|
||||
sprintf(image_name, "%d.jpg", mtgid);
|
||||
if (id < 0){
|
||||
sprintf(image_name, "%dt.jpg", -mtgid);
|
||||
}else{
|
||||
sprintf(image_name, "%d.jpg", mtgid);
|
||||
}
|
||||
#ifdef WIN32
|
||||
OutputDebugString(image_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
int MTGCard::getMTGId(){
|
||||
|
||||
@@ -36,6 +36,7 @@ MTGCardInstance::~MTGCardInstance(){
|
||||
void MTGCardInstance::initMTGCI(){
|
||||
sample = "";
|
||||
model=NULL;
|
||||
isToken = false;
|
||||
lifeOrig = 0;
|
||||
doDamageTest = 0;
|
||||
belongs_to=NULL;
|
||||
@@ -73,11 +74,6 @@ int MTGCardInstance::isInPlay(){
|
||||
|
||||
int MTGCardInstance::afterDamage(){
|
||||
if (!doDamageTest) return 0;
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096], *p = buf;
|
||||
sprintf(buf,"After Damage Test, life is %i for %s \n",life,model->getName());
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
doDamageTest = 0;
|
||||
if (life <=0 && isInPlay()){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
|
||||
@@ -89,10 +89,7 @@ void MTGPlayerCards::putInGraveyard(MTGCardInstance * card){
|
||||
|
||||
void MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to){
|
||||
if (from->removeCard(card)){
|
||||
to->addCard(card);
|
||||
card->changedZoneRecently = 1.f;
|
||||
|
||||
card->reset();
|
||||
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME] > 0){
|
||||
if (to == graveyard){
|
||||
if (card->isACreature()){
|
||||
@@ -101,6 +98,20 @@ void MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (card->isToken){
|
||||
GameObserver *g = GameObserver::GetInstance();
|
||||
if (to != g->players[0]->game->inPlay && to != g->players[1]->game->inPlay){
|
||||
//Token leaves play: we destroy it
|
||||
//TODO DELETE Object
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
to->addCard(card);
|
||||
card->changedZoneRecently = 1.f;
|
||||
|
||||
card->reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +234,7 @@ MTGCardInstance * MTGLibrary::draw(){
|
||||
void MTGGameZone::debugPrint(){
|
||||
int i;
|
||||
for (i=0;i<nb_cards;i++){
|
||||
MTGCard * card = cards[i]->model;
|
||||
MTGCard * card = cards[i];
|
||||
fprintf(stderr, "%s", card->getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ OutputDebugString("COLOR FOUND !!!");
|
||||
}
|
||||
|
||||
TargetChooser * TargetChooserFactory::createTargetChooser(MTGCardInstance * card){
|
||||
int id = card->model->getId();
|
||||
int id = card->getId();
|
||||
string s = card->spellTargetType;
|
||||
if (card->alias){
|
||||
id = card->alias;
|
||||
|
||||
@@ -96,7 +96,9 @@ CardTexture::CardTexture(MTGCard * card, int _type): type(_type){
|
||||
}else{
|
||||
sprintf(filename, "sets/%s/%s", card->getSetName(), card->getImageName());
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
OutputDebugString(filename);
|
||||
#endif
|
||||
tex = JRenderer::GetInstance()->LoadTexture(filename, false);
|
||||
if (tex){
|
||||
quad = NEW JQuad(tex, 0.0f, 0.0f, tex->mWidth, tex->mHeight);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "../include/Token.h"
|
||||
|
||||
Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness):MTGCardInstance(){
|
||||
isToken = true;
|
||||
tokenSource = source;
|
||||
power = _power;
|
||||
toughness = _toughness;
|
||||
life=toughness;
|
||||
lifeOrig = life;
|
||||
name = _name;
|
||||
setMTGId(- source->getMTGId());
|
||||
setId = source->setId;
|
||||
model = this;
|
||||
owner = source->owner;
|
||||
belongs_to=source->controller()->game;
|
||||
initAttackersDefensers();
|
||||
mCache = source->mCache;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user