Re: [wizs] 巫師升等測驗題目三

看板mud_sanc (Sanctuary - 聖殿)作者 (龍娃娃)時間17年前 (2008/11/20 20:16), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
程式位置: /u/d/dragondoll/question/q3.c 程式大小: 我也知道是小程式。 執行結果: 一樣略 想試奇怪寫法結果害我多花一個小時...。 改回正常寫法時有啥紕漏我也不管了,反正題目要求到的沒少寫。 inherit ROOM; void create() { ::create(); seteuid(getuid()); set("light",1); set("short","Test3"); set("long",@PLAIN PLAIN ); } void init() { add_action("test41","test3"); add_action("stopxx","stop"); return; } int stopxx(string str) { if(!query("target"))return notify_fail("你沒有在追蹤玩家!\n"); remove_call_out("show_msg"); delete("target"); return notify_fail("你停止了對玩家的追蹤!\n"); } int test41(string str) { write("區域管理選單 =============================================== 1)可輸入玩家 ID 查詢其所在的房間資訊及區域資訊 2)可輸入玩家 ID 追蹤其移動路徑 3)離開功\能表 ==============================================="); input_to("choice",2); } void choice(string choice) { int cc; cc = atoi(choice); if(cc>3||cc<=0){write("無此選項!\n"); return;} else if(cc==3){write("感謝使用!\n"); return;} else if(cc==1) { write("請輸入玩家ID\n"); input_to("choice2",2,this_player()); } else if(cc==2) { write("請輸入玩家ID\n"); input_to("choice3",2,this_player()); } } string cstatus(object ppl) { if(interactive(ppl)==0)return "斷線中"; else if(ppl->query_temp("ats"))return "戰鬥中"; else return "無所事事"; } int show_msg() { object ppl,room; string msg="<<目前該玩家所在地資訊>>\n"; if(!query("target")) { write("對象已不在, 停止追蹤\n"); return 1; } ppl = query("target"); room = environment(ppl); msg = msg + "房間檔名:" + base_name(room)+"\n"; msg = msg + "房間地名:" + room->query("short")+"\n"; if(!interactive(ppl)) { write("該玩家斷線中, 停止追蹤\n"); remove_call_out("show_msg"); return 1; } write(msg); call_out("show_msg",10); return 1; } void choice2(string choice) { object ppl,room,ppls; mixed ex,ex2; int i,tmp; string msg="",path,mm,strr; ppl = find_player(choice); if(!ppl){write("無此玩家!\n"); return;} room = environment(ppl); msg = msg + "房間檔名:" + base_name(room)+"\n"; msg = msg + "房間地名:" + room->query("short")+"\n"+"房間出口:"; ex = keys(room->query("exits")); for(i=0;i<sizeof(ex);i++) { msg = msg + ex[i]+" "; } msg = msg + "\n"; ex = all_inventory(room); for(i=0;i<sizeof(ex);i++) { if(userp(ex[i])) msg = msg + ex[i]->query("name") + "["+cstatus(ex[i])+"]\n"; } ex=explode(base_name(room),"/"); path="/"+implode(ex[0..sizeof(ex)-2],"/")+"/"; msg = msg + "房間所在目錄:" + path+"\n"; ex = get_dir(path); for(i=0;i<sizeof(ex);i++) { mm = ex[i]; if(mm[strlen(mm)-2..strlen(mm)-1]==".c")tmp++; } msg = msg+"此目錄下的房間數有: "+tmp+"\n"; ex = users(); tmp = 0; foreach(ppls in ex) { strr = base_name(environment(ppls)); ex2=explode(strr,"/"); strr="/"+implode(ex2[0..sizeof(ex2)-2],"/")+"/"; if(strr == path)tmp++; } msg = msg+"此區域的總人數有: "+tmp+"\n"; write(msg); return; } void choice3(string choice) { object ppl,room,ob; string msg=""; ppl = find_player(choice); if(!ppl){write("無此玩家!\n"); return;} if(query("target")) {write("已經在追蹤中, 請下stop停止追蹤!\n"); return;} write("開始追蹤玩家!\n"); set("target",ppl); show_msg(); return; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.194.152.155
文章代碼(AID): #199LK3eZ (mud_sanc)
文章代碼(AID): #199LK3eZ (mud_sanc)