Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
62ad13e0cf
1
go.mod
1
go.mod
@ -10,7 +10,6 @@ require (
|
||||
github.com/atotto/clipboard v0.1.4
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
|
||||
github.com/boltdb/bolt v1.3.1
|
||||
github.com/gin-gonic/autotls v0.0.5
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-playground/validator/v10 v10.10.1
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
|
5
go.sum
5
go.sum
@ -173,8 +173,6 @@ github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2/go.mod h1:eO7W361vml
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/autotls v0.0.5 h1:SXQWwWGDJHujDlthIij1+jxn3m5IPV8I9Za9bcPzMdo=
|
||||
github.com/gin-gonic/autotls v0.0.5/go.mod h1:RK6LjOz47xARPGuceCOz3pQcYruxM0bVB7jb4AsDYeI=
|
||||
github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8=
|
||||
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
||||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
@ -966,7 +964,6 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -996,7 +993,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@ -1079,7 +1075,6 @@ golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
@ -19,7 +19,6 @@ func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.SmithyC
|
||||
return
|
||||
}
|
||||
|
||||
///美食城创建订单
|
||||
func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreateOrderReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
res []*cfg.Gameatn
|
||||
@ -46,14 +45,12 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
|
||||
if _smithy.Ctime == 0 {
|
||||
_smithy.Ctime = configure.Now().Unix()
|
||||
}
|
||||
_smithy.Orders = append(_smithy.Orders, req.Order...) // 直接追加订单数据
|
||||
//_smithy.OrderCostTime += costTime
|
||||
if _smithy.Clang == nil || (_smithy.Clang != nil && _smithy.Clang.ETime == 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 {
|
||||
if v.Count > 0 {
|
||||
v.Count--
|
||||
@ -66,13 +63,16 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 計算耗時
|
||||
for _, v := range _smithy.Orders {
|
||||
if v.Count > 0 {
|
||||
v.NeedTime = needTime * v.Count
|
||||
}
|
||||
if skillLv, ok := _smithy.Skill[v.DeskType]; ok {
|
||||
conf := this.module.configure.GetSmithyConfigData(v.DeskType, skillLv)
|
||||
res = append(res, conf.Orderneed...) // 订单消耗
|
||||
}
|
||||
}
|
||||
if _smithy.Clang != nil && _smithy.Clang.ETime == 0 {
|
||||
_smithy.Clang = nil
|
||||
@ -103,6 +103,7 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
|
||||
mapData["orders"] = _smithy.Orders
|
||||
mapData["orderCostTime"] = _smithy.OrderCostTime
|
||||
mapData["clang"] = _smithy.Clang // 正在做的
|
||||
mapData["ctime"] = _smithy.Ctime
|
||||
code = this.module.ModifySmithyData(session.GetUserId(), mapData)
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), SmithyCreateOrderResp, &pb.SmithyCreateOrderResp{Data: _smithy})
|
||||
|
@ -48,7 +48,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
return
|
||||
}
|
||||
|
||||
// 获取美食馆配置数据
|
||||
func (this *configureComp) GetSmithyConfigData(smithyType int32, level int32) (data *cfg.GameSmithyData) {
|
||||
|
||||
return this._smithyMap[int64(smithyType<<16)+int64(level)]
|
||||
|
@ -63,88 +63,72 @@ func (this *modelSmithy) modifySmithyDataByObjId(uid string, data map[string]int
|
||||
}
|
||||
func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
var (
|
||||
bCooking bool
|
||||
costTime int32
|
||||
curTime int32
|
||||
szTime map[int32]int32 // k 台子类型 v订单耗时
|
||||
zeroTime int64 // 订单开始的时间对应第二天0点时间
|
||||
nextDay bool // 是否跨天了
|
||||
nextDayTime int32 // 跨天累计时间
|
||||
szTime map[int32]int32
|
||||
zeroTime int64 // 当前时间对应的0点时间戳,用来判断是否跨天了
|
||||
)
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
szTime = make(map[int32]int32, 0)
|
||||
defer this.module.ModifySmithyData(uid, mapData)
|
||||
|
||||
// 记录每个食材耗时
|
||||
for k, v := range smithy.Skill {
|
||||
// 计算出需要的时间
|
||||
_skillCfg := this.module.configure.GetSmithyStoveConfigData(v) // 技能配置表
|
||||
szTime[k] = _skillCfg.Time
|
||||
}
|
||||
if smithy.Clang != nil && smithy.Clang.ETime > 0 {
|
||||
zeroTime = utils.GetZeroTime(smithy.Clang.STime) // 获取订单开始时间当天的0点
|
||||
costTime = int32(configure.Now().Unix() - smithy.Clang.ETime) // 当前过去的时间
|
||||
if costTime < 0 { // 没有完成 不做处理
|
||||
return
|
||||
}
|
||||
_skillCfg := this.module.configure.GetSmithyStoveConfigData(v)
|
||||
szTime[k] += _skillCfg.Time
|
||||
}
|
||||
|
||||
// 有订单在做
|
||||
zeroTime = utils.GetTodayZeroTime(configure.Now().Unix())
|
||||
for {
|
||||
if smithy.Clang != nil {
|
||||
if configure.Now().Unix() < smithy.Clang.ETime {
|
||||
break
|
||||
}
|
||||
}
|
||||
bRet := false
|
||||
for _, order := range smithy.Orders {
|
||||
if order.Count == 0 {
|
||||
continue
|
||||
}
|
||||
desktype := order.DeskType
|
||||
skillLv := smithy.Skill[desktype] // 获取技能等级
|
||||
// 计算出需要的时间
|
||||
|
||||
_smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv) // 美食家配置表
|
||||
|
||||
for i := 0; i < int(order.Count); i++ {
|
||||
curTime += szTime[order.DeskType]
|
||||
_gourmetcfg := this.module.configure.GetSmithyConfigData(order.DeskType, smithy.Skill[order.DeskType]) // 美食家配置表
|
||||
if order.Count > 0 {
|
||||
order.Count--
|
||||
if order.Count == 0 {
|
||||
order.NeedTime = 0
|
||||
}
|
||||
order.NeedTime = order.Count * szTime[order.DeskType]
|
||||
if smithy.Clang == nil {
|
||||
if zeroTime == 0 {
|
||||
zeroTime = utils.GetZeroTime(configure.Now().Unix())
|
||||
}
|
||||
smithy.Clang = &pb.Clang{}
|
||||
smithy.Clang.STime = configure.Now().Unix()
|
||||
smithy.Clang.ETime = configure.Now().Unix() + int64(szTime[order.DeskType])
|
||||
|
||||
} else {
|
||||
smithy.Clang.STime += int64(szTime[order.DeskType])
|
||||
oldTime := smithy.Clang.ETime
|
||||
smithy.Clang.ETime += int64(szTime[order.DeskType])
|
||||
}
|
||||
smithy.Clang.DeskType = order.DeskType
|
||||
|
||||
// 判断订单是否跨天
|
||||
if smithy.Clang.ETime >= zeroTime && !nextDay {
|
||||
smithy.Ctime = zeroTime // 设置
|
||||
// 如果此时跨天了 清除订单时常
|
||||
if oldTime < zeroTime && zeroTime <= smithy.Clang.ETime { // 跨天清空订单耗时
|
||||
smithy.OrderCostTime = 0
|
||||
nextDay = true
|
||||
// 重新计算订单时常
|
||||
for _, order := range smithy.Orders {
|
||||
smithy.OrderCostTime += order.Count * szTime[order.DeskType]
|
||||
}
|
||||
}
|
||||
if nextDay {
|
||||
nextDayTime += szTime[order.DeskType]
|
||||
}
|
||||
smithy.Items = this.module.configure.GetMultipleDropReward(_smithycfg.Using, _smithycfg.Drop, smithy.Items) // 获取掉落奖励
|
||||
if curTime > costTime {
|
||||
// 转时间戳
|
||||
smithy.Clang.DeskType = order.DeskType
|
||||
|
||||
smithy.Clang.ETime = configure.Now().Unix() + int64(curTime-costTime)
|
||||
smithy.Clang.STime = smithy.Clang.ETime - int64(szTime[order.DeskType])
|
||||
bCooking = true
|
||||
|
||||
// 设置掉落组
|
||||
smithy.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Drop, smithy.Items) // 获取掉落奖励
|
||||
// 记录下订单时间
|
||||
smithy.Ctime = configure.Now().Unix()
|
||||
|
||||
smithy.Ctime = smithy.Clang.ETime
|
||||
mapData["ctime"] = smithy.Ctime
|
||||
bRet = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if bCooking { // 分配了正在製作的食物
|
||||
if !bRet { // 没有订单可以做
|
||||
if smithy.Clang != nil {
|
||||
if 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
|
||||
}
|
||||
}
|
||||
@ -156,33 +140,13 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
}
|
||||
}
|
||||
smithy.Orders = append(smithy.Orders[:0], smithy.Orders[pos:]...)
|
||||
if nextDay {
|
||||
smithy.OrderCostTime += nextDayTime
|
||||
for _, order := range smithy.Orders {
|
||||
if order.Count == 0 {
|
||||
continue
|
||||
}
|
||||
smithy.OrderCostTime += szTime[order.DeskType] * order.Count
|
||||
}
|
||||
}
|
||||
|
||||
if utils.GetZeroTime(smithy.Ctime) <= configure.Now().Unix() {
|
||||
smithy.OrderCostTime = 0
|
||||
}
|
||||
|
||||
if smithy.Clang != nil && smithy.Clang.ETime <= configure.Now().Unix() { // 当前时间超过正在做的时间
|
||||
desktype := smithy.Clang.DeskType
|
||||
skillLv := smithy.Skill[desktype] // 获取技能等级
|
||||
_smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv)
|
||||
smithy.Items = this.module.configure.GetMultipleDropReward(_smithycfg.Using, _smithycfg.Drop, smithy.Items)
|
||||
smithy.Clang = nil
|
||||
}
|
||||
// 保存信息
|
||||
mapData["items"] = smithy.Items
|
||||
mapData["orders"] = smithy.Orders
|
||||
mapData["foods"] = smithy.Orders
|
||||
mapData["orderCostTime"] = smithy.OrderCostTime
|
||||
mapData["clang"] = smithy.Clang // 正在做的
|
||||
mapData["ctime"] = smithy.Ctime
|
||||
mapData["cookingFood"] = smithy.Clang // 正在做的
|
||||
|
||||
this.module.ModifySmithyData(uid, mapData) // 同步数据
|
||||
}
|
||||
|
||||
func (this *modelSmithy) CalculationDeskSkillLv(uid string, Smithy *pb.DBSmithy) {
|
||||
|
Loading…
Reference in New Issue
Block a user