Skip to content

Commit

Permalink
fix robbery bug:Wallet is negative
Browse files Browse the repository at this point in the history
fix robbery bug:Wallet is negative。
修复了打劫失败可能导致钱包为负数的情况。
  • Loading branch information
vatebur committed May 22, 2024
1 parent a5a24e7 commit e7b4056
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugin/robbery/robbery.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func init() {

// 判断打劫是否成功
if rand.Intn(100) > 60 {
if wallet.GetWalletOf(uid) < 1000 {
ctx.SendChain(message.Text("打劫失败,您身上没有钱支付罚款"))
return
}
ctx.SendChain(message.Text("打劫失败,罚款1000"))
err := wallet.InsertWalletOf(uid, -1000)
if err != nil {
Expand Down

0 comments on commit e7b4056

Please sign in to comment.