Skip to content

update robbery, fix:spelling mistakes #932

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
Jul 24, 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
22 changes: 11 additions & 11 deletions plugin/robbery/robbery.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ func init() {
}
return
}
userIncrMonry := math.Min(rand.Intn(victimWallet/20)+500, 10000)
victimDecrMonry := userIncrMonry / (rand.Intn(4) + 1)
userIncrMoney := math.Min(rand.Intn(victimWallet/20)+500, 10000)
victimDecrMoney := userIncrMoney / (rand.Intn(4) + 1)

// 记录结果
err = wallet.InsertWalletOf(victimID, -victimDecrMonry)
err = wallet.InsertWalletOf(victimID, -victimDecrMoney)
if err != nil {
ctx.SendChain(message.Text("[ERROR]:钱包坏掉力:\n", err))
return
}
err = wallet.InsertWalletOf(uid, +userIncrMonry)
err = wallet.InsertWalletOf(uid, +userIncrMoney)
if err != nil {
ctx.SendChain(message.Text("[ERROR]:打劫失败,脏款掉入虚无\n", err))
return
Expand All @@ -142,8 +142,8 @@ func init() {
ctx.SendChain(message.At(uid), message.Text("[ERROR]:犯罪记录写入失败\n", err))
}

ctx.SendChain(message.At(uid), message.Text("打劫成功,钱包增加:", userIncrMonry, "ATRI币"))
ctx.SendChain(message.At(victimID), message.Text("保险公司对您进行了赔付,您实际损失:", victimDecrMonry, "ATRI币"))
ctx.SendChain(message.At(uid), message.Text("打劫成功,钱包增加:", userIncrMoney, "ATRI币"))
ctx.SendChain(message.At(victimID), message.Text("保险公司对您进行了赔付,您实际损失:", victimDecrMoney, "ATRI币"))
})
}

Expand All @@ -163,19 +163,19 @@ func (sql *robberyRepo) getRecord(victimID, uid int64) (ok int, err error) {
// 没有记录即不用比较
return 0, nil
}
cdinfo := robberyRecord{}
cdInfo := robberyRecord{}

err = sql.db.FindFor("criminal_record", &cdinfo, limitID, func() error {
if time.Now().Format("2006/01/02") != cdinfo.Time {
err = sql.db.FindFor("criminal_record", &cdInfo, limitID, func() error {
if time.Now().Format("2006/01/02") != cdInfo.Time {
// // 如果跨天了就删除
err = sql.db.Del("criminal_record", limitID)
return nil
}
// 俩个if是为了保证,重复打劫同一个人,ok == 3
if cdinfo.UserID == uid {
if cdInfo.UserID == uid {
ok += 2
}
if cdinfo.VictimID == victimID {
if cdInfo.VictimID == victimID {
// lint 不允许使用 ok += 1
ok++
}
Expand Down
Loading