From b536a756ae1ba219023abb8bc244442a391c2980 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 20 Feb 2023 15:40:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=86=94=E5=B2=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/smithy/api_forgeequip.go | 50 +++++++++++++++++++++++++------- pb/errorcode.pb.go | 11 +++++-- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/modules/smithy/api_forgeequip.go b/modules/smithy/api_forgeequip.go index 806df5114..15bae92a6 100644 --- a/modules/smithy/api_forgeequip.go +++ b/modules/smithy/api_forgeequip.go @@ -5,13 +5,14 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "strconv" "google.golang.org/protobuf/proto" ) //参数校验 func (this *apiComp) ForgeEquipCheck(session comm.IUserSession, req *pb.SmithyForgeEquipReq) (code pb.ErrorCode) { - if req.ReelId == 0 { + if req.ReelId == 0 || req.Lava < 0 || req.Quality < 0 { code = pb.ErrorCode_ReqParameterError return } @@ -59,19 +60,48 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq if req.Quality > 0 { costRes = append(costRes, reelcfg.RefineCos) } + + // 是否是熔岩打造 + if req.Lava > 0 { + // 预计消耗温度 + exemption := this.module.configure.GetGlobalConf().ExemptionTemperatureCos + if len(exemption) != 2 { + code = pb.ErrorCode_ConfigNoFound + return + } + if reelcfg.TemperatureCos > req.Lava*exemption[1] { + code = pb.ErrorCode_SmithyLackLava // 缺少熔岩 + return + } + // 检查消耗 + lavaCost := &cfg.Gameatn{ + A: "item", + T: strconv.Itoa(int(exemption[0])), + N: req.Lava, + } + if code = this.module.CheckRes(session, []*cfg.Gameatn{lavaCost}); code != pb.ErrorCode_Success { + return + } + costRes = append(costRes, lavaCost) + + } else { + // 熟练度减少的温度 + t := this.module.modelStove.CheckTemperature(req.ReelId, stove.Data[req.ReelId].Lv) + // 检查炉温 是否够 + if stove.Temperature < reelcfg.TemperatureCos-t { + code = pb.ErrorCode_SmithyNoTemperature // 炉温不够 直接返回 + return + } + stove.Temperature -= (reelcfg.TemperatureCos - t) // 消耗温度 + update["temperature"] = stove.Temperature + } + costRes = append(costRes, reelcfg.BasicCos...) subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) costRes = append(costRes, subAtn...) if code = this.module.CheckRes(session, costRes); code != pb.ErrorCode_Success { return } - // 熟练度减少的温度 - t := this.module.modelStove.CheckTemperature(req.ReelId, stove.Data[req.ReelId].Lv) - // 检查炉温 是否够 - if stove.Temperature < reelcfg.TemperatureCos-t { - code = pb.ErrorCode_SmithyNoTemperature // 炉温不够 直接返回 - return - } // 检查是否提升了熟练度等级 nextProficiency := this.module.configure.GetSmithyProficileData(req.ReelId, stove.Data[req.ReelId].Lv+1) @@ -98,11 +128,11 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq if code = this.module.ConsumeRes(session, costRes, true); code != pb.ErrorCode_Success { return } - stove.Temperature -= (reelcfg.TemperatureCos - t) // 消耗温度 + stove.RecoveTime = configure.Now().Unix() update["data"] = stove.Data update["recoveTime"] = stove.RecoveTime - update["temperature"] = stove.Temperature + this.module.modelStove.updateSmithyStove(session.GetUserId(), update) session.SendMsg(string(this.module.GetType()), "forgeequip", &pb.SmithyForgeEquipResp{Data: stove}) return diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index aeb40d5b7..b959252d0 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -321,6 +321,7 @@ const ( ErrorCode_SmithyStoveMaxLv ErrorCode = 4103 // 炉子达到最大等级 ErrorCode_SmithyCustomerLimit ErrorCode = 4104 //顾客上限 ErrorCode_SmithyMaxTemperature ErrorCode = 4105 //炉温达上限 + ErrorCode_SmithyLackLava ErrorCode = 4106 //缺少熔岩 ) // Enum value maps for ErrorCode. @@ -592,6 +593,7 @@ var ( 4103: "SmithyStoveMaxLv", 4104: "SmithyCustomerLimit", 4105: "SmithyMaxTemperature", + 4106: "SmithyLackLava", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -860,6 +862,7 @@ var ( "SmithyStoveMaxLv": 4103, "SmithyCustomerLimit": 4104, "SmithyMaxTemperature": 4105, + "SmithyLackLava": 4106, } ) @@ -894,7 +897,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0x8b, 0x30, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xa0, 0x30, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -1278,8 +1281,10 @@ var file_errorcode_proto_rawDesc = []byte{ 0x76, 0x65, 0x4d, 0x61, 0x78, 0x4c, 0x76, 0x10, 0x87, 0x20, 0x12, 0x18, 0x0a, 0x13, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x10, 0x88, 0x20, 0x12, 0x19, 0x0a, 0x14, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x4d, 0x61, - 0x78, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x10, 0x89, 0x20, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x78, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x10, 0x89, 0x20, 0x12, + 0x13, 0x0a, 0x0e, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x4c, 0x61, 0x63, 0x6b, 0x4c, 0x61, 0x76, + 0x61, 0x10, 0x8a, 0x20, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var (