From 15e6fabd9f01d9de61395cf5a4197230d4a38046 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Sat, 4 Dec 2010 16:08:51 +0000 Subject: [PATCH] redid the counters menutext function to be more like the one "add mana" uses. makes it easier to read and add to later if needed. --- projects/mtg/include/AllAbilities.h | 1 + projects/mtg/src/AllAbilities.cpp | 36 ++++++++++++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index aeca297e8..ff389c66a 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -625,6 +625,7 @@ public: int power; int toughness; string name; + string menu; AACounter(int id, MTGCardInstance * source, MTGCardInstance * target, const char * _name, int power, int toughness, int nb, ManaCost * cost = NULL, int doTap = 0); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 2c18a7638..42d99c249 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -250,6 +250,7 @@ AACounter::AACounter(int id, MTGCardInstance * source, MTGCardInstance * target, { this->target = target; if (name.find("Level")) aType = MTGAbility::STANDARD_LEVELUP; + menu = ""; } int AACounter::resolve() @@ -282,27 +283,34 @@ int AACounter::resolve() const char* AACounter::getMenuText() { + if(menu.size()) + { + return menu.c_str(); + } + char buffer[128]; - if(name.size()){ + if(name.size()) + { string s = name; - if(power == 0 && toughness == 0) + menu.append(s.c_str()); + } + + if(power != 0 || toughness != 0) { - if( nb != 1) sprintf(menuText, "%s Counter:%i", s.c_str(),nb); - else sprintf(menuText, "%s Counter", s.c_str(),nb); + sprintf(buffer, " %i/%i", power,toughness); + menu.append(buffer); } - else + + menu.append(" Counter"); + if(nb != 1) { - if( nb != 1) sprintf(menuText, "%i/%i %s Counter:%i",power,toughness, s.c_str(),nb); - else sprintf(menuText, "%i/%i %s Counter",power,toughness, s.c_str(),nb); + sprintf(buffer, ": %i", nb); + menu.append(buffer); } - } - else - { - if(nb != 1) sprintf(menuText, "%i/%i Counter:%i",power,toughness,nb); - else sprintf(menuText, "%i/%i Counter",power,toughness,nb); - } + + sprintf(menuText, "%s",menu.c_str()); return menuText; -} + } AACounter * AACounter::clone() const {