anmonite / wows-stats-plus

Battle match statistics viewer for World of Warships
MIT License
23 stars 9 forks source link

WTR and PR not displayed correctly #13

Closed phoebustam closed 4 years ago

phoebustam commented 5 years ago

Hello, the WTR and PR have been displayed incorrectly for quite a while. Whenever I start a match, all players are set to 300 WTR and NaN PR, I have tried to study the codes but I had difficulty understanding them. I wonder how could I solve this issue?

anmonite commented 5 years ago

Thanks for opening this issue.

Please turn off the setting to display WTR and PR in temporal.

To calculate WTR and PR, my app need to get a json file from Warships.Today site at the first time of starting app. The json file contains coefficient data (av. damage/ av. exp/ av. destroy and so on) for all ships.

But unfortunately, Warships.Today site have been stopping to update coefficient data since early January. We can still download the coefficient json file but it has empty data field. And It seems that Warships.Today site is no longer fix it. (This may be come from changing specification of WG API server...)

So I decide to reject WTR parameter from my app in the next release. But I will keep to use PR parameter. And I will refine my code to backup download file and check it correct or not. Then use the backup file instead of new file if the download process fail or the file contains illegal data.

And I know the other issues. For example, change the specification of setting the replay file path on game client...

I will release new version of my app in later March or middle April.

Thanks.

phoebustam commented 5 years ago

Thank you for all the hard work. It seems that WarshipsToday's site is down for now, but I wonder if it is possible to retrieve PR directly from wows-numbers, so that the calculation part could be bypassed? Thanks in advance for the continuation of the project.

anmonite commented 5 years ago

WoWs Stats & Numbers has a expression page for PR value. https://asia.wows-numbers.com/personal/rating/

And this page contains a link to json file of expected values for each ship.

RaySmith07 commented 5 years ago

Thanks for the response ! I will try again in March/April to see if it is working again, as it is a great App !

phoebustam commented 5 years ago

Hi, I wonder if there is an update to the issue?

anmonite commented 5 years ago

Because of other many enhancement item, the plan to release new version of app is postponed until middle of May.

I'm sorry for all of users about delay of my development progress.

phoebustam commented 5 years ago

Thank you for the response, I'm sure all the users would be pleased to wait for a new update. :)

anmonite commented 5 years ago

Because I have been facing several technical issues when I would resolve the technical debt in my app about upgrading AngularJS from 1.5.6 to 1.7.8 and also jQuery from 1.12.3 to 3.4.1, my development schedule have to be rescheduled.

I will release next version maybe until early of June.

Sorry for the delay.

phoebustam commented 5 years ago

Noted with thanks. We appreciate your continuing support of the app.

phoebustam commented 5 years ago

Hi, just passing by to see if there is any progress at all. :)

anmonite commented 5 years ago

I'm sorry for the late release. Since around June, I have never had enough time to correct several unknown and critical degraded problems. And this situation will continue until end of next month.

Please wait for next version with patience (;´Д`) Sorry for inconvenience.

phoebustam commented 5 years ago

Thank you for the reply, I am sorry to hear about your difficulties. While I might not be able to offer any help, I would like to express my gratitude towards your dedication to the project.

phoebustam commented 5 years ago

wows-stats-plus-fixed With my knowledge on JS, JQuery, and Java learned at work, I re-read what you said and substituted the coefficients JSON provided by wows-numbers and replacing the WTR one. Then changed the variable names in the calculatePersonalRating() method. I ended up getting the PR column working again. Unfortunately the JSON does not have the information WTR calculation need so there is no hope reviving the column.

I personally like the CSS colors of WTR more so I will move the PR CSS color onto WTR on my own :)

anmonite commented 5 years ago

Nice works!

Yes. To change to use the expected JSON file by wows-numbers site, you need to change some points in "index,js" and "static/js/app.js" and also "static/js/calculatePersonalRating.js" as follows.

1- Replace "update_WTRcoefficientsJSON()" to "update_PRexpectedJSON() " in "index,js"

function update_PRexpectedJSON() {

    var req_options = {
        // need change both REGION and LANG to your region and language 
        url: 'https://REGION.wows-numbers.com/LANG/personal/rating/expected/json/',
        method: 'GET',
        json: true
    }
    request(req_options, function(error, response, body) {
        if ((!error && response.statusCode == 200) || (!error && response.statusCode == 304)) {
            console.log('Got expected json file for PR.');

            if (body.data != null) {
                fs.writeFile('static/js/expected.json', JSON.stringify(body, null, '    '), (err) => {
                    if (!err) {
                        console.log('Download & Overwrite completed as \'./static/js/expected.json\'.');

                        // copy json file as a stable
                        fs.copyFileSync('static/js/expected.json', 'static/js/expected_stable.json');
                        console.log('Success copy to \'expected_stable.json\'.');
                    } else {
                        console.log("Overwrite error './static/js/expected.json'. : %s", err);

                        // rollback expected.json from stable one
                        fs.copyFileSync('static/js/expected_stable.json', 'static/js/expected.json');
                        console.log('Success replace expected json file from stable one.');
                    }
                });
            } else {
                console.log('empty expected list');

                // rollback expected.json from stable one
                fs.copyFileSync('static/js/expected_stable.json', 'static/js/expected.json');
                console.log('Success replace expected json file from stable one.');
            }
        } else {
            console.log('Error getting expected data.');

            // rollback expected.json from stable one
            fs.copyFileSync('static/js/expected_stable.json', 'static/js/expected.json');
            console.log('Success replace expected json file from stable one.');
        }
    });
}
update_PRexpectedJSON();

Above code contains file backup functionality to prepare missing expected JSON file.

2- Replace "get_WTRcoefficientsShipList()" to "get_PRexpectedShipList()" and change the label strings "coefficients" to "expected" in "app.js".

var coefficientsList = {}; ↓ var expectedList = {};

var ready_coefficients = false; ↓ var ready_expected = false;

function get_PRexpectedShipList() {
    var sync_getExpectedShipList = new Promise (function (resolve, reject) {
        $.getJSON('js/expected.json', function(data) {
            if (data.status = 'ok') {
                expectedList = data.data;
                if (expectedList != null) {
                    resolve();
                }   else {
                    reject();
                }
            } else {
                reject();
            }
        });
    });

    sync_getExpectedShipList.then ( function () {
        ready_expected = true;
    });
}

// loading WTR coefficients table get_WTRcoefficientsShipList(); ↓ // loading PR expected value table get_PRexpectedShipList();

// view handling after sync-loaded of languages.json & shipname covert table & stats site list & WTR expected data
if (ready_lang && ready_shipTable &&  ready_siteList && ready_coefficients) {
↓
// view handling after sync-loaded of languages.json & shipname covert table & stats site list & PR expected data
if (ready_lang && ready_shipTable && ready_siteList && ready_expected) {

3- Change value name and constant numeric in "calculatePersonalRating.js".

var calculatePersonalRating = function(expected, actual) {
    var wins = (actual.wins * 100) / expected.win_rate;
    var damage = actual.damage_dealt / expected.average_damage_dealt;
    var frags = actual.frags / expected.average_frags;

maybe, that's all to use PR expected JSON to show PR data properly.

I have already written these code changes in WIP version. I'm sorry for bothering with you.

phoebustam commented 5 years ago

Yeah the codes above are all it takes to refined the codes for PR compatibility. My work just desperately made PR work and ignored the entire WTR part lol. The JSON backup functionality is awesome, such that the program still functions even if the wows-numbers site is down. It would be really helpful for other people if you could include the above codes in a new commit :) Cheers!

anmonite commented 5 years ago

I have to let you know a sad announcement.

My PC have been in power suply related trouble (I could't specified where part is damaged ... power module. mother board or HDD) since this spring. But I have been working software development as my buisuness with my unstable PC. I had planned to enhance of this app after completion my several buisuness works.

But today, my PC was down in no operation time. This means my entire devlopment working progress will be long delayed more than ever.

I'm sorry for all of you about this situation.

phoebustam commented 5 years ago

I'm sorry to hear that your computer is nonoperational. As a developer myself I feel the pain to live without a computer. Meanwhile as I got that PR thingy kind of fixed, the issue isn't so urgent. However, I have got another issue with PR, which I don't really understand. I checked the weightings in the app and on wows-numbers site, and the settings were identical, but when I compare the stats shown in the app and on wows-numbers' site, they are quite different, in fact, fluctuated quite seriously. Here is an example: wows stats plus - Google Chrome 2019_10_7 10_27_56 QQ截图20191007102933 The PR is a level down in the app, then the actual value. There must be some calculation mistake involved but the algorithm are the same. I had no idea how to fix this.

phoebustam commented 5 years ago

Got the problem. I printed out the values in calculatePR.js and I discovered that the actual.wins was in 0-1 format, while the expected.win_rate was in percentage format. This will cause normalize_wins to be zero and eliminating the entire win factor. Multiplying actual.wins by 100 solved the problem.

anmonite commented 5 years ago

Yes. I had known about wins value difference between wows-numbers and warships,today in JSON file.

So I pointed out code changing in the bottom of my message.

3- Change value name and constant numeric in "calculatePersonalRating.js".

var calculatePersonalRating = function(expected, actual) {
  var wins = (actual.wins * 100) / expected.win_rate;
  var damage = actual.damage_dealt / expected.average_damage_dealt;
  var frags = actual.frags / expected.average_frags;
phoebustam commented 5 years ago

Uhh... Sorry about that. Ever since I made changes in the code myself and had the PR working again I did not make further changes you mentioned above. Yeah you are right that was how I fixed it.

phoebustam commented 5 years ago

stats Sorry for spamming in this post. I'm kind of addicted in modifying the app myself. I found some useful statistics offered by the official API, so I included them in my version of the app. Perhaps I should have forked your project and upload my source code, or maybe make pull requests too. But I do not really pledge to maintain the app myself :\

anmonite commented 5 years ago

Ya, I also could implement all useful value in my app :) But if done so, it needs many static pixel width of browser window. I designed the layout of my app based on full HD screen size(1920x1080), but I also knew several percentage users use under 1440px width screen size. So I selected current most useful values.

However, I have already planned to add a new statistic of the accuracy of main guns in the next version :) And also I will change the calculation of combat power with taking into the percentage of sinking ships. I believe this change will indicate the player skill more accurate than current one.

Thanks,

phoebustam commented 5 years ago

I do recognize that the app itself would slightly adjust the fields if there is not enough room for each columns. However, if one is using a smaller monitor, they would really have to sacrifice some fields by using the display settings themselves. After all, the number of fields to display is customizable. It would be better to give people with more options what they would like to see (if the API offers), and it is entirely up to them to choose what to exclude.

phoebustam commented 5 years ago

I finally decided to fork your project and upload my codes. Though the code are dirty, as I did not remove the WTR-related codes, and instead, I blocked users from accessing them. Maybe I'll clean them up later when I have time. Meanwhile I also got the Ranked value fixed. I tried to adapt to server changes too, for cross-realm clan battles, but I did not succeed. Kind of stuck with the request function (I need the request to call itself with a different URL which I can retrieve from an array, but I can't).

anmonite commented 4 years ago

Fix this issue on version 1.2.0.