diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index f4c983f58..9e4a753e6 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -126,6 +126,12 @@ "vcmi.lobby.mod.state.version" : "Version mismatch", "vcmi.lobby.mod.state.excessive" : "Must be disabled", "vcmi.lobby.mod.state.missing" : "Not installed", + "vcmi.lobby.pvp.coin.hover" : "Coin", + "vcmi.lobby.pvp.coin.help" : "Flips a coin", + "vcmi.lobby.pvp.randomTown.hover" : "Random town", + "vcmi.lobby.pvp.randomTown.help" : "Write a random city in the chat", + "vcmi.lobby.pvp.randomTownVs.hover" : "Random town vs.", + "vcmi.lobby.pvp.randomTownVs.help" : "Write two random cities in the chat", "vcmi.client.errors.invalidMap" : "{Invalid map or campaign}\n\nFailed to start game! Selected map or campaign might be invalid or corrupted. Reason:\n%s", "vcmi.client.errors.missingCampaigns" : "{Missing data files}\n\nCampaigns data files were not found! You may be using incomplete or corrupted Heroes 3 data files. Please reinstall game data.", diff --git a/client/lobby/CSelectionBase.cpp b/client/lobby/CSelectionBase.cpp index aefcdf4c0..43fc52234 100644 --- a/client/lobby/CSelectionBase.cpp +++ b/client/lobby/CSelectionBase.cpp @@ -413,28 +413,33 @@ PvPBox::PvPBox(const Rect & rect) return bannedTowns; }; - buttonFlipCoin = std::make_shared(Point(190, 6), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("flip coin"), [](){ + auto buttonColor = CSH->isGuest() ? Colors::WHITE : Colors::ORANGE; + + buttonFlipCoin = std::make_shared(Point(190, 6), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("", CGI->generaltexth->translate("vcmi.lobby.pvp.coin.help")), [](){ LobbyPvPAction lpa; lpa.action = LobbyPvPAction::COIN; CSH->sendLobbyPack(lpa); }, EShortcut::NONE); - buttonFlipCoin->setTextOverlay("Flip coin2", EFonts::FONT_SMALL, Colors::WHITE); + buttonFlipCoin->setTextOverlay(CGI->generaltexth->translate("vcmi.lobby.pvp.coin.hover"), EFonts::FONT_SMALL, buttonColor); + buttonFlipCoin->block(!CSH->isGuest()); - buttonRandomTown = std::make_shared(Point(190, 31), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town"), [getBannedTowns](){ + buttonRandomTown = std::make_shared(Point(190, 31), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("", CGI->generaltexth->translate("vcmi.lobby.pvp.randomTown.help")), [getBannedTowns](){ LobbyPvPAction lpa; lpa.action = LobbyPvPAction::RANDOM_TOWN; lpa.bannedTowns = getBannedTowns(); CSH->sendLobbyPack(lpa); }, EShortcut::NONE); - buttonRandomTown->setTextOverlay("random town", EFonts::FONT_SMALL, Colors::WHITE); + buttonRandomTown->setTextOverlay(CGI->generaltexth->translate("vcmi.lobby.pvp.randomTown.hover"), EFonts::FONT_SMALL, buttonColor); + buttonRandomTown->block(!CSH->isGuest()); - buttonRandomTownVs = std::make_shared(Point(190, 56), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town vs"), [getBannedTowns](){ + buttonRandomTownVs = std::make_shared(Point(190, 56), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("", CGI->generaltexth->translate("vcmi.lobby.pvp.randomTownVs.help")), [getBannedTowns](){ LobbyPvPAction lpa; lpa.action = LobbyPvPAction::RANDOM_TOWN_VS; lpa.bannedTowns = getBannedTowns(); CSH->sendLobbyPack(lpa); }, EShortcut::NONE); - buttonRandomTownVs->setTextOverlay("random town vs", EFonts::FONT_SMALL, Colors::WHITE); + buttonRandomTownVs->setTextOverlay(CGI->generaltexth->translate("vcmi.lobby.pvp.randomTownVs.hover"), EFonts::FONT_SMALL, buttonColor); + buttonRandomTownVs->block(!CSH->isGuest()); } FactionSelector::FactionSelector(const Point & loc) diff --git a/server/NetPacksLobbyServer.cpp b/server/NetPacksLobbyServer.cpp index 3c6c81678..da3184e97 100644 --- a/server/NetPacksLobbyServer.cpp +++ b/server/NetPacksLobbyServer.cpp @@ -372,32 +372,32 @@ void ApplyOnServerNetPackVisitor::visitLobbyForceSetPlayer(LobbyForceSetPlayer & void ApplyOnServerNetPackVisitor::visitLobbyPvPAction(LobbyPvPAction & pack) { - std::vector allowedFactions; + std::vector allowedTowns; - VLC->townh->forEach([pack, &allowedFactions](const Faction *entity, bool &stop){ + VLC->townh->forEach([pack, &allowedTowns](const Faction *entity, bool &stop){ if(!entity->hasTown()) return; if(std::find(pack.bannedTowns.begin(), pack.bannedTowns.end(), entity->getId()) == pack.bannedTowns.end()) { - allowedFactions.push_back(entity->getId()); + allowedTowns.push_back(entity->getId()); } }); std::vector randomFaction1; - std::sample(allowedFactions.begin(), allowedFactions.end(), std::back_inserter(randomFaction1), 1, std::mt19937{std::random_device{}()}); + std::sample(allowedTowns.begin(), allowedTowns.end(), std::back_inserter(randomFaction1), 1, std::mt19937{std::random_device{}()}); std::vector randomFaction2; - std::sample(allowedFactions.begin(), allowedFactions.end(), std::back_inserter(randomFaction2), 1, std::mt19937{std::random_device{}()}); + std::sample(allowedTowns.begin(), allowedTowns.end(), std::back_inserter(randomFaction2), 1, std::mt19937{std::random_device{}()}); switch(pack.action) { case LobbyPvPAction::COIN: srv.announceTxt("Coin - " + std::to_string(std::rand()%2)); break; case LobbyPvPAction::RANDOM_TOWN: - if(allowedFactions.size()) - srv.announceTxt("Faction - " + VLC->townh->getById(randomFaction1[0])->getNameTranslated()); + if(allowedTowns.size()) + srv.announceTxt("Town - " + VLC->townh->getById(randomFaction1[0])->getNameTranslated()); break; case LobbyPvPAction::RANDOM_TOWN_VS: - if(allowedFactions.size()) - srv.announceTxt("Factions - " + VLC->townh->getById(randomFaction1[0])->getNameTranslated() + " vs. " + VLC->townh->getById(randomFaction2[0])->getNameTranslated()); + if(allowedTowns.size()) + srv.announceTxt("Towns - " + VLC->townh->getById(randomFaction1[0])->getNameTranslated() + " vs. " + VLC->townh->getById(randomFaction2[0])->getNameTranslated()); break; } result = true;