diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index 1e44c86f..325a3c41 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -22,6 +22,29 @@ type LoginRsp struct { HeadId string `json:"head_id"` HeroId string `json:"hero_id"` HeadFrame string `json:"head_frame"` + SpecSkill string `json:"spec_skill"` + } `json:"user_info"` + HeroInfo struct { + HeroUniId string `json:"hero_uniid"` + HeroId string `json:"hero_id"` + Quality string `json:"quality"` + } `json:"hero_info"` + } `json:"info"` +} + +type UpdateBattleInfoRsp struct { + Errcode int `json:"errcode"` + Errmsg string `json:"errmsg"` + Info struct { + UserInfo struct { + Activated string `json:"activated"` + RenameCount string `json:"rename_count"` + AccountId string `json:"account_id"` + Name string `json:"name"` + HeadId string `json:"head_id"` + HeroId string `json:"hero_id"` + HeadFrame string `json:"head_frame"` + SpecSkill string `json:"spec_skill"` } `json:"user_info"` HeroInfo struct { HeroUniId string `json:"hero_uniid"` diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index 9ae1903b..fa098f99 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -7,6 +7,8 @@ import ( "github.com/golang/protobuf/proto" "main/common" . "main/global" + "fmt" + "mt" ) type hero struct { @@ -49,6 +51,7 @@ func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){ this.name = rsp.Info.UserInfo.Name this.avatarUrl = rsp.Info.UserInfo.HeadId this.headFrame = rsp.Info.UserInfo.HeadFrame + this.specSkill = q5.ToInt32(rsp.Info.UserInfo.SpecSkill) { this.hero.heroUniId = rsp.Info.HeroInfo.HeroUniId this.hero.heroId = q5.ToInt32(rsp.Info.HeroInfo.HeroId) @@ -261,10 +264,24 @@ func (this *player) CMSpecSkill(hdr *f5.MsgHdr, msg *cs.CMSetSpecSkill) { if this.GetTeam().Started() { rspMsg.Errcode = proto.Int32(1) rspMsg.Errmsg = proto.String("team already started") + return } else { + this.updateChoose( + msg.GetSkillId(), + this.hero.heroUniId, + func (errCode int32, errMsg string) { + if errCode == 0 { + this.SendMsg(rspMsg) + if this.GetTeam() != nil { + this.GetTeam().SendUpdateNotify() + } + } else { + rspMsg.Errcode = proto.Int32(2) + rspMsg.Errmsg = proto.String("server internal error") + this.SendMsg(rspMsg) + } + }) } - this.SendMsg(rspMsg) - this.GetTeam().SendUpdateNotify() } func (this *player) CMChooseHero(hdr *f5.MsgHdr, msg *cs.CMChooseHero) { @@ -272,10 +289,24 @@ func (this *player) CMChooseHero(hdr *f5.MsgHdr, msg *cs.CMChooseHero) { if this.GetTeam().Started() { rspMsg.Errcode = proto.Int32(1) rspMsg.Errmsg = proto.String("team already started") + return } else { + this.updateChoose( + this.specSkill, + msg.GetHeroUniid(), + func (errCode int32, errMsg string) { + if errCode == 0 { + this.SendMsg(rspMsg) + if this.GetTeam() != nil { + this.GetTeam().SendUpdateNotify() + } + } else { + rspMsg.Errcode = proto.Int32(2) + rspMsg.Errmsg = proto.String("server internal error") + this.SendMsg(rspMsg) + } + }) } - this.SendMsg(rspMsg) - this.GetTeam().SendUpdateNotify() } func (this *player) CMChooseMap(hdr *f5.MsgHdr, msg *cs.CMChooseMap) { @@ -290,7 +321,28 @@ func (this *player) CMChooseMap(hdr *f5.MsgHdr, msg *cs.CMChooseMap) { this.GetTeam().SendUpdateNotify() } -func (this *player) updateChoose(skillId int32, heroUniId string) { +func (this *player) updateChoose(skillId int32, heroUniId string, + cb func (int32, string)) { + params := map[string]string{ + "c": "User", + "a": "updateBattleInfo", + "account_id": this.accountId, + "session_id": this.sessionId, + "skill_id": q5.ToString(skillId), + "hero_uniid": heroUniId, + } + url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl()) + f5.GetHttpCliMgr().SendJsStyleRequest( + url, + params, + func(rsp f5.HttpCliResponse) { + if this.GetTeam() != nil && !this.GetTeam().Started() { + if rsp.GetErr() != nil { + cb(500, "server internal error") + return + } + } + }) } func (this *player) CMGrantInvitePermission(hdr *f5.MsgHdr, msg *cs.CMGrantInvitePermission) {