Displaying Ties and OTL in Records
mamamia5x opened this issue · 4 comments
So I was playing hockey GM with a league that allowed OTL's and ties. When displaying the record, there is no distinction from OTL and ties if you have 0 OTL and 1 or more ties. Like in my case, I have one tie and no OTL's. The record is really confusing then, making me believe that I have 1 OTL, not 1 tie.
let record = `${won}-${lost}`;
if (typeof otl === "number" && !Number.isNaN(otl) && otl > 0) {
record += `-${otl}`;
}
if (typeof tied === "number" && !Number.isNaN(tied) && tied > 0) {
if (typeof otl === "number" && !Number.isNaN(otl) && otl == 0){
record += `-${otl}`;
}
record += `-${tied}`;
}
I figured out how to change this in the helper.js
file at line 1337 with the code above. It now displays like this:
This was my type of fix, which works on my roster page. This doesn't work on the dashboard page and draft lottery page, and I can't seem to figure out what else generates the record text.
What other files need to be changed in other for the records to be displayed properly?
Yeah it's confusing to format records with OTL and ties enabled. Not sure if any IRL leagues have both, and if so how they show them?
You did find the correct place to change how records are formatted, the formatRecord
function in helpers.ts. And you are also correct that it doesn't seem to work everywhere. That's because originally formatRecord
didn't exist and the records were just formatted inline everywhere, and when I wrote formatRecord
I tried to use it everywhere, but clearly I missed some places. The solution would be to change those places to use formatRecord
.
So far you identified these places:
zengm/src/ui/views/LeagueDashboard/index.tsx
Lines 94 to 96 in 7372599
zengm/src/ui/views/DraftLottery.tsx
Lines 212 to 214 in 7372599
And I also found this similar one from a quick search of the codebase:
zengm/src/ui/views/Trade/index.tsx
Lines 384 to 386 in 7372599
If you want to send a PR to fix this, feel free! If not, let me know and I'll fix it myself - it's an easy fix for me, but if you want to have fun and try to do it yourself, you can :)
I'll try myself, I could use the experience with TS
Going through the files, this fix also shows when OTL's are disabled. In a league where there are ties and no OTL's, it'll display 5-2-0-1
instead of 5-2-1
for example. Is there a quick way for me to check if OTL is enabled?
Edit: or is there a way to store OTL's as null (when its disabled), then check if the value is null?
No, there's two complications:
- the UI process doesn't have access to the otl setting currently
- the history of the otl setting isn't currently stored, so just looking at the current setting
Both of those could be solved relatively easily, but there's another problem:
- settings with history do not have history exposed to the ui currently
That would be a bit more work to fix.
And I'm not inclined to do any of this, because the current formatRecord behavior works good enough and doesn't require it. Sorry if that makes things worse for your version :)