-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(niuniu): 出售牛牛 #1047
base: master
Are you sure you want to change the base?
feat(niuniu): 出售牛牛 #1047
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1053,6 +1053,8 @@ print("run[CQ:image,file="+j["img"]+"]") | |
|
||
- [x] 赎牛牛 | ||
|
||
- [x] 出售牛牛 | ||
|
||
- [x] 牛牛商店 | ||
|
||
- [x] 牛牛背包 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,8 +142,14 @@ | |
load, ok := prop.Load(t) | ||
info = *u | ||
if props != "" { | ||
if contains(t, dajiaoProp) { | ||
return "", errors.New("道具不存在") | ||
if props != "伟哥" && props != "媚药" { | ||
err = errors.New("道具不存在") | ||
} | ||
if props == "击剑神器" || props == "击剑神稽" { | ||
err = errors.New("道具不能混着用哦") | ||
} | ||
if err != nil { | ||
return "", err | ||
} | ||
if err = u.createUserInfoByProps(props); err != nil { | ||
return "", err | ||
|
@@ -221,8 +227,11 @@ | |
v, ok := prop.Load(t) | ||
info = *u | ||
if props != "" { | ||
if contains(t, jjProp) { | ||
return "", errors.New("道具不存在") | ||
if props != "击剑神器" && props != "击剑神稽" { | ||
err = errors.New("道具不存在") | ||
Check failure on line 231 in plugin/niuniu/model.go GitHub Actions / lint
|
||
} | ||
if props == "伟哥" || props == "媚药" { | ||
err = errors.New("道具不能混着用哦") | ||
Check failure on line 234 in plugin/niuniu/model.go GitHub Actions / lint
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我觉得你直接return比较好🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 没必要专门给第二个if判断return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 你err最后不都被下面这个 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
} | ||
if err = u.createUserInfoByProps(props); err != nil { | ||
return "", err | ||
|
@@ -347,12 +356,12 @@ | |
} | ||
|
||
// findNiuNiu 返回一个用户的牛牛信息 | ||
func (db *model) findNiuNiu(gid, uid int64) (userInfo, error) { | ||
func (db *model) findNiuNiu(gid, uid int64) (*userInfo, error) { | ||
db.RLock() | ||
defer db.RUnlock() | ||
u := userInfo{} | ||
err := db.sql.Find(strconv.FormatInt(gid, 10), &u, "where UID = "+strconv.FormatInt(uid, 10)) | ||
return u, err | ||
return &u, err | ||
} | ||
|
||
// insertNiuNiu 更新一个用户的牛牛信息 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,25 +5,9 @@ import ( | |
"fmt" | ||
"math" | ||
"math/rand" | ||
"strings" | ||
"time" | ||
) | ||
|
||
var ( | ||
jjProp = []string{"击剑神器", "击剑神稽"} | ||
dajiaoProp = []string{"伟哥", "媚药"} | ||
) | ||
|
||
// 检查字符串是否在切片中 | ||
func contains(s string, array []string) bool { | ||
for _, item := range array { | ||
if strings.EqualFold(item, s) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func randomChoice(options []string) string { | ||
return options[rand.Intn(len(options))] | ||
} | ||
|
@@ -56,6 +40,46 @@ func updateMap(t string, d bool) { | |
} | ||
} | ||
|
||
func getMoneyForNumber(n int) (money int) { | ||
switch n { | ||
case 1: | ||
money = 5 | ||
case 2: | ||
money = 10 | ||
default: | ||
money = n * 10 | ||
} | ||
return | ||
} | ||
|
||
func niuNiuProfit(niuniu float64) (money int, message string) { | ||
switch { | ||
case 0 < niuniu && niuniu <= 15: | ||
message = randomChoice([]string{ | ||
"你的牛牛太小啦", | ||
"这么小的牛牛就要肩负起这么大的责任吗?快去打胶吧!", | ||
}) | ||
case niuniu > 15: | ||
money = int(niuniu * 10) | ||
message = randomChoice([]string{ | ||
fmt.Sprintf("你的牛牛已经离你而去了,你赚取了%d个ATRI币", money), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
fmt.Sprintf("啊!你的牛☞已经没啦🤣,为了这点钱就出卖你的牛牛可真不值,你赚取了%d个ATRI币", money), | ||
}) | ||
case niuniu <= 0 && niuniu >= -15: | ||
message = randomChoice([]string{ | ||
"你的牛牛太小啦", | ||
"这么小的牛牛就要肩负起这么大的责任吗?快去找别人玩吧!", | ||
}) | ||
case niuniu < -15: | ||
money = int(math.Abs(niuniu * 10)) | ||
message = randomChoice([]string{ | ||
fmt.Sprintf("此世做了女孩子来世来当男孩子(bushi),你赚取了%d个ATRI币", money), | ||
fmt.Sprintf("呜呜呜,不哭不哭当女孩子不委屈的,你赚取了%d个ATRI币", money), | ||
}) | ||
} | ||
return | ||
} | ||
|
||
func generateRandomStingTwo(niuniu float64) (string, float64) { | ||
probability := rand.Intn(100 + 1) | ||
reduce := math.Abs(hitGlue(niuniu)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATRI币
不建议硬编码进去可以用
wallet.GetWalletName()