This commit is contained in:
wh_zcy 2023-03-08 16:56:59 +08:00
commit e56446667e
13 changed files with 76 additions and 51 deletions

View File

@ -74,11 +74,11 @@
"main": [
{
"key": 1,
"param": 1
"param": 30
}
],
"optional": "",
"wkqbx": 0,
"wkqbx": 2,
"kqbx": 0,
"img": "zc_icon_01",
"prompt": {
@ -844,7 +844,7 @@
"main": [
{
"key": 1,
"param": 1
"param": 100
}
],
"optional": "",

View File

@ -157,7 +157,7 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.
if ais, err = this.modelArena.matcheAI(info.Dan, 1); err != nil && err != mgo.MongodbNil {
return
}
if len(players) > 0 {
if len(ais) > 0 {
captain = ais[0].Defend.Leadpos
if rules, code = this.battle.CreateRolesByHeros(ais[0].Defend.Formt); code != pb.ErrorCode_Success {
err = fmt.Errorf("AI CreateRolesByHeros fail:%d", code)

View File

@ -268,8 +268,10 @@ func (this *Battle) CreateRolesByFormat(fid int32) (captain int32, roles []*pb.B
func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRole, code pb.ErrorCode) {
roles = make([]*pb.BattleRole, len(heros))
for i, v := range heros {
if roles[i], code = this.modelBattle.createBattleRole(v, 100+i, i); code != pb.ErrorCode_Success {
return
if v != nil {
if roles[i], code = this.modelBattle.createBattleRole(v, 100+i, i); code != pb.ErrorCode_Success {
return
}
}
}
return

View File

@ -44,6 +44,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.EnchantChallen
code = pb.ErrorCode_ItemsNoEnough
return
}
_, ok := enchant.Boss[req.BossType]
if !ok { // 类型校验
enchant.Boss[req.BossType] = 0

View File

@ -30,10 +30,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.EnchantGetListRe
list.Boss = make(map[int32]int64)
list.BossTime = make(map[int32]int32)
_cfg := this.module.configure.GetEnchantBossTypeConfigData()
for k := range _cfg {
list.BossTime[k] = 0
}
this.module.modelEnchant.Add(session.GetUserId(), list)
}
if session.GetUserId() != "" { // 恢复时间

View File

@ -68,25 +68,6 @@ func (this *configureComp) GetConfigure(name string) (v interface{}, err error)
return configure.GetConfigure(name)
}
// get boss Type
func (this *configureComp) GetEnchantBossTypeConfigData() (mapType map[int32]struct{}) {
mapType = make(map[int32]struct{}, 0)
if v, err := this.GetConfigure(game_enchantboss); err == nil {
if configure, ok := v.(*cfg.GameEnchantBoss); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
if _, ok := mapType[value.Bossid]; !ok {
mapType[value.Bossid] = struct{}{}
}
}
}
}
return
}
func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameEnchantShopData) {
if v, err := this.GetConfigure(game_enchantshop); err == nil {
if configure, ok := v.(*cfg.GameEnchantShop); ok {

View File

@ -37,6 +37,7 @@ func newAgent(gateway IGateway, conn *websocket.Conn) *Agent {
writeChan: make(chan []byte, 2),
closeSignal: make(chan bool),
state: 1,
protoMsg: make(map[string]int64, 0),
}
agent.wg.Add(2)
go agent.readLoop()
@ -55,6 +56,8 @@ type Agent struct {
closeSignal chan bool
state int32 //状态 0 关闭 1 运行 2 关闭中
wg sync.WaitGroup
hlock sync.RWMutex
protoMsg map[string]int64
}
func (this *Agent) readLoop() {
@ -93,12 +96,39 @@ locp:
var code pb.ErrorCode
code, err = this.secAuth(msg)
if err == nil {
// this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
if this.uId != "" {
key := this.uId + msg.MainType + msg.SubType // 加锁
if v, ok := this.protoMsg[key]; ok {
if v != 0 && configure.Now().Unix()-v < 2 {
// 返回错误码
this.hlock.Lock()
this.protoMsg[key] = configure.Now().Unix()
this.hlock.Unlock()
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{
ReqMainType: msg.MainType,
ReqSubType: msg.SubType,
Arg: msg.Data,
Code: pb.ErrorCode_InsufficientPermissions})
err = this.WriteMsg(&pb.UserMessage{
MainType: comm.MainTypeNotify,
SubType: comm.SubTypeErrorNotify,
Data: data,
})
continue
}
}
this.hlock.Lock()
this.protoMsg[key] = configure.Now().Unix()
this.hlock.Unlock()
}
if err := this.messageDistribution(msg); err != nil {
this.gateway.Errorf("messageDistribution err:%v", err)
go this.Close()
break locp
}
} else {
this.gateway.Errorf("agent:%s uId:%s 密钥无效 err:%v", this.sessionId, this.uId, err)
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: code, Message: err.Error()})
@ -111,6 +141,7 @@ locp:
break locp
}
}
}
}
this.gateway.Debugf("agent:%s uId:%s readLoop end!", this.sessionId, this.uId)
@ -129,11 +160,12 @@ locp:
break locp
case msg, ok := <-this.writeChan:
if ok {
// data, err = proto.Marshal(msg)
//data, err = proto.Marshal(msg)
if err = this.wsConn.WriteMessage(websocket.BinaryMessage, msg); err != nil {
this.gateway.Errorf("agent:%s uId:%d WriteMessage err:%v", this.sessionId, this.uId, err)
go this.Close()
}
} else {
go this.Close()
}
@ -340,6 +372,15 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
log.Field{Key: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
log.Field{Key: "reply", Value: reply.String()},
)
if this.uId != "" {
key := this.uId + msg.MainType + msg.SubType
this.hlock.Lock()
if v, ok := this.protoMsg[key]; ok && v != 0 { // 发送消息 协议解锁
v = 0
}
this.hlock.Unlock()
}
if reply.Code != pb.ErrorCode_Success {
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{
ReqMainType: msg.MainType,

View File

@ -541,7 +541,7 @@ func (this *ModelItemsComp) recoverTicket(session comm.IUserSession) (code pb.Er
}
global := this.module.configure.GetGlobalConf()
playerlv := this.module.configure.GetPlayerlvConf(user.Lv)
ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.UnifiedTicket))
ticket = int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), comm.UnifiedTicket))
if ticket < global.DreamlandFightnum && info.Recovertimeunifiedticket > 0 {
duration = configure.Now().Sub(time.Unix(info.Recovertimeunifiedticket, 0))
ticketNum = int32(math.Floor(duration.Seconds() / float64(global.CopsRecoveryTime)))

View File

@ -35,6 +35,7 @@ func (this *modelPandata) queryUserMartialhall(uid string) (result *pb.DBPractic
result = &pb.DBPracticeRoom{}
if err = this.Get(uid, result); err != nil && err != mgo.MongodbNil {
this.module.Errorln(err)
return
}
if err == mgo.MongodbNil {
result = &pb.DBPracticeRoom{
@ -51,6 +52,7 @@ func (this *modelPandata) queryUserMartialhall(uid string) (result *pb.DBPractic
Statuers: make([]*pb.DBPracticeStatuer, 0),
}
if err = this.refreshnpc(result); err != nil {
this.module.Errorln(err)
return
}
if err = this.Add(uid, result); err != nil {

View File

@ -81,22 +81,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
return
}
//初始化用户扩展
initUpdate := map[string]interface{}{
"modifynameCount": 1, //修改名称1次
"sociatyTicket": globalConf.GuildBossInitialNum, //公会BOSS挑战券
"expitem": make(map[string]int32, 0), // 初始化
"mline": make(map[string]int32, 0),
}
if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), initUpdate); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("创建初始修改名称次数",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: initUpdate},
log.Field{Key: "err", Value: err.Error()},
)
return
}
var (
res []*cfg.Gameatn
)

View File

@ -43,7 +43,25 @@ func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err
}
}
} else {
if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments != err {
if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments == err {
globalConf := this.module.configure.GetGlobalConf()
initUpdate := map[string]interface{}{
"uid": uid,
"modifynameCount": 1, //修改名称1次
"sociatyTicket": globalConf.GuildBossInitialNum, //公会BOSS挑战券
"expitem": make(map[string]int32, 0), // 初始化
"mline": make(map[string]int32, 0),
}
result.SociatyTicket = globalConf.GuildBossInitialNum
if err = this.module.modelExpand.ChangeUserExpand(uid, initUpdate); err != nil {
this.module.Error("创建初始修改名称次数",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: initUpdate},
log.Field{Key: "err", Value: err.Error()},
)
return
}
this.module.Error("Get", log.Field{Key: "uid", Value: uid})
return result, err
}

View File

@ -279,7 +279,7 @@ type BattleRole struct {
MainSuitSkill int32 `protobuf:"varint,8,opt,name=mainSuitSkill,proto3" json:"mainSuitSkill" bson:"mainSuitSkill"` /// 主套装技能
SubSuitSkill int32 `protobuf:"varint,9,opt,name=subSuitSkill,proto3" json:"subSuitSkill" bson:"subSuitSkill"` /// 副套装技能
NormalSkill []*SkillData `protobuf:"bytes,10,rep,name=normalSkill,proto3" json:"normalSkill" bson:"normalSkill"` //普通技能
EquipSkill []*SkillData `protobuf:"bytes,11,rep,name=equipSkill,proto3" json:"equipSkill" bson:"normalSkill"` //普通技能
EquipSkill []*SkillData `protobuf:"bytes,11,rep,name=equipSkill,proto3" json:"equipSkill" bson:"equipSkill"` //普通技能
PandaBuff int32 `protobuf:"varint,12,opt,name=PandaBuff,proto3" json:"PandaBuff"` //熊猫buff技能id
Property map[string]int32 `protobuf:"bytes,13,rep,name=property,proto3" json:"property" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 属性相关
Ishelp bool `protobuf:"varint,14,opt,name=ishelp,proto3" json:"ishelp"` //是否是助战英雄

View File

@ -287,7 +287,7 @@ type DBPracticeRoom struct {
Pillarf *DBPracticePillar `protobuf:"bytes,11,opt,name=pillarf,proto3" json:"pillarf"` //好友柱子
Statuers []*DBPracticeStatuer `protobuf:"bytes,12,rep,name=statuers,proto3" json:"statuers"` //武馆雕像
Currnpc int32 `protobuf:"varint,13,opt,name=currnpc,proto3" json:"currnpc"` //当前npc
Npcstate int32 `protobuf:"varint,14,opt,name=npcstate,proto3" json:"npcstate"` //npc状态 0 未挑战 1 挑战失败 2挑战成功
Npcstate int32 `protobuf:"varint,14,opt,name=npcstate,proto3" json:"npcstate"` //npc状态 0 未挑战 1 挑战失败 2挑战成功 3 CD中
Refresh int64 `protobuf:"varint,15,opt,name=refresh,proto3" json:"refresh"` //刷新时间
Battlenum int32 `protobuf:"varint,16,opt,name=battlenum,proto3" json:"battlenum"` //战斗次数
Captain int32 `protobuf:"varint,17,opt,name=captain,proto3" json:"captain"` //战斗征信队长位