Merge branch 'master' into wp8
This commit is contained in:
@@ -823,13 +823,13 @@ int GenericChooseTypeColor::resolve()
|
||||
for (size_t i = 0; i < values.size(); ++i)
|
||||
{
|
||||
string menu = values[i];
|
||||
if(!ANonWall || (menu != "wall" && menu != "Wall"))
|
||||
if (!ANonWall || (menu != "wall" && menu != "Wall"))
|
||||
{
|
||||
setType = NEW AASetTypeChosen(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i,menu,baseAbility);
|
||||
MTGAbility * set = setType->clone();
|
||||
set->oneShot = true;
|
||||
selection.push_back(set);
|
||||
SAFE_DELETE(setType);
|
||||
setType = NEW AASetTypeChosen(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i,menu,baseAbility);
|
||||
MTGAbility * set = setType->clone();
|
||||
set->oneShot = true;
|
||||
selection.push_back(set);
|
||||
SAFE_DELETE(setType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5419,83 +5419,83 @@ AACastCard::AACastCard(GameObserver* observer, int _id, MTGCardInstance * _sourc
|
||||
}
|
||||
|
||||
|
||||
void AACastCard::Update(float dt)
|
||||
void AACastCard::Update(float dt)
|
||||
{
|
||||
MTGAbility::Update(dt);
|
||||
if (processed)
|
||||
return;
|
||||
if(cardNamed.size() && !theNamedCard)
|
||||
{
|
||||
theNamedCard = makeCard();
|
||||
}
|
||||
if (restricted)
|
||||
{
|
||||
MTGAbility::Update(dt);
|
||||
if (processed)
|
||||
return;
|
||||
if(cardNamed.size() && !theNamedCard)
|
||||
{
|
||||
theNamedCard = makeCard();
|
||||
}
|
||||
if (restricted)
|
||||
{
|
||||
MTGCardInstance * toCheck = (MTGCardInstance*)target;
|
||||
if(theNamedCard)
|
||||
toCheck = theNamedCard;
|
||||
if (game->currentActionPlayer->game->playRestrictions->canPutIntoZone(toCheck, source->controller()->game->stack) == PlayRestriction::CANT_PLAY)
|
||||
{
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return ;
|
||||
}
|
||||
if(!allowedToCast(toCheck,source->controller()))
|
||||
{
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
if(!toCheck->hasType(Subtypes::TYPE_INSTANT) && !(game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
|
||||
{
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
MTGCardInstance * toCheck = (MTGCardInstance*)target;
|
||||
if(theNamedCard)
|
||||
toCheck = theNamedCard;
|
||||
if (Spell * checkSpell = dynamic_cast<Spell*>(target))
|
||||
if (game->currentActionPlayer->game->playRestrictions->canPutIntoZone(toCheck, source->controller()->game->stack) == PlayRestriction::CANT_PLAY)
|
||||
{
|
||||
toCheck = checkSpell->source;
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return ;
|
||||
}
|
||||
if (!game->targetListIsSet(toCheck))
|
||||
if(!allowedToCast(toCheck,source->controller()))
|
||||
{
|
||||
if(game->targetChooser)
|
||||
game->targetChooser->Owner = source->controller();//sources controller is the caster
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
resolveSpell();
|
||||
this->forceDestroy = 1;
|
||||
if(!toCheck->hasType(Subtypes::TYPE_INSTANT) && !(game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
|
||||
{
|
||||
processed = true;
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
MTGCardInstance * toCheck = (MTGCardInstance*)target;
|
||||
if(theNamedCard)
|
||||
toCheck = theNamedCard;
|
||||
if (Spell * checkSpell = dynamic_cast<Spell*>(target))
|
||||
{
|
||||
toCheck = checkSpell->source;
|
||||
}
|
||||
if (!game->targetListIsSet(toCheck))
|
||||
{
|
||||
if(game->targetChooser)
|
||||
game->targetChooser->Owner = source->controller();//sources controller is the caster
|
||||
return;
|
||||
}
|
||||
int AACastCard::isReactingToTargetClick(Targetable * card){return 0;}
|
||||
int AACastCard::reactToTargetClick(Targetable * object)
|
||||
{
|
||||
if (MTGCardInstance * cObject = dynamic_cast<MTGCardInstance *>(object))
|
||||
return reactToClick(cObject);
|
||||
resolveSpell();
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
int AACastCard::isReactingToTargetClick(Targetable * card){return 0;}
|
||||
int AACastCard::reactToTargetClick(Targetable * object)
|
||||
{
|
||||
if (MTGCardInstance * cObject = dynamic_cast<MTGCardInstance *>(object))
|
||||
return reactToClick(cObject);
|
||||
|
||||
if (waitingForAnswer)
|
||||
if (waitingForAnswer)
|
||||
{
|
||||
if (tc->toggleTarget(object) == TARGET_OK_FULL)
|
||||
{
|
||||
if (tc->toggleTarget(object) == TARGET_OK_FULL)
|
||||
{
|
||||
waitingForAnswer = 0;
|
||||
game->mLayers->actionLayer()->setCurrentWaitingAction(NULL);
|
||||
return MTGAbility::reactToClick(source);
|
||||
}
|
||||
return 1;
|
||||
waitingForAnswer = 0;
|
||||
game->mLayers->actionLayer()->setCurrentWaitingAction(NULL);
|
||||
return MTGAbility::reactToClick(source);
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
MTGCardInstance * AACastCard::makeCard()
|
||||
{
|
||||
MTGCardInstance * card = NULL;
|
||||
MTGCard * cardData = MTGCollection()->getCardByName(cardNamed);
|
||||
card = NEW MTGCardInstance(cardData, source->controller()->game);
|
||||
source->controller()->game->temp->addCard(card);
|
||||
return card;
|
||||
}
|
||||
MTGCardInstance * AACastCard::makeCard()
|
||||
{
|
||||
MTGCardInstance * card = NULL;
|
||||
MTGCard * cardData = MTGCollection()->getCardByName(cardNamed);
|
||||
card = NEW MTGCardInstance(cardData, source->controller()->game);
|
||||
source->controller()->game->temp->addCard(card);
|
||||
return card;
|
||||
}
|
||||
|
||||
int AACastCard::resolveSpell()
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Counters.h"
|
||||
#include "ModRules.h"
|
||||
#include "CardDescriptor.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
const float CardGui::Width = 28.0;
|
||||
const float CardGui::Height = 40.0;
|
||||
@@ -110,17 +111,17 @@ void CardGui::Update(float dt)
|
||||
PlayGuiObject::Update(dt);
|
||||
}
|
||||
|
||||
void CardGui::DrawCard(const Pos& inPosition, int inMode)
|
||||
void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb)
|
||||
{
|
||||
DrawCard(card, inPosition, inMode);
|
||||
DrawCard(card, inPosition, inMode, thumb);
|
||||
}
|
||||
|
||||
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode)
|
||||
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb)
|
||||
{
|
||||
switch (inMode)
|
||||
{
|
||||
case DrawMode::kNormal:
|
||||
RenderBig(inCard, inPosition);
|
||||
RenderBig(inCard, inPosition, thumb);
|
||||
break;
|
||||
case DrawMode::kText:
|
||||
AlternateRender(inCard, inPosition);
|
||||
@@ -957,7 +958,7 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad)
|
||||
}
|
||||
|
||||
//Renders a big card on screen. Defaults to the "alternate" rendering if no image is found
|
||||
void CardGui::RenderBig(MTGCard* card, const Pos& pos)
|
||||
void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb)
|
||||
{
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
//GameObserver * game = GameObserver::GetInstance();
|
||||
@@ -966,7 +967,8 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos)
|
||||
//i want this but ai targets cards so quickly that it can crash the game.
|
||||
float x = pos.actX;
|
||||
|
||||
JQuadPtr quad = WResourceManager::Instance()->RetrieveCard(card);
|
||||
JQuadPtr quad = thumb ? WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_THUMB)
|
||||
: WResourceManager::Instance()->RetrieveCard(card);
|
||||
MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card);
|
||||
if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "MTGDeck.h"
|
||||
#include "Subtypes.h"
|
||||
#include "Translate.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
@@ -228,6 +229,9 @@ void CardPrimitive::setSubtype(const string& value)
|
||||
}
|
||||
}
|
||||
|
||||
// "Artifact Creature" should have "Creature" as parent type
|
||||
if (parentType == Subtypes::TYPE_ARTIFACT && isCreature())
|
||||
parentType = Subtypes::TYPE_CREATURE;
|
||||
|
||||
int id = MTGAllCards::add(value, parentType);
|
||||
addType(id);
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
#include "CarouselDeckView.h"
|
||||
|
||||
const float CarouselDeckView::max_scale = 0.96f;
|
||||
const float CarouselDeckView::x_center = 180;
|
||||
const float CarouselDeckView::right_border = SCREEN_WIDTH + 180;
|
||||
const float CarouselDeckView::slide_animation_duration = 0.6f;
|
||||
|
||||
CarouselDeckView::CarouselDeckView() :
|
||||
DeckView(10), mScrollOffset(0), mSlideOffset(0), mScrollEasing(mScrollOffset), mSlideEasing(mSlideOffset)
|
||||
{
|
||||
}
|
||||
|
||||
CarouselDeckView::~CarouselDeckView()
|
||||
{}
|
||||
|
||||
void CarouselDeckView::UpdateViewState(float dt)
|
||||
{
|
||||
if(!mScrollEasing.finished())
|
||||
{
|
||||
mScrollEasing.update(dt);
|
||||
|
||||
if(mScrollOffset <= -1.0f)
|
||||
{
|
||||
SwitchPosition(-1);
|
||||
mScrollEasing.translate(1.0f);
|
||||
}
|
||||
else if(mScrollOffset >= 1.0f)
|
||||
{
|
||||
SwitchPosition(1);
|
||||
mScrollEasing.translate(-1.0f);
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
|
||||
if(!mSlideEasing.finished())
|
||||
{
|
||||
mSlideEasing.update(dt);
|
||||
|
||||
if(mSlideOffset < mSlideEasing.start_value)
|
||||
{
|
||||
//going downwards
|
||||
if(mSlideOffset < -1.0f)
|
||||
{
|
||||
mSlideEasing.translate(2.0f);
|
||||
SwitchFilter(1);
|
||||
}
|
||||
}
|
||||
else if(mSlideOffset > mSlideEasing.start_value)
|
||||
{
|
||||
//upwards
|
||||
if(mSlideOffset > 1.0f)
|
||||
{
|
||||
mSlideEasing.translate(-2.0f);
|
||||
SwitchFilter(-1);
|
||||
}
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CarouselDeckView::UpdateCardPosition(CardRep &rep, int index)
|
||||
{
|
||||
float rotation = mScrollOffset + 8 - index;
|
||||
|
||||
rep.x = x_center + cos((rotation) * M_PI / 12) * (right_border - x_center);
|
||||
rep.scale = max_scale / 1.12f * cos((rep.x - x_center) * 1.5f / (right_border - x_center)) + 0.2f * max_scale * cos(
|
||||
cos((rep.x - x_center) * 0.15f / (right_border - x_center)));
|
||||
rep.y = (SCREEN_HEIGHT_F) / 2.0f + SCREEN_HEIGHT_F * mSlideOffset * (rep.scale + 0.2f);
|
||||
}
|
||||
|
||||
void CarouselDeckView::Reset()
|
||||
{
|
||||
mSlideEasing.finish();
|
||||
mScrollEasing.finish();
|
||||
|
||||
DeckView::Reset();
|
||||
}
|
||||
|
||||
void CarouselDeckView::Render()
|
||||
{
|
||||
// even though we want to draw the cards in a particular z order for layering, we want to prefetch them
|
||||
// in a different order, ie the center card should appear first, then the adjacent ones
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(0).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(3).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(4).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(2).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(5).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(1).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(6).card);
|
||||
}
|
||||
|
||||
renderCard(6);
|
||||
renderCard(5);
|
||||
renderCard(4);
|
||||
renderCard(0);
|
||||
|
||||
if (mScrollOffset < 0.5 && mScrollOffset > -0.5)
|
||||
{
|
||||
renderCard(1);
|
||||
renderCard(3);
|
||||
renderCard(2);
|
||||
}
|
||||
else if (mScrollOffset < -0.5)
|
||||
{
|
||||
renderCard(3);
|
||||
renderCard(2);
|
||||
renderCard(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderCard(1);
|
||||
renderCard(2);
|
||||
renderCard(3);
|
||||
}
|
||||
}
|
||||
|
||||
MTGCard * CarouselDeckView::Click(int x, int y)
|
||||
{
|
||||
int n = getCardIndexNextTo(x, y);
|
||||
last_user_activity = 0;
|
||||
|
||||
//clicked active card, and no animation is running
|
||||
if(mSlideEasing.finished() && mScrollEasing.finished())
|
||||
{
|
||||
if(n == 2)
|
||||
{
|
||||
return getActiveCard();
|
||||
}
|
||||
else
|
||||
{
|
||||
changePosition(n - 2);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CarouselDeckView::changePosition(int offset)
|
||||
{
|
||||
mScrollEasing.start((float)offset, (float)(0.3f*abs(offset)));
|
||||
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void CarouselDeckView::changeFilter(int offset)
|
||||
{
|
||||
if(offset < 0)
|
||||
{
|
||||
mSlideEasing.start(-2.0f, slide_animation_duration);
|
||||
}
|
||||
else if(offset > 0)
|
||||
{
|
||||
mSlideEasing.start(2.0f, slide_animation_duration);
|
||||
}
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard *CarouselDeckView::getActiveCard()
|
||||
{
|
||||
return getCardRep(2).card;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
#include "DeckView.h"
|
||||
|
||||
#include "GameOptions.h"
|
||||
#include "CardGui.h"
|
||||
|
||||
const float DeckView::no_user_activity_show_card_delay = 0.1f;
|
||||
|
||||
DeckView::DeckView(int numberOfCards)
|
||||
: dirtyFilters(true), dirtyCardPos(true), last_user_activity(0.0f), mFilter(0), mCurrentDeck(NULL)
|
||||
{
|
||||
mCards.resize(numberOfCards);
|
||||
}
|
||||
|
||||
DeckView::~DeckView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DeckView::Reset()
|
||||
{
|
||||
dirtyFilters = true;
|
||||
dirtyCardPos = true;
|
||||
last_user_activity = 0;
|
||||
mFilter = 0;
|
||||
mCurrentDeck = NULL;
|
||||
}
|
||||
|
||||
void DeckView::Update(float dt)
|
||||
{
|
||||
last_user_activity += dt;
|
||||
|
||||
UpdateViewState(dt);
|
||||
|
||||
if(dirtyCardPos)
|
||||
{
|
||||
for(unsigned int i = 0; i < mCards.size(); ++i)
|
||||
{
|
||||
UpdateCardPosition(mCards[i], i);
|
||||
}
|
||||
dirtyCardPos = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DeckView::ButtonPressed(Buttons button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_LEFT:
|
||||
changePosition(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
changePosition(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
changeFilter(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
changeFilter(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeckView::SetDeck(DeckDataWrapper *toShow)
|
||||
{
|
||||
mCurrentDeck = toShow;
|
||||
dirtyCardPos = true;
|
||||
dirtyFilters = true;
|
||||
reloadIndexes();
|
||||
}
|
||||
|
||||
DeckDataWrapper* DeckView::deck()
|
||||
{
|
||||
return mCurrentDeck;
|
||||
}
|
||||
|
||||
void DeckView::SwitchFilter(int delta)
|
||||
{
|
||||
unsigned int FilterCount = Constants::NB_Colors + 1;
|
||||
mFilter = (FilterCount + mFilter + delta) % FilterCount;
|
||||
dirtyFilters = true;
|
||||
}
|
||||
|
||||
void DeckView::SwitchPosition(int delta)
|
||||
{
|
||||
for(int i = 0; i < delta; ++i)
|
||||
{
|
||||
mCurrentDeck->next();
|
||||
}
|
||||
|
||||
for(int i = 0; i > delta; --i)
|
||||
{
|
||||
mCurrentDeck->prev();
|
||||
}
|
||||
|
||||
reloadIndexes();
|
||||
}
|
||||
|
||||
int DeckView::filter()
|
||||
{
|
||||
return mFilter;
|
||||
}
|
||||
|
||||
void DeckView::reloadIndexes()
|
||||
{
|
||||
if(mCurrentDeck != NULL)
|
||||
{
|
||||
for (unsigned int i = 0; i < mCards.size(); i++)
|
||||
{
|
||||
mCards[i].card = deck()->getCard(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeckView::CardRep& DeckView::getCardRep(unsigned int index)
|
||||
{
|
||||
return mCards[index];
|
||||
}
|
||||
|
||||
void DeckView::renderCard(int index, int alpha, bool asThumbnail)
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||
|
||||
const CardRep& cardPosition = getCardRep(index);
|
||||
|
||||
if (!cardPosition.card) return;
|
||||
|
||||
if (!WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||
JQuadPtr quad;
|
||||
|
||||
int cacheError = CACHE_ERROR_NONE;
|
||||
|
||||
if (!options[Options::DISABLECARDS].number)
|
||||
{
|
||||
quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card, RETRIEVE_EXISTING);
|
||||
cacheError = WResourceManager::Instance()->RetrieveError();
|
||||
if (!quad.get() && cacheError != CACHE_ERROR_404)
|
||||
{
|
||||
if (last_user_activity > (abs(2 - index) + 1) * no_user_activity_show_card_delay)
|
||||
quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card);
|
||||
else
|
||||
{
|
||||
quad = backQuad;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quad.get())
|
||||
{
|
||||
if (quad == backQuad)
|
||||
{
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
float _scale = cardPosition.scale * (285 / quad->mHeight);
|
||||
JRenderer::GetInstance()->RenderQuad(quad.get(), cardPosition.x, cardPosition.y, 0.0f, _scale, _scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, asThumbnail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, DrawMode::kText, asThumbnail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mode = !options[Options::DISABLECARDS].number ? DrawMode::kNormal : DrawMode::kText;
|
||||
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, mode, asThumbnail);
|
||||
}
|
||||
|
||||
int quadAlpha = alpha;
|
||||
if (!deck()->count(cardPosition.card)) quadAlpha /= 2;
|
||||
quadAlpha = 255 - quadAlpha;
|
||||
if (quadAlpha > 0)
|
||||
{
|
||||
JRenderer::GetInstance()->FillRect(cardPosition.x - cardPosition.scale * 100.0f, cardPosition.y - cardPosition.scale * 142.5f, cardPosition.scale * 200.0f, cardPosition.scale * 285.0f,
|
||||
ARGB(quadAlpha,0,0,0));
|
||||
}
|
||||
if (last_user_activity < 3)
|
||||
{
|
||||
int fontAlpha = alpha;
|
||||
float qtY = cardPosition.y - 135 * cardPosition.scale;
|
||||
float qtX = cardPosition.x + 40 * cardPosition.scale;
|
||||
char buffer[4096];
|
||||
sprintf(buffer, "x%i", deck()->count(cardPosition.card));
|
||||
WFont * font = mFont;
|
||||
font->SetColor(ARGB(fontAlpha/2,0,0,0));
|
||||
JRenderer::GetInstance()->FillRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 16, ARGB(fontAlpha/2,0,0,0));
|
||||
font->DrawString(buffer, qtX + 4, qtY + 4);
|
||||
font->SetColor(ARGB(fontAlpha,255,255,255));
|
||||
font->DrawString(buffer, qtX + 2, qtY + 2);
|
||||
font->SetColor(ARGB(255,255,255,255));
|
||||
}
|
||||
}
|
||||
|
||||
int DeckView::getCardIndexNextTo(int x, int y)
|
||||
{
|
||||
int bestCardIndex = -1;
|
||||
float bestDistance = 0;
|
||||
|
||||
for(unsigned int i = 0; i < mCards.size(); i++)
|
||||
{
|
||||
const CardRep& cardPosition = getCardRep(i);
|
||||
|
||||
float dx = (x - cardPosition.x);
|
||||
float dy = (y - cardPosition.y);
|
||||
float dist = dx*dx + dy*dy;
|
||||
|
||||
if(dist < bestDistance || bestCardIndex == -1)
|
||||
{
|
||||
bestDistance = dist;
|
||||
bestCardIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
return bestCardIndex;
|
||||
}
|
||||
|
||||
int DeckView::getPosition()
|
||||
{
|
||||
if(!mCurrentDeck)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int total = mCurrentDeck->Size();
|
||||
int currentPos = (mCurrentDeck->getOffset() + 3) % total;
|
||||
|
||||
while (currentPos <= 0) currentPos += total;
|
||||
return currentPos;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@
|
||||
#include "Translate.h"
|
||||
#include "Rules.h"
|
||||
#include "ModRules.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
#ifdef TESTSUITE
|
||||
#include "TestSuiteAI.h"
|
||||
|
||||
@@ -259,8 +259,8 @@ void GameStateShop::cancelCard(int controlId)
|
||||
break;
|
||||
}
|
||||
price = price - (rnd * price) / 100;
|
||||
if (price < pricelist->getPrice(c->getMTGId())) //filters have a tendancy to increase the price instead of lowering it!
|
||||
pricelist->setPrice(c->getMTGId(), price);
|
||||
if (price < pricelist->getPrice(c)) //filters have a tendancy to increase the price instead of lowering it!
|
||||
pricelist->setPrice(c, price);
|
||||
//Prices do not immediately go down when you ignore something.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
#include "GridDeckView.h"
|
||||
|
||||
const float GridDeckView::scroll_animation_duration = 0.3f;
|
||||
const float GridDeckView::slide_animation_duration = 0.6f;
|
||||
const float GridDeckView::card_scale_small = 0.48f;
|
||||
const float GridDeckView::card_scale_big = 0.7f;
|
||||
|
||||
GridDeckView::GridDeckView()
|
||||
: DeckView(16), mCols(8), mRows(2), mScrollOffset(0), mSlideOffset(0),
|
||||
mScrollEasing(mScrollOffset), mSlideEasing(mSlideOffset), mCurrentSelection(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GridDeckView::~GridDeckView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GridDeckView::Reset()
|
||||
{
|
||||
mSlideEasing.finish();
|
||||
mScrollEasing.finish();
|
||||
|
||||
mCurrentSelection = 0;
|
||||
|
||||
DeckView::Reset();
|
||||
}
|
||||
|
||||
void GridDeckView::UpdateViewState(float dt)
|
||||
{
|
||||
if(!mScrollEasing.finished())
|
||||
{
|
||||
mScrollEasing.update(dt);
|
||||
|
||||
if(mScrollOffset <= -1.0f)
|
||||
{
|
||||
SwitchPosition(2);
|
||||
mScrollEasing.translate(1.0f);
|
||||
mCurrentSelection = (mCurrentSelection >= 6) ? mCurrentSelection - 2 : -1;
|
||||
}
|
||||
else if(mScrollOffset >= 1.0f)
|
||||
{
|
||||
SwitchPosition(-2);
|
||||
mScrollEasing.translate(-1.0f);
|
||||
mCurrentSelection = (mCurrentSelection >= 0 && mCurrentSelection < 10) ? mCurrentSelection + 2 : -1;
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
|
||||
if(!mSlideEasing.finished())
|
||||
{
|
||||
mSlideEasing.update(dt);
|
||||
|
||||
if(mSlideOffset < -1.0f)
|
||||
{
|
||||
mSlideEasing.translate(2.0f);
|
||||
SwitchFilter(1);
|
||||
}
|
||||
else if(mSlideOffset > 1.0f)
|
||||
{
|
||||
mSlideEasing.translate(-2.0f);
|
||||
SwitchFilter(-1);
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GridDeckView::UpdateCardPosition(CardRep &rep, int index)
|
||||
{
|
||||
int col = index / mRows;
|
||||
int row = index % mRows;
|
||||
float colWidth = SCREEN_WIDTH_F / (mCols - 3);
|
||||
float rowHeight = SCREEN_HEIGHT_F / mRows;
|
||||
|
||||
rep.x = (col + mScrollOffset) * colWidth - colWidth;
|
||||
rep.y = row * rowHeight + mSlideOffset*SCREEN_HEIGHT + rowHeight/2;
|
||||
|
||||
if(mCurrentSelection == index)
|
||||
{
|
||||
rep.scale = card_scale_big;
|
||||
if(row == 0)
|
||||
{
|
||||
rep.y += rowHeight * (card_scale_big - card_scale_small);
|
||||
}
|
||||
else
|
||||
{
|
||||
rep.y -= rowHeight * (card_scale_big - card_scale_small);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rep.scale = card_scale_small;
|
||||
}
|
||||
}
|
||||
|
||||
void GridDeckView::Render()
|
||||
{
|
||||
int firstVisibleCard = 2;
|
||||
int lastVisibleCard = mCards.size() - 2;
|
||||
|
||||
if(!mScrollEasing.finished())
|
||||
{
|
||||
if(mScrollEasing.delta_value > 0){
|
||||
firstVisibleCard = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastVisibleCard = mCards.size();
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = firstVisibleCard; i < lastVisibleCard; ++i)
|
||||
{
|
||||
|
||||
if(mCurrentSelection != i)
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card, RETRIEVE_THUMB);
|
||||
}
|
||||
renderCard(i, 255, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(2 <= mCurrentSelection && mCurrentSelection < 12)
|
||||
{
|
||||
renderCard(mCurrentSelection, 255, false);
|
||||
}
|
||||
}
|
||||
|
||||
MTGCard * GridDeckView::Click(int x, int y)
|
||||
{
|
||||
int n = getCardIndexNextTo(x, y);
|
||||
last_user_activity = 0;
|
||||
|
||||
if(mScrollEasing.finished() && mSlideEasing.finished())
|
||||
{ //clicked and no animations running
|
||||
if(n == mCurrentSelection)
|
||||
{
|
||||
return getActiveCard();
|
||||
}
|
||||
else if(n < 4)
|
||||
{
|
||||
changePosition(-1);
|
||||
}
|
||||
else if(n >= 12)
|
||||
{
|
||||
changePosition(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentSelection = n;
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GridDeckView::changePosition(int offset)
|
||||
{
|
||||
mScrollEasing.start(-1.0f * offset, scroll_animation_duration * abs(offset));
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void GridDeckView::changeFilter(int offset)
|
||||
{
|
||||
if(offset < 0)
|
||||
{
|
||||
mSlideEasing.start(-2.0f, slide_animation_duration);
|
||||
}
|
||||
else if(offset > 0)
|
||||
{
|
||||
mSlideEasing.start(2.0f, slide_animation_duration);
|
||||
}
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard* GridDeckView::getActiveCard()
|
||||
{
|
||||
if(mCurrentSelection >= 0 && mCurrentSelection < int(mCards.size()))
|
||||
{
|
||||
return mCards[mCurrentSelection].card;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "GuiMana.h"
|
||||
#include "OptionItem.h"
|
||||
#include "Player.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
//using std::cout;
|
||||
using std::endl;
|
||||
|
||||
@@ -1039,6 +1039,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
observer->addObserver(NEW MTGMorphCostRule(observer, -1));
|
||||
return NULL;
|
||||
}
|
||||
found = s.find("playfromgraveyardrule");
|
||||
if(found != string::npos)
|
||||
{
|
||||
observer->addObserver(NEW MTGPlayFromGraveyardRule(observer, -1));
|
||||
return NULL;
|
||||
}
|
||||
//this rule handles attacking ability during attacker phase
|
||||
found = s.find("attackrule");
|
||||
if(found != string::npos)
|
||||
@@ -1145,7 +1151,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
|
||||
|
||||
if(s.compare(0, strlen("chooseacolor "), "chooseacolor ") == 0 || s.compare(0, strlen("chooseatype "), "chooseatype ") == 0)
|
||||
if (StartsWith(s, "chooseacolor ") || StartsWith(s, "chooseatype "))
|
||||
{
|
||||
MTGAbility * choose = parseChooseActionAbility(s,card,spell,target,0,id);
|
||||
choose = NEW GenericActivatedAbility(observer, "","",id, card,choose,NULL);
|
||||
@@ -3272,7 +3278,7 @@ MTGAbility * AbilityFactory::parseChooseActionAbility(string s,MTGCardInstance *
|
||||
a->canBeInterrupted = false;
|
||||
return a;
|
||||
}
|
||||
//choose a color
|
||||
//choose a color
|
||||
vector<string> splitChooseAColor = parseBetween(s, "chooseacolor ", " chooseend");
|
||||
if (splitChooseAColor.size())
|
||||
{
|
||||
|
||||
@@ -131,7 +131,8 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"poisondamager",//deals damage to players as poison counters.
|
||||
"soulbond",
|
||||
"lure",
|
||||
"nolegend"
|
||||
"nolegend",
|
||||
"canplayfromgraveyard"
|
||||
};
|
||||
|
||||
map<string,int> Constants::MTGBasicAbilitiesMap;
|
||||
|
||||
@@ -273,6 +273,7 @@ MTGEventBonus * MTGEventBonus::clone() const
|
||||
{
|
||||
return NEW MTGEventBonus(*this);
|
||||
}
|
||||
|
||||
MTGPutInPlayRule::MTGPutInPlayRule(GameObserver* observer, int _id) :
|
||||
PermanentAbility(observer, _id)
|
||||
{
|
||||
@@ -716,7 +717,6 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
|
||||
copy->alternateCostPaid[alternateCostType] = 1;
|
||||
spell->resolve();
|
||||
SAFE_DELETE(spell);
|
||||
game->mLayers->stackLayer()->addSpell(copy, NULL, NULL, alternateCostType, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1140,8 +1140,49 @@ MTGMorphCostRule * MTGMorphCostRule::clone() const
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
MTGPlayFromGraveyardRule::MTGPlayFromGraveyardRule(GameObserver* observer, int _id) :
|
||||
MTGAlternativeCostRule(observer, _id)
|
||||
{
|
||||
aType = MTGAbility::PUT_INTO_PLAY;
|
||||
}
|
||||
|
||||
int MTGPlayFromGraveyardRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
|
||||
if (!player->game->graveyard->hasCard(card))
|
||||
return 0;
|
||||
if (!card->has(Constants::CANPLAYFROMGRAVEYARD))
|
||||
return 0;
|
||||
|
||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, cost);
|
||||
}
|
||||
|
||||
int MTGPlayFromGraveyardRule::reactToClick(MTGCardInstance * card)
|
||||
{
|
||||
if (!isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
ManaCost * cost = card->getManaCost();
|
||||
|
||||
card->paymenttype = MTGAbility::PUT_INTO_PLAY;
|
||||
|
||||
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID);
|
||||
}
|
||||
|
||||
ostream& MTGPlayFromGraveyardRule::toString(ostream& out) const
|
||||
{
|
||||
out << "MTGPlayFromGraveyardRule ::: (";
|
||||
return MTGAbility::toString(out) << ")";
|
||||
}
|
||||
|
||||
MTGPlayFromGraveyardRule * MTGPlayFromGraveyardRule::clone() const
|
||||
{
|
||||
return NEW MTGPlayFromGraveyardRule(*this);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool MTGAttackRule::select(Target* t)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "TranslateKeys.h"
|
||||
#include "StyleManager.h"
|
||||
#include <dirent.h>
|
||||
#include "SimpleMenu.h"
|
||||
|
||||
//OptionItem
|
||||
OptionItem::OptionItem(int _id, string _displayValue) :
|
||||
|
||||
@@ -47,12 +47,12 @@ int PriceList::save()
|
||||
|
||||
return 1;
|
||||
}
|
||||
int PriceList::getPrice(int cardId)
|
||||
int PriceList::getPrice(MTGCard * card)
|
||||
{
|
||||
map<int, int>::iterator it = prices.find(cardId);
|
||||
map<int, int>::iterator it = prices.find(card->getId());
|
||||
if (it != prices.end()) return (*it).second;
|
||||
|
||||
char rarity = collection->getCardById(cardId)->getRarity();
|
||||
char rarity = card->getRarity();
|
||||
switch (rarity)
|
||||
{
|
||||
case Constants::RARITY_M:
|
||||
@@ -77,7 +77,11 @@ int PriceList::getPrice(int cardId)
|
||||
return Constants::PRICE_1C;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int PriceList::getPrice(int cardId)
|
||||
{
|
||||
return getPrice(collection->getCardById(cardId));
|
||||
}
|
||||
|
||||
int PriceList::setPrice(int cardId, int price)
|
||||
@@ -85,10 +89,23 @@ int PriceList::setPrice(int cardId, int price)
|
||||
prices[cardId] = price;
|
||||
return price;
|
||||
}
|
||||
|
||||
int PriceList::setPrice(MTGCard * card, int price)
|
||||
{
|
||||
prices[card->getId()] = price;
|
||||
return price;
|
||||
}
|
||||
|
||||
int PriceList::getSellPrice(int cardid)
|
||||
{
|
||||
return getPrice(cardid);
|
||||
return getPrice(collection->getCardById(cardid));
|
||||
}
|
||||
|
||||
int PriceList::getSellPrice(MTGCard *card)
|
||||
{
|
||||
return getPrice(card);
|
||||
}
|
||||
|
||||
float PriceList::difficultyScalar(float price, int cardid)
|
||||
{
|
||||
float badluck = (float) (abs(cardid + randomKey) % 201) / 100; //Float between 0 and 2.
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Player.h"
|
||||
#include "AIMomirPlayer.h"
|
||||
|
||||
#include "GameApp.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "MTGAbility.h"
|
||||
#include "AllAbilities.h"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "PlayerData.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "WFont.h"
|
||||
#include "GameApp.h"
|
||||
#include <JFileSystem.h>
|
||||
|
||||
#define LINE_SPACE 2
|
||||
|
||||
@@ -54,7 +54,9 @@ int Subtypes::add(string value, unsigned int parentType)
|
||||
}
|
||||
if (isSubType(subtype) && (parentType == TYPE_CREATURE))
|
||||
{
|
||||
if(value != "forest" && value != "Forest")//http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=136196 one creature with a land subtype exist, but the card has special ruling.
|
||||
if (value != "forest" && value != "Forest")
|
||||
//http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=136196
|
||||
//one creature with a land subtype exist, but the card has special ruling.
|
||||
subtypesCreature.push_back(value);
|
||||
}
|
||||
return subtype;
|
||||
@@ -115,8 +117,7 @@ void Subtypes::sortSubTypes()
|
||||
|
||||
const vector<string>& Subtypes::getCreatureValuesById()
|
||||
{
|
||||
sort(subtypesCreature.begin(),subtypesCreature.end());
|
||||
subtypesCreature.erase(unique(subtypesCreature.begin(),subtypesCreature.end()),subtypesCreature.end());
|
||||
sortSubTypes();
|
||||
return subtypesCreature;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include "Subtypes.h"
|
||||
#include "TranslateKeys.h"
|
||||
#include <hge/hgedistort.h>
|
||||
#include "SimpleMenu.h"
|
||||
#include "Pos.h"
|
||||
#include "CardGui.h"
|
||||
|
||||
/**
|
||||
Provides an interface to retrieve some standardized colors. The idea here is that a child of WGuiBase
|
||||
|
||||
Reference in New Issue
Block a user