diff --git a/projects/mtg/bin/Res/sets/FUT/_cards.dat b/projects/mtg/bin/Res/sets/FUT/_cards.dat index ba64c44b9..551f63f78 100644 --- a/projects/mtg/bin/Res/sets/FUT/_cards.dat +++ b/projects/mtg/bin/Res/sets/FUT/_cards.dat @@ -201,7 +201,7 @@ id=136148 name=Magus of the Moat rarity=R mana={2}{W}{W} -auto=lord(creature|inplay) cantattack +auto=lord(creature[-flying]) cantattack type=Creature subtype=Human Wizard power=0 @@ -335,4 +335,4 @@ name=Venser's Diffusion rarity=C type=Instant mana={2}{U} -[/card] +[/card] diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index ac7eca8ee..b9a3058fa 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -139,6 +139,7 @@ master_of_etherium.txt memory_erosion.txt millstone.txt #mind_rot.txt +moat.txt mobile_fort.txt nantuko_husk.txt necrogenesis.txt diff --git a/projects/mtg/bin/Res/test/moat.txt b/projects/mtg/bin/Res/test/moat.txt new file mode 100644 index 000000000..37b773d8f --- /dev/null +++ b/projects/mtg/bin/Res/test/moat.txt @@ -0,0 +1,23 @@ +#Bug: http://code.google.com/p/wagic/issues/detail?id=2 +#Moat doesn't prevent creatures from attacking +[INIT] +COMBATATTACKERS +[PLAYER1] +inplay:moat,grizzly bears,air elemental +[PLAYER2] +[DO] +grizzly bears +air elemental +next +#blockers +next +#damage +next +#end +[ASSERT] +COMBATEND +[PLAYER1] +inplay:moat,grizzly bears,air elemental +[PLAYER2] +life:16 +[END] \ No newline at end of file diff --git a/projects/mtg/include/SimpleMenu.h b/projects/mtg/include/SimpleMenu.h index 00fee6e8e..e8a16ec09 100644 --- a/projects/mtg/include/SimpleMenu.h +++ b/projects/mtg/include/SimpleMenu.h @@ -42,7 +42,7 @@ class SimpleMenu:public JGuiController{ SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title = "", int _maxItems = 7); void Render(); void Update(float dt); - void Add(int id, const char * Text,string desc = ""); + void Add(int id, const char * Text,string desc = "", bool forceFocus = false); void Close(); float selectionTargetY; diff --git a/projects/mtg/src/GameStateDeckViewer.cpp b/projects/mtg/src/GameStateDeckViewer.cpp index 08971b12f..9774432fe 100644 --- a/projects/mtg/src/GameStateDeckViewer.cpp +++ b/projects/mtg/src/GameStateDeckViewer.cpp @@ -284,7 +284,7 @@ void GameStateDeckViewer::Update(float dt) sprintf(buffer,"%s : %i %s",_(card->getName()).c_str(),price,_("credits").c_str()); sellMenu = NEW SimpleMenu(2,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer); sellMenu->Add(20,"Yes"); - sellMenu->Add(21,"No"); + sellMenu->Add(21,"No","",true); } } break; diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 0b2364981..829d02bbd 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -47,29 +47,26 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int if (!spadeRTex) spadeRTex = resources.RetrieveTexture("spade_ur.png", RETRIEVE_MANAGE); if (!jewelTex) jewelTex= renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM); if (!sideTex) sideTex = resources.RetrieveTexture("menuside.png", RETRIEVE_MANAGE); -if (NULL == spadeL) spadeL = resources.RetrieveQuad("spade_ul.png", 2, 1, 16, 13, "spade_ul", RETRIEVE_MANAGE); + if (NULL == spadeL) spadeL = resources.RetrieveQuad("spade_ul.png", 2, 1, 16, 13, "spade_ul", RETRIEVE_MANAGE); if (NULL == spadeR) spadeR = resources.RetrieveQuad("spade_ur.png", 2, 1, 16, 13, "spade_ur", RETRIEVE_MANAGE); if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3); if (NULL == side) side = resources.RetrieveQuad("menuside.png", 1, 1, 1, 7,"menuside", RETRIEVE_MANAGE); - if (NULL == titleFont) - { + if (NULL == titleFont) { resources.LoadJLBFont("smallface", 7); titleFont = resources.GetJLBFont("smallface"); - } + } - if (NULL == stars){ + if (NULL == stars) { JQuad * starQuad = resources.GetQuad("stars"); hgeParticleSystemInfo * psi = resources.RetrievePSI("stars.psi", starQuad); - if(psi) - stars = NEW hgeParticleSystem(psi); + if(psi) stars = NEW hgeParticleSystem(psi); } stars->MoveTo(mX, mY); } -void SimpleMenu::drawHorzPole(int x, int y, int width) -{ +void SimpleMenu::drawHorzPole(int x, int y, int width) { JRenderer* renderer = JRenderer::GetInstance(); renderer->RenderQuad(side, x + 5 , y - SIDE_SIZE / 2, 0, width - 10); @@ -81,8 +78,8 @@ void SimpleMenu::drawHorzPole(int x, int y, int width) renderer->RenderQuad(jewel, x, y - 1); renderer->RenderQuad(jewel, x + width - 1, y - 1); } -void SimpleMenu::drawVertPole(int x, int y, int height) -{ + +void SimpleMenu::drawVertPole(int x, int y, int height) { JRenderer* renderer = JRenderer::GetInstance(); renderer->RenderQuad(side, x - SIDE_SIZE / 2, y + height - 5, -M_PI/2, height - 10); @@ -95,27 +92,30 @@ void SimpleMenu::drawVertPole(int x, int y, int height) renderer->RenderQuad(jewel, x - 1, y + height - 1); } -void SimpleMenu::Render(){ - if (0 == mWidth) - { - for (int i = startId; i < startId + mCount; ++i) - { - int width = (static_cast(mObjects[i]))->GetWidth(); - if (mWidth < width) mWidth = width; - } - if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str()))) mWidth = titleFont->GetStringWidth(title.c_str()); - mWidth += 2*HMARGIN; - for (int i = startId; i < startId + mCount; ++i) - static_cast(mObjects[i])->Relocate(mX + mWidth / 2, mY + VMARGIN + i * LINE_HEIGHT); - stars->Fire(); - selectionTargetY = selectionY = mY + VMARGIN; - timeOpen = 0; +void SimpleMenu::Render() { + if (0 == mWidth) { + float sY = mY + VMARGIN; + for (int i = startId; i < startId + mCount; ++i) { + int width = (static_cast(mObjects[i]))->GetWidth(); + if (mWidth < width) mWidth = width; + } + if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str()))) mWidth = titleFont->GetStringWidth(title.c_str()); + mWidth += 2*HMARGIN; + for (int i = startId; i < startId + mCount; ++i) { + float y = mY + VMARGIN + i * LINE_HEIGHT; + SimpleMenuItem * smi = static_cast(mObjects[i]); + smi->Relocate(mX + mWidth / 2, y); + if (smi->hasFocus()) sY = y; } + stars->Fire(); + selectionTargetY = selectionY = sY; + timeOpen = 0; + } + JRenderer * renderer = JRenderer::GetInstance(); float height = mHeight; - if (timeOpen < 1) - height *= timeOpen > 0 ? timeOpen : -timeOpen; + if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen; renderer->FillRect(mX, mY, mWidth, height, options[Metrics::POPUP_MENU_FC].asColor(ARGB(180,0,0,0))); @@ -132,18 +132,16 @@ void SimpleMenu::Render(){ titleFont->DrawString(title.c_str(), mX+mWidth/2, mY - 3, JGETEXT_CENTER); for (int i = startId; i < startId + maxItems ; i++){ if (i > mCount-1) break; - if ((static_cast(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7) - { - if (static_cast(mObjects[i])->hasFocus()){ - resources.GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15); - mFont->SetColor(options[Metrics::POPUP_MENU_TCH].asColor(ARGB(255,255,255,0))); - } - else - mFont->SetColor(options[Metrics::POPUP_MENU_TC].asColor(ARGB(150,255,255,255))); - (static_cast(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId); + if ((static_cast(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7) { + if (static_cast(mObjects[i])->hasFocus()){ + resources.GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15); + mFont->SetColor(options[Metrics::POPUP_MENU_TCH].asColor(ARGB(255,255,255,0))); + } else { + mFont->SetColor(options[Metrics::POPUP_MENU_TC].asColor(ARGB(150,255,255,255))); } + (static_cast(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId); + } } - drawHorzPole(mX - 25, mY + height, mWidth + 50); } @@ -158,23 +156,25 @@ void SimpleMenu::Update(float dt){ selectionT += 3*dt; selectionY += (selectionTargetY - selectionY) * 8 * dt; stars->MoveTo(mX + HMARGIN + ((mWidth-2*HMARGIN)*(1+cos(selectionT))/2), selectionY + 5 * cos(selectionT*2.35) + LINE_HEIGHT / 2 - LINE_HEIGHT * startId); - if (timeOpen < 0) - { - timeOpen += dt * 10; - if (timeOpen >= 0) { timeOpen = 0; closed = true; } - } - else - { - closed = false; - timeOpen += dt * 10; - } + if (timeOpen < 0) { + timeOpen += dt * 10; + if (timeOpen >= 0) { timeOpen = 0; closed = true; } + } else { + closed = false; + timeOpen += dt * 10; + } } -void SimpleMenu::Add(int id, const char * text,string desc){ +void SimpleMenu::Add(int id, const char * text,string desc, bool forceFocus){ SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0)); smi->desc = desc; JGuiController::Add(smi); if (mCount <= maxItems) mHeight += LINE_HEIGHT; + if (forceFocus){ + mObjects[mCurr]->Leaving(PSP_CTRL_DOWN); + mCurr = mCount-1; + smi->Entering(); + } } void SimpleMenu::Close()