- opponentshroud small bug fix
- added "kicker=" line and "kicker" auto keyword. See Vines of Vastwood (ZEN) for an example. WARNING: kicker= line has to be AFTER "mana=" line
- daily build
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-09-27 09:53:29 +00:00
parent e464b8616a
commit 9704ee4a24
17 changed files with 126 additions and 27 deletions
+6 -3
View File
@@ -114,13 +114,16 @@ Spell::Spell(MTGCardInstance * _source): Interruptible(0){
}
Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _cost): Interruptible(id), tc(tc),cost(_cost){
Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _cost, int payResult): Interruptible(id), tc(tc),cost(_cost), payResult(payResult){
source = _source;
mHeight = 40;
type = ACTION_SPELL;
from = _source->getCurrentZone();
}
bool Spell::kickerWasPaid(){
return (payResult == ManaCost::MANA_PAID_WITH_KICKER);
}
const string Spell::getDisplayName() const {
return source->getName();
@@ -389,13 +392,13 @@ int ActionStack::addAction(Interruptible * action){
return 1;
}
Spell * ActionStack::addSpell(MTGCardInstance * _source, TargetChooser * tc, ManaCost * mana){
Spell * ActionStack::addSpell(MTGCardInstance * _source, TargetChooser * tc, ManaCost * mana, int payResult){
#if defined (WIN32) || defined (LINUX)
char buf[4096], *p = buf;
sprintf(buf, "ACTIONSTACK Add spell\n");
OutputDebugString(buf);
#endif
Spell * spell = NEW Spell(mCount,_source,tc, mana);
Spell * spell = NEW Spell(mCount,_source,tc, mana,payResult);
addAction(spell);
if (!game->players[0]->isAI() &&
_source->controller()==game->players[0] &&
+12 -4
View File
@@ -229,7 +229,15 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
SAFE_DELETE(cost);
}
//kicker cost
found = s.find("kicker ");
if (found == 0){
if (spell->kickerWasPaid()){
string s1 = s.substr(found+7);
return parseMagicLine(s1,id,spell, card);
}
return NULL;
}
//When...comes into play, you may...
found = s.find("may ");
if (found == 0){
@@ -286,10 +294,10 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
if (end != string::npos){
int lordIncludeSelf = 1;
size_t other = s.find("other", end);
size_t other = s1.find("other");
if ( other != string::npos){
lordIncludeSelf = 0;
s.replace(other, 5,"");
s1.replace(other, 5,"");
}
string lordTargetsString = s.substr(found+header,end-found-header);
TargetChooserFactory tcf;
@@ -596,7 +604,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
//Gain/loose Ability
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
found = s.find(Constants::MTGBasicAbilities[j]);
if (found!= string::npos){
if (found == 0 || found == 1){
int modifier = 1;
if (found > 0 && s[found-1] == '-') modifier = 0;
if (!activated){
+7
View File
@@ -141,7 +141,14 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
}
}else if(key.compare("toughness")==0){
card->setToughness(atoi(value.c_str()));
}else if(key.compare("kicker")==0){
std::transform( value.begin(), value.end(), value.begin(),::tolower );
if (ManaCost * cost = card->getManaCost()){
cost->kicker = ManaCost::parseManaCost(value);
}
}else{
string error = "MTGDECK Parsing Error:" + s + "\n";
OutputDebugString(error.c_str());
}
+3 -3
View File
@@ -49,7 +49,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
return 0;
}
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
player->getManaPool()->pay(card->getManaCost());
int payResult = player->getManaPool()->pay(card->getManaCost());
card->getManaCost()->doPayExtra();
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
delete previousManaPool;
@@ -64,10 +64,10 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
Spell * spell = NULL;
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack);
if (game->targetChooser){
spell = game->mLayers->stackLayer()->addSpell(copy,game->targetChooser, spellCost);
spell = game->mLayers->stackLayer()->addSpell(copy,game->targetChooser, spellCost,payResult);
game->targetChooser = NULL;
}else{
spell = game->mLayers->stackLayer()->addSpell(copy,NULL, spellCost);
spell = game->mLayers->stackLayer()->addSpell(copy,NULL, spellCost, payResult);
}
}
return 1;
+26 -2
View File
@@ -128,6 +128,8 @@ ManaCost::~ManaCost(){
if (!extraCostsIsCopy) {
SAFE_DELETE(extraCosts);
}
SAFE_DELETE(kicker);
}
void ManaCost::x(){
@@ -142,6 +144,7 @@ void ManaCost::init(){
nbhybrids = 0;
extraCosts = NULL;
extraCostsIsCopy = 0;
kicker = NULL;
}
@@ -149,6 +152,9 @@ void ManaCost::copy(ManaCost * _manaCost){
for (unsigned int i = 0; i <= Constants::MTG_NB_COLORS; i++){
cost[i] = _manaCost->getCost(i);
}
for (unsigned int i = 0; i < nbhybrids ; i++){
SAFE_DELETE(hybrids[i]);
}
for (unsigned int i = 0; i < _manaCost->nbhybrids; i++){
hybrids[i] = NEW ManaCostHybrid((*_manaCost->hybrids[i]));
}
@@ -160,6 +166,12 @@ void ManaCost::copy(ManaCost * _manaCost){
extraCosts = _manaCost->extraCosts;
extraCostsIsCopy = 1;
}
SAFE_DELETE(kicker);
if (_manaCost->kicker){
kicker = NEW ManaCost();
kicker->copy(_manaCost->kicker);
}
}
int ManaCost::getCost(int color){
@@ -267,12 +279,24 @@ int ManaCost::setExtraCostsAction(MTGAbility * action, MTGCardInstance * card){
}
int ManaCost::pay(ManaCost * _cost){
ManaCost * diff = Diff(_cost);
int result = MANA_PAID;
ManaCost * toPay = NEW ManaCost();
toPay->copy(_cost);
if (toPay->kicker){
toPay->add(toPay->kicker);
if (!canAfford(toPay)){
toPay->copy(_cost);
}else{
result = MANA_PAID_WITH_KICKER;
}
}
ManaCost * diff = Diff(toPay);
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
cost[i] = diff->getCost(i);
}
delete diff;
return 1;
delete toPay;
return result;
//TODO return 0 if can't afford the cost!
}