上传代码
This commit is contained in:
parent
77d5c22b86
commit
a001631410
@ -21,6 +21,7 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.Uniongve
|
||||
score *cfg.GameGuildBossScoreData
|
||||
info *pb.DBUnionGve
|
||||
prop []*cfg.Gameatn
|
||||
award []*pb.UserAssets
|
||||
ok bool
|
||||
err error
|
||||
)
|
||||
@ -48,10 +49,6 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.Uniongve
|
||||
}
|
||||
}
|
||||
|
||||
if errdata = this.module.DispenseRes(session, prop, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
lock, _ := this.module.modelUniongve.userlock(req.Unionid)
|
||||
err = lock.Lock()
|
||||
if err != nil {
|
||||
@ -73,9 +70,21 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.Uniongve
|
||||
if v.Hp > 0 {
|
||||
ok = true
|
||||
v.Hp -= score.Hp
|
||||
|
||||
record := &pb.DBGveRecord{
|
||||
Uid: session.GetUserId(),
|
||||
Formation: make([]string, 0),
|
||||
}
|
||||
for i, v := range req.Report.Info.Redflist[0].Team {
|
||||
record.Formation[i] = ""
|
||||
if v != nil {
|
||||
record.Formation[i] = v.HeroID
|
||||
}
|
||||
}
|
||||
v.Record = append(v.Record)
|
||||
if v.Hp < 0 {
|
||||
v.Hp = 0
|
||||
this.module.modelUniongve.booskill(req.Unionid, req.Boosid, info)
|
||||
go this.module.modelUniongve.booskill(req.Unionid, req.Boosid, info)
|
||||
}
|
||||
}
|
||||
break
|
||||
@ -92,15 +101,33 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.Uniongve
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if err = this.module.modelUniongve.updateUnionGve(info); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
if errdata = this.module.DispenseRes(session, prop, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
award = make([]*pb.UserAssets, 0)
|
||||
for _, v := range prop {
|
||||
award = append(award, &pb.UserAssets{
|
||||
A: v.A,
|
||||
T: v.T,
|
||||
N: v.N,
|
||||
})
|
||||
}
|
||||
|
||||
if err = this.module.modelUniongve.updateUnionGve(info); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "challengefinish", &pb.UniongveChallengeFinishResp{})
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "challengefinish", &pb.UniongveChallengeFinishResp{
|
||||
Unionid: req.Unionid,
|
||||
Boosid: req.Boosid,
|
||||
Efficient: ok,
|
||||
Award: award,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -162,5 +162,28 @@ func (this *ModelUniongve) userlock(id string) (result *redis.RedisMutex, err er
|
||||
|
||||
// 击杀boos
|
||||
func (this *ModelUniongve) booskill(unionid string, boosid int32, info *pb.DBUnionGve) {
|
||||
var (
|
||||
// conf *cfg.GameGuildBossData
|
||||
members []*pb.SociatyMemberInfo
|
||||
offlist []string = make([]string, 0)
|
||||
onine []string = make([]string, 0)
|
||||
// err error
|
||||
)
|
||||
// if conf, err = this.module.configure.getguildbossByid(boosid); err != nil {
|
||||
// this.module.Errorln(err)
|
||||
// return
|
||||
// }
|
||||
members = this.module.sociaty.MembersBySociatyId(unionid)
|
||||
if members == nil || len(members) == 0 {
|
||||
this.module.Error("MembersBySociatyId is nil !")
|
||||
return
|
||||
}
|
||||
for _, v := range members {
|
||||
if v.OfflineTime != 0 {
|
||||
offlist = append(offlist, v.Uid)
|
||||
} else {
|
||||
onine = append(onine, v.Uid)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ func NewModule() core.IModule {
|
||||
type UnionGve struct {
|
||||
modules.ModuleBase
|
||||
service core.IService
|
||||
sociaty comm.ISociaty
|
||||
mail comm.Imail
|
||||
battle comm.IBattle
|
||||
api *apiComp
|
||||
modelUniongve *ModelUniongve
|
||||
@ -34,6 +36,14 @@ func (this *UnionGve) Init(service core.IService, module core.IModule, options c
|
||||
func (this *UnionGve) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
var module core.IModule
|
||||
if module, err = this.service.GetModule(comm.ModuleSociaty); err != nil {
|
||||
return
|
||||
}
|
||||
this.sociaty = module.(comm.ISociaty)
|
||||
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
|
||||
return
|
||||
}
|
||||
this.mail = module.(comm.Imail)
|
||||
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user