This commit is contained in:
wh_zcy 2022-08-30 12:02:14 +08:00
commit 2188bb269a
10 changed files with 60 additions and 124 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

@ -11,7 +11,7 @@ import (
)
//参数校验
func (this *apiComp) DeskSkillLvCkeck(session comm.IUserSession, req *pb.SmithyDeskSkillLvReq) (code pb.ErrorCode) {
func (this *apiComp) DeskSkillLvCheck(session comm.IUserSession, req *pb.SmithyDeskSkillLvReq) (code pb.ErrorCode) {
if req.DeskType == 0 {
code = pb.ErrorCode_ReqParameterError
}
@ -23,7 +23,7 @@ func (this *apiComp) DeskSkillLv(session comm.IUserSession, req *pb.SmithyDeskSk
bFindSkill bool
curSkillCfg *cfg.GameSmithyData
)
code = this.DeskSkillLvCkeck(session, req)
code = this.DeskSkillLvCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}

View File

@ -10,14 +10,14 @@ import (
)
//参数校验
func (this *apiComp) StoveSkillLvCkeck(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode) {
func (this *apiComp) StoveSkillLvCheck(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode, dat proto.Message) {
code = this.StoveSkillLvCkeck(session, req)
code = this.StoveSkillLvCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}

View File

@ -52,6 +52,7 @@ func (this *configureComp) GetSmithyConfigData(smithyType int32, level int32) (d
return this._smithyMap[int64(smithyType<<16)+int64(level)]
}
func (this *configureComp) GetSmithyTypeConfigData() (mapType map[int32]struct{}) {
mapType = make(map[int32]struct{}, 0)
if v, err := this.GetConfigure(game_smithy); err == nil {
if configure, ok := v.(*cfg.GameSmithy); ok {
for _, v1 := range configure.GetDataList() {

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
}

View File

@ -18,6 +18,7 @@ import (
"go_dreamfactory/modules/pagoda"
"go_dreamfactory/modules/rtask"
"go_dreamfactory/modules/shop"
"go_dreamfactory/modules/smithy"
"go_dreamfactory/modules/task"
"go_dreamfactory/modules/user"
"go_dreamfactory/modules/viking"
@ -67,6 +68,7 @@ func main() {
martialhall.NewModule(),
rtask.NewModule(),
viking.NewModule(),
smithy.NewModule(),
)
}