Author Topic: PHP Utilities for PvPGN (Ladder Stats)  (Read 216071 times)

Offline USA~Archer

  • Grunt
  • ***
  • Posts: 158
  • Don't shoot the sheep!
    • View Profile
PHP Utilities for PvPGN (Ladder Stats)
« Reply #15 on: April 21, 2015, 11:51:33 AM »
Tupac,

I dont see it in bnetd.conf

The storage option section is only for storing accounts in db, which i have set to store in mysql but reports doesnt have a db option


Sent from my iPhone using Tapatalk

Offline Certified MENSA Genius Brain (smart)

  • "The Architect"
  • Global Moderator
  • Dragon
  • *****
  • Posts: 5384
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #16 on: April 21, 2015, 05:45:33 PM »
hmm yteah i wrote the ladder without ever learning how to program.  frostbitten made the stylesheet.  il came in and cleaned up the ladder code to a degree.  there was a player recently that asked to see the script and i said sure and mousetopher sent it to him, he was planning to see if he could add in a skill rating.  havent heard anything about it.  usa~archer is talking about wanting to look at our custom ladder?  or about some sort of pvpgn ladder?
    

Offline USA~Archer

  • Grunt
  • ***
  • Posts: 158
  • Don't shoot the sheep!
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #17 on: April 21, 2015, 07:19:15 PM »
Your custom ladder, the pvpgn ladder i installed on my own server to play with it but it isnt what we need.

iL said its best to rewrite oldgames.php from start so thats what were working on but still curious to see your code

How did u write it without knowing how to? Code generator of some kind?


Sent from my iPhone using Tapatalk

Offline mousEtopher

  • Administrator
  • Ogre Mage
  • *****
  • Posts: 2065
    • View Profile
    • War2.me
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #18 on: April 21, 2015, 08:58:09 PM »
Maybe that he never sat down and formally "learned" any programming language? It's not really necessary, I only really know the PHP & SQL I've picked up from working with WP and was still able to figure out War2TV and some other crap. Programming languages all basically do the same thing, the important part is figuring out the necessary logic to make something work, then it's just a matter of Googling the syntax to make it happen.

So, if pvpgn can be configured to output reports directly to mysql then that's the way to go for sure. Writing the script to retrieve them from the db based on date or whatever would be sooper easy.

Tupac,

I dont see it in bnetd.conf

The storage option section is only for storing accounts in db, which i have set to store in mysql but reports doesnt have a db option


I think this is right though. Even so, it'd also be sooper easy to process the report files and put them into a db. The two main concerns are 1) making it efficient (iL said there's like 200k old report files to deal with?) and 2) making it secure. But even factoring that in, I don't think it'd be hard.
squeak!

Offline USA~Archer

  • Grunt
  • ***
  • Posts: 158
  • Don't shoot the sheep!
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #19 on: April 21, 2015, 09:39:16 PM »
So instead of reworking pvpgn to save gr's to db, you think it would be easier to make some kind of script that reads past, current, and future gr's, and imports them to db?

Im taking some classes at teamtreehouse.com right now on PHP + MySQL


Sent from my iPhone using Tapatalk

Offline mousEtopher

  • Administrator
  • Ogre Mage
  • *****
  • Posts: 2065
    • View Profile
    • War2.me
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #20 on: April 21, 2015, 10:09:07 PM »
If pvpgn doesn't already support exporting reports to db, then yes. (coming from someone who knows nothing about C but a little about PHP). I have no idea how you expect to write a script that reads reports for games that haven't happened yet though. :D 
squeak!

Offline USA~Archer

  • Grunt
  • ***
  • Posts: 158
  • Don't shoot the sheep!
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #21 on: April 21, 2015, 10:18:05 PM »
Ok makes sense.

Lol @ future games



Sent from my iPhone using Tapatalk

Offline Delete mine too

  • Death Knight
  • *********
  • Posts: 2652
  • http://meatspin.com
    • View Profile
    • http://meatspin.com
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #22 on: April 21, 2015, 11:02:09 PM »
Edit the pvpgn source I looking into this now I have more time.

Offline USA~Archer

  • Grunt
  • ***
  • Posts: 158
  • Don't shoot the sheep!
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #23 on: April 21, 2015, 11:11:31 PM »
Cool


Sent from my iPhone using Tapatalk

Offline Certified MENSA Genius Brain (smart)

  • "The Architect"
  • Global Moderator
  • Dragon
  • *****
  • Posts: 5384
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #24 on: April 22, 2015, 12:37:39 AM »
Your custom ladder, the pvpgn ladder i installed on my own server to play with it but it isnt what we need.

iL said its best to rewrite oldgames.php from start so thats what were working on but still curious to see your code

How did u write it without knowing how to? Code generator of some kind?
learned php as i went along.  as a result the code worked but wasn't very clean or efficient but il might have fixed that stuff.  ive forgotten all php since then. 
    

Offline Certified MENSA Genius Brain (smart)

  • "The Architect"
  • Global Moderator
  • Dragon
  • *****
  • Posts: 5384
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #25 on: April 22, 2015, 12:41:54 AM »
the code i wrote uses entirely publicly available info, it literally does not use a single thing you need admin access for.  goes to somewhere like this: http://reportb.war2.ru/, and opens all the unchecked reports, parses them, and adds them to its own db.

if pvpgn just outputs game results direct to a db the coding couldve been a lot easier heh
    

Offline iL

  • Administrator
  • Ogre Mage
  • *****
  • Posts: 1650
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #26 on: April 22, 2015, 05:58:30 AM »
I think the first thing that needs to be done is to have PvPGN store the game data in the database instead of text files

Once the data is stored in a database, we can work on writing PHP to talk to the db and display game data more efficiently

So far I dont know how to do either of those things however...

AFAIK PvPGN have no option to store it's log in DB. So we should make a report parser ourselves.
To parse the report and upload it's data to DB.
the code i wrote uses entirely publicly available info, it literally does not use a single thing you need admin access for.  goes to somewhere like this: http://reportb.war2.ru/, and opens all the unchecked reports, parses them, and adds them to its own db.

Yes, exactly, this reportb should be used with parser.
Also note that these reports should contain different languages depend on war2-client language: english (usual), german (for some clients), russian (for russian combat), spanish (for spanish build) and maybe several more.

I think the 1-st thing we need is parser function.
Proper function should return one of 3 values:
- success, when the game parsed and result is inside the DB
- broken report, when game parsed but script detected an error in the report
- parse error, when game has not been parsed but not sure if it's error script or not. A reason to check and debug the script.

Also, it should parse all the games: were people have been dropped, used different languages and played 1v1, 2v5, 4v4 or any others.
That is how i see this.

Also, i dislike current database format and prefer to refactor it also.
I think about 2 main tables:
- games with all game parameters (name, id, type, option, 3 dates, map, mapauth, mapsize, tile, joins, maxplayers, minutes).
- players - the table contains each player in each game (game_id, player_order, name, race, WIN_LOSS_DISC, map, play_time, language, score, units, structures, resources, etc...)
I mean everyting except maybe normal/ladder/iron records as not related to the game.

Maybe several more tables needed to improve performance and size: player_name2id, map_name2id, etc.

Any your offers about DB structure are welcomed also.
iL said its best to rewrite oldgames.php from start so thats what were working on but still curious to see your code

Yes, i mean oldgames and ladder stats have common part for report parsing, that part is non-trival, so looks reasonable to use the same code for both projects.
Also would be much easier to read oldgames from DB when we upload data to it.
« Last Edit: April 22, 2015, 06:07:56 AM by iL »
Need help to translate War2Combat to German, French, Italian, Polish or another language: http://forum.war2.ru/index.php/topic,4728.0.html
Please, contact me if you are interested in that.

Offline iL

  • Administrator
  • Ogre Mage
  • *****
  • Posts: 1650
    • View Profile
Re: PHP Utilities for PvPGN (Ladder Stats)
« Reply #27 on: April 22, 2015, 06:00:47 AM »
In addition to previous:
good idea for parsing based on templates and scanf. I'd go that way for the game parsing:
https://code.google.com/p/hwstats/
hwstats_2.35f-sc.zip
Check scripts/parse_reports.php:
Code: [Select]
function LoadReport($filename, $template)
{
    $template = file_get_contents($template);
    $content = file_get_contents($filename);
....
    $ri = sscanf( $content, $template ); // report info
...
    $info=array(
        //game info
        "GameName" => $ri[0],
        "GameID" => $ri[1],
        "ClientTag" => $ri[2],
        "GameType" => GetGameOption($ri[3]),
...
there's for 2 players only, we need up to 8.
Need help to translate War2Combat to German, French, Italian, Polish or another language: http://forum.war2.ru/index.php/topic,4728.0.html
Please, contact me if you are interested in that.