1
0
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:
Laserlicht 2024-09-28 01:47:32 +02:00
parent 7707adc44f
commit 3559f9f923
7 changed files with 42 additions and 5 deletions

View File

@ -59,6 +59,10 @@
"vcmi.spellBook.search" : "search...", "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.serverConnecting" : "Connecting...",
"vcmi.mainMenu.serverAddressEnter" : "Enter address:", "vcmi.mainMenu.serverAddressEnter" : "Enter address:",
"vcmi.mainMenu.serverConnectionFailed" : "Failed to connect", "vcmi.mainMenu.serverConnectionFailed" : "Failed to connect",

View File

@ -58,6 +58,10 @@
"vcmi.spellBook.search" : "suchen...", "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.serverConnecting" : "Verbinde...",
"vcmi.mainMenu.serverAddressEnter" : "Addresse eingeben:", "vcmi.mainMenu.serverAddressEnter" : "Addresse eingeben:",
"vcmi.mainMenu.serverConnectionFailed" : "Verbindung fehlgeschlagen", "vcmi.mainMenu.serverConnectionFailed" : "Verbindung fehlgeschlagen",

View File

@ -2032,7 +2032,37 @@ void CMageGuildScreen::Scroll::clickPressed(const Point & cursorPosition)
{ {
const CGTownInstance * town = LOCPLINT->cb->getTown(townId); const CGTownInstance * town = LOCPLINT->cb->getTown(townId);
if(LOCPLINT->cb->getSettings().getBoolean(EGameSettings::TOWNS_SPELL_RESEARCH)) 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 else
LOCPLINT->showInfoDialog(spell->getDescriptionTranslated(0), std::make_shared<CComponent>(ComponentType::SPELL, spell->id)); LOCPLINT->showInfoDialog(spell->getDescriptionTranslated(0), std::make_shared<CComponent>(ComponentType::SPELL, spell->id));
} }

View File

@ -313,7 +313,7 @@
// Chances for a town with default buildings to receive corresponding dwelling level built in start // Chances for a town with default buildings to receive corresponding dwelling level built in start
"startingDwellingChances": [100, 50], "startingDwellingChances": [100, 50],
// Enable spell research in mage guild // Enable spell research in mage guild
"spellResearch": true "spellResearch": false
}, },
"combat": "combat":

View File

@ -915,7 +915,7 @@ void CGameState::initTowns()
vti->spells[s->getLevel()-1].push_back(s->id); vti->spells[s->getLevel()-1].push_back(s->id);
vti->possibleSpells -= s->id; vti->possibleSpells -= s->id;
} }
vti->possibleSpells.clear(); //SR vti->possibleSpells.clear();
} }
} }

View File

@ -944,6 +944,7 @@ void SetTownSpells::applyGs(CGameState *gs)
CGTownInstance *town = gs->getTown(tid); CGTownInstance *town = gs->getTown(tid);
town->spells[level] = spells; town->spells[level] = spells;
town->lastSpellResearchDay = gs->getDate(Date::DAY);
} }
void SetMana::applyGs(CGameState *gs) void SetMana::applyGs(CGameState *gs)

View File

@ -2273,8 +2273,6 @@ bool CGameHandler::spellResearch(ObjectInstanceID tid, SpellID spellAtSlot)
giveResources(t->getOwner(), -cost); giveResources(t->getOwner(), -cost);
t->lastSpellResearchDay = gs->getDate(Date::DAY);
auto spells = t->spells.at(level); auto spells = t->spells.at(level);
std::swap(spells.at(t->spellsAtLevel(level, false)), spells.at(vstd::find_pos(spells, spellAtSlot))); std::swap(spells.at(t->spellsAtLevel(level, false)), spells.at(vstd::find_pos(spells, spellAtSlot)));