SetupBBS 板


遊戲規則寫在遊戲畫面中了 :) == src/maple/menu.c == + "bin/seven.so:seven_main", PERM_VALID, - M_XMODE, + "Seven 接龍遊戲", == src/so 下新增下面那隻程式 == /*-------------------------------------------------------*/ /* so/seven.c ( YZU WindTopBBS Ver 3.00 ) */ /*-------------------------------------------------------*/ /* author : [email protected] */ /* target : 接龍遊戲 */ /* create : 2001/01/12 */ /*-------------------------------------------------------*/ #include "bbs.h" #define DO_LOG int cards[52]; int seven[7]; int points[7]; /*************************************** 畫出牌 ***************************************/ void draw_card(card,x,y) int card; int x; int y; { char *flower[] ={"C","D","H","S"}; char *number[] ={"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; move(x ,y);prints("╭───╮"); move(x+1,y);prints("│%s  │",(card<0)?" ":number[card%13]); move(x+2,y);prints("│%s  │",(card<0)?" ":flower[card%4]); move(x+3,y);prints("│   │"); move(x+4,y);prints("│   │"); move(x+5,y);prints("╰───╯"); return ; } /*************************************** 遊戲說明 ***************************************/ int draw_explain(void) { int x=4; clear(); vs_head("接龍遊戲", str_site); move(x+ 0,10);prints("【遊戲說明】"); move(x+ 2,15);prints("(1) 在螢幕上方為牌墩,可以利用←、→或 j , k 切換。"); move(x+ 4,15);prints("(2) 在螢幕左下方為持牌 , 可以利用 c 切換。"); move(x+ 6,15);prints("(3) 當牌墩的牌是持牌的下一張或上一張,即可利用 Enter 吃牌。"); move(x+ 7,15);prints(" (只看點數,不看花色)"); move(x+ 9,15);prints("(4) 當牌墩的牌都吃完,及遊戲獲勝。"); move(x+11,15);prints("(5) 當持牌切換完且尚未吃完牌墩的牌,即遊戲失敗。"); move(x+13,15);prints("(6) 此遊戲版權屬於 [email protected]"); vmsg(NULL); } /*************************************** 畫出遊戲牌的配置 ***************************************/ void draw_screen(void) { int i,j; clear(); vs_head("接龍遊戲", str_site); for(i=0;i<7;i++) for(j=0;j<i+1;j++) { draw_card((i==j)?cards[i]:-1,4+j,5+i*10); } } /*************************************** 畫出游標 ***************************************/ void draw_cursor(location,mode) int location; int mode; { move(8+seven[location],9+location*10); prints("%s",(mode==0)?" ":"●"); } /*************************************** 清除螢幕上的牌 ***************************************/ void clear_card(location) int location; { move(9+seven[location],5+location*10); prints("     "); } /*************************************** 遊戲參數初始化 ***************************************/ int init(void) { int i,num,tmp; for(i=0;i<52;i++) cards[i] = i; srand(time(0)); for(i=0;i<52;i++) { num = cards[i] ; tmp = rand() % 52 ; cards[i] = cards[tmp] ; cards[tmp] = num; } for(i=0;i<7;i++) { seven[i] = i; points[i] = cards[i] ; } return 0; } /*************************************** 判斷遊戲是否結束 ***************************************/ int gameover(void) { int i; for(i=0;i<7;i++) if(seven[i] != -1 ) return 0; return 1; } /*************************************** 遊戲主程式 ***************************************/ int play(void) { int location = 0; int c,i; int now_card=7; int have_card=22; int point; draw_screen(); draw_cursor(location,1); point = cards[now_card] ; draw_card(cards[now_card++],14,5); move(19,40); prints("你還有 %2d 機會可以換牌",have_card); move(18,10); outz("\033[1;37;42m【操作說明】 [j]左移 [k]右移 [enter]吃牌 [c]換牌 [q]離開 \033[m"); do { c = vkey(); switch ( c ) { case 'c' : if(have_card == 0) return -1; have_card--; move(19,40); prints("你還有 %2d 機會可以換牌",have_card); point = cards[now_card]; draw_card(cards[now_card++],14,5); break; case 'k' : case KEY_RIGHT : draw_cursor(location,0); do { location = (location+1) % 7; }while(seven[location] == -1); draw_cursor(location,1); break; case 'j' : case KEY_LEFT : draw_cursor(location,0); do { location = (location==0)?6:location-1; }while(seven[location] == -1); draw_cursor(location,1); break; case '\n' : case ' ' : if(points[location]%13-point%13 == 1 || points[location]%13-point%13 == -1 || points[location]%13-point%13 == 12 || points[location]%13-point%13 == -12) { point = points[location]; draw_card(point,14,5); clear_card(location); draw_cursor(location,0); seven[location]--; if(seven[location]>=0) { points[location] = cards[now_card]; draw_card(cards[now_card++],4+seven[location],5+location*10); draw_cursor(location,1); } else { for(i=0;i<5;i++) { move(4+i,5+location*10); prints("     "); } if( gameover() == 1) return have_card; do { location = (location+1) % 7; }while(seven[location] == -1); draw_cursor(location,1); } } break; case 'q' : return -2 ; } }while(1); return 0; } int seven_main(void) { int tmp; draw_explain(); do { init(); clear(); tmp = play(); if(tmp>=0){ vmsg("恭喜你過關啦 !!"); } else if(tmp==-1){ vmsg("挑戰失敗 !!"); } else if(tmp==-2) { vmsg("下次再來玩唷 !!"); return 0; } if(vans("是否要繼續? [y/N]") != 'y') break; }while(1); return 0; } -- ※ Origin: 元智大學 風之塔 <bbs.yzu.edu.tw> ※ From : bbs.yzu.edu.tw







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草
伺服器連線錯誤,造成您的不便還請多多包涵!
「贊助商連結」






like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:WOW站內搜尋

TOP