---
title: '排行榜/跑馬燈廣播功能'
---[TOC]
# 需求說明:
## 排行榜
在TendaServer能夠配合各遊戲告知玩家 "中獎玩家" 排名。
### 企劃規格: (排行榜參數,額外拉出來變成設定檔)
財富榜(特定贏分)
玩家、中獎時間、顯示贏分、MsgId(訊息編號) IconId(圖片編號)
大獎榜(特定獎項大小)
玩家、中獎時間、顯示倍數、MsgId IconId
## 跑馬燈廣播
在TendaServer中能夠即時通知線上玩家 "中獎玩家" 資訊。
### 企劃規格: (使用跟排行榜一樣的參數表)
廣播條件: 超過 **777倍(參數)** 且 押注大於 **設定值(參數)**
財富榜(特定贏分)
中文:恭喜 [NickName] 擊殺 [IconId] 獲得 [Odds]倍 [Win]分
英文:$$$ [NickName] Won [IconId] ,[Odds]x $[Score]. $$$
大獎榜(特定獎項大小)
中文:恭喜 [NickName] 擊殺 [IconId] 獲得 [Odds]倍 [Win]分
英文:$$$ [NickName] Won [IconId] ,[Odds]x $[Win]. $$$
[企劃必須填寫的排行榜廣播規格表連結](https://docs.google.com/spreadsheets/u/1/d/1BEAOW2dA6wGrfdf_Ex5ydz2alWCbqZEPjDKoBSIqUFQ/edit#gid=0)
後端RD會根據此文件來更新資料庫內容
# 循序圖/流程圖:
**資料流**
```sequence
participant Client
participant GS
participant BS
participant LS
Note left of LS: 規則表\n放在LS(rang_rule)
LS->GS: GS開機時取得規則表
GS->Client: Fish Kill
Note right of GS: GS判斷可以廣播時,\n把排行榜資訊紀錄於GS FishHigh\n,等搬移工具將資料搬到BS做後續排行處理
GS->Client: 廣播 跑馬燈資訊
GS->BS:取得要加入排行榜的資訊
Client->GS:索取過濾後的排行榜資訊
GS->BS:索取過濾後的排行榜資訊
BS->GS:回傳索取過濾後的排行榜資訊
GS->Client:回傳索取過濾後的排行榜資訊
Note over Client,LS:第二版分隔線
LS->GS:在線更新 排行榜/跑馬燈條件
GS->BS:排行榜公版規劃
```
**跑馬燈廣播**(多Server版本)
```flow
st=>start: 開始
e=>end: 結束
op=>operation: 玩家射擊/擊殺魚種
cond=>condition: 達到跑馬燈廣播標準?
op2=>operation: GS跑馬燈廣播資訊紀錄
op3=>operation: BS取得GS跑馬燈廣播資訊紀錄
cond2=>condition: BS判斷跑馬燈廣播
op4=>operation: GS收到BS要廣播 跑馬燈廣播資訊
st->op->cond->
cond(yes)->op2
cond(no)->e
op2->op3->cond2
cond2(yes)->op4
cond2(no)->e
op4->e
```
```sequence
Client->GS: Hit Fish
GS-->Client: Fish Kill
Note right of GS: GS判斷可以廣播,\n把跑馬燈資訊紀錄於GS,等BS來拿
GS-->BS:取得跑馬燈資訊
BS->GS:提供過濾後的跑馬燈資訊
GS->Client: 廣播 跑馬燈資訊
```
# 資料格式 / Table規劃
rank_rule 排行榜規則表
| 欄位 | 資料型態 | 說明 |
| -------- | -------- | -------- |
| RuleId | int | 規則流水編號 |
| PlatformID | int | 平台編號 |
| GameMode | int | 遊戲模式 1:魚機 2:SLOT 3:撲克 4:麻將 5:小遊戲 |
| GameID | int | 遊戲編號 |
| Currency |string | 幣值 |
| MsgId |int | 訊息編號 |
| IconId | int | 圖片編號 |
| Win | int | 排名的依據:贏分參考 當 贏分 大於此值, 則要列入排行榜依據內, 或是要廣播的依據 |
| Odds | int | 排名的依據:賠率參考 當 賠率 大於此值, 則要列入排行榜依據內, 或是要廣播的依據\n賠率 ( 已經放大一萬倍 ) |
| Memo | int | 條件說明 |
## Client排行榜json資訊
****************************錯誤****************************
``` json
{
"code":0,
"message":"執行成功",
"sys":"system",
"clientId":0,
"sn":3,
"isEncode":false,
"ver":0,
"ret":"fish_top_list_get",
"data":{
"data":null
}
}
```
## Client廣播json資訊
``` json
{
"String":"String",
"Int":123456,
"boolean":false,
"obj":
{
"int":234567,
"String":"String"
}
}
```
# API規劃:
## GS->BS GS透過API向BS取得排行榜資料
``` json
##topType 0: 分數排行榜
## 1: 倍率排行榜
##Currency : 幣值
FromData:
platformId : 7
authKey : 112233
sendData : {
"sys":"system",
"cmd":"fish_top_list_get",
"isEncode":false,
"data":{
"topType":1,
"Currency":"RD"
}
}
```
## BS->GS
``` json
{
"code":0,
"message":"執行成功",
"sys":"system",
"clientId":0,
"sn":2,
"isEncode":false,
"ver":0,
"ret":"topList",
"data":{"win":[
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:27",
"fishType":"11",
"win":10,
"odds":0
},
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:28",
"fishType":"12",
"win":20,
"odds":0
}],
"odds":[
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:27",
"fishType":"11",
"win":0,
"odds":10
},
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:28",
"fishType":"12",
"win":0,
"odds":20
}]
}
}
**錯誤**
{
"code":0,
"message":"錯誤",
"sys":"system",
"clientId":0,
"sn":3,
"isEncode":false,
"ver":0,
"ret":"topList",
"data":{
"data":null
}
}
```
## Client->GS 遊戲透過websocket向GS取得排行榜資料 json格式
```json=
##currency : 幣值
##gameID
{
"cmd":"topList",
"sys":"system",
"sn":12345,
"isEncode":false,
"data":{
"gameId": 1,
"currency":"RD",
}
}
```
## GS->Client 排行榜
``` json
{
"code":0,
"message":"執行成功",
"sys":"system",
"clientId":0,
"sn":2,
"isEncode":false,
"ver":0,
"ret":"topList",
"data":{"win":[
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:27",
"fishType":"11",
"win":10,
"odds":0
},
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:28",
"fishType":"12",
"win":20,
"odds":0
}],
"odds":[
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:27",
"fishType":"11",
"win":0,
"odds":10
},
{
"account":"RD-25081",
"createTime":"2019-10-28 16:58:28",
"fishType":"12",
"win":0,
"odds":20
}]
}
}
**錯誤**
{
"code":0,
"message":"錯誤",
"sys":"system",
"clientId":0,
"sn":3,
"isEncode":false,
"ver":0,
"ret":"topList",
"data":{
"data":null
}
}
```
## GS->Client 廣播
Cmd = broadcast_msg
```json=
{
"fw":{
"user_id": 2234,
"nickname": "joe動感超人",
"gameId":1001,
"win":5000,
"odds":300,
"msgId":1,
"iconId":1
}
}
```
| 欄位 | 說明 |
| -------- | -------- |
| user_id | 玩家ID |
| nickname | 顯示的玩家暱稱 |
| gameId | 遊戲ID |
| win | 玩家贏分|
| odds | 賠率 |
| msgId | 前端顯示的多語系字串編號 ( Client 端 預先寫好多語系陣列 ) |
| iconId | 前端顯示文字時使用到的icon編號 |
#### Client自行定義的內建顯示訊息表
zh_cn
| msgId | msgId顯示內文 |
| -------- | -------- |
| 0 | 恭喜 [nickname] 击杀 [Icon] 获得 [win]分 |
| 1 | 恭喜 [nickname] 击杀 [Icon] 获得 [odds]倍 |
| 2 | 恭喜 [nickname] 击杀 [Icon] 获得 [odds]倍 [win]分|
en
| msgId | msgId顯示內文 |
| ----- | ---------------------------------------------- |
| 0 | Congrats![nickname] won [Icon] [win] pts.|
| 1 | Congrats![nickname] won [Icon] [odds]x.|
| 2 | Congrats![nickname] won [Icon] [odds]x, [win] pts.|
### Client自行定義的Icon列表
| iconIdx | Icon說明 |
| ------- | -------- |
| 09 | 金蛙怪 |
| 10 | 寶箱蟹 |
| 11 | 懸賞單 |
| 16 | 克拉肯 |
# 預計工項:
- [ ] 1.LS + GS
- [x] 1.1 規劃流程 - 預計天數
- [x] 1.2 LS建立排行榜規則表(rank_rule) - 預計天數
- [x] 1.3 GS啟動跟LS取得排行榜規則表
- [x] 1.4 GS廣播和自己連線的所有Client
- [x] 1.5 GS根據排行榜規則表, 來決定廣播時機, 並且廣播給Client
- [x] 1.6 GS廣播時, 將資料寫一份到 gamelog_fish_high 資料表內
- [ ] 1.7 將企劃人員填寫好的排行榜, 同步內到DB rank_rule 內 - 預計1小時
- [ ] 1.8 測試和微調功能 - 預計2天
- [x] 2.BS + 搬移工具
- [x] 1.1 BS排行榜資料收集, 回傳給Client - 預計2天數
- [x] 1.2 搬移工具搬移規則 - 預計0.1天數
- [x] 3.Client
- [x] 1.1 Client傳送TopListGet(取得排行榜)封包給GS, 並且正確收到資料-預計天數
- [x] 1.2 Client將收到的排行榜資料正確顯示在UI介面上-預計天數
- [x] 2.1 Client根據企劃文件, 將跑馬燈文字製作成多語系表, 製作成陣列-預計天數
- [x] 2.2 Client將訊息陣列 + 圖片陣列, 數值同步給後端人員-預計天數
- [x] 2.3 Client收到GS主動廣播跑馬燈資料時, 能夠正確接收資料-預計天數
- [x] 2.4 Client正確顯示跑馬燈資訊在畫面上-預計天數