taught told Ai bushido is a good thing. laid ground for Foreach lesson for Ai :) fixed yet another reported bug with aslongas. gave becomes( a better menu name system for the manlands to use.

it will now say "becomes [types]"
This commit is contained in:
omegablast2002@yahoo.com
2010-10-25 14:41:09 +00:00
parent 142dfab57c
commit fbd5cffbbd
5 changed files with 22 additions and 9 deletions
+1
View File
@@ -24,6 +24,7 @@ protected:
static int currentId; static int currentId;
public: public:
MTGAbility * ability; MTGAbility * ability;
NestedAbility * nability;
Player * player; Player * player;
int id; int id;
MTGCardInstance * click; MTGCardInstance * click;
+14 -3
View File
@@ -2327,7 +2327,7 @@ public:
int canBeInList(MTGCardInstance * card){ int canBeInList(MTGCardInstance * card){
int size = 0; int size = 0;
size = (int)cards.size(); size = (int)cards.size();
if(includeSelf && maxi && card == source && size < maxi) if(includeSelf && maxi && card == source && size > maxi)
{ {
removed(card); removed(card);
} }
@@ -2368,7 +2368,7 @@ public:
int _added(Damageable * d){ int _added(Damageable * d){
int size =(int)cards.size(); int size =(int)cards.size();
if (maxi && size < maxi) return 0; if (maxi && size < maxi) return 0;
if (maxi && size >= maxi) return removeAbilityFromGame(); if (maxi && size > maxi) return removeAbilityFromGame();
if (maxi) return 0; if (maxi) return 0;
if (size <= mini) return 0; if (size <= mini) return 0;
return addAbilityToGame(); return addAbilityToGame();
@@ -2385,7 +2385,7 @@ public:
int removed(MTGCardInstance * card){ int removed(MTGCardInstance * card){
size_t size = cards.size(); size_t size = cards.size();
if (maxi && (int)size < maxi) return addAbilityToGame(); if (maxi && (int)size <= maxi) return addAbilityToGame();
if (mini && (int)size > mini) return 0; if (mini && (int)size > mini) return 0;
if (mini && (int)size <= mini) return removeAbilityFromGame(); if (mini && (int)size <= mini) return removeAbilityFromGame();
if (!mini && !maxi && size !=0) return 0; if (!mini && !maxi && size !=0) return 0;
@@ -2502,6 +2502,8 @@ public:
tc->targetter = NULL; tc->targetter = NULL;
includeSelf = _includeSelf; includeSelf = _includeSelf;
ability->target = _target; ability->target = _target;
aType = MTGAbility::FOREACH;
naType = ability->aType;
} }
int canBeInList(MTGCardInstance * card){ int canBeInList(MTGCardInstance * card){
@@ -2638,6 +2640,7 @@ public:
ability->source = source; ability->source = source;
ability->target = target; ability->target = target;
SAFE_DELETE(tc); SAFE_DELETE(tc);
aType = FOREACH;
} }
int removeFromGame(){ int removeFromGame(){
@@ -3494,6 +3497,7 @@ public:
list<int>types; list<int>types;
list<int>colors; list<int>colors;
WParsedPT * wppt; WParsedPT * wppt;
string menu;
ABecomes(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, WParsedPT * wppt, string sabilities):MTGAbility(id,source,target),wppt(wppt){ ABecomes(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, WParsedPT * wppt, string sabilities):MTGAbility(id,source,target),wppt(wppt){
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class; //TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
@@ -3512,6 +3516,7 @@ public:
} }
string s = stypes; string s = stypes;
menu = stypes;
while (s.size()){ while (s.size()){
size_t found = s.find(" "); size_t found = s.find(" ");
if (found != string::npos){ if (found != string::npos){
@@ -3561,6 +3566,12 @@ public:
return 1; return 1;
} }
const char * getMenuText(){
string s = menu;
sprintf(menuText, "Becomes %s",s.c_str());
return menuText;
}
ABecomes * clone() const{ ABecomes * clone() const{
ABecomes * a = NEW ABecomes(*this); ABecomes * a = NEW ABecomes(*this);
a->wppt = NEW WParsedPT(*(a->wppt)); a->wppt = NEW WParsedPT(*(a->wppt));
+2
View File
@@ -56,6 +56,7 @@ class MTGAbility: public ActionElement{
Targetable * target; Targetable * target;
int aType; int aType;
int naType;
MTGCardInstance * source; MTGCardInstance * source;
MTGAbility(int id, MTGCardInstance * card); MTGAbility(int id, MTGCardInstance * card);
MTGAbility(int id, MTGCardInstance * _source, Targetable * _target); MTGAbility(int id, MTGCardInstance * _source, Targetable * _target);
@@ -93,6 +94,7 @@ class MTGAbility: public ActionElement{
STANDARD_PREVENT = 13, STANDARD_PREVENT = 13,
STANDARD_EQUIP = 14, STANDARD_EQUIP = 14,
STANDARD_LEVELUP = 15, STANDARD_LEVELUP = 15,
FOREACH = 16,
}; };
-2
View File
@@ -163,7 +163,6 @@ int AIAction::getEfficiency(){
} }
if (!((AIPlayer *)p)->canHandleCost(ability)) return 0; if (!((AIPlayer *)p)->canHandleCost(ability)) return 0;
switch (a->aType){ switch (a->aType){
case MTGAbility::DAMAGER: case MTGAbility::DAMAGER:
{ {
@@ -317,7 +316,6 @@ int AIPlayer::selectAbility(){
MTGAbility * a = ((MTGAbility *)g->mLayers->actionLayer()->mObjects[i]); MTGAbility * a = ((MTGAbility *)g->mLayers->actionLayer()->mObjects[i]);
//Skip mana abilities for performance //Skip mana abilities for performance
if (dynamic_cast<AManaProducer*>(a)) continue; if (dynamic_cast<AManaProducer*>(a)) continue;
//Make sure we can use the ability //Make sure we can use the ability
for (int j=0; j < game->inPlay->nb_cards; j++){ for (int j=0; j < game->inPlay->nb_cards; j++){
MTGCardInstance * card = game->inPlay->cards[j]; MTGCardInstance * card = game->inPlay->cards[j];
+1
View File
@@ -1663,6 +1663,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
if (dynamic_cast<AADrawer *>(a)) return BAKA_EFFECT_GOOD; if (dynamic_cast<AADrawer *>(a)) return BAKA_EFFECT_GOOD;
if (dynamic_cast<AARandomDiscarder *>(a)) return BAKA_EFFECT_BAD; if (dynamic_cast<AARandomDiscarder *>(a)) return BAKA_EFFECT_BAD;
if (dynamic_cast<ARampageAbility *>(a)) return BAKA_EFFECT_GOOD; if (dynamic_cast<ARampageAbility *>(a)) return BAKA_EFFECT_GOOD;
if (dynamic_cast<ABushidoAbility *>(a)) return BAKA_EFFECT_GOOD;
if (AInstantPowerToughnessModifierUntilEOT * abi = dynamic_cast<AInstantPowerToughnessModifierUntilEOT *>(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD; if (AInstantPowerToughnessModifierUntilEOT * abi = dynamic_cast<AInstantPowerToughnessModifierUntilEOT *>(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
if (APowerToughnessModifier * abi = dynamic_cast<APowerToughnessModifier *>(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD; if (APowerToughnessModifier * abi = dynamic_cast<APowerToughnessModifier *>(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
if (APowerToughnessModifierUntilEndOfTurn * abi = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a)) return abilityEfficiency(abi->ability, p, mode,tc); if (APowerToughnessModifierUntilEndOfTurn * abi = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a)) return abilityEfficiency(abi->ability, p, mode,tc);