[DiscordArchive] Yeah, your code made this easy. But how should GetCompletedAchievementsCount act? Do I include or om
[DiscordArchive] Yeah, your code made this easy. But how should GetCompletedAchievementsCount act? Do I include or om
Archived author: syco • Posted: 2023-09-17T16:19:49.547000+00:00
Original source
Yeah, your code made this easy. But how should GetCompletedAchievementsCount act? Do I include or omit like blizzard does?
Archived author: Roboto • Posted: 2023-09-17T16:22:15.013000+00:00
Original source
I'd do an optional boolean argument `countFeatsOfStrength`
Archived author: Roboto • Posted: 2023-09-17T16:22:19.155000+00:00
Original source
would be false by default
Archived author: syco • Posted: 2023-09-17T17:46:40.998000+00:00
Original source
Added the optional argument, not sure if code structure is correct.
ush(L, count);Archived author: syco • Posted: 2023-09-17T17:50:26.887000+00:00
Original source
```c
int GetCompletedAchievementsCount(lua_State* L, Player* player)
{
uint32 count = 0;
bool countFeatsOfStrength = Eluna::CHECKVAL<bool>(L, 2, false);
const CompletedAchievementMap& completedAchievements = player->GetAchievementMgr()->GetCompletedAchievements();
for (auto& pair : completedAchievements)
{
AchievementEntry const* achievement = sAchievementStore.LookupEntry(pair.first);
if (achievement && countFeatsOfStrength == false)
{
if (achievement->categoryId != 81)
{
count++;
}
}
else if (achievement)
{
count++;
}
}
Eluna:
ush(L, count);
return 1;
}
```
![[Image: image.png?ex=690c3903&is=690ae783&hm=962...97f2477a8&]](https://cdn.discordapp.com/attachments/448835144564867094/1153027201818693763/image.png?ex=690c3903&is=690ae783&hm=9621fa90bfc44d47a8613480e3540c063e62912738522aa60890f7f97f2477a8&)
Archived author: syco • Posted: 2023-09-17T17:58:27.168000+00:00
Original source
![[Image: image.png?ex=690c3903&is=690ae783&hm=962...97f2477a8&]](https://cdn.discordapp.com/attachments/448835144564867094/1153027201818693763/image.png?ex=690c3903&is=690ae783&hm=9621fa90bfc44d47a8613480e3540c063e62912738522aa60890f7f97f2477a8&)
Archived author: Roboto • Posted: 2023-09-17T18:15:27.188000+00:00
Original source
You can trim it down a bit. If my bool algebra is correct:
```cpp
AchievementEntry const* achievement = sAchievementStore.LookupEntry(pair.first);
if (achievement && (achievement->categoryId != 81 || countFeatsOfStrength))
{
count++;
}
```