精華區beta mud 關於我們 聯絡資訊
聊點相關的。 假設 n 個玩家,第一個玩家簽 m1 組,第二個玩家簽 m2 組, .....,第 n 個玩家簽 mn 組。 mapping player_dbase=([ "玩家1":({ ({所簽號碼組1}),({所簽號碼組2}),... }), "玩家2":({ ({所簽號碼組1}),({所簽號碼組2}),... }), . . "玩家n":({ ({所簽號碼組1}),({所簽號碼組2}),... }), ]); 而開出的獎號組假設為 numbers=({1,2,3,4,5,6,1}); 宣告一個 mapping award_dbase=([]); 而得獎的基本條件是前 6 個號碼至少中 2 個,後面中 1 個 ,或前 6 個號碼至少中 3 個。 players=keys(player_dbase); foreach(player in players) { award_dbase[player]=({}); tmps=player_dbase[player]; n1=0; n2=0; foreach(sub_tmps in tmps) { for(i=0;i<6;i++) if(member_array(numbers[i],sub_tmps)!=-1) n1++; if(numbers[6]==sub_tmps[6]) n2=1; // n1: 所簽的某一組號碼, 第一組區六個號碼中幾個 // n2: 所簽的某一組號碼, 第二組區的號碼有沒有中 // 當玩家所簽的這組完全摃龜 continue; if(n1<2 || (n1<3 && n2!=1)) continue; // 儲存玩家該組的 n1 n2 award_dbase[player]+=({ ({n1,n2}) }); } } 「因為摃龜多」,所以大部份在 if(n1<2 || (n1<3 && n2!=1)) 這裡就會 continue (abort) 掉。 上面跑完就會得到 award_dbase 資料庫。 players=keys(award_dbase); foreach(player in players) { tmps=award_dbase[player]; foreach(sub_tmps in tmps) { n1=sub_tmps[0]; n2=sub_tmps[1]; switch(n1) { case 6: if(n2==1) { 得頭獎; 頭獎人數+1; } else { 得X獎; X獎人數+1; } break; . . } } } 一般我的習慣會用兩段的迴圈,先把 player_dbase 做個 資料前處理(資料過濾),再對留存下來的資料做獎金計算 前提就是「摃龜多」。 分兩段還有一個好處,我的話,有時我會先跑完一段,然 後 call_out 另一個函數隔幾秒後處理另一段。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ※ 編輯: laechan 來自: 1.165.164.2 (01/22 23:32)
kyoe :其實我只是想賺文章數我想發sex!!! 111.240.22.89 01/22 23:37
申請 mud_ky 板比較快唷~ ※ 編輯: laechan 來自: 1.165.164.2 (01/22 23:48)
kyoe :if(numbers[6]==sub_tmps[6])這句 111.240.22.89 01/22 23:48
這是對第二區(號碼 1~8)的獎號。 ※ 編輯: laechan 來自: 1.165.164.2 (01/23 00:00)
kyoe :喔那是威力彩-.- 111.240.22.89 01/23 00:06
kyoe :要開連署要po文200篇-.-淦 111.240.22.89 01/23 10:56
laechan :不一定要你連署,可參考mud_mars模式 210.61.157.53 01/23 11:37
kyoe :mars也是連署開新版的阿? 1.163.12.224 01/23 11:40
laechan :發起連署者並非目前 mars' adm eplis 210.61.157.53 01/23 12:07
kyoe :Q_Q 1.163.12.224 01/23 12:08
eplis :因為我文章數不夠,另請玩家幫發起 42.71.143.112 01/23 12:38
kyoe :申請好嚴苛..要30個200篇的連署... 1.163.12.224 01/23 12:52
deathcustom :1729篇可不可以當八個人用= = 220.130.149.28 01/23 13:19