From 5c90f2f0b7d5a54f9de8b7ca8f1b0a4f882cca82 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 10 May 2024 15:29:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B8=B8=E6=88=8F=E6=8E=89=E8=90=BD?= =?UTF-8?q?=E9=81=93=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srvdata/gamedropmgr.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/srvdata/gamedropmgr.go b/srvdata/gamedropmgr.go index 557d4a3..915270c 100644 --- a/srvdata/gamedropmgr.go +++ b/srvdata/gamedropmgr.go @@ -76,9 +76,9 @@ func (this *GameDropMgr) GetDropInfoByBaseScore(gameId, baseCoin int32) []*GameD i := sort.Search(len(arr), func(i int) bool { return arr[i].BaseCoin > int64(baseCoin) }) - if i < len(arr) && i > 0 { - n := arr[i-1].BaseCoin - for i := i - 1; i >= 0; i-- { + + f := func(n int64, i int) { + for ; i >= 0; i-- { if arr[i].BaseCoin == n { ret = append(ret, arr[i]) } else { @@ -86,5 +86,21 @@ func (this *GameDropMgr) GetDropInfoByBaseScore(gameId, baseCoin int32) []*GameD } } } + + // 找到 + if i < len(arr) && i > 0 { + n := arr[i-1].BaseCoin + f(n, i-1) + } + + if len(ret) == 0 { + // 没找到,最大底注是否可用 + i = len(arr) - 1 + n := arr[i].BaseCoin + if n <= int64(baseCoin) { + f(n, i) + } + } + return ret }