Skip to content
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

修复牛牛为负数时jj时的错误 #984

Merged
merged 57 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a29bbec
Update main.go
xyy0411 Aug 31, 2024
c22079e
Update model.go
xyy0411 Aug 31, 2024
78e9d1a
Update utils.go
xyy0411 Aug 31, 2024
4f9c58f
Update README.md
xyy0411 Aug 31, 2024
66afee9
Update main.go
xyy0411 Aug 31, 2024
be5ec00
Update main.go
xyy0411 Sep 1, 2024
22e2447
Update model.go
xyy0411 Sep 1, 2024
05a28c9
Update main.go
xyy0411 Sep 2, 2024
fa0c9d8
Update main.go
xyy0411 Sep 2, 2024
83ee8b6
Update main.go
xyy0411 Sep 2, 2024
dd676ad
Update main.go
xyy0411 Sep 3, 2024
85ca08a
Update main.go
xyy0411 Sep 3, 2024
52d5e87
Merge branch 'FloatTech:master' into master
xyy0411 Sep 8, 2024
2cde59d
Update main.go
xyy0411 Sep 8, 2024
e06ece6
Update utils.go
xyy0411 Sep 8, 2024
8b862fa
Update model.go
xyy0411 Sep 8, 2024
d2f4a29
Update README.md
xyy0411 Sep 8, 2024
4e222f4
Update main.go
xyy0411 Sep 10, 2024
acc2fc4
修改了一些问题
xyy0411 Sep 13, 2024
a74efd7
修改了一些问题
xyy0411 Sep 13, 2024
75c77f1
修改了一些问题
xyy0411 Sep 13, 2024
09a24f7
修改了一些问题
xyy0411 Sep 14, 2024
9bac2a7
Merge remote-tracking branch 'origin/master'
xyy0411 Sep 14, 2024
da37ca6
修改了一些问题
xyy0411 Sep 14, 2024
40e77d8
牛牛商店改面向对象形式,加入NiuNiuPlugin接口
xyy0411 Sep 15, 2024
704f2e8
修改了一些问题
xyy0411 Sep 15, 2024
ffcede5
修改了一些问题
xyy0411 Sep 17, 2024
0c817c9
修改了一些问题
xyy0411 Sep 21, 2024
2b4d380
修复lint
xyy0411 Sep 21, 2024
531da5a
修复一些逻辑问题
xyy0411 Sep 25, 2024
7f4adce
修lint
xyy0411 Sep 25, 2024
6ab034d
Merge branch 'master' into master
fumiama Sep 26, 2024
f9819c7
修正逻辑
xyy0411 Sep 26, 2024
185f857
修正逻辑
xyy0411 Sep 26, 2024
9b9a17f
修正逻辑
xyy0411 Sep 26, 2024
12bc059
Merge remote-tracking branch 'origin/master'
xyy0411 Sep 26, 2024
9ce8dc2
修正逻辑
xyy0411 Sep 26, 2024
5651011
Merge remote-tracking branch 'origin/master'
xyy0411 Sep 26, 2024
d68d6af
修正逻辑
xyy0411 Sep 26, 2024
05e18c7
修正逻辑
xyy0411 Sep 26, 2024
630de6b
给qqwife插件添加查询结婚函数,修复niuniu的一些bug
xyy0411 Sep 27, 2024
2052c68
删除一些测试代码
xyy0411 Sep 27, 2024
1a36392
修正qqwife里结构体的大小写
xyy0411 Sep 27, 2024
ba0ae14
Update utils.go
xyy0411 Sep 27, 2024
393f89f
Update main.go
xyy0411 Sep 27, 2024
954bf86
Merge branch 'master' of https://github.com/xyy0411/ZeroBot-Plugin
xyy0411 Sep 27, 2024
952e579
修改niuniu的一些逻辑问题
xyy0411 Sep 28, 2024
cbf58b4
Merge pull request #1 from xyy0411/test
xyy0411 Sep 28, 2024
16d8326
修改fencing函数
xyy0411 Sep 28, 2024
3fb3a08
Merge remote-tracking branch 'origin/master'
xyy0411 Sep 28, 2024
5cd50cc
修正niuniu的逻辑问题
xyy0411 Sep 28, 2024
89bb313
Update command.go
xyy0411 Sep 28, 2024
c162044
Update function.go
xyy0411 Sep 28, 2024
6cca55a
修正niuniu的逻辑问题
xyy0411 Sep 28, 2024
8b2e3ca
Merge remote-tracking branch 'origin/master'
xyy0411 Sep 28, 2024
0e00827
修正niuniu的逻辑问题
xyy0411 Sep 28, 2024
a0fe94d
添加一些暂定道具
xyy0411 Sep 28, 2024
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
17 changes: 10 additions & 7 deletions plugin/niuniu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func init() {
for {
select {
case <-timer.C:
ctx.SendChain(message.At(uid), message.Text("超时,已自动取消"))
ctx.SendChain(message.At(uid), message.Text(" 超时,已自动取消"))
return
case r := <-recv:
answer = r.Event.Message.String()
Expand All @@ -122,7 +122,7 @@ func init() {
return
}

u, money, err := purchaseItem(n, info)
money, err := purchaseItem(n, info)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
Expand All @@ -138,7 +138,7 @@ func init() {
return
}

if err = db.insertNiuNiu(u, gid); err != nil {
if err = db.insertNiuNiu(&info, gid); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func init() {
result.WriteString(fmt.Sprintf("\n📛%s<%s>的牛牛信息\n⭕性别:%s\n⭕%s度:%.2fcm\n⭕排行:%d\n⭕%s ",
ctx.CardOrNickName(uid), strconv.FormatInt(uid, 10),
sex, sexLong, niuniu, niuniuList.ranking(niuniu, uid), generateRandomString(niuniu)))
ctx.SendChain(message.At(uid), message.Text(&result))
ctx.SendChain(message.Text(&result))
})
en.OnRegex(`^(?:.*使用(.*))??打胶$`, zero.OnlyGroup,
getdb).SetBlock(true).Limit(func(ctx *zero.Ctx) *rate.Limiter {
Expand All @@ -288,22 +288,25 @@ func init() {
t := fmt.Sprintf("%d_%d", gid, uid)
fiancee := ctx.State["regex_matched"].([]string)
updateMap(t, false)

niuniu, err := db.findNiuNiu(gid, uid)
if err != nil {
ctx.SendChain(message.Text("请先注册牛牛!"))
dajiaoLimiter.Delete(fmt.Sprintf("%d_%d", gid, uid))
return
}
messages, err := processNiuniuAction(t, niuniu, fiancee[1])

messages, err := processNiuniuAction(t, &niuniu, fiancee[1])
if err != nil {
ctx.SendChain(message.Text(err))
return
}
ctx.SendChain(message.Text(messages))
if err = db.insertNiuNiu(&niuniu, gid); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}

ctx.SendChain(message.Text(messages))
})
en.OnFullMatch("注册牛牛", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) {
gid := ctx.Event.GroupID
Expand Down Expand Up @@ -375,7 +378,7 @@ func init() {
jjLimiter.Delete(t)
return
}
fencingResult, f1, err := processJJuAction(myniuniu, adduserniuniu, t, fiancee[1])
fencingResult, f1, err := processJJuAction(&myniuniu, &adduserniuniu, t, fiancee[1])
if err != nil {
ctx.SendChain(message.Text(err))
return
Expand Down
5 changes: 5 additions & 0 deletions plugin/niuniu/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ type userInfo struct {
Philter int // 媚药
Artifact int // 击剑神器
ShenJi int // 击剑神稽
Buff1 int // 暂定
Buff2 int // 暂定
Buff3 int // 暂定
Buff4 int // 暂定
Buff5 int // 暂定
}

type users []*userInfo
Expand Down
25 changes: 14 additions & 11 deletions plugin/niuniu/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"
)

func createUserInfoByProps(props string, niuniu userInfo) error {
func createUserInfoByProps(props string, niuniu *userInfo) error {
var (
err error
)
Expand Down Expand Up @@ -46,7 +46,7 @@ func createUserInfoByProps(props string, niuniu userInfo) error {

// 接收值依次是 自己和被jj用户的信息 一个包含gid和uid的字符串 道具名称
// 返回值依次是 要发生的消息 错误信息
func processJJuAction(myniuniu, adduserniuniu userInfo, t string, props string) (string, float64, error) {
func processJJuAction(myniuniu, adduserniuniu *userInfo, t string, props string) (string, float64, error) {
var (
fencingResult string
f float64
Expand All @@ -55,7 +55,7 @@ func processJJuAction(myniuniu, adduserniuniu userInfo, t string, props string)
err error
)
v, ok := prop.Load(t)
u = myniuniu
u = *myniuniu
if props != "" {
if props != "击剑神器" && props != "击剑神稽" {
return "", 0, errors.New("道具不存在")
Expand Down Expand Up @@ -84,15 +84,15 @@ func processJJuAction(myniuniu, adduserniuniu userInfo, t string, props string)
}
return fencingResult, f1, err
}
func processNiuniuAction(t string, niuniu userInfo, props string) (string, error) {
func processNiuniuAction(t string, niuniu *userInfo, props string) (string, error) {
var (
messages string
f float64
u userInfo
err error
f float64
)
load, ok := prop.Load(t)
u = niuniu
u = *niuniu
if props != "" {
if props != "伟哥" && props != "媚药" {
return "", errors.New("道具不存在")
Expand Down Expand Up @@ -126,7 +126,7 @@ func processNiuniuAction(t string, niuniu userInfo, props string) (string, error
return messages, err
}

func purchaseItem(n int, info userInfo) (*userInfo, int, error) {
func purchaseItem(n int, info userInfo) (int, error) {
var (
money int
err error
Expand All @@ -147,7 +147,7 @@ func purchaseItem(n int, info userInfo) (*userInfo, int, error) {
default:
err = errors.New("无效的选择")
}
return &info, money, err
return money, err
}

func generateRandomStingTwo(niuniu float64) (string, float64) {
Expand Down Expand Up @@ -293,6 +293,7 @@ func calculateWinProbability(heightA, heightB float64) float64 {
// applySkill 应用击剑技巧并生成结果
func applySkill(myLength, oppoLength float64, increaseLength1 bool) (string, float64, float64) {
reduce := fence(oppoLength)
//兜底操作
if reduce == 0 {
reduce = rand.Float64() + float64(rand.Intn(3))
}
Expand All @@ -314,10 +315,12 @@ func applySkill(myLength, oppoLength float64, increaseLength1 bool) (string, flo

// fence 根据长度计算减少的长度
func fence(rd float64) float64 {
r := hitGlue(rd)*2 + rand.Float64()*math.Log2(rd)
if rand.Intn(2) == 1 {
return rd - rand.Float64()*r
rd = math.Abs(rd)
if rd == 0 {
rd = 1
}
r := hitGlue(rd)*2 + rand.Float64()*math.Log2(rd)

return float64(int(r * rand.Float64()))
}

Expand Down
Loading