Пример #1
0
varargs mixed query(string prop, int raw) {
        mixed data, pdata; 
        if(!mapp(dbase)) {
                return 0;
        }
        
        if(undefinedp(dbase[prop]) && (strsrch(prop, '/')!=-1)) {
                data = _query(dbase, explode(prop, "/"));
        } else {
                data = dbase[prop];
        }
        
        if(default_ob) {
                if(undefinedp(data)) {
                        data = default_ob->query(prop, 1);
                } else if(mapp(data)) {
                        pdata = default_ob->query(prop, 1);
                        if(mapp(pdata)) {
                                data = pdata + data;
                        }
                }
        }
        
        if(raw) {
                return data;
        }
        
        return evaluate( data, this_object() );
} 
Пример #2
0
varargs int receive_wound(string type, int damage, mixed who)
{
	int val;

	if( damage < 0 ) error("F_DAMAGE: 伤害值为负值。\n");
	if( type!="jing" && type!="qi" )
		error("F_DAMAGE: 伤害种类错误( 只能是 jing, qi 其中之一 )。\n");

	set_temp("last_damage_from", who);
	
	
	if(living(this_object()) && objectp(who) && userp(who)) 
		set_temp("last_eff_damage_from", who->query("id"));
	
	val = (int)query("eff_" + type) - damage;

	if( val >= 0 ) set("eff_" + type, val);
	else {
		set( "eff_" + type, -1 );
		val = -1;
	}

	if( (int)query(type) > val ) set(type, val);

	set_heart_beat(1);

	return damage;
}
Пример #3
0
varargs mixed query_with_slash(string prop, int raw)
{
        mixed data; 
        if( !mapp(dbase) ) return 0; 
        if( undefinedp(dbase[prop]) && (strsrch(prop, '.')!=-1) )
                data = _query(dbase, explode(prop, "."));
        else
                data = dbase[prop]; 
        if( undefinedp(data) && default_ob )
                data = default_ob->query(prop, 1); 
        if( raw ) return data; 
        return evaluate( data, this_object() );
} 
Пример #4
0
void remove_eternal_fate(mixed ob)
{
    string keyword;
    
    if (stringp(ob)) keyword = ob;
    else if (objectp(ob)) {
        keyword = ob->query("fate_keyword");
        if (!keyword)
            keyword = file_name(ob);
    } else
        return;

    map_delete(eternal_fates, keyword);
}
Пример #5
0
void add_eternal_fate(mixed ob, string fate)
{
    string keyword;
    
    if (stringp(ob)) keyword = ob;
    else if (objectp(ob)) {
        keyword = ob->query("fate_keyword");
        if (!keyword)
            keyword = file_name(ob);
    } else
        return;

    if (!eternal_fates) eternal_fates = ([]);
    eternal_fates += ([ keyword : fate ]);
}
Пример #6
0
void add_fate(mixed ob, function f)
{
    string keyword;

    if (stringp(ob)) keyword = ob;
    else if (objectp(ob)) {
        keyword = ob->query("fate_keyword");
        if (!keyword)
            keyword = file_name(ob);
    } else
        return;

    if (!fates) fates = ([]);
    fates += ([ keyword : f ]);
}
Пример #7
0
string pluralize(mixed single) {
    int x;
    string str, tmp;
    if(!single) return single;
    if(objectp(single)) {
        if(str = (string)single->query("plural name")) return str;
        else str = (string)single->query_name();
    }
    else str = (string)single;
    if(!str) return str;
    x = strlen(str);
    if(ABNORMAL[str]) return ABNORMAL[str];
    if(x > 2 && str[x-3..x-1] == "man")
        return str[0..x-3]+"en";
    if(x > 1) {
        tmp = str[x-2..x-1];
        switch(tmp) {
        case "ts": return str+"";
        case "ch": case "sh":
            return str+"es";
        case "ff": case "fe":
            return str[0..x-3]+"ves";
        case "us":
            return str[0..x-3]+"i";
        case "um":
            return str[0..x-3]+"a";
        case "ef":
            return str+"s";
        }
    }
    tmp = str[x-1..x-1];
    //  2 bug fixes by Whit
    if(str[sizeof(str)-2..sizeof(str)] == "ts") return str;
    if(str[sizeof(str)-2..sizeof(str)] == "es") return str;
    switch(tmp) {
    case "s":
        return str+"es";
    case "o": case "x": 
        return str+"es";
    case "wolf": return str[0..x-4]+"wolves";
    case "f": return str[0..x-2]+"ves";
    case "y" : return str[0..x-2]+"ies";
    }
    return str+"s";
}
Пример #8
0
int valid_leave(mixed me, string dir)
{
        int i;
        string room;

        if (dir == "south") {
                i = (int)me->query_temp("back_road");
                i = i + 1;
                if (i >= (random(5) + 5)) {
                    me->set_temp("back_road", 10);
                    return notify_fail("�������ô��ؼ���  �ðɣ�����������Ը������Ҫ�����ܴ�Ĵ���ร���\n�������֮�� �������Ҫ��ȥ�Ļ����������߰ɣ���\n");
                } else {
                        me->set_temp("back_road",i);
                        return notify_fail("�㻹��ؼң����˵ظ���û��·�����ˣ�\n");
                }
        }
        else if (dir == "north") {
                me->delete_temp("back_road");
                return 1;
                }
        else if (dir == "up" || dir == "����")
        {
            if ( (int) me->query_temp("back_road") >= 10 )
            {
                end_death(me);
		me->delete_temp("back_road");
                me->reincarnate();
                if(!stringp(room = me->query("startroom")))
                    room = STARTROOM;
                me->move(room);
                message_vision(
                "ͻȻ���н���һ����⣬�����޷�������ֱ�ӡ�\n����һ��������ɢȥ��һ����Ӱ���֣�$N���ڴ�����͵�ܻ����ˡ�\n",me);
                return notify_fail("���������ػ������ˡ�\n");
            } else
		return notify_fail("���ȥ���� û��ô�򵥣���\n");
        }
        else
        return 1;
}