azerothcore-wotlk icon indicating copy to clipboard operation
azerothcore-wotlk copied to clipboard

Character Statistics - Average Gold Earned Per Day Incorrect

Open Azcobu opened this issue 3 years ago • 3 comments

WHAT CLIENT DO YOU PLAY ON?

  • [ ] enGB
  • [x] enUS
  • [ ] other (specify)
FACTION
  • [ ] Alliance
  • [x] Horde
CONTENT PHASE:
  • [x] Generic
  • [ ] 1-19
  • [ ] 20-29
  • [ ] 30-39
  • [ ] 40-49
  • [ ] 50-59
CURRENT BEHAVIOUR:

Original report: https://github.com/chromiecraft/chromiecraft/issues/1168

In the statistics tab, the average gold earned per day does not scale with time.

Picture from Chromiecraft: image

@jamadaha adds: The same thing occurs on my character. (Unedited Chromiecraft instance on active server) image

Tester: confirmed, same issue on various characters I checked.

WoWScrnShot_071221_222124 WoWScrnShot_071221_221646

EXPECTED BLIZZLIKE BEHAVIOUR:

Average gold earned per day should be total gold aquired divided by the number of days since your character was created.

SOURCE:

image Picture from Retail

STEPS TO REPRODUCE THE PROBLEM:
  1. Have a character older than 1 day.
  2. View statistics -> Wealth.
EXTRA NOTES:
AC HASH/COMMIT:

https://github.com/chromiecraft/azerothcore-wotlk/commit/7c21d567d59153b37978756a5bf02daf6998e665

OPERATING SYSTEM:

Ubuntu 20.04

MODULES:
OTHER CUSTOMIZATIONS:

None.

SERVER:

ChromieCraft


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Azcobu avatar Jul 12 '21 13:07 Azcobu

This issue is due to the achievement flag ACHIEVEMENT_FLAG_AVERAGE not being implemented at all. It would need to grab the creation date of the character from the characters table/DB, have the criteria divided by the days since that date (since it's stored in timestamp) and send it to the client that way. The criteria (I don't think) can't be stored in the DB, since according to the Achievement.DBC, this particular statistic shares its criteria with the total gold earned statistic as well.

heyitsbench avatar Aug 26 '22 07:08 heyitsbench

Worth pointing out, this issue also applies to the statistics Average daily quests completed per day and Average quests completed per day.

heyitsbench avatar Aug 28 '22 05:08 heyitsbench

This will be fixed in https://github.com/azerothcore/azerothcore-wotlk/pull/12255 once all details are resolved.

ZhengPeiRu21 avatar Sep 06 '22 18:09 ZhengPeiRu21

Since #12255 "Average gold earned per day" can actually show a different value than "Total gold aquired"

But since this issue was still open I went on to check if it actually shows the correct average value.

  • tested on e2eef0631

  • achievement 753 ("Average gold earned per day") has 4 relevant achievement criteria:

4091 ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS
4092 ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD
4093 ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY
4225 ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS
```	

observations:
- for each achievement_criteria a timestamp is beeing stored in character_achievement_progress
- the average is calcluated based on the LOWEST timestamp of all referenced criteria (4091, 4092, 4093, 4225)
-> then "Total gold aquired" is divided by the difference of time(now) minus the LOWEST timestamp, then rounded down, so basically:

`gold_average = gold_total / floor((time(now) - time(criteria_lowest)) * IN_DAYS)`

- since these achievement criteria will not be created in character_achievement_progress before any gold is earned, these dates are usually LATER than the character creation

- also the criteria date ALWAYS gets updated when the criteria itself gets updated (e.g. new gold is earned)

---

**HOW TO REPRODUCE:**
- create character
- loot some gold from creatures (don't earn any other gold)
- wait 2-3 days (or update timestamp in character_achievement_progress for ID 4093 to (NOW minus 3 days))
- login
- observe correct "Average gold earned per day" in statistics
- loot some more gold from creatures
- logout
-> this will update the timestamp in character_achievement_progress for ID 4093 to NOW
- login
- observe "Total gold aquired" == "Average gold earned per day"

---

conclusion:
- issue confirmed @Kitzunu 
- "Average gold earned per day" is showing incorrect values and needs to be fixed

---

How to fix?
- for achievement criteria of type AVERAGE the timestamp should be set on character creation and not changed anymore
-> would you agree?

sudlud avatar Sep 12 '23 12:09 sudlud

gold_average = gold_total / (total_played_time * IN_DAYS)

Something like this should be the correct calculation from what I can tell

Kitzunu avatar Sep 12 '23 14:09 Kitzunu