参数优化

This commit is contained in:
meixiongfeng 2022-12-28 18:04:13 +08:00
parent eea7b83101
commit f9eb2a3fad
5 changed files with 65 additions and 46 deletions

View File

@ -257,7 +257,7 @@ type (
AutoBuyTicket(session IUserSession) (code pb.ErrorCode)
// 自动战斗 战斗信息
AutoBattleInfo(session IUserSession, battle *pb.BattleFormation, bossId, difficulty int32) (code pb.ErrorCode, battleInfo *pb.BattleInfo)
AutoBattleOver(session IUserSession, bossId int32, difficulty int32, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (code pb.ErrorCode, atno []*pb.UserAtno)
AutoBattleOver(session IUserSession, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (code pb.ErrorCode, atno []*pb.UserAtno)
CheckBattelParameter(session IUserSession, battle *pb.BattleFormation, bossid, difficulty int32) (code pb.ErrorCode)
}
IHunting interface {

View File

@ -47,6 +47,7 @@ func (this *apiComp) AutoChallenge(session comm.IUserSession, req *pb.AutoBattle
Ptype: req.Ptype,
BossId: req.BossId,
Difficulty: req.Difficulty,
Battle: req.Battle,
}
battle[_d.Id] = _d
if err = this.module.modelAutoBattle.AddListByObjId(session.GetUserId(), battle); err != nil {
@ -58,11 +59,9 @@ func (this *apiComp) AutoChallenge(session comm.IUserSession, req *pb.AutoBattle
if req.Ptype == pb.PlayType_viking {
if req.AutoBuy {
this.viking.AutoBuyTicket(session)
code = this.viking.CheckBattelParameter(session, req.Battle, req.BossId, req.Difficulty)
if code == pb.ErrorCode_Success {
session.SendMsg(string(this.module.GetType()), "challenge", &pb.AutoBattleChallengeResp{
Info: battleInfo,
})
code = this.viking.CheckBattelParameter(session, req.Battle, req.BossId, req.Difficulty) // 参数校验
if code != pb.ErrorCode_Success {
return
}
code, battleInfo = this.viking.AutoBattleInfo(session, req.Battle, req.BossId, req.Difficulty)
if code == pb.ErrorCode_Success {

View File

@ -45,18 +45,20 @@ func (this *apiComp) AutoOver(session comm.IUserSession, req *pb.AutoBattleOverR
}
// 分析战报 数据
if req.Ptype == pb.PlayType_viking {
if code, atno = this.viking.AutoBattleOver(session, autoBattle.BossId, autoBattle.Difficulty, req.Report, autoBattle); code != pb.ErrorCode_Success {
if code, atno = this.viking.AutoBattleOver(session, req.Report, autoBattle); code != pb.ErrorCode_Success {
this.module.modelAutoBattle.DelListByObjId(session.GetUserId(), autoBattle.Id) // 自动战斗结束 删除数据
// session.SendMsg(string(this.module.GetType()), "overenv", &pb.AutoBattleOverEnvPush{
// Success: false,
// })
//return
autoOver = true
}
}
code, battleInfo := this.viking.AutoBattleInfo(session, autoBattle.Battle, autoBattle.BossId, autoBattle.Difficulty)
if code == pb.ErrorCode_Success {
session.SendMsg(string(this.module.GetType()), "challenge", &pb.AutoBattleChallengeResp{
Info: battleInfo,
})
}
session.SendMsg(string(this.module.GetType()), "over", &pb.AutoBattleOverResp{
Asset: atno,
Info: &pb.BattleInfo{},
Info: battleInfo,
Over: autoOver,
})
return

View File

@ -227,7 +227,9 @@ func (this *Viking) AutoBattleInfo(session comm.IUserSession, battle *pb.BattleF
}
// 自动战斗完成
func (this *Viking) AutoBattleOver(session comm.IUserSession, bossId int32, difficulty int32, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (code pb.ErrorCode, atno []*pb.UserAtno) {
func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (code pb.ErrorCode, atno []*pb.UserAtno) {
bossId := autoBattle.BossId
difficulty := autoBattle.Difficulty
atno = make([]*pb.UserAtno, 0)
costRes := this.configure.GetGlobalConf().VikingExpeditionCos
if costRes == nil {

View File

@ -26,15 +26,16 @@ type DBAutoBattle struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
AutoWin bool `protobuf:"varint,3,opt,name=autoWin,proto3" json:"autoWin" bson:"autoWin"` //失败自动停止
MaxExp bool `protobuf:"varint,4,opt,name=maxExp,proto3" json:"maxExp"` //@go_tags(`bson:"maxExp"`)雄达到满级则停止连续战斗
AutoBuy bool `protobuf:"varint,5,opt,name=autoBuy,proto3" json:"autoBuy" bson:"autoBuy"` //自动购买
AutoSell int32 `protobuf:"varint,6,opt,name=autoSell,proto3" json:"autoSell" bson:"autoSell"` //自动出售星级装备
Ptype PlayType `protobuf:"varint,7,opt,name=ptype,proto3,enum=PlayType" json:"ptype"` // 类型
BossId int32 `protobuf:"varint,8,opt,name=bossId,proto3" json:"bossId" bson:"bossId"`
Difficulty int32 `protobuf:"varint,9,opt,name=difficulty,proto3" json:"difficulty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
AutoWin bool `protobuf:"varint,3,opt,name=autoWin,proto3" json:"autoWin" bson:"autoWin"` //失败自动停止
MaxExp bool `protobuf:"varint,4,opt,name=maxExp,proto3" json:"maxExp"` //@go_tags(`bson:"maxExp"`)雄达到满级则停止连续战斗
AutoBuy bool `protobuf:"varint,5,opt,name=autoBuy,proto3" json:"autoBuy" bson:"autoBuy"` //自动购买
AutoSell int32 `protobuf:"varint,6,opt,name=autoSell,proto3" json:"autoSell" bson:"autoSell"` //自动出售星级装备
Ptype PlayType `protobuf:"varint,7,opt,name=ptype,proto3,enum=PlayType" json:"ptype"` // 类型
BossId int32 `protobuf:"varint,8,opt,name=bossId,proto3" json:"bossId" bson:"bossId"`
Difficulty int32 `protobuf:"varint,9,opt,name=difficulty,proto3" json:"difficulty"`
Battle *BattleFormation `protobuf:"bytes,10,opt,name=battle,proto3" json:"battle"` // 阵容信息
}
func (x *DBAutoBattle) Reset() {
@ -132,28 +133,40 @@ func (x *DBAutoBattle) GetDifficulty() int32 {
return 0
}
func (x *DBAutoBattle) GetBattle() *BattleFormation {
if x != nil {
return x.Battle
}
return nil
}
var File_auto_auto_db_proto protoreflect.FileDescriptor
var file_auto_auto_db_proto_rawDesc = []byte{
0x0a, 0x12, 0x61, 0x75, 0x74, 0x6f, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x64, 0x62, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x2f, 0x62, 0x61, 0x74,
0x74, 0x6c, 0x65, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf1, 0x01, 0x0a,
0x0c, 0x44, 0x42, 0x41, 0x75, 0x74, 0x6f, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a,
0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12,
0x18, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x57, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08,
0x52, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x57, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x78,
0x45, 0x78, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6d, 0x61, 0x78, 0x45, 0x78,
0x70, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x42, 0x75, 0x79, 0x18, 0x05, 0x20, 0x01,
0x28, 0x08, 0x52, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x42, 0x75, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x61,
0x75, 0x74, 0x6f, 0x53, 0x65, 0x6c, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61,
0x75, 0x74, 0x6f, 0x53, 0x65, 0x6c, 0x6c, 0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65,
0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70,
0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x73, 0x73,
0x49, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x6f, 0x73, 0x73, 0x49, 0x64,
0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x09,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x6c, 0x65, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x62, 0x61,
0x74, 0x74, 0x6c, 0x65, 0x2f, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x6d, 0x73, 0x67, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9b, 0x02, 0x0a, 0x0c, 0x44, 0x42, 0x41, 0x75, 0x74, 0x6f,
0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x6f,
0x57, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x57,
0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x78, 0x45, 0x78, 0x70, 0x18, 0x04, 0x20, 0x01,
0x28, 0x08, 0x52, 0x06, 0x6d, 0x61, 0x78, 0x45, 0x78, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x75,
0x74, 0x6f, 0x42, 0x75, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x61, 0x75, 0x74,
0x6f, 0x42, 0x75, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x75, 0x74, 0x6f, 0x53, 0x65, 0x6c, 0x6c,
0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x75, 0x74, 0x6f, 0x53, 0x65, 0x6c, 0x6c,
0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32,
0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70,
0x65, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x73, 0x73, 0x49, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28,
0x05, 0x52, 0x06, 0x62, 0x6f, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x69, 0x66,
0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x64,
0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x12, 0x28, 0x0a, 0x06, 0x62, 0x61, 0x74,
0x74, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, 0x74,
0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x62, 0x61, 0x74,
0x74, 0x6c, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
@ -170,16 +183,18 @@ func file_auto_auto_db_proto_rawDescGZIP() []byte {
var file_auto_auto_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_auto_auto_db_proto_goTypes = []interface{}{
(*DBAutoBattle)(nil), // 0: DBAutoBattle
(PlayType)(0), // 1: PlayType
(*DBAutoBattle)(nil), // 0: DBAutoBattle
(PlayType)(0), // 1: PlayType
(*BattleFormation)(nil), // 2: BattleFormation
}
var file_auto_auto_db_proto_depIdxs = []int32{
1, // 0: DBAutoBattle.ptype:type_name -> PlayType
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
2, // 1: DBAutoBattle.battle:type_name -> BattleFormation
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_auto_auto_db_proto_init() }
@ -188,6 +203,7 @@ func file_auto_auto_db_proto_init() {
return
}
file_battle_battle_db_proto_init()
file_battle_battle_msg_proto_init()
if !protoimpl.UnsafeEnabled {
file_auto_auto_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBAutoBattle); i {