mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
HMI for spell research
This commit is contained in:
parent
7707adc44f
commit
3559f9f923
@ -59,6 +59,10 @@
|
||||
|
||||
"vcmi.spellBook.search" : "search...",
|
||||
|
||||
"vcmi.spellResearch.canNotAfford" : "You can't afford to research a spell.",
|
||||
"vcmi.spellResearch.comeAgain" : "Research has already been done today. Come back tomorrow.",
|
||||
"vcmi.spellResearch.pay" : "Would you like to research a new spell and replace this?",
|
||||
|
||||
"vcmi.mainMenu.serverConnecting" : "Connecting...",
|
||||
"vcmi.mainMenu.serverAddressEnter" : "Enter address:",
|
||||
"vcmi.mainMenu.serverConnectionFailed" : "Failed to connect",
|
||||
|
@ -58,6 +58,10 @@
|
||||
|
||||
"vcmi.spellBook.search" : "suchen...",
|
||||
|
||||
"vcmi.spellResearch.canNotAfford" : "Ihr könnt es Euch nicht leisten, einen Zauberspruch zu erforschen.",
|
||||
"vcmi.spellResearch.comeAgain" : "Die Forschung wurde heute bereits abgeschlossen. Kommt morgen wieder.",
|
||||
"vcmi.spellResearch.pay" : "Möchtet Ihr einen neuen Zauberspruch erforschen und diesen ersetzen?",
|
||||
|
||||
"vcmi.mainMenu.serverConnecting" : "Verbinde...",
|
||||
"vcmi.mainMenu.serverAddressEnter" : "Addresse eingeben:",
|
||||
"vcmi.mainMenu.serverConnectionFailed" : "Verbindung fehlgeschlagen",
|
||||
|
@ -2032,7 +2032,37 @@ void CMageGuildScreen::Scroll::clickPressed(const Point & cursorPosition)
|
||||
{
|
||||
const CGTownInstance * town = LOCPLINT->cb->getTown(townId);
|
||||
if(LOCPLINT->cb->getSettings().getBoolean(EGameSettings::TOWNS_SPELL_RESEARCH))
|
||||
LOCPLINT->cb->spellResearch(town, spell->id);
|
||||
{
|
||||
int daysSinceLastResearch = LOCPLINT->cb->getDate(Date::DAY) - town->lastSpellResearchDay;
|
||||
if(!daysSinceLastResearch)
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.spellResearch.comeAgain"));
|
||||
return;
|
||||
}
|
||||
|
||||
int level = -1;
|
||||
for(int i = 0; i < town->spells.size(); i++)
|
||||
if(vstd::find_pos(town->spells[i], spell->id) != -1)
|
||||
level = i;
|
||||
|
||||
TResources cost;
|
||||
cost[EGameResID::GOLD] = 1000;
|
||||
cost[EGameResID::MERCURY] = (level + 1) * 2;
|
||||
cost[EGameResID::SULFUR] = (level + 1) * 2;
|
||||
cost[EGameResID::CRYSTAL] = (level + 1) * 2;
|
||||
cost[EGameResID::GEMS] = (level + 1) * 2;
|
||||
|
||||
std::vector<std::shared_ptr<CComponent>> resComps;
|
||||
for(TResources::nziterator i(cost); i.valid(); i++)
|
||||
{
|
||||
resComps.push_back(std::make_shared<CComponent>(ComponentType::RESOURCE, i->resType, i->resVal));
|
||||
}
|
||||
|
||||
if(LOCPLINT->cb->getResourceAmount().canAfford(cost))
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->translate("vcmi.spellResearch.pay"), [this, town](){ LOCPLINT->cb->spellResearch(town, spell->id); }, nullptr, resComps);
|
||||
else
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.spellResearch.canNotAfford"), resComps);
|
||||
}
|
||||
else
|
||||
LOCPLINT->showInfoDialog(spell->getDescriptionTranslated(0), std::make_shared<CComponent>(ComponentType::SPELL, spell->id));
|
||||
}
|
||||
|
@ -313,7 +313,7 @@
|
||||
// Chances for a town with default buildings to receive corresponding dwelling level built in start
|
||||
"startingDwellingChances": [100, 50],
|
||||
// Enable spell research in mage guild
|
||||
"spellResearch": true
|
||||
"spellResearch": false
|
||||
},
|
||||
|
||||
"combat":
|
||||
|
@ -915,7 +915,7 @@ void CGameState::initTowns()
|
||||
vti->spells[s->getLevel()-1].push_back(s->id);
|
||||
vti->possibleSpells -= s->id;
|
||||
}
|
||||
vti->possibleSpells.clear(); //SR
|
||||
vti->possibleSpells.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -944,6 +944,7 @@ void SetTownSpells::applyGs(CGameState *gs)
|
||||
CGTownInstance *town = gs->getTown(tid);
|
||||
|
||||
town->spells[level] = spells;
|
||||
town->lastSpellResearchDay = gs->getDate(Date::DAY);
|
||||
}
|
||||
|
||||
void SetMana::applyGs(CGameState *gs)
|
||||
|
@ -2273,8 +2273,6 @@ bool CGameHandler::spellResearch(ObjectInstanceID tid, SpellID spellAtSlot)
|
||||
|
||||
giveResources(t->getOwner(), -cost);
|
||||
|
||||
t->lastSpellResearchDay = gs->getDate(Date::DAY);
|
||||
|
||||
auto spells = t->spells.at(level);
|
||||
|
||||
std::swap(spells.at(t->spellsAtLevel(level, false)), spells.at(vstd::find_pos(spells, spellAtSlot)));
|
||||
|
Loading…
Reference in New Issue
Block a user