📄 dhs.c
字号:
// dhs.c 大话色// Make by 猫部猫(Catyboy)#include <ansi.h>#define MAX_SE 6#define MAX_TOSS 5inherit ITEM;int has_start;int has_guess;int se_num; // 每人的色子数量int se_total; // 每人的色子数量2int cur_point; // 当前的点数int cur_amount; // 当前的数量int has_guess_one; // 是否猜过1string cur_player; // 当前的玩家IDstring last_player; // 上一个玩家string who_lost; // 输方mapping player; // 两个玩家 [id:({色,色...})]mapping player_deal; // 完成的玩家mapping player_toss; // 玩家toss次数mapping player_follow; // 玩家顺序mapping visitor; // 观战的人 [id:({id,...})]mapping counter = ([]); // 计数器mixed history; // 历史 stringint reset_game(int all);mixed se_text = ({ ({"","","","",""}), ({ "┏━━━┐", "│ │", "│ ● │", "│ │", "┖━━━┛", }), ({ "┏━━━┐", "│ ● │", "│ │", "│ ● │", "┖━━━┛", }), ({ "┏━━━┐", "│● │", "│ ● │", "│ ●│", "┖━━━┛", }), ({ "┏━━━┐", "│● ●│", "│ │", "│● ●│", "┖━━━┛", }), ({ "┏━━━┐", "│● ●│", "│ ● │", "│● ●│", "┖━━━┛", }), ({ "┏━━━┐", "│● ●│", "│● ●│", "│● ●│", "┖━━━┛", })});void msg(object me,object who,string msg){ if(me) message_vision(msg,me,who); else tell_room(environment(this_object()),msg,0);}object get_player(string id){ object ob; ob= find_player(id); if( !ob || environment(ob) != environment(this_object()) ) return 0; return ob;}object get_cur_player(){ return get_player(cur_player);}int is_playing(object ob){ string id; id = ob->query("id"); if(undefinedp(player[id])) return 0; return 1;}mixed get_se(int num){ return se_text[num];}void create(){ set_name("大话色台", ({ "da hua se desk","se","desk","dhs"}) ); set_weight(10000000); if( clonep() ) set_default_object(__FILE__); else { set("unit", "张"); set("long", "这是一张大话色台,玩家可以在上面玩大话色,使用方法请使用(helpse)命令。\n"); set("value", 1); set("no_get", 1); set("material", "wood"); } se_total = 5; reset_game(1); setup();}string for_other_msg(object who){ object ob; string m; m = ""; if(has_guess&&last_player) { ob = get_player(last_player); if(ob) { m = sprintf("%s\n%s(%s)猜色子数为:%d个%d\n",m,ob->query("name"),ob->query("id"),cur_amount,cur_point); if(ob!=who) m = m + "如果你不相信,可以拆穿大话("HIY"dahua "+ob->query("id")+NOR")\n"; } } return m;}string for_guess_msg(){ string m; m = ""; if( has_guess&&last_player ) m=m+for_other_msg(0)+"否则"; m = m+"你的猜测是("HIY"guess 色子数目 色子点数"NOR")?\n"; if(has_guess&&last_player) m = m+"注意:" HIC "色子数目或者色子点数必须比前一位玩家大。\n"NOR; return m;}int is_visitor(object who,string which){ if(!get_player(which)) return 0; if(!visitor[which]||member_array(who->query("id"),visitor[which])==-1) return 0; return 1;}string build_se(object who){ mixed *s; string r,t; int i,y,num; object ob; if(!who) return ""; r = ""; if(s = player[who->query("id")]) { for(y=0;y<5;y++) { t = ""; for(i=0;i<sizeof(s);i++) { num = s[i]; t = t + se_text[num][y] + " "; } r = r + t + "\n"; } if(has_guess&&last_player) r = r + for_other_msg(who); } return r;}void toss(object ob){ int i; mixed* s; if(!ob) return; if(s = player[ob->query("id")]) { for(i=0;i<sizeof(s);i++) s[i] = random(6)+1; } player[ob->query("id")] = sort_array(s,1);}int auto_order(){ int i; string* key; string who,start_one; key = keys(player); player_follow = ([]); who = ""; for(i=0;i<sizeof(key);i++) { if(get_player(key[i])) { if(!start_one) start_one = key[i]; if(who =="") who = key[i]; else { player_follow[who] = key[i]; who = key[i]; } } } player_follow[who] = start_one; return 1;}int reset_game(int all){ int i; string* idx; object ob; if(all)has_start = 0; has_guess = 0; se_num = se_total; cur_point = 0; cur_amount = 0; cur_player = 0; has_guess_one = 0; last_player = 0; if(all)who_lost = 0; if(all)player = ([]); player_deal = ([]); player_toss = ([]); player_follow = ([]); if(all)visitor = ([]); if(all)counter = ([]); history = 0; if(!all) { idx = keys(player); for(i=0;i<sizeof(idx);i++) { if(ob = get_player(idx[i])) { player[idx[i]] = allocate(se_num); toss(ob); } else map_delete(player,idx[i]); } auto_order(); } return 1;}string extra_long(){ object who; string r; mixed *idx; int i; if(sizeof(player)>0) { idx = keys(player); r = "******************************************\n"; for(i=0;i<sizeof(idx);i++) { who = get_player(idx[i]); if(who) r = r + who->short() + "\n"; } r += "******************************************\n"; } return r;}int view_se(object who,object bsee){ if(who) { if(bsee) tell_object(bsee,build_se(who)); else tell_object(who,build_se(who)); } return 1;}void start_game(int num){ if(num>1&&num<=MAX_SE) se_total = num; reset_game(0); has_start = 1; msg(0,0,"开始游戏了\n");}void init(){ add_action("do_help","helpse"); // 帮助 add_action("do_reset","reset"); // 重置游戏 add_action("do_start","start"); // 重新开始 add_action("do_join","join"); // 加入游戏 add_action("do_toss","toss"); // 摇色子 add_action("do_view","view"); // 查看情况 add_action("do_finish","finish"); // 完成 add_action("do_finish","deal"); // 完成 add_action("do_dahua","dahua"); // 发现大话 add_action("do_guess","guess"); // 猜测 add_action("do_guess","g"); // 猜测 add_action("do_next","next"); // 催促 add_action("do_showc","showc"); // 显示计数器 add_action("do_visitor","visit"); // 增加旁观者 add_action("do_history","history"); // 查看猜测历史}int do_toss(string arg){ object me,v; string* idx; int i; me = this_player(); if(!is_playing(me)) return notify_fail("你都不玩啊!\n"); if(!has_start) return notify_fail("游戏还没有开始了。\n"); if(has_guess) return notify_fail("已经开始猜色子了。\n"); if(player_toss[me->query("id")]>=MAX_TOSS) return notify_fail(sprintf("你已经摇过%d次了。\n",MAX_TOSS)); toss(me); player_toss[me->query("id")]++; msg(me,0,"$N拿起色子在手中摇了两摇。\n"); view_se(me,0); if(idx = visitor[me->query("id")]) { for(i=0;i<sizeof(idx);i++) { v = get_player(idx[i]); if(v) view_se(me,v); } } return 1;}int do_reset(string arg){ int i; mixed* idx; if(!this_object()->id(arg)) return 0; if(!is_playing(this_player())) { idx = keys(player); for(i=0;i<sizeof(idx);i++) { if(get_player(idx[i])) return notify_fail("你都不玩啊!\n"); } } reset_game(1); msg(this_player(),0,"$N重置了游戏。\n"); return 1;}int do_start(string arg){ int i; if(!is_playing(this_player())) return notify_fail("你都不玩啊!\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -