📄 cch.c
字号:
if( ob->query("name2") )return notify_fail("已经有两个人在下棋了。\n");if( me->name() == ob->query("name1") )return notify_fail("你已经投过一次骰子了。\n"); num = random(6);if( ob->query("num") == num ) num = random(6); text = "拿起骰子在手中摇了两摇, 掷出了一个:\n"; text += tossText[6]+tossText[num]+tossText[7]; message_vision( "$N"+text,me );if( ob->query("name1") ){ob->query("num")>num?ob->set("first",ob->query("name1")):ob->set("first",me->name()); message_vision( ob->query("first")+"使用红色棋子先行。\n",me );}ob->set("num",num);ob->query("name1")?ob->set("name2",me->name()): ob->set("name1",me->name());ob->query("id1")?ob->set("id2",me->query("id")):ob->set("id1",me->query("id")); return 1;}string long() { int row,col,i; string text,round,msg;object ob,me;ob = this_object();me = this_player(); text = "\n1 2 3 4 5 6 7 8 9\n";msg = ob->query("name1")==ob->query("first")?ob->query("name2"):ob->query("name1");if( ob->query("name2") ){if( ob->query("over") )round = " 这盘棋"+ob->query("over")+"赢了。";elseif( ob->query("round") == 1 )round = " 现在轮到"+HIC"蓝子"NOR+"下";elseround = " 现在轮到"+HIR"红子"NOR+"下";TABLE[table[9]][0][1] = sprintf("%s%s",TABLE[table[9]][0][0],round );}if( me->name() != ob->query("first") ){TABLE[table[17]][0][1] = "┃";TABLE[table[3]][0][1] = "┃";TABLE[table[5]][0][1] = "┃";TABLE[table[13]][0][1] = "┃";TABLE[table[15]][0][1] = "┃";TABLE[table[0]][0][0] = "┌";TABLE[table[10]][0][0] = "┌";TABLE[table[0]][16][0] = "┐";TABLE[table[10]][16][0] = "┐";TABLE[table[18]][16][0] = "┘";TABLE[table[8]][16][0] = "┘";TABLE[table[8]][0][0] = "└";TABLE[table[18]][0][0] = "└";TABLE[table[2]][16][0] = TABLE[table[4]][16][0]= TABLE[table[6]][16][0] = TABLE[table[12]][16][0]= TABLE[table[14]][16][0] = TABLE[table[16]][16][0]= "┤";TABLE[table[2]][0][0] = TABLE[table[4]][0][0]= TABLE[table[6]][0][0] = TABLE[table[12]][0][0]= TABLE[table[14]][0][0] = TABLE[table[16]][0][0]= "├";TABLE[table[1]][16][1] = "┃ 如有问题,请参看“help cchess”";TABLE[table[15]][16][1] = sprintf("%s%s%s",TABLE[table[15]][16][0]," ",bche );TABLE[table[5]][16][1] = sprintf("%s%s%s",TABLE[table[5]][16][0]," ",rche );if( ob->query("name2") ){TABLE[table[3]][16][1] = sprintf("%s%s%s","┃"," ("+ob->query("first")+") ",HIR"红方"NOR+"所吃棋子:" );TABLE[table[13]][16][1] = sprintf("%s%s%s","┃"," ("+msg+") ",HIC"蓝方"NOR+"所吃棋子:" );}for( i=2;i<16;i++){if( i%2!=0) continue;TABLE[table[8]][i][0] = "┴";TABLE[table[10]][i][0] = "┬";TABLE[table[18]][i][0] = "┴";TABLE[table[0]][i][0] = "┬";} for( row=0; row<sizeof(table); row++ ) { for( col=0; col<sizeof(TABLE[table[row]]); col++ ) { if( TABLE[table[row]][col][1] == " " ) text += sprintf("%s", TABLE[table[row]][col][0] ); else text += sprintf("%s", TABLE[table[row]][col][1] ); } if( row%2 == 0) text += sprintf(" %d", row/2 ); text += "\n"; }} else { text = "\n9 8 7 6 5 4 3 2 1\n";TABLE[table[1]][16][1] = "┃";TABLE[table[3]][16][1] = "┃";TABLE[table[5]][16][1] = "┃";TABLE[table[13]][16][1] = "┃";TABLE[table[15]][16][1] = "┃";TABLE[table[0]][0][0] = "┘";TABLE[table[18]][16][0]= "┌";TABLE[table[0]][16][0] = "└";TABLE[table[18]][0][0] = "┐";TABLE[table[8]][16][0] = "┌";TABLE[table[10]][16][0] = "└";TABLE[table[2]][16][0] = TABLE[table[4]][16][0]= TABLE[table[6]][16][0] = TABLE[table[12]][16][0]= TABLE[table[14]][16][0] = TABLE[table[16]][16][0]= "├";TABLE[table[10]][0][0] = "┚";TABLE[table[8]][0][0] = "┐";TABLE[table[2]][0][0] = TABLE[table[4]][0][0]= TABLE[table[6]][0][0] = TABLE[table[12]][0][0]= TABLE[table[14]][0][0] = TABLE[table[16]][0][0]= "┤";TABLE[table[17]][0][1] = "┃ 如有问题,请参看“help cchess”";TABLE[table[13]][0][1] = sprintf("%s%s%s",TABLE[table[15]][16][0]," ",bche );TABLE[table[3]][0][1] = sprintf("%s%s%s",TABLE[table[5]][16][0]," ",rche );if( ob->query("name2") ){TABLE[table[5]][0][1] = sprintf("%s%s%s","┃"," ("+ob->query("first")+") ",HIR"红方"NOR+"所吃棋子:" );TABLE[table[15]][0][1] = sprintf("%s%s%s","┃"," ("+msg+") ",HIC"蓝方"NOR+"所吃棋子:" );}for( i=2;i<16;i++){if( i%2!=0) continue;TABLE[table[8]][i][0] = "┬";TABLE[table[10]][i][0] = "┴";TABLE[table[18]][i][0] = "┬";TABLE[table[0]][i][0] = "┴";} for( row=(sizeof(table)-1); row>-1; row-- ) { for( col=(sizeof(TABLE[table[row]])-1); col>-1; col-- ) { if( TABLE[table[row]][col][1] == " " ) text += sprintf("%s", TABLE[table[row]][col][0] ); else text += sprintf("%s", TABLE[table[row]][col][1] ); } if( row%2 == 0) text += sprintf(" %d", row/2 ); text += "\n"; }} return text;}void do_check(){int x,y,tem,tem1,i,tem3,check;object ob = this_object();check = 0;if( ob->query("over") ) return;if( ob->query("round") == 1 ) for( y=0;y<5;y++ ){if( y%2 != 0 ) continue; for( x=6;x<11;x++ ) {if( x%2 != 0 ) continue; if( TABLE[table[y]][x][2] == 5 ){tem = x;tem1 = y;break; }}}else for( y=14;y<19;y++ ){if( y%2 != 0 ) continue; for( x=6;x<11;x++ ) {if( x%2 != 0 ) continue; if( TABLE[table[y]][x][2] == 5 ){tem = x;tem1 = y;break;} }}if( tem1 < 9 )if( TABLE[table[tem1+2]][tem][2] == 7 &&TABLE[table[tem1+2]][tem][3] != TABLE[table[tem1]][tem][3] )check = 1;if( tem1 > 9 )if( TABLE[table[tem1-2]][tem][2] == 7 && TABLE[table[tem1-2]][tem][3] != TABLE[table[tem1]][tem][3] )check = 1;if( TABLE[table[tem1]][tem+2][2] == 7 )check = 1;if( TABLE[table[tem1]][tem-2][2] == 7 )check = 1;tem3 = 0;for (i=tem+2;i<17;i++){if( i%2!=0) continue;if( tem3 == 1 && TABLE[table[tem1]][i][2] == 6 )if( TABLE[table[tem1]][i][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[tem1]][i][2] == 1 && tem3 == 0 )if( TABLE[table[tem1]][i][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[tem1]][i][2] != 0 )tem3 += 1;}tem3 = 0;for (i=tem-2;i>-1;i--){if( i%2!=0) continue;if( tem3 == 1 && TABLE[table[tem1]][i][2] == 6 )if( TABLE[table[tem1]][i][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[tem1]][i][2] == 1 && tem3 == 0 )if( TABLE[table[tem1]][i][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[tem1]][i][2] != 0 )tem3 += 1;}tem3 = 0;for (i=tem1-2;i>-1;i--){if( i%2!=0) continue;if( tem3 == 1 && TABLE[table[i]][tem][2] == 6 )if( TABLE[table[i]][tem][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[i]][tem][2] == 1 && tem3 == 0 )if( TABLE[table[i]][tem][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[i]][tem][2] != 0 )tem3 += 1;}tem3 = 0;for (i=tem1+2;i<19;i++){if( i%2!=0) continue;if( tem3 == 1 && TABLE[table[i]][tem][2] == 6 )if( TABLE[table[i]][tem][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[i]][tem][2] == 1 && tem3 == 0 )if( TABLE[table[i]][tem][3] != TABLE[table[tem1]][tem][3] ){check = 1;break;}if( TABLE[table[i]][tem][2] != 0 )tem3 += 1;}if( tem1 > 1 ){if( TABLE[table[tem1-2]][tem-2][2] == 0 ){if( tem1 > 2 )if( TABLE[table[tem1-4]][tem-2][2] == 2 && TABLE[table[tem1-4]][tem-2][3] != TABLE[table[tem1]][tem][3] )check = 1;if( TABLE[table[tem1-2]][tem-4][2] == 2 && TABLE[table[tem1-2]][tem-4][3] != TABLE[table[tem1]][tem][3] )check = 1;}if( TABLE[table[tem1-2]][tem+2][2] == 0 ){if( tem1 > 2 )if( TABLE[table[tem1-4]][tem+2][2] == 2 && TABLE[table[tem1-4]][tem+2][3] != TABLE[table[tem1]][tem][3] )check = 1;if( TABLE[table[tem1-2]][tem+4][2] == 2 && TABLE[table[tem1-2]][tem+4][3] != TABLE[table[tem1]][tem][3] )check = 1;}}if( tem1 < 17 ){if( TABLE[table[tem1+2]][tem-2][2] == 0 ){if( tem1 < 16 )if( TABLE[table[tem1+4]][tem-2][2] == 2 && TABLE[table[tem1+4]][tem-2][3] != TABLE[table[tem1]][tem][3] )check = 1;if( TABLE[table[tem1+2]][tem-4][2] == 2 && TABLE[table[tem1+2]][tem-4][3] != TABLE[table[tem1]][tem][3] )check = 1;}if( TABLE[table[tem1+2]][tem+2][2] == 0 ){if( tem1 < 16 )if( TABLE[table[tem1+4]][tem+2][2] == 2 && TABLE[table[tem1+4]][tem+2][3] != TABLE[table[tem1]][tem][3] )check = 1;if( TABLE[table[tem1+2]][tem+4][2] == 2 && TABLE[table[tem1+2]][tem+4][3] != TABLE[table[tem1]][tem][3] )check = 1;}}if( check ) message_vision("$N说道"+HIG"“将军!!”\n"NOR,this_player() );}int do_save(){bb = 1;save();write("记录完毕\n");return 1;}int do_deploy(){object me,ob;me = this_player();ob = this_object();bb = 1; if( ob->query("id1") )if( (present(ob->query("id1"),environment(ob))) || (present(ob->query("id2"),environment(ob))) )if( me->name() != ob->query("name1") && me->name() != ob->query("name2") && !ob->query("over") )return notify_fail("比赛还在进行中,你不能乱动棋盘!\n"); if( !restore() ) return notify_fail("你目前没有纪录的残局。\n");setup();write("OK!\n");return 1;}int do_lose(){object ob,me;ob = this_object();me = this_player();if( me->name() != ob->query("name1") && me->name() != ob->query("name2") )return notify_fail("你并没有在下棋。\n"); if( ob->query("over") )return notify_fail("这盘棋已经结束了。\n"); if( bche == "" && rche == "" )return notify_fail("这样就认输了?\n"); message_vision(HIW"$N长叹一声“...我输了!...”\n"NOR,this_player());ob->set("over", ob->query("name1") == me->name()?ob->query("name2"):ob->query("name1") );return 1;}int do_help(string arg){if( arg == "cchess" ){write(sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n","———————————————————————————","中国象棋(cchess)", "———————————————————————————","下子 :move <横座标> <纵座标> to <横座标> <纵座标>","重下 :reset","读出残局 :deploy","记录残局 :csave","掷骰 :toss","回顾 :review","认输 :lose",)); return 1;}}int do_review(){write("目前走过的棋子。\n");write(aaa+"\n");return 1;}int do_reset(){object me,ob;me = this_player();ob = this_object();bb = 0;if( ob->query("id2") )if( (present(ob->query("id1"),environment(ob))) || (present(ob->query("id2"),environment(ob))) )if( me->name() != ob->query("name1") && me->name() != ob->query("name2") && !ob->query("over") )return notify_fail("比赛还在进行中,你不能乱动棋盘!\n"); if( restore() ){setup(); message_vision( "$N把棋盘重新摆好了。\n",this_player());}return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -