⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 place.c

📁 C实现的MUD,对大家基本入门网络游戏很有帮助!
💻 C
📖 第 1 页 / 共 2 页
字号:
// place.c
// dzj
// new 1/29/02

#include <room.h>
#include <ansi.h>
#include <combat.h>
inherit F_CLEAN_UP;
void create() { seteuid(getuid()); }

int color_len(string str)
{
        int i;
        int extra;
        extra = 0;
        for (i = 0; i < strlen(str); i++)
        {
                if (str[i] == ESC[0])
                {
                        while ((extra++, str[i] < 'A' ||
                                         str[i] > 'z' ||
                                         str[i] > 'Z' && str[i] < 'a') && i < strlen(str))
                                i++;
                }
        }
        return extra;
}

int main(object me, string arg)
{
	int i, j;
	object env, room;
	mapping exits;
	string str, *dirs, describe;
	env = environment(me);
	if( !env )
		return notify_fail("你的四周灰蒙蒙地一片,什么也没有。\n");
	if( !env->query("exits") )
		return notify_fail("你的四周没有明显的出口。\n");

	if( me->is_busy() )
		return notify_fail("你现在正忙着呢。\n");
	if( me->is_fighting() )
		return notify_fail("你现在正忙着呢。\n");
	if( mapp(exits = env->query("exits")) ) {
		dirs = sort_array(keys(exits), 1);
		for(i=0; i<sizeof(dirs); i++)
			if( (int)env->query_door(dirs[i], "status") & DOOR_CLOSED )
				dirs[i] = 0;
		dirs -= ({ 0 });
	} else return notify_fail("这里没有任何明显的出路。\n");
	if( sizeof(dirs)==0 )
		return notify_fail("这里没有任何明显的出路。\n");
        me->start_busy(2);
	str = sprintf( CYN"这里是"HIR"%s"CYN",共有%s个出口,分别通往:\n"NOR,
		env->query("short"),
		chinese_number(sizeof(dirs)));
	str += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";

       if( env->query("exits/northup") && !(int)env->query_door("northup", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/northup"))) room = load_object(env->query("exits/northup"));
	describe = room->query("short")+"(Nu)";
	j = 29-(strlen(describe)-color_len(describe))/2;
	for(i=0;i<j;i++) str += " ";
	str += describe+"\n";
	}

       if( env->query("exits/northdown") && !(int)env->query_door("northdown", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/northdown"))) room = load_object(env->query("exits/northdown"));
	describe = room->query("short")+"(Nd)";
	j = 29-(strlen(describe)-color_len(describe))/2;
	for(i=0;i<j;i++) str += " ";
	str += describe+"\n";
	}

       if( env->query("exits/northwest") && !(int)env->query_door("northwest", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/northwest"))) room = load_object(env->query("exits/northwest"));
	describe = room->query("short")+"(Nw)";
	str += sprintf("%"+(18+color_len(describe))+"s",describe);
	} else if( (env->query("exits/northup")&&!(int)env->query_door("northup", "status") & DOOR_CLOSED)
	|| (env->query("exits/northdown")&&!(int)env->query_door("northdown", "status") & DOOR_CLOSED)
	|| (env->query("exits/north")&&!(int)env->query_door("north", "status") & DOOR_CLOSED)
	|| (env->query("exits/northeast")&&!(int)env->query_door("northeast", "status") & DOOR_CLOSED) )
	str += "                  ";

       if( env->query("exits/north") && !(int)env->query_door("north", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/north"))) room = load_object(env->query("exits/north"));
	describe = room->query("short")+"(N)";
	j = (24-(strlen(describe)-color_len(describe)))/2;
	for(i=0;i<j;i++) str += " ";
	str += describe+"";
	for(i=0;i<j;i++) str += " ";
	} else if( (env->query("exits/northup")&&!(int)env->query_door("northup", "status") & DOOR_CLOSED)
	|| (env->query("exits/northdown")&&!(int)env->query_door("northdown", "status") & DOOR_CLOSED)
	|| (env->query("exits/northeast")&&!(int)env->query_door("northeast", "status") & DOOR_CLOSED) )
	str += "                       ";

       if( env->query("exits/northeast") && !(int)env->query_door("northeast", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/northeast"))) room = load_object(env->query("exits/northeast"));
	describe = room->query("short")+"(Ne)";
	str += describe+"\n";
	}
	else if( (env->query("exits/northup")&&!(int)env->query_door("northup", "status") & DOOR_CLOSED)
	|| (env->query("exits/northdown")&&!(int)env->query_door("northdown", "status") & DOOR_CLOSED)
	|| (env->query("exits/northwest")&&!(int)env->query_door("northwest", "status") & DOOR_CLOSED)
	|| (env->query("exits/north")&&!(int)env->query_door("north", "status") & DOOR_CLOSED) )
	str += "\n";

	if( (env->query("exits/northup")&&!(int)env->query_door("northup", "status") & DOOR_CLOSED)
	|| (env->query("exits/northdown")&&!(int)env->query_door("northdown", "status") & DOOR_CLOSED)
	|| (env->query("exits/northwest")&&!(int)env->query_door("northwest", "status") & DOOR_CLOSED)
	|| (env->query("exits/north")&&!(int)env->query_door("north", "status") & DOOR_CLOSED)
	|| (env->query("exits/northeast")&&!(int)env->query_door("northeast", "status") & DOOR_CLOSED) )
{
	str += "\n";

	if( (env->query("exits/northwest")&&!(int)env->query_door("northwest", "status") & DOOR_CLOSED) )
	str += "                \"; else str += "                  ";

	if( (env->query("exits/northup")&&!(int)env->query_door("northup", "status") & DOOR_CLOSED)
	|| (env->query("exits/northdown")&&!(int)env->query_door("northdown", "status") & DOOR_CLOSED)
	|| (env->query("exits/north")&&!(int)env->query_door("north", "status") & DOOR_CLOSED) )
	str += "          ┃          "; else  str += "                      ";

	if( (env->query("exits/northeast")&&!(int)env->query_door("northeast", "status") & DOOR_CLOSED) )
	str += "/\n"; else str += "\n";

	if( (env->query("exits/northwest")&&!(int)env->query_door("northwest", "status") & DOOR_CLOSED) )
	str += "                  \"; else str += "                    ";

	if( (env->query("exits/northup")&&!(int)env->query_door("northup", "status") & DOOR_CLOSED)
	|| (env->query("exits/northdown")&&!(int)env->query_door("northdown", "status") & DOOR_CLOSED)
	|| (env->query("exits/north")&&!(int)env->query_door("north", "status") & DOOR_CLOSED) )
	str += "        ┃        "; else str += "                  ";

	if( (env->query("exits/northeast")&&!(int)env->query_door("northeast", "status") & DOOR_CLOSED) )
	str += "/\n"; else str += "\n";
}

       if( env->query("exits/westup") && !(int)env->query_door("westup", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/westup"))) room = load_object(env->query("exits/westup"));
	describe = room->query("short")+"(Wu)";
	j = 10-(strlen(describe)-color_len(describe))/2;
	for(i=0;i<j;i++) str += " ";
	str += describe+"";
	for(i=0;i<j;i++) str += " ";
	} else str += "                    ";

	if( (env->query("exits/northwest")&&!(int)env->query_door("northwest", "status") & DOOR_CLOSED) )
	str += "\"; else str += "  ";

       if( env->query("exits/up") && !(int)env->query_door("up", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/up"))) room = load_object(env->query("exits/up"));
	describe = room->query("short")+"(U)";
	j = (14-(strlen(describe)-color_len(describe)-1))/2;
	for(i=0;i<j;i++) str += " ";
	str += describe+"";
	for(i=0;i<j;i++) str += " ";
	} else str += "              ";

	if( (env->query("exits/northeast")&&!(int)env->query_door("northeast", "status") & DOOR_CLOSED) )
	str += "/"; else str += "  ";

       if( env->query("exits/eastup") && !(int)env->query_door("eastup", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/eastup"))) room = load_object(env->query("exits/eastup"));
	describe = room->query("short")+"(Eu)";
	j = 10-(strlen(describe)-color_len(describe))/2;
	for(i=0;i<j;i++) str += " ";
	str += describe+"\n";
	} else str += "\n";

// 上半身制作完成。

       if( env->query("exits/west") && !(int)env->query_door("west", "status") & DOOR_CLOSED ) {
       if( !room = find_object(env->query("exits/west"))) room = load_object(env->query("exits/west"));
	describe = room->query("short")+"(W)";
	str += sprintf("%"+(15+color_len(describe))+"s",describe);
	str += " ━━━ ";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -