This commit is contained in:
liwei1dao 2023-03-06 18:17:19 +08:00
commit 3fd878e271
10 changed files with 55 additions and 66 deletions

View File

@ -721,16 +721,16 @@ const (
)
const (
PrivilegeType1 = iota + 1 //每日获得
PrivilegeType2 //金币商店每日免费刷新次数
PrivilegeType3 //维京远征每日可购买挑战次数
PrivilegeType4 //狩猎每日可购买挑战次数
PrivilegeType5 //竞技场每日可购买挑战次数
PrivilegeType6 //梦境每日可购买挑战次数
PrivilegeType7 //巨怪商队背包容量
PrivilegeType8 //美食馆每日最大制作时间
PrivilegeType9 //武馆每日最大练功时间
PrivilegeType10 //铁匠铺每日最大锻造时间
PrivilegeType1 = iota + 1 //每日获得
PrivilegeType2 //金币商店每日免费刷新次数
PrivilegeType3 //维京远征每日可购买挑战次数
PrivilegeType4 //狩猎每日可购买挑战次数
PrivilegeType5 //竞技场每日可购买挑战次数
PrivilegeType6 //梦境每日可购买挑战次数
PrivilegeType7 //巨怪商队背包容量
PrivilegeType8 //美食馆每日最大制作时间
PrivilegeType9 //武馆每日最大练功时间
)
const (
MainStarType1 = 1 //成功通关

View File

@ -67,7 +67,7 @@ type (
//清理玩家英雄数据
CleanData(uid string)
// 获取指定星级等级的英雄
GetSpecifiedHero(session IUserSession, heroConfId string, star, lv, amount int32) (code pb.ErrorCode)
GetSpecifiedHero(session IUserSession, heroConfId string, star, lv int32) (code pb.ErrorCode)
// 英雄加经验
AddHeroExp(session IUserSession, heroObjID string, exp int32) (curAddExp int32, code pb.ErrorCode)
// 英雄练功

View File

@ -41,9 +41,8 @@ type configureComp struct {
hlock sync.RWMutex
drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级
awakenMap map[int64]*cfg.GameHeroAwakenData
starMap map[int64]*cfg.GameHeroStarupData
module *Hero
starMap map[int64]*cfg.GameHeroStarupData
module *Hero
}
//组件初始化接口
@ -78,9 +77,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
defer this.hlock.Unlock()
if _configure, ok := v.(*cfg.GameHeroAwaken); ok {
for _, v := range _configure.GetDataList() {
this.awakenMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Phase)] = v
this.awakenMap[utils.ToInt64(v.Hid)+int64(v.Phase<<31)] = v
}
return
}
} else {
@ -96,7 +94,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
this.hlock.Lock()
defer this.hlock.Unlock()
for _, v := range _configure.GetDataList() {
this.starMap[int64(utils.ToInt32(v.Id)<<8)+int64(v.Star)] = v
this.starMap[utils.ToInt64(v.Id)+int64(v.Star<<31)] = v
}
return
@ -111,22 +109,23 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
// 获取英雄升星相关配置数据
func (this *configureComp) GetHeroStarupConfig(hid string, star int32) *cfg.GameHeroStarupData {
return this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star)]
return this.starMap[utils.ToInt64(hid)+int64(star<<31)]
}
// 获取当前英雄最高星级
func (this *configureComp) GetHeroMaxStar(hid string, curStar int32) int32 {
var star int32
for star = curStar; star < 100; star++ {
if _, ok := this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star+1)]; !ok {
if _, ok := this.starMap[utils.ToInt64(hid)+int64((star+1)<<31)]; !ok {
return star
}
}
return star
}
// 获取觉醒配置
func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) *cfg.GameHeroAwakenData {
return this.awakenMap[int64(utils.ToInt32(hid)<<8)+int64(phase)]
return this.awakenMap[utils.ToInt64(hid)+int64(phase<<31)]
}
// 抽卡配置表
@ -238,7 +237,7 @@ func (this *configureComp) GetHeroLvgrow(heroId string) *cfg.GameHeroLevelgrowDa
return configure.Get(heroId)
}
}
this.module.Errorf("cfg.GetHeroLvgrow :id = %s", heroId)
return nil
}
@ -251,7 +250,7 @@ func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.GameHe
return
}
}
this.module.Errorf("cfg.GetHeroSkillUpConfig :id = %d", skillid)
return
}
@ -267,7 +266,7 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 {
}
}
}
this.module.Errorf("cfg.GetHeroSkillMaxLvConfig :id = %d", skillId)
return 0
}

View File

@ -204,8 +204,8 @@ func (this *Hero) CleanData(uid string) {
}
// 创建一些特殊的英雄
func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string, star, lv, amount int32) (code pb.ErrorCode) {
if session.GetUserId() == "" || heroConfId == "" || star == 0 || lv == 0 || amount == 0 {
func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string, star, lv int32) (code pb.ErrorCode) {
if session.GetUserId() == "" || heroConfId == "" || star == 0 || lv == 0 {
return pb.ErrorCode_ReqParameterError
}
// 等级校验
@ -235,11 +235,11 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string,
}
hero.Lv = lv
hero.Star = star
hero.SameCount = amount
hero.SameCount = 1
_heroMap := map[string]interface{}{
"lv": hero.Lv,
"star": hero.Star,
"sameCount": amount,
"sameCount": 1,
}
// 保存数据
err = this.modelHero.ChangeList(session.GetUserId(), hero.Id, _heroMap)

View File

@ -234,14 +234,14 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
return
}
this.Debug("任务事件触发",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "taskType", Value: rtaskType},
log.Field{Key: "params", Value: params},
)
// this.Debug("任务事件触发",
// log.Field{Key: "uid", Value: uid},
// log.Field{Key: "taskType", Value: rtaskType},
// log.Field{Key: "params", Value: params},
// )
var (
err error
condiId int32
// err error
// condiId int32
condis []*rtaskCondi
)
@ -264,11 +264,11 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
return
}
if condiId, err = v.find(codiConf, params...); condiId == 0 {
if err != nil {
this.Warnln(errors.WithMessage(err, uid).Error())
}
} else {
if condiId, _ := v.find(codiConf, params...); condiId != 0 {
// if err != nil {
// this.Warnln(errors.WithMessage(err, uid).Error())
// }
// } else {
v.condId = codiConf.Id
condis = append(condis, v)
}

View File

@ -2,8 +2,6 @@
package rtask
import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
@ -109,12 +107,12 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
}
err = this.Change(uid, update)
}
log.Debug("累计次数更新",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condiId", Value: cfg.Id},
log.Field{Key: "params", Value: vals},
log.Field{Key: "updated", Value: record.Vals[cfg.Id]},
)
// log.Debug("累计次数更新",
// log.Field{Key: "uid", Value: uid},
// log.Field{Key: "condiId", Value: cfg.Id},
// log.Field{Key: "params", Value: vals},
// log.Field{Key: "updated", Value: record.Vals[cfg.Id]},
// )
return
}

View File

@ -154,7 +154,6 @@ func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) (
// 指定英雄等级
func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
m, err := this.service.GetModule(comm.ModuleHero)
if err != nil {
return
@ -182,7 +181,6 @@ func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (
// 指定英雄的指定装备数量
func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
m, err := this.service.GetModule(comm.ModuleHero)
if err != nil {
return
@ -220,7 +218,6 @@ func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (
// 指定英雄星级
func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
m, err := this.service.GetModule(comm.ModuleHero)
if err != nil {
return
@ -247,7 +244,6 @@ func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (
// 日常登录一次
func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return
@ -263,7 +259,6 @@ func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (
// 累计登陆xx天
func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return
@ -281,7 +276,6 @@ func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (
// 连续登陆xx天
func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return
@ -299,7 +293,6 @@ func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (
// 拥有xx个好友
func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
m, err := this.service.GetModule(comm.ModuleFriend)
if err != nil {
return
@ -314,7 +307,6 @@ func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData)
// 用户等级达到xx级
func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
defer printCondiLog(uid, cfg)
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return

View File

@ -20,9 +20,8 @@ func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.SmithyC
func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreateOrderReq) (code pb.ErrorCode, data proto.Message) {
var (
res []*cfg.Gameatn
costTime int32
privilegeAddItme int32 // 特权额外增加的时间
res []*cfg.Gameatn
costTime int32
)
code = this.CreateOrderCheck(session, req)
@ -83,8 +82,7 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
return
}
_smithy.OrderCostTime += costTime
privilegeAddItme = this.module.ModulePrivilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType10)
if cfgCom.SmithyMaxtime+privilegeAddItme < _smithy.OrderCostTime { // 大于总时长是不允许的
if cfgCom.SmithyMaxtime < _smithy.OrderCostTime { // 大于总时长是不允许的
code = pb.ErrorCode_GourmetMoreOrderTime
return
}

View File

@ -11,8 +11,6 @@ import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"time"
)
var _ comm.ITask = (*ModuleTask)(nil)
@ -59,10 +57,6 @@ func (this *ModuleTask) Start() (err error) {
// 初始化日常、周常、成就
func (this *ModuleTask) InitTaskAll(uid string) {
t := configure.Now()
defer func() {
log.Debugf("初始化任务 耗时:%v", time.Since(t))
}()
this.modelTask.initTask(uid, comm.TASK_DAILY)
this.modelTask.initTask(uid, comm.TASK_WEEKLY)
this.modelTask.initTask(uid, comm.TASK_ACHIEVE)

View File

@ -88,3 +88,11 @@ func ToInt32(s string) int32 {
return int32(j)
}
}
func ToInt64(s string) int64 {
if j, err := strconv.ParseInt(s, 10, 32); err != nil {
return 0
} else {
return int64(j)
}
}