Stats script for your own server?

All your MAngband related technical questions answered. Problems compiling or running the game/server? No problem! Ask here.
Post Reply
FlyveHest
Nasty Little Gnome
Posts: 24
Joined: Mon 28.07.2008, 18:29

Stats script for your own server?

Post by FlyveHest » Mon 28.07.2008, 19:05

Is it possible to get my hands on the stats scripts that are used on http://www.mangband.org/Main/Statistics ?

I am running a private MAngband server, and would very much like to serve stats like the ones available, but can't seem to find any information on how you do this?

Jug
King Lich
Posts: 342
Joined: Sat 26.10.2002, 15:00
Location: UK
Contact:

Re: Stats script for your own server?

Post by Jug » Mon 28.07.2008, 19:59

No, not currently. The MAngband Project hasn't yet released a "stats script". We have a whole load of interrelated hacks for mangband.org itself, databases based on text file parsers based on cron based on wiki plugins based on custom php hacks based on voodoo based on witchcraft. :-)

For a small private site you may not need to worry about backend SQL databases or such an elaborate system. I recommend you look to the character dumps themselves. The first line is machine readable data which can be easily parsed.

It may be that we package up a series of scripts to do this one day, but we haven't as yet.

FlyveHest
Nasty Little Gnome
Posts: 24
Joined: Mon 28.07.2008, 18:29

Re: Stats script for your own server?

Post by FlyveHest » Wed 30.07.2008, 06:53

The player files are the ones in lib\user\*.txt ?

Would it be possible to get an explanation for the individual fields? (Some are self explanatory, but others are not), or should I grab the source and try and get the information from there?

The highscore is in lib\data\scores.raw ?

I've looked at it in binary form, and it looks pretty easy to parse also, but, a short explanation about what the various "fields" do would very much be appreciated :)

Jug
King Lich
Posts: 342
Joined: Sat 26.10.2002, 15:00
Location: UK
Contact:

Re: Stats script for your own server?

Post by Jug » Wed 30.07.2008, 08:15

Yes, the character dumps are saved in lib/user/ and are named <charactername>-<server-turn>.txt. The combination of character name and server turn gives you a unique key for any given character.

The machine readable line in the dump is the first line, and always begins with "#". Fields are delimited with "|".

Fields are:
  • score
  • gold
  • date died
  • character name
  • sex (m/f)
  • race index
  • class index
  • current character level
  • dungeon depth
  • max character level
  • max dungeon depth
  • killed by
  • mangband version id (1.1.0)
Race Index is an integer 0 to 10, the races are: 'Human','Half-Elf','Elf','Hobbit','Gnome','Dwarf','Half-Orc','Half-Troll','Dunadan','High-Elf','Kobold'

Class Index is an integer 0 to 5, the clases are: 'Warrior','Mage','Priest','Rogue','Ranger','Paladin'

Personally I wouldn't bother parsing the scores.raw file if you are parsing the dumps. We don't touch scores.raw on mangband.org. It works ok more or less in game, but it's broken in some subtle ways which make it unsuitable for a reliable ladder.

FlyveHest
Nasty Little Gnome
Posts: 24
Joined: Mon 28.07.2008, 18:29

Re: Stats script for your own server?

Post by FlyveHest » Wed 30.07.2008, 08:55

Excellent, thanks a lot Jug, really appreciate it, will get into making a stats script later today :)

FlyveHest
Nasty Little Gnome
Posts: 24
Joined: Mon 28.07.2008, 18:29

Re: Stats script for your own server?

Post by FlyveHest » Wed 30.07.2008, 14:54

Is it safe to remove the files from the user directory, when I have parsed them?

Or does the server use them for anything (ie, generating highscorelists later on?)

Jug
King Lich
Posts: 342
Joined: Sat 26.10.2002, 15:00
Location: UK
Contact:

Re: Stats script for your own server?

Post by Jug » Wed 30.07.2008, 16:05

It is technically safe to remove the files, yes. The server never attempts to read any of these files.

However, a character who dies above level 20 gets a full character dump attached below this machine readable line, which you may want to keep...

FlyveHest
Nasty Little Gnome
Posts: 24
Joined: Mon 28.07.2008, 18:29

Re: Stats script for your own server?

Post by FlyveHest » Wed 30.07.2008, 16:11

I'll just save them in a TEXT field in the DB, so i'll be able to grap needed information from them later.

Thanks a lot for the help. :)

FlyveHest
Nasty Little Gnome
Posts: 24
Joined: Mon 28.07.2008, 18:29

Re: Stats script for your own server?

Post by FlyveHest » Thu 31.07.2008, 16:36

Another question has popped up, does MAngband write a "deathfile" when you die and become a ghost, or is it only when you die finally?

If it does, is it possible to distinguish between a death-to-ghost and a death-to-final file?

Jug
King Lich
Posts: 342
Joined: Sat 26.10.2002, 15:00
Location: UK
Contact:

Re: Stats script for your own server?

Post by Jug » Thu 31.07.2008, 20:15

Ghosts don't feature in this process, just pretend they don't exist. :) MAngband writes a character dump when a character dies.

When a ghost is destroyed it has no effect on anything (the character was already dead) and no additional dump is written.

Post Reply