From 88b2127ad8a84ac47f79b175e864c51037149eb1 Mon Sep 17 00:00:00 2001 From: hanshino Date: Fri, 19 Jan 2024 18:59:25 +0000 Subject: [PATCH] Add NumberController for Sic Bo game --- app/locales/zh_tw.json | 5 +- app/src/app.js | 3 + .../application/NumberController.js | 141 +++++++++++++ app/src/templates/application/Number.js | 198 ++++++++++++++++++ 4 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 app/src/controller/application/NumberController.js create mode 100644 app/src/templates/application/Number.js diff --git a/app/locales/zh_tw.json b/app/locales/zh_tw.json index 210bae4d..52660d95 100644 --- a/app/locales/zh_tw.json +++ b/app/locales/zh_tw.json @@ -171,7 +171,10 @@ "add_start_analyze_success": "成功分析開始時間...", "add_end_now": "未指定結束時間,設定為現在之後一小時...", "add_end_analyze_success": "成功分析結束時間...", - "admin_now": "正在舉辦的遊戲:\n{{ id }}\n{{ name }}" + "admin_now": "正在舉辦的遊戲:\n{{ id }}\n{{ name }}", + "sic_bo_rolled": "骰出了 {{ dice1 }}、{{ dice2 }}、{{ dice3 }},總和為 {{ sum }}", + "sic_bo_win": "你選擇的是 {{ option }},獲得 {{ chips }} * {{ payout }} = {{ total }} 顆女神石", + "sic_bo_lose": "你選擇的是 {{ option }},失去 {{ chips }} 顆女神石" }, "trade": { "no_mention": "請標記要交易的對象", diff --git a/app/src/app.js b/app/src/app.js index fb110a36..aabb443c 100644 --- a/app/src/app.js +++ b/app/src/app.js @@ -34,6 +34,7 @@ const LotteryController = require("./controller/application/LotteryController"); const BullshitController = require("./controller/application/BullshitController"); const SubscribeController = require("./controller/application/SubscribeController"); const ScratchCardController = require("./controller/application/ScratchCardController"); +const NumberController = require("./controller/application/NumberController"); const { transfer } = require("./middleware/dcWebhook"); const redis = require("./util/redis"); const traffic = require("./util/traffic"); @@ -97,6 +98,7 @@ async function HandlePostback(context, { next }) { () => action === "exchangeScratchCard", withProps(ScratchCardController.exchange, { payload }) ), + route(() => action === "sicBoGuess", withProps(NumberController.postbackDecide, { payload })), route("*", next), ]); } catch (e) { @@ -134,6 +136,7 @@ async function OrderBased(context, { next }) { ...BullshitController.router, ...SubscribeController.router, ...ScratchCardController.router, + ...NumberController.router, text(/^[/#.](使用說明|help)$/, welcome), text(/^[/#.]抽(\*(?\d+))?(\s*(?[\s\S]+))?$/, gacha.play), text(/^[/#.]消耗抽(\*(?\d+))?(\s*(?[\s\S]+))?$/, (context, props) => diff --git a/app/src/controller/application/NumberController.js b/app/src/controller/application/NumberController.js new file mode 100644 index 00000000..8ea8952c --- /dev/null +++ b/app/src/controller/application/NumberController.js @@ -0,0 +1,141 @@ +const { text } = require("bottender/router"); +const { sample, get } = require("lodash"); +const NumberTemplate = require("../../templates/application/Number"); +const i18n = require("../../util/i18n"); + +exports.router = [ + text(/^[.#/](猜大小) (?\d{1,7})$/, privateSicBoHolding), + text(/^[.#/](猜) (?