merentha_mudos_v1/
merentha_mudos_v1/bin/
merentha_mudos_v1/lib/cfg/
merentha_mudos_v1/lib/cfg/races/
merentha_mudos_v1/lib/cmds/abilities/
merentha_mudos_v1/lib/cmds/actions/
merentha_mudos_v1/lib/cmds/spells/
merentha_mudos_v1/lib/daemon/include/
merentha_mudos_v1/lib/daemon/services/
merentha_mudos_v1/lib/doc/
merentha_mudos_v1/lib/doc/building/
merentha_mudos_v1/lib/doc/help/classes/
merentha_mudos_v1/lib/doc/help/general/
merentha_mudos_v1/lib/doc/help/races/
merentha_mudos_v1/lib/doc/help/skills/
merentha_mudos_v1/lib/doc/help/stats/
merentha_mudos_v1/lib/doc/man/efuns/
merentha_mudos_v1/lib/doc/man/lfuns/
merentha_mudos_v1/lib/doc/news/
merentha_mudos_v1/lib/doc/old/
merentha_mudos_v1/lib/doc/old/concepts/
merentha_mudos_v1/lib/doc/old/lpc/constructs/
merentha_mudos_v1/lib/doc/old/lpc/types/
merentha_mudos_v1/lib/domains/ROOMS/
merentha_mudos_v1/lib/domains/obj/armour/
merentha_mudos_v1/lib/domains/obj/monsters/
merentha_mudos_v1/lib/domains/obj/other/
merentha_mudos_v1/lib/domains/obj/weapons/
merentha_mudos_v1/lib/realms/petrarch/
merentha_mudos_v1/lib/save/daemons/
merentha_mudos_v1/lib/save/rid/
merentha_mudos_v1/lib/save/users/a/
merentha_mudos_v1/lib/save/users/p/
merentha_mudos_v1/lib/save/users/t/
merentha_mudos_v1/lib/std/login/
merentha_mudos_v1/lib/std/obj/
merentha_mudos_v1/v22.2b12m1/
merentha_mudos_v1/v22.2b12m1/ChangeLog.old/
merentha_mudos_v1/v22.2b12m1/Win32/
merentha_mudos_v1/v22.2b12m1/compat/
merentha_mudos_v1/v22.2b12m1/compat/simuls/
merentha_mudos_v1/v22.2b12m1/include/
merentha_mudos_v1/v22.2b12m1/mudlib/
merentha_mudos_v1/v22.2b12m1/testsuite/
merentha_mudos_v1/v22.2b12m1/testsuite/clone/
merentha_mudos_v1/v22.2b12m1/testsuite/command/
merentha_mudos_v1/v22.2b12m1/testsuite/data/
merentha_mudos_v1/v22.2b12m1/testsuite/etc/
merentha_mudos_v1/v22.2b12m1/testsuite/include/
merentha_mudos_v1/v22.2b12m1/testsuite/inherit/
merentha_mudos_v1/v22.2b12m1/testsuite/inherit/master/
merentha_mudos_v1/v22.2b12m1/testsuite/log/
merentha_mudos_v1/v22.2b12m1/testsuite/single/
merentha_mudos_v1/v22.2b12m1/testsuite/single/tests/compiler/
merentha_mudos_v1/v22.2b12m1/testsuite/single/tests/efuns/
merentha_mudos_v1/v22.2b12m1/testsuite/single/tests/operators/
merentha_mudos_v1/v22.2b12m1/testsuite/u/
merentha_mudos_v1/v22.2b12m1/tmp/
// Petrarch
// Merentha Lib 1.0
// race daemon

// race daemon keeps track of stats and limbs for races

#include <std.h>

inherit DAEMON;

mapping __Limbs=([]), __Stats=([]);

void load_races() {
    string *files=get_dir("/cfg/races/"), *lines;
    string file, race, tmp;
    int i=sizeof(files), j;
    while(i--) {
	if(file_size(file="/cfg/races/"+files[i]) > 0) {
	    file=read_file(file);
	    j=sizeof(lines=explode(file, "\n"));
	    while(j--) {
		if (sscanf(lines[j], "race:%s", tmp)) {
		    race=tmp;
		    continue;
		}
		if (sscanf(lines[j], "stats:%s", tmp)) { __Stats[race]=tmp; continue; }
		if (sscanf(lines[j], "limbs:%s", tmp)) { __Limbs[race]=tmp; continue; }
	    }
	}
    }
}

string *query_limbs(string race) {
    if(!race || !__Limbs[race]) return 0;
    return explode(__Limbs[race], ";");
}

mapping query_stats(string race) {
    mapping val;
    string *stats;
    if(!val=__Stats[race]) return 0;
    stats=explode(val, ";");
    return (["strength":to_int(stats[0]),"constitution":to_int(stats[1]),"dexterity":to_int(stats[2]),"wisdom":to_int(stats[3]),"intelligence":to_int(stats[4]),"charisma":to_int(stats[5]),"luck":to_int(stats[6]),"eyes":to_int(stats[7]),"size":to_int(stats[8]),"mass":to_int(stats[9])]);
}

string *query_races() {
  return keys(__Stats);
}

int valid_race(string str) {
  return (1+member_array(str, keys(__Stats)));
}

void create() {
    load_races();
}