Skip to content

Commit f0330c4

Browse files
committed
refactor: Use StringFormat()
1 parent 8ca0dff commit f0330c4

File tree

1 file changed

+17
-46
lines changed

1 file changed

+17
-46
lines changed

src/mod_zone_difficulty_scripts.cpp

+17-46
Original file line numberDiff line numberDiff line change
@@ -767,28 +767,23 @@ class mod_zone_difficulty_rewardnpc : public CreatureScript
767767
{
768768
npcText = NPC_TEXT_DENIED;
769769
SendGossipMenuFor(player, npcText, creature);
770-
std::string whisper;
771-
whisper.append("I am sorry, time-traveler. This reward costs ");
772-
whisper.append(std::to_string(sZoneDifficulty->TierRewards[category].Price));
773-
whisper.append(" score but you only have ");
774-
whisper.append(std::to_string(availableScore));
775-
whisper.append(" ");
776-
whisper.append(sZoneDifficulty->GetContentTypeString(category));
770+
std::string whisper = Acore::StringFormat("I am sorry, time-traveler. This reward costs {} score but you only have {} {}",
771+
sZoneDifficulty->TierRewards[category].Price,
772+
availableScore,
773+
sZoneDifficulty->GetContentTypeString(category));
774+
777775
creature->Whisper(whisper, LANG_UNIVERSAL, player);
778776
return true;
779777
}
780778
npcText = NPC_TEXT_CONFIRM;
781779
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(sZoneDifficulty->TierRewards[category].Entry);
782-
std::string gossip;
783780
std::string name = proto->Name1;
784781

785782
if (ItemLocale const* leftIl = sObjectMgr->GetItemLocale(sZoneDifficulty->TierRewards[category].Entry))
786783
ObjectMgr::GetLocaleString(leftIl->Name, player->GetSession()->GetSessionDbcLocale(), name);
787784

788-
gossip.append("Yes, ").append(name).append(" is the item i want.");
789785
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "No!", GOSSIP_SENDER_MAIN, 999998);
790-
AddGossipItemFor(player, GOSSIP_ICON_VENDOR, gossip, GOSSIP_SENDER_MAIN, 99001000 + category);
791-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: AddingGossipItem with action {}", 99001000 + category);
786+
AddGossipItemFor(player, GOSSIP_ICON_VENDOR, Acore::StringFormat("Yes, {} is the item I want.", name), GOSSIP_SENDER_MAIN, 99001000 + category);
792787
SendGossipMenuFor(player, npcText, creature);
793788
return true;
794789
}
@@ -800,24 +795,16 @@ class mod_zone_difficulty_rewardnpc : public CreatureScript
800795
{
801796
npcText = NPC_TEXT_CATEGORY;
802797
if (sZoneDifficulty->HasCompletedFullTier(action, player->GetGUID().GetCounter()))
803-
{
804-
std::string gossip = "I want to redeem the ultimate Mythicmode reward ";
805-
gossip.append(sZoneDifficulty->GetContentTypeString(action));
806-
AddGossipItemFor(player, GOSSIP_ICON_MONEY_BAG, gossip, GOSSIP_SENDER_MAIN, 99000000 + action);
807-
}
798+
AddGossipItemFor(player, GOSSIP_ICON_MONEY_BAG, Acore::StringFormat("I want to redeem the ultimate Mythicmode reward {}", sZoneDifficulty->GetContentTypeString(action)), GOSSIP_SENDER_MAIN, 99000000 + action);
808799

809800
uint32 i = 1;
810801
for (auto& itemType : sZoneDifficulty->Rewards[action])
811802
{
812-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: typedata.first is {}", itemType.first);
813-
std::string gossip;
814803
std::string typestring = sZoneDifficulty->GetItemTypeString(itemType.first);
815804
if (sZoneDifficulty->ItemIcons.find(i) != sZoneDifficulty->ItemIcons.end())
816-
{
817-
gossip.append(sZoneDifficulty->ItemIcons[i]);
818-
}
819-
gossip.append("I am interested in items from the ").append(typestring).append(" category.");
820-
AddGossipItemFor(player, GOSSIP_ICON_CHAT, gossip, GOSSIP_SENDER_MAIN, itemType.first + (action * 100));
805+
AddGossipItemFor(player, GOSSIP_ICON_CHAT, Acore::StringFormat("{} I am interested in items from the {} category.", sZoneDifficulty->ItemIcons[i], typestring), GOSSIP_SENDER_MAIN, itemType.first + (action * 100));
806+
else
807+
AddGossipItemFor(player, GOSSIP_ICON_CHAT, Acore::StringFormat("I am interested in items from the {} category.", typestring), GOSSIP_SENDER_MAIN, itemType.first + (action * 100));
821808
++i;
822809
}
823810
}
@@ -871,29 +858,23 @@ class mod_zone_difficulty_rewardnpc : public CreatureScript
871858
{
872859
npcText = NPC_TEXT_DENIED;
873860
SendGossipMenuFor(player, npcText, creature);
874-
std::string whisper;
875-
whisper.append("I am sorry, time-traveler. This item costs ");
876-
whisper.append(std::to_string(sZoneDifficulty->Rewards[category][itemType][counter].Price));
877-
whisper.append(" score but you only have ");
878-
whisper.append(std::to_string(sZoneDifficulty->MythicmodeScore[category][player->GetGUID().GetCounter()]));
879-
whisper.append(" ");
880-
whisper.append(sZoneDifficulty->GetContentTypeString(category));
861+
std::string whisper = Acore::StringFormat("I am sorry, time-traveler. This item costs {} but you only have {} {}",
862+
sZoneDifficulty->Rewards[category][itemType][counter].Price,
863+
sZoneDifficulty->MythicmodeScore[category][player->GetGUID().GetCounter()],
864+
sZoneDifficulty->GetContentTypeString(category));
881865
creature->Whisper(whisper, LANG_UNIVERSAL, player);
882866
return true;
883867
}
884868

885869
npcText = NPC_TEXT_CONFIRM;
886870
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(sZoneDifficulty->Rewards[category][itemType][counter].Entry);
887-
std::string gossip;
888871
std::string name = proto->Name1;
889872

890873
if (ItemLocale const* leftIl = sObjectMgr->GetItemLocale(sZoneDifficulty->Rewards[category][itemType][counter].Entry))
891874
ObjectMgr::GetLocaleString(leftIl->Name, player->GetSession()->GetSessionDbcLocale(), name);
892875

893-
gossip.append("Yes, ").append(name).append(" is the item i want.");
894876
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "No!", GOSSIP_SENDER_MAIN, 999998);
895-
AddGossipItemFor(player, GOSSIP_ICON_VENDOR, gossip, GOSSIP_SENDER_MAIN, 100000 + (1000 * category) + (100 * itemType) + counter);
896-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: AddingGossipItem with action {}", 100000 + (1000 * category) + (100 * itemType) + counter);
877+
AddGossipItemFor(player, GOSSIP_ICON_VENDOR, Acore::StringFormat("Yes, {} is the item I want.", name), GOSSIP_SENDER_MAIN, 100000 + (1000 * category) + (100 * itemType) + counter);
897878
}
898879
else if (action > 100000)
899880
{
@@ -923,19 +904,14 @@ class mod_zone_difficulty_rewardnpc : public CreatureScript
923904
return true;
924905

925906
// Check if the player has the neccesary achievement
926-
if (sZoneDifficulty->Rewards[category][itemType][counter].Achievement != 0)
907+
if (sZoneDifficulty->Rewards[category][itemType][counter].Achievement)
927908
{
928909
if (!player->HasAchieved(sZoneDifficulty->Rewards[category][itemType][counter].Achievement))
929910
{
930911
std::string gossip = "You do not have the required achievement with ID ";
931912
gossip.append(std::to_string(sZoneDifficulty->Rewards[category][itemType][counter].Achievement));
932913
gossip.append(" to receive this item. Before i can give it to you, you need to complete the whole dungeon where it can be obtained.");
933914
creature->Whisper(gossip, LANG_UNIVERSAL, player);
934-
/* debug
935-
* LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Player missing achiement with ID {} to obtain item with category {}, itemType {}, counter {}",
936-
* sZoneDifficulty->Rewards[category][itemType][counter].Achievement, category, itemType, counter);
937-
* end debug
938-
*/
939915
CloseGossipMenuFor(player);
940916
return true;
941917
}
@@ -958,15 +934,10 @@ class mod_zone_difficulty_rewardnpc : public CreatureScript
958934

959935
for (auto& typedata : sZoneDifficulty->Rewards)
960936
{
961-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: typedata.first is {}", typedata.first);
962937
if (typedata.first != 0)
963938
{
964-
std::string gossip;
965-
std::string typestring = sZoneDifficulty->GetContentTypeString(typedata.first);
966-
gossip.append("I want to redeem rewards ").append(typestring);
967-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: typestring is: {} gossip is: {}", typestring, gossip);
968939
// typedata.first is the ContentType
969-
AddGossipItemFor(player, GOSSIP_ICON_INTERACT_1, gossip, GOSSIP_SENDER_MAIN, typedata.first);
940+
AddGossipItemFor(player, GOSSIP_ICON_INTERACT_1, Acore::StringFormat("I want to redeem rewards {}", sZoneDifficulty->GetContentTypeString(typedata.first)), GOSSIP_SENDER_MAIN, typedata.first);
970941
}
971942
}
972943

0 commit comments

Comments
 (0)