Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
70ab245740
@ -707,3 +707,8 @@ const (
|
||||
MainStarType2 = 1 //死亡人数不超过{0}人
|
||||
MainStarType3 = 1 //不超过{0}回合通关
|
||||
)
|
||||
|
||||
const (
|
||||
UseType1 int32 = 1 //英雄碎片
|
||||
UseType8 int32 = 8 //觉醒材料合成
|
||||
)
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -23,7 +22,7 @@ func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.Gourmet
|
||||
func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
res []*cfg.Gameatn // 订单消耗
|
||||
costTime int32
|
||||
costTime int32 // 当前订单的总耗时
|
||||
szTime map[int32]int32 // 记录每个类型的订单耗时 key 是技能组type value 订单耗时
|
||||
privilegeAddItme int32 // 特权额外增加的时间
|
||||
)
|
||||
@ -48,10 +47,10 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
}
|
||||
}
|
||||
|
||||
if !utils.IsToday(_gourmet.Ctime) { // 跨天了
|
||||
_gourmet.Ctime = configure.Now().Unix()
|
||||
_gourmet.OrderCostTime = 0
|
||||
}
|
||||
// if !utils.IsToday(_gourmet.Ctime) { // 跨天了
|
||||
// _gourmet.Ctime = configure.Now().Unix()
|
||||
// _gourmet.OrderCostTime = 0
|
||||
// }
|
||||
// 计算消耗
|
||||
for _, order := range req.Order {
|
||||
if order.FoodCount == 0 {
|
||||
@ -97,9 +96,6 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
}
|
||||
// 重新计算时间
|
||||
for _, v := range _gourmet.Foods {
|
||||
if v.FoodCount == 0 {
|
||||
continue
|
||||
}
|
||||
if v1, ok := szTime[v.FoodType]; ok {
|
||||
v.CookTime = v1 * v.FoodCount
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]i
|
||||
// 计算订单信息
|
||||
func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) {
|
||||
var (
|
||||
szTime map[int32]int32
|
||||
szTime map[int32]int32 // 食材耗时
|
||||
zeroTime int64 // 当前时间对应的0点时间戳,用来判断是否跨天了
|
||||
)
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
@ -87,13 +87,8 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
|
||||
// 有订单在做
|
||||
zeroTime = utils.GetTodayZeroTime(configure.Now().Unix())
|
||||
for {
|
||||
if gourmet.CookingFood != nil {
|
||||
if configure.Now().Unix() < gourmet.CookingFood.ETime {
|
||||
break
|
||||
}
|
||||
}
|
||||
bRet := false
|
||||
|
||||
if (gourmet.CookingFood != nil && gourmet.CookingFood.ETime >= configure.Now().Unix()) || gourmet.CookingFood == nil {
|
||||
for _, order := range gourmet.Foods {
|
||||
_gourmetcfg := this.module.configure.GetGourmetConfigData(order.FoodType, gourmet.Skill[order.FoodType]) // 美食家配置表
|
||||
if order.FoodCount > 0 {
|
||||
@ -109,7 +104,13 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
gourmet.CookingFood = &pb.Cooking{}
|
||||
gourmet.CookingFood.STime = configure.Now().Unix()
|
||||
gourmet.CookingFood.ETime = configure.Now().Unix() + int64(szTime[order.FoodType])
|
||||
|
||||
// 如果此时跨天了 清除订单时常
|
||||
if gourmet.CookingFood.STime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时
|
||||
gourmet.OrderCostTime = 0
|
||||
for _, order := range gourmet.Foods { // 重新计算订单时常
|
||||
gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gourmet.CookingFood.STime += int64(szTime[order.FoodType])
|
||||
oldTime := gourmet.CookingFood.ETime
|
||||
@ -117,8 +118,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
// 如果此时跨天了 清除订单时常
|
||||
if oldTime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时
|
||||
gourmet.OrderCostTime = 0
|
||||
// 重新计算订单时常
|
||||
for _, order := range gourmet.Foods {
|
||||
for _, order := range gourmet.Foods { // 重新计算订单时常
|
||||
gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType]
|
||||
}
|
||||
}
|
||||
@ -128,32 +128,25 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
gourmet.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励
|
||||
// 记录下订单时间
|
||||
gourmet.Ctime = gourmet.CookingFood.ETime
|
||||
mapData["ctime"] = gourmet.Ctime
|
||||
bRet = true
|
||||
gourmet.TotalTime += szTime[order.FoodType]
|
||||
mapData["totalTime"] = gourmet.TotalTime
|
||||
}
|
||||
}
|
||||
if !bRet { // 没有订单可以做
|
||||
if gourmet.CookingFood != nil {
|
||||
if gourmet.CookingFood.ETime <= configure.Now().Unix() {
|
||||
|
||||
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= configure.Now().Unix() {
|
||||
_gourmetcfg := this.module.configure.GetGourmetConfigData(gourmet.CookingFood.FoodType, gourmet.Skill[gourmet.CookingFood.FoodType])
|
||||
gourmet.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items)
|
||||
gourmet.CookingFood = nil
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 保存信息
|
||||
mapData["items"] = gourmet.Items
|
||||
mapData["foods"] = gourmet.Foods
|
||||
mapData["orderCostTime"] = gourmet.OrderCostTime
|
||||
mapData["cookingFood"] = gourmet.CookingFood // 正在做的
|
||||
|
||||
mapData["totalTime"] = gourmet.TotalTime
|
||||
mapData["ctime"] = gourmet.Ctime
|
||||
this.module.ModifyGourmetData(uid, mapData) // 同步数据
|
||||
|
||||
}
|
||||
|
||||
// 技能等级提高了 重新计算订单时间(只对订单中数据有影响)
|
||||
|
@ -114,7 +114,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
// 狩猎副本掉落觉醒材料
|
||||
for _, v := range reward {
|
||||
if _conf, err := this.module.configure.GetItemConfigureData(v.T); err == nil {
|
||||
if _conf.Usetype == 8 {
|
||||
if _conf.Usetype == comm.UseType8 {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype154, v.N)
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
if newChallenge && bWin {
|
||||
for _, v := range cfgHunting.Firstprize {
|
||||
if _conf, err := this.module.configure.GetItemConfigureData(v.T); err == nil {
|
||||
if _conf.Usetype == 8 {
|
||||
if _conf.Usetype == comm.UseType8 {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype154, v.N)
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
return
|
||||
}
|
||||
switch itemcf.Usetype {
|
||||
case 1: //英雄碎片
|
||||
case comm.UseType1: //英雄碎片
|
||||
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
@ -122,7 +122,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
return
|
||||
}
|
||||
break
|
||||
case 8: //觉醒材料合成
|
||||
case comm.UseType8: //觉醒材料合成
|
||||
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
|
@ -42,23 +42,16 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge
|
||||
}
|
||||
}
|
||||
if curChapter == nil { // 校验是不是新的数据
|
||||
if stageConf.Previoustage == 0 { // 创建一条新的章节数据
|
||||
chapter := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验
|
||||
bCheck := false
|
||||
if chapter == 0 {
|
||||
bCheck = true
|
||||
} else {
|
||||
for _, v := range list {
|
||||
if chapter == v.ChapterId { // 有上一章节数据
|
||||
if _, ok := v.Star[stageConf.Previoustage]; ok {
|
||||
bCheck = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
preStage := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验
|
||||
preStageConf := this.module.configure.GetMainStageConf(preStage)
|
||||
if stageConf == nil { // 配置文件校验
|
||||
code = pb.ErrorCode_MainlineNotFindChapter
|
||||
return
|
||||
}
|
||||
|
||||
if bCheck {
|
||||
for _, v := range list {
|
||||
if preStageConf.CaptainId == v.ChapterId { // 有上一章节数据
|
||||
if _, ok := v.Star[v.StageId]; ok {
|
||||
newData := &pb.DBMline{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: session.GetUserId(),
|
||||
@ -70,12 +63,13 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge
|
||||
Ps: map[int32]int32{},
|
||||
}
|
||||
this.module.modelMline.addNewChapter(session.GetUserId(), newData)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
code = pb.ErrorCode_MainlineNotFindChapter
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := curChapter.Ps[req.StageId]; ok && v > 0 {
|
||||
if v != 0 { // 扣1点
|
||||
@ -109,9 +103,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge
|
||||
this.module.modelMline.modifyMlineData(session.GetUserId(), curChapter.Id, map[string]interface{}{
|
||||
"ps": curChapter.Ps,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Ptype: pb.PlayType_mainline,
|
||||
Title: "",
|
||||
|
@ -73,20 +73,13 @@ func (this *configureComp) GetMainStageConf(id int32) (data *cfg.GameMainStageDa
|
||||
return
|
||||
}
|
||||
|
||||
// 获取上一章节信息
|
||||
func (this *configureComp) GetPreMainChapter(id int32) (stageID int32) {
|
||||
if v, err := this.GetConfigure(game_mainchapter); err == nil {
|
||||
if configure, ok := v.(*cfg.GameMainChapter); ok {
|
||||
for index, v1 := range configure.GetDataList() {
|
||||
if v1.Id == id {
|
||||
if index > 0 {
|
||||
data := configure.GetDataList()[index-1]
|
||||
if v1.ChapterType != data.ChapterType { // 章节类型必须一致
|
||||
stageID = data.Id
|
||||
}
|
||||
} else { // 第一章节
|
||||
stageID = 0
|
||||
}
|
||||
// 获取上一关卡信息
|
||||
func (this *configureComp) GetPreMainChapter(stageId int32) (preStageID int32) {
|
||||
if v, err := this.GetConfigure(game_mainstage); err == nil {
|
||||
if configure, ok := v.(*cfg.GameMainStage); ok {
|
||||
for _, v1 := range configure.GetDataList() {
|
||||
if v1.Previoustage == stageId {
|
||||
preStageID = v1.Id
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -46,10 +45,10 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
|
||||
if _smithy.Ctime == 0 {
|
||||
_smithy.Ctime = configure.Now().Unix()
|
||||
}
|
||||
if !utils.IsToday(_smithy.Ctime) {
|
||||
_smithy.Ctime = configure.Now().Unix()
|
||||
_smithy.OrderCostTime = 0
|
||||
}
|
||||
// if !utils.IsToday(_smithy.Ctime) {
|
||||
// _smithy.Ctime = configure.Now().Unix()
|
||||
// _smithy.OrderCostTime = 0
|
||||
// }
|
||||
_smithy.Orders = append(_smithy.Orders, req.Order...) // 直接追加订单数据
|
||||
if _smithy.Clang == nil || (_smithy.Clang != nil && _smithy.Clang.ETime == 0) {
|
||||
for _, v := range _smithy.Orders {
|
||||
|
@ -78,18 +78,13 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
|
||||
// 有订单在做
|
||||
zeroTime = utils.GetTodayZeroTime(configure.Now().Unix())
|
||||
for {
|
||||
if smithy.Clang != nil {
|
||||
if configure.Now().Unix() < smithy.Clang.ETime {
|
||||
break
|
||||
}
|
||||
}
|
||||
bRet := false
|
||||
|
||||
if (smithy.Clang != nil && smithy.Clang.ETime >= configure.Now().Unix()) || smithy.Clang == nil {
|
||||
for _, order := range smithy.Orders {
|
||||
_gourmetcfg := this.module.configure.GetSmithyConfigData(order.DeskType, smithy.Skill[order.DeskType]) // 美食家配置表
|
||||
|
||||
if order.Count > 0 {
|
||||
if smithy.Clang.ETime > configure.Now().Unix() {
|
||||
if smithy.Clang != nil && smithy.Clang.ETime > configure.Now().Unix() {
|
||||
break
|
||||
}
|
||||
order.Count--
|
||||
@ -101,7 +96,12 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
smithy.Clang = &pb.Clang{}
|
||||
smithy.Clang.STime = configure.Now().Unix()
|
||||
smithy.Clang.ETime = configure.Now().Unix() + int64(szTime[order.DeskType])
|
||||
|
||||
if smithy.Clang.STime < zeroTime && zeroTime <= smithy.Clang.ETime { // 跨天清空订单耗时
|
||||
smithy.OrderCostTime = 0
|
||||
for _, order := range smithy.Orders { // 重新计算订单时常
|
||||
smithy.OrderCostTime += order.Count * szTime[order.DeskType]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
smithy.Clang.STime += int64(szTime[order.DeskType])
|
||||
oldTime := smithy.Clang.ETime
|
||||
@ -109,8 +109,7 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
// 如果此时跨天了 清除订单时常
|
||||
if oldTime < zeroTime && zeroTime <= smithy.Clang.ETime { // 跨天清空订单耗时
|
||||
smithy.OrderCostTime = 0
|
||||
// 重新计算订单时常
|
||||
for _, order := range smithy.Orders {
|
||||
for _, order := range smithy.Orders { // 重新计算订单时常
|
||||
smithy.OrderCostTime += order.Count * szTime[order.DeskType]
|
||||
}
|
||||
}
|
||||
@ -120,23 +119,17 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
smithy.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Drop, smithy.Items) // 获取掉落奖励
|
||||
// 记录下订单时间
|
||||
smithy.Ctime = smithy.Clang.ETime
|
||||
mapData["ctime"] = smithy.Ctime
|
||||
bRet = true
|
||||
smithy.TotalTime += szTime[order.DeskType]
|
||||
mapData["totalTime"] = smithy.TotalTime
|
||||
}
|
||||
}
|
||||
if !bRet { // 没有订单可以做
|
||||
if smithy.Clang != nil {
|
||||
if smithy.Clang.ETime <= configure.Now().Unix() {
|
||||
|
||||
if smithy.Clang != nil && smithy.Clang.ETime <= configure.Now().Unix() {
|
||||
_gourmetcfg := this.module.configure.GetSmithyConfigData(smithy.Clang.DeskType, smithy.Skill[smithy.Clang.DeskType])
|
||||
smithy.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Drop, smithy.Items)
|
||||
smithy.Clang = nil
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 清除数量为0 的订单
|
||||
pos := 0
|
||||
for _, order := range smithy.Orders {
|
||||
@ -150,7 +143,8 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
mapData["orders"] = smithy.Orders
|
||||
mapData["orderCostTime"] = smithy.OrderCostTime
|
||||
mapData["clang"] = smithy.Clang // 正在做的
|
||||
|
||||
mapData["ctime"] = smithy.Ctime
|
||||
mapData["totalTime"] = smithy.TotalTime
|
||||
this.module.ModifySmithyData(uid, mapData) // 同步数据
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user