添加熔岩

This commit is contained in:
meixiongfeng 2023-02-20 15:40:05 +08:00
parent 31dc53c6d3
commit b536a756ae
2 changed files with 48 additions and 13 deletions

View File

@ -5,13 +5,14 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"strconv"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
//参数校验 //参数校验
func (this *apiComp) ForgeEquipCheck(session comm.IUserSession, req *pb.SmithyForgeEquipReq) (code pb.ErrorCode) { 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 code = pb.ErrorCode_ReqParameterError
return return
} }
@ -59,19 +60,48 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
if req.Quality > 0 { if req.Quality > 0 {
costRes = append(costRes, reelcfg.RefineCos) 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...) costRes = append(costRes, reelcfg.BasicCos...)
subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv)
costRes = append(costRes, subAtn...) costRes = append(costRes, subAtn...)
if code = this.module.CheckRes(session, costRes); code != pb.ErrorCode_Success { if code = this.module.CheckRes(session, costRes); code != pb.ErrorCode_Success {
return 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) 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 { if code = this.module.ConsumeRes(session, costRes, true); code != pb.ErrorCode_Success {
return return
} }
stove.Temperature -= (reelcfg.TemperatureCos - t) // 消耗温度
stove.RecoveTime = configure.Now().Unix() stove.RecoveTime = configure.Now().Unix()
update["data"] = stove.Data update["data"] = stove.Data
update["recoveTime"] = stove.RecoveTime update["recoveTime"] = stove.RecoveTime
update["temperature"] = stove.Temperature
this.module.modelStove.updateSmithyStove(session.GetUserId(), update) this.module.modelStove.updateSmithyStove(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), "forgeequip", &pb.SmithyForgeEquipResp{Data: stove}) session.SendMsg(string(this.module.GetType()), "forgeequip", &pb.SmithyForgeEquipResp{Data: stove})
return return

View File

@ -321,6 +321,7 @@ const (
ErrorCode_SmithyStoveMaxLv ErrorCode = 4103 // 炉子达到最大等级 ErrorCode_SmithyStoveMaxLv ErrorCode = 4103 // 炉子达到最大等级
ErrorCode_SmithyCustomerLimit ErrorCode = 4104 //顾客上限 ErrorCode_SmithyCustomerLimit ErrorCode = 4104 //顾客上限
ErrorCode_SmithyMaxTemperature ErrorCode = 4105 //炉温达上限 ErrorCode_SmithyMaxTemperature ErrorCode = 4105 //炉温达上限
ErrorCode_SmithyLackLava ErrorCode = 4106 //缺少熔岩
) )
// Enum value maps for ErrorCode. // Enum value maps for ErrorCode.
@ -592,6 +593,7 @@ var (
4103: "SmithyStoveMaxLv", 4103: "SmithyStoveMaxLv",
4104: "SmithyCustomerLimit", 4104: "SmithyCustomerLimit",
4105: "SmithyMaxTemperature", 4105: "SmithyMaxTemperature",
4106: "SmithyLackLava",
} }
ErrorCode_value = map[string]int32{ ErrorCode_value = map[string]int32{
"Success": 0, "Success": 0,
@ -860,6 +862,7 @@ var (
"SmithyStoveMaxLv": 4103, "SmithyStoveMaxLv": 4103,
"SmithyCustomerLimit": 4104, "SmithyCustomerLimit": 4104,
"SmithyMaxTemperature": 4105, "SmithyMaxTemperature": 4105,
"SmithyLackLava": 4106,
} }
) )
@ -894,7 +897,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{ var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 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, 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, 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, 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, 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, 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, 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, 0x78, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x10, 0x89, 0x20, 0x12,
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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 ( var (