Skip to content

Commit 502693e

Browse files
authored
fix robbery bug:Wallet is negative (FloatTech#914)
fix robbery bug:Wallet is negative。 修复了打劫失败可能导致钱包为负数的情况。
1 parent 23e567f commit 502693e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugin/robbery/robbery.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func init() {
4141
Help: "- 打劫[对方Q号|@对方QQ]\n" +
4242
"1. 受害者钱包少于1000不能被打劫\n" +
4343
"2. 打劫成功率 40%\n" +
44-
"4. 打劫失败罚款1000(钱不够不罚钱\n" +
44+
"4. 打劫失败罚款1000(钱不够,钱包归零\n" +
4545
"5. 保险赔付0-80%\n" +
4646
"6. 打劫成功获得对方0-5%+500的财产(最高1W)\n" +
4747
"7. 每日可打劫或被打劫一次\n" +
@@ -104,8 +104,12 @@ func init() {
104104

105105
// 判断打劫是否成功
106106
if rand.Intn(100) > 60 {
107+
updateMoney := wallet.GetWalletOf(uid)
108+
if updateMoney >= 1000 {
109+
updateMoney = 1000
110+
}
107111
ctx.SendChain(message.Text("打劫失败,罚款1000"))
108-
err := wallet.InsertWalletOf(uid, -1000)
112+
err := wallet.InsertWalletOf(uid, -updateMoney)
109113
if err != nil {
110114
ctx.SendChain(message.Text("[ERROR]:罚款失败,钱包坏掉力:\n", err))
111115
return

0 commit comments

Comments
 (0)