drop接口修改 支持多参数

This commit is contained in:
meixiongfeng 2022-08-30 11:34:15 +08:00
parent a875f850ba
commit 8490699f6d
6 changed files with 53 additions and 120 deletions

View File

@ -2,9 +2,11 @@ package modules
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"sync"
@ -156,7 +158,55 @@ func (this *MCompConfigure) GetPlayerFigureConf() (list []*cfg.GameFacemodData)
}
return
}
func (this *MCompConfigure) GetDropData(dropId int32) (data []*cfg.GameDropData) {
data = this._dropMap[dropId]
return
}
// todo 调用drop 表 获取掉落信息
func (this *MCompConfigure) GetMultipleDropReward(count, dropId int32, Items []*pb.UserAssets) {
res := make([]*cfg.Gameatn, 0)
for i := 0; i < int(count); i++ {
data := this.GetDropData(dropId)
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)
}
if len(szW) > 0 {
index := comm.GetRandW(szW)
res = append(res, data[index].Prize...)
}
}
for _, v := range res {
bFind := false
for _, v1 := range Items {
if v.A == v1.A && v.T == v1.T {
v1.N += v.N
bFind = true
}
}
if !bFind {
Items = append(Items, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
return
}
func (this *MCompConfigure) GetDropReward(dropId int32, Items []*cfg.Gameatn) {
Items = make([]*cfg.Gameatn, 0)
data := this.GetDropData(dropId)
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)
}
index := comm.GetRandW(szW)
Items = append(Items, data[index].Prize...)
return
}

View File

@ -6,7 +6,6 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"time"
@ -65,40 +64,6 @@ func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]i
return this.Change(uid, data)
}
// todo 调用drop 表 获取掉落信息
func (this *modelGourmet) GetDropReward(count, dropId int32, Items []*pb.UserAssets) {
res := make([]*cfg.Gameatn, 0)
for i := 0; i < int(count); i++ {
data := this.module.configure.GetDropData(dropId)
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)
}
if len(szW) > 0 {
index := comm.GetRandW(szW)
res = append(res, data[index].Prize...)
}
}
for _, v := range res {
bFind := false
for _, v1 := range Items {
if v.A == v1.A && v.T == v1.T {
v1.N += v.N
bFind = true
}
}
if !bFind {
Items = append(Items, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
return
}
// 计算订单信息
func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) {
var (
@ -140,7 +105,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
gourmet.OrderCostTime = 0 // 清空当天的订单时长
}
order.FoodCount--
this.GetDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励
this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励
if curTime > costTime {
gourmet.OrderCostTime += int32(curTime - costTime)

View File

@ -6,7 +6,6 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"time"
@ -61,38 +60,6 @@ func (this *modelSmithy) modifySmithyDataByObjId(uid string, data map[string]int
return this.Change(uid, data)
}
// todo 调用drop 表 获取掉落信息
func (this *modelSmithy) GetDropReward(count, dropId int32, Items []*pb.UserAssets) {
res := make([]*cfg.Gameatn, 0)
for i := 0; i < int(count); i++ {
data := this.module.configure.GetDropData(dropId)
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)
}
index := comm.GetRandW(szW)
res = append(res, data[index].Prize...)
}
for _, v := range res {
bFind := false
for _, v1 := range Items {
if v.A == v1.A && v.T == v1.T {
v1.N += v.N
bFind = true
}
}
if !bFind {
Items = append(Items, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
return
}
// 计算订单信息
func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) {
var (
@ -134,7 +101,7 @@ func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) {
Smithy.OrderCostTime = 0 // 清空当天的订单时长
}
order.Count--
this.GetDropReward(1, _Smithycfg.Drop, Smithy.Items) // 获取掉落奖励
this.module.configure.GetMultipleDropReward(1, _Smithycfg.Drop, Smithy.Items) // 获取掉落奖励
if curTime > costTime {
Smithy.OrderCostTime += int32(curTime - costTime)

View File

@ -70,7 +70,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
viking.ChallengeTime[req.BossType<<16+req.Difficulty] = 0
code = this.module.ModifyVikingData(session.GetUserId(), mapData)
// 发放通关随机奖励
this.module.GetDropReward(cfg.Drop, reward) // 获取掉落奖励
this.module.configure.GetDropReward(cfg.Drop, reward) // 获取掉落奖励
if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success {
return
}

View File

@ -6,7 +6,6 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
@ -40,37 +39,3 @@ func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err err
func (this *modelViking) modifyVikingDataByObjId(uid string, data map[string]interface{}) error {
return this.Change(uid, data)
}
// todo 调用drop 表 获取掉落信息
func (this *modelViking) GetDropReward(count, dropId int32, Items []*pb.UserAssets) {
res := make([]*cfg.Gameatn, 0)
for i := 0; i < int(count); i++ {
data := this.module.configure.GetDropData(dropId)
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)
}
if len(szW) > 0 {
index := comm.GetRandW(szW)
res = append(res, data[index].Prize...)
}
}
for _, v := range res {
bFind := false
for _, v1 := range Items {
if v.A == v1.A && v.T == v1.T {
v1.N += v.N
bFind = true
}
}
if !bFind {
Items = append(Items, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
return
}

View File

@ -10,7 +10,6 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
)
type Viking struct {
@ -51,16 +50,3 @@ func (this *Viking) ModifyVikingData(uid string, data map[string]interface{}) (c
}
return
}
func (this *Viking) GetDropReward(dropId int32, Items []*cfg.Gameatn) {
Items = make([]*cfg.Gameatn, 0)
data := this.configure.GetDropData(dropId)
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)
}
index := comm.GetRandW(szW)
Items = append(Items, data[index].Prize...)
return
}