定制打造装备

This commit is contained in:
meixiongfeng 2023-02-21 17:42:35 +08:00
parent 0be6315357
commit 17af1fddc6
7 changed files with 353 additions and 485 deletions

View File

@ -26,7 +26,9 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
err error
update map[string]interface{}
costRes []*cfg.Gameatn
costRes []*cfg.Gameatn
customLv int32 // 定制装备的等级
rsp *pb.SmithyForgeEquipResp
)
update = make(map[string]interface{})
code = this.ForgeEquipCheck(session, req)
@ -61,6 +63,25 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
if req.Quality > 0 {
costRes = append(costRes, reelcfg.RefineCos)
}
// 校验是不是装备定制打造
if req.SuiteId != 0 {
// 检查消耗
if code = this.module.CheckRes(session, []*cfg.Gameatn{reelcfg.CustomizedCos1}); code != pb.ErrorCode_Success {
return
}
costRes = append(costRes, reelcfg.CustomizedCos1)
if req.Position == -1 {
if code = this.module.CheckRes(session, []*cfg.Gameatn{reelcfg.CustomizedCos2}); code != pb.ErrorCode_Success {
return
}
costRes = append(costRes, reelcfg.CustomizedCos2)
}
// 随机权重 获取等级
index := this.module.modelStove.GetRandEquipLv(reelcfg.CustomizedLvDistribution)
if int32(len(reelcfg.CustomizedLv)) > index {
customLv = reelcfg.CustomizedLv[index]
}
}
// 是否是熔岩打造
if req.Lava > 0 {
@ -131,13 +152,25 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
}
// 装备资源分发
res := this.module.configure.GetDropReward(reelcfg.BasicDrop)
this.module.DispenseRes(session, res, true)
if customLv > 0 { //
if equip, code1 := this.module.ModuleEquipment.GetForgeEquip(req.SuiteId, req.Position, customLv); code1 != pb.ErrorCode_Success {
rsp.Equip = append(rsp.Equip, equip.CId)
return
}
} else {
res := this.module.configure.GetDropReward(reelcfg.BasicDrop)
this.module.DispenseRes(session, res, true)
for _, v := range res {
rsp.Equip = append(rsp.Equip, v.T)
}
}
stove.RecoveTime = configure.Now().Unix()
update["data"] = stove.Data
update["recoveTime"] = stove.RecoveTime
update["forge"] = stove.Forge // 打造次数
this.module.modelStove.updateSmithyStove(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), "forgeequip", &pb.SmithyForgeEquipResp{Data: stove})
rsp.Data = stove
session.SendMsg(string(this.module.GetType()), "forgeequip", rsp)
return
}

View File

@ -1,35 +0,0 @@
package smithy
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) OrderEquipCheck(session comm.IUserSession, req *pb.SmithyOrderEquipReq) (code pb.ErrorCode) {
if req.SuiteId == 0 || req.Position == 0 {
code = pb.ErrorCode_ReqParameterError
return
}
return
}
// 打造装备
func (this *apiComp) OrderEquip(session comm.IUserSession, req *pb.SmithyOrderEquipReq) (code pb.ErrorCode, data proto.Message) {
var ()
code = this.OrderEquipCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
stove, err := this.module.modelStove.getSmithyStoveList(session.GetUserId())
if err != nil {
code = pb.ErrorCode_DBError
return
}
session.SendMsg(string(this.module.GetType()), "orderequip", &pb.SmithyOrderEquipResp{Data: stove})
return
}

View File

@ -1,6 +1,7 @@
package smithy
import (
"crypto/rand"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/redis"
@ -8,9 +9,9 @@ import (
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"math/rand"
"math/big"
"strconv"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -91,8 +92,9 @@ func (this *modelStove) CheckForgetwoEquip(reelId int32, lv int32) (b bool) {
}
}
if value > 0 {
rand.Seed(time.Now().UnixNano())
if value < int32(rand.Intn(100)) {
n, _ := rand.Int(rand.Reader, big.NewInt(100))
if value < int32(n.Int64()) {
return true
}
}
@ -212,3 +214,23 @@ func (this *modelStove) StoveSkillBuyEquip(uid string) int32 {
}
return 0
}
func (this *modelStove) GetRandEquipLv(sz []int32) int32 {
if len(sz) > 0 {
var _totalW int64 // 总权重
var _tmpW int64 // 临时权重
for _, v := range sz {
_totalW += int64(v)
}
// 随机权重
n, _ := rand.Int(rand.Reader, big.NewInt(_totalW))
for i, v := range sz {
_tmpW += int64(v)
if n.Int64() < _tmpW {
return int32(i)
}
}
}
return 0
}

View File

@ -166,8 +166,8 @@ func (s *modelTrade) GetSuitRandom(uid string) string {
}
//获取玩家已有装备
ec, suites := s.module.ModuleEquipment.GetActionableSuit(uid)
if ec!=pb.ErrorCode_Success {
s.module.Error("获取玩家已有装备:", log.Field{Key:"code",Value: ec})
if ec != pb.ErrorCode_Success {
s.module.Error("获取玩家已有装备:", log.Field{Key: "code", Value: ec})
return ""
}
var ownerSuiteItems []*WeightItem

View File

@ -223,11 +223,12 @@ const (
ErrorCode_LibraryFetterTaskNoFound ErrorCode = 2806 //未找到羁绊任务数据
ErrorCode_LibraryPreTaskNoFinished ErrorCode = 2807 //前置任务未完成
// Battle
ErrorCode_BattleValidationFailed ErrorCode = 2901 //战斗校验失败
ErrorCode_BattleNoWin ErrorCode = 2902 //战斗失败
ErrorCode_BattleCreateFailed ErrorCode = 2903 //创建战斗失败
ErrorCode_BattleInCmdFailed ErrorCode = 2904 //战斗指令输入失败
ErrorCode_BattleUserOff ErrorCode = 2905 //由用户离线
ErrorCode_BattleValidationFailed ErrorCode = 2901 //战斗校验失败
ErrorCode_BattleNoWin ErrorCode = 2902 //战斗失败
ErrorCode_BattleCreateFailed ErrorCode = 2903 //创建战斗失败
ErrorCode_BattleInCmdFailed ErrorCode = 2904 //战斗指令输入失败
ErrorCode_BattleUserOff ErrorCode = 2905 //由用户离线
ErrorCode_BattleCapskillCheckFailed ErrorCode = 2906 //战斗队长技校验失败
// sociaty
ErrorCode_SociatyNoFound ErrorCode = 3000 //公会不存在
ErrorCode_SociatyAdded ErrorCode = 3001 //已在公会里
@ -515,6 +516,7 @@ var (
2903: "BattleCreateFailed",
2904: "BattleInCmdFailed",
2905: "BattleUserOff",
2906: "BattleCapskillCheckFailed",
3000: "SociatyNoFound",
3001: "SociatyAdded",
3002: "SociatyDiamondNoEnough",
@ -787,6 +789,7 @@ var (
"BattleCreateFailed": 2903,
"BattleInCmdFailed": 2904,
"BattleUserOff": 2905,
"BattleCapskillCheckFailed": 2906,
"SociatyNoFound": 3000,
"SociatyAdded": 3001,
"SociatyDiamondNoEnough": 3002,
@ -906,7 +909,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, 0xf1, 0x30, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0x91, 0x31, 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,
@ -1167,7 +1170,9 @@ var file_errorcode_proto_rawDesc = []byte{
0x6c, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0xd7,
0x16, 0x12, 0x16, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x43, 0x6d, 0x64,
0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0xd8, 0x16, 0x12, 0x12, 0x0a, 0x0d, 0x42, 0x61, 0x74,
0x74, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x66, 0x66, 0x10, 0xd9, 0x16, 0x12, 0x13, 0x0a,
0x74, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x66, 0x66, 0x10, 0xd9, 0x16, 0x12, 0x1e, 0x0a,
0x19, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x61, 0x70, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0xda, 0x16, 0x12, 0x13, 0x0a,
0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x10,
0xb8, 0x17, 0x12, 0x11, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x64, 0x64,
0x65, 0x64, 0x10, 0xb9, 0x17, 0x12, 0x1b, 0x0a, 0x16, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79,

View File

@ -184,9 +184,9 @@ type CustomerInfo struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
CustomerId int32 `protobuf:"varint,1,opt,name=customerId,proto3" json:"customerId"` //顾客ID
SuitId string `protobuf:"bytes,2,opt,name=suitId,proto3" json:"suitId"` //套装ID 随机套装
EquipCount int32 `protobuf:"varint,3,opt,name=equipCount,proto3" json:"equipCount"` //装备数量
CustomerId int32 `protobuf:"varint,1,opt,name=customerId,proto3" json:"customerId"` //顾客ID
SuitId int32 `protobuf:"varint,2,opt,name=suitId,proto3" json:"suitId"` //套装ID 随机套装
EquipCount int32 `protobuf:"varint,3,opt,name=equipCount,proto3" json:"equipCount"` //装备数量
}
func (x *CustomerInfo) Reset() {
@ -228,11 +228,11 @@ func (x *CustomerInfo) GetCustomerId() int32 {
return 0
}
func (x *CustomerInfo) GetSuitId() string {
func (x *CustomerInfo) GetSuitId() int32 {
if x != nil {
return x.SuitId
}
return ""
return 0
}
func (x *CustomerInfo) GetEquipCount() int32 {
@ -773,7 +773,7 @@ var file_smithy_smithy_db_proto_rawDesc = []byte{
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x75,
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75,
0x69, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x75, 0x69, 0x74,
0x69, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x75, 0x69, 0x74,
0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x43, 0x6f, 0x75, 0x6e, 0x74,
0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x43, 0x6f, 0x75,
0x6e, 0x74, 0x22, 0x9b, 0x01, 0x0a, 0x0a, 0x44, 0x42, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65,

File diff suppressed because it is too large Load Diff