diff --git a/JGE/lib/win/jge.lib b/JGE/lib/win/jge.lib index 500f8ab70..74492c662 100644 Binary files a/JGE/lib/win/jge.lib and b/JGE/lib/win/jge.lib differ diff --git a/projects/mtg/bin/Res/sets/SHM/_cards.dat b/projects/mtg/bin/Res/sets/SHM/_cards.dat index 72c3a640f..12389aa2a 100644 --- a/projects/mtg/bin/Res/sets/SHM/_cards.dat +++ b/projects/mtg/bin/Res/sets/SHM/_cards.dat @@ -23,6 +23,18 @@ subtype=Elemental Warrior toughness=3 [/card] [card] +text=Ashenmoor Gouger can't block. +abilities=cantblock +id=153981 +name=Ashenmoor Gouger +rarity=U +type=Creature +mana={BR}{BR}{BR} +power=4 +subtype=Elemental Warrior +toughness=4 +[/card] +[card] text=First strike Ballynock Cohort gets +1/+1 as long as you control another white creature. abilities=first strike auto=aslongas(creature[white]|myinplay) 1/1 other @@ -354,6 +366,18 @@ subtype=Scarecrow toughness=1 [/card] [card] +text=Inkfathom Infiltrator can't block and is unblockable. +abilities=unblockable,cantblock +id=154401 +name=Inkfathom Infiltrator +rarity=U +type=Creature +mana={UB}{UB} +power=2 +subtype=Merfolk Rogue +toughness=1 +[/card] +[card] text={T}: Add {U} to your mana pool. auto={T}:Add{U} id=158237 diff --git a/projects/mtg/bin/Res/sets/SHM/todo.dat b/projects/mtg/bin/Res/sets/SHM/todo.dat index 2514ba310..b598a5da0 100644 --- a/projects/mtg/bin/Res/sets/SHM/todo.dat +++ b/projects/mtg/bin/Res/sets/SHM/todo.dat @@ -35,17 +35,7 @@ toughness=1 [/card] -[card] -text=Ashenmoor Gouger can't block. -id=153981 -name=Ashenmoor Gouger -rarity=U -type=Creature -mana={BR}{BR}{BR} -power=4 -subtype=Elemental Warrior -toughness=4 -[/card] + [card] text=Other black creatures you control get +1/+1. Other red creatures you control get +1/+1. Whenever Ashenmoor Liege becomes the target of a spell or ability an opponent controls, that player loses 4 life. id=146065 @@ -804,17 +794,7 @@ power=3 subtype=Giant Warrior toughness=3 [/card] -[card] -text=Inkfathom Infiltrator can't block and is unblockable. -id=154401 -name=Inkfathom Infiltrator -rarity=U -type=Creature -mana={UB}{UB} -power=2 -subtype=Merfolk Rogue -toughness=1 -[/card] + [card] text=Fear {2}{U}{B}: Each unblocked creature becomes 4/1 until end of turn. id=157879 diff --git a/projects/mtg/include/GameStateShop.h b/projects/mtg/include/GameStateShop.h index 5c97d12d6..d3aed8b34 100644 --- a/projects/mtg/include/GameStateShop.h +++ b/projects/mtg/include/GameStateShop.h @@ -12,7 +12,7 @@ #define STAGE_SHOP_MENU 3 #define STAGE_SHOP_SHOP 4 -#define SHOP_BOOSTERS 3 + class GameStateShop: public GameState, public JGuiListener { diff --git a/projects/mtg/include/ShopItem.h b/projects/mtg/include/ShopItem.h index a3c2bb180..47b2028c8 100644 --- a/projects/mtg/include/ShopItem.h +++ b/projects/mtg/include/ShopItem.h @@ -12,6 +12,8 @@ #include using std::string; +#define SHOP_BOOSTERS 3 + class ShopItem:public JGuiObject{ private: bool mHasFocus; @@ -51,7 +53,7 @@ class ShopItems:public JGuiController,public JGuiListener{ MTGAllCards * collection; SimpleMenu * dialog; int showPriceDialog; - int setIds[2];; + int setIds[SHOP_BOOSTERS]; MTGCardInstance * displayCards[100]; CardDisplay * display; void safeDeleteDisplay(); diff --git a/projects/mtg/include/utils.h b/projects/mtg/include/utils.h index fe593472c..e875ee12c 100644 --- a/projects/mtg/include/utils.h +++ b/projects/mtg/include/utils.h @@ -14,6 +14,9 @@ #include #include #include + +#include +#include #endif @@ -38,5 +41,22 @@ int fileExists(const char * filename); void dumpStack(); #endif + +/* RAM simple check functions header */ + +// *** DEFINES *** + +#if defined (WIN32) || defined (LINUX) +#define RAM_BLOCK (100 * 1024 * 1024) +#else +#define RAM_BLOCK (1024 * 1024) +#endif + +// *** FUNCTIONS DECLARATIONS *** + +u32 ramAvailableLineareMax (void); +u32 ramAvailable (void); + + #endif diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index e0b591878..1c4af85f4 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -143,6 +143,10 @@ void GameApp::Create() mCurrentState = NULL; mNextState = mGameStates[GAME_STATE_MENU]; + + char buf[512]; + sprintf(buf, "size of MTGCardInstance : %i\n" , sizeof(MTGCardInstance)); + OutputDebugString(buf); } @@ -230,6 +234,18 @@ void GameApp::Update() mCurrentState->End(); mCurrentState = mNextState; + + +#if defined (WIN32) || defined (LINUX) +#else + /* + int maxLinear = ramAvailableLineareMax(); + int ram = ramAvailable(); + char buf[512]; + sprintf(buf, "Ram : linear max: %i - total : %i\n",maxLinear, ram); + fprintf(stderr,buf); + */ +#endif mCurrentState->Start(); mNextState = NULL; diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 08e4ae727..dfed66980 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -43,7 +43,7 @@ void GameStateShop::Start() int sets[500]; int nbsets = 0; for (int i = 0; i < MtgSets::SetsList->nb_items; i++){ - if (mParent->collection->countBySet(i) > 100){ //Only sets with more than 100 cards can get boosters and starters + if (mParent->collection->countBySet(i) > 80){ //Only sets with more than 80 cards can get boosters and starters sets[nbsets] = i; nbsets++; } diff --git a/projects/mtg/src/ShopItem.cpp b/projects/mtg/src/ShopItem.cpp index 9e9fecc50..d377a0b0c 100644 --- a/projects/mtg/src/ShopItem.cpp +++ b/projects/mtg/src/ShopItem.cpp @@ -238,23 +238,17 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){ safeDeleteDisplay(); display = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5); int curNbcards = playerdata->collection->totalCards(); - //if (showPriceDialog == 0){ - // //Starter Deck - // playerdata->collection->addRandomCards(3,setId,Constants::RARITY_R,NULL); - // playerdata->collection->addRandomCards(9, setId,Constants::RARITY_U,NULL); - // playerdata->collection->addRandomCards(48, setId,Constants::RARITY_C,NULL); - //}else{ - //Booster - playerdata->collection->addRandomCards(1, setIds[showPriceDialog],Constants::RARITY_R); - playerdata->collection->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U); - playerdata->collection->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C); - // } - int newNbCards = playerdata->collection->totalCards();; - for (int i = curNbcards; i < newNbCards ; i++){ - MTGCardInstance * card = NEW MTGCardInstance(playerdata->collection->_(i), NULL); - displayCards[i-curNbcards] = card; - display->AddCard(card); - } + + playerdata->collection->addRandomCards(1, setIds[showPriceDialog],Constants::RARITY_R); + playerdata->collection->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U); + playerdata->collection->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C); + + int newNbCards = playerdata->collection->totalCards();; + for (int i = curNbcards; i < newNbCards ; i++){ + MTGCardInstance * card = NEW MTGCardInstance(playerdata->collection->_(i), NULL); + displayCards[i-curNbcards] = card; + display->AddCard(card); + } } //Remove(showPriceDialog); showPriceDialog = -1; diff --git a/projects/mtg/src/utils.cpp b/projects/mtg/src/utils.cpp index bdb047750..4a35bfd43 100644 --- a/projects/mtg/src/utils.cpp +++ b/projects/mtg/src/utils.cpp @@ -59,3 +59,93 @@ void dumpStack() free(tab); } #endif + + +/* RAM simple check functions source */ + + +// *** FUNCTIONS *** + +u32 ramAvailableLineareMax (void) +{ + u32 size, sizeblock; + u8 *ram; + + + // Init variables + size = 0; + sizeblock = RAM_BLOCK; + + // Check loop + while (sizeblock) + { + // Increment size + size += sizeblock; + + // Allocate ram + ram = (u8 *) malloc(size); + + // Check allocate + if (!(ram)) + { + // Restore old size + size -= sizeblock; + + // Size block / 2 + sizeblock >>= 1; + } + else + free(ram); + } + + return size; +} + +u32 ramAvailable (void) +{ + u8 **ram, **temp; + u32 size, count, x; + + + // Init variables + ram = NULL; + size = 0; + count = 0; + + // Check loop + for (;;) + { + // Check size entries + if (!(count % 10)) + { + // Allocate more entries if needed + temp = (u8**) realloc(ram,sizeof(u8 *) * (count + 10)); + if (!(temp)) break; + + // Update entries and size (size contains also size of entries) + ram = temp; + size += (sizeof(u8 *) * 10); + } + + // Find max lineare size available + x = ramAvailableLineareMax(); + if (!(x)) break; + + // Allocate ram + ram[count] = (u8 *) malloc(x); + if (!(ram[count])) break; + + // Update variables + size += x; + count++; + } + + // Free ram + if (ram) + { + for (x=0;x