Skip to content

fix robbery bug:Wallet is negative #914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions plugin/robbery/robbery.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
Help: "- 打劫[对方Q号|@对方QQ]\n" +
"1. 受害者钱包少于1000不能被打劫\n" +
"2. 打劫成功率 40%\n" +
"4. 打劫失败罚款1000(钱不够不罚钱)\n" +
"4. 打劫失败罚款1000(钱不够,钱包归零)\n" +
"5. 保险赔付0-80%\n" +
"6. 打劫成功获得对方0-5%+500的财产(最高1W)\n" +
"7. 每日可打劫或被打劫一次\n" +
Expand Down Expand Up @@ -104,8 +104,12 @@ func init() {

// 判断打劫是否成功
if rand.Intn(100) > 60 {
updateMoney := wallet.GetWalletOf(uid)
if updateMoney >= 1000 {
updateMoney = 1000
}
ctx.SendChain(message.Text("打劫失败,罚款1000"))
err := wallet.InsertWalletOf(uid, -1000)
err := wallet.InsertWalletOf(uid, -updateMoney)
if err != nil {
ctx.SendChain(message.Text("[ERROR]:罚款失败,钱包坏掉力:\n", err))
return
Expand Down