上传头像框
This commit is contained in:
parent
60f626ab81
commit
67cce21c5e
@ -13,11 +13,29 @@ func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.IsLandInfoReq)
|
||||
|
||||
// /获取自己的排行榜信息
|
||||
func (this *apiComp) Info(session comm.IUserSession, req *pb.IsLandInfoReq) (errdata *pb.ErrorData) {
|
||||
var ()
|
||||
var (
|
||||
info *pb.DBIsland
|
||||
heros []*pb.DBHero
|
||||
err error
|
||||
)
|
||||
if errdata = this.InfoCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "info", &pb.IsLandInfoResp{})
|
||||
if info, err = this.module.model.getmodel(session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if heros, err = this.module.modelhero.getHeroList(session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "info", &pb.IsLandInfoResp{Info: info, Heros: heros})
|
||||
return
|
||||
}
|
||||
|
76
modules/island/api_battle.go
Normal file
76
modules/island/api_battle.go
Normal file
@ -0,0 +1,76 @@
|
||||
package island
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
// 参数校验
|
||||
func (this *apiComp) BattleCheck(session comm.IUserSession, req *pb.IsLandBattleReq) (errdata *pb.ErrorData) {
|
||||
if req.Level == 0 || req.Battle == nil {
|
||||
this.module.Error("战斗开始参数错误",
|
||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||
log.Field{Key: "params", Value: req.String()},
|
||||
)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: "BattleConfId is 0",
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// /获取系统公告
|
||||
func (this *apiComp) Battle(session comm.IUserSession, req *pb.IsLandBattleReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
conf *cfg.GameHeroupstoryChapterData
|
||||
bconf *cfg.GameHeroupstoryBattleData
|
||||
record *pb.DBBattleRecord
|
||||
err error
|
||||
)
|
||||
if errdata = this.BattleCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if conf, err = this.module.configure.getGameHeroupstoryChapter(req.Level); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if bconf, err = this.module.configure.getGameHeroupstoryBattle(conf.Battle); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Rulesid: bconf.BattleReadyID,
|
||||
Ptype: pb.PlayType_rtask,
|
||||
Format: req.Battle,
|
||||
Mformat: bconf.FormatList,
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "battle", &pb.StorylineBattleResp{
|
||||
Level: req.Level,
|
||||
Info: &pb.BattleInfo{
|
||||
Id: record.Id,
|
||||
Rulesid: bconf.BattleReadyID,
|
||||
Btype: record.Btype,
|
||||
Ptype: record.Ptype,
|
||||
RedCompId: record.RedCompId,
|
||||
Redflist: record.Redflist,
|
||||
BlueCompId: record.BlueCompId,
|
||||
Buleflist: record.Buleflist,
|
||||
Tasks: record.Tasks,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
155
modules/island/api_complete.go
Normal file
155
modules/island/api_complete.go
Normal file
@ -0,0 +1,155 @@
|
||||
package island
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
)
|
||||
|
||||
// 参数校验
|
||||
func (this *apiComp) CompleteCheck(session comm.IUserSession, req *pb.IsLandCompleteReq) (errdata *pb.ErrorData) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// /获取自己的排行榜信息
|
||||
func (this *apiComp) Complete(session comm.IUserSession, req *pb.IsLandCompleteReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
info *pb.DBIsland
|
||||
item *pb.DBIslandItem
|
||||
award []*pb.UserAtno
|
||||
ok bool
|
||||
iswin bool
|
||||
isfish bool
|
||||
err error
|
||||
)
|
||||
if errdata = this.CompleteCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if conf, err = this.module.configure.getGameHeroupstoryChapter(req.Level); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if info, err = this.module.model.getmodel(session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if item, ok = info.Item[conf.Hero]; !ok {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("no activation hero:%d", conf.Hero),
|
||||
}
|
||||
return
|
||||
}
|
||||
//前置判断
|
||||
if conf.Onlevel != 0 && item.Level[conf.Onlevel] == 0 {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("%d onlevel no Complete", req.Level),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//前置判断
|
||||
if len(conf.Onlevelstory) == 2 && item.Level[conf.Onlevelstory[0]] == conf.Onlevelstory[1] {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("%d onlevel no Complete", req.Level),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if conf.Leveltype != 1 && item.Level[req.Level] != 0 {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("%d received", req.Level),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if item.Level[req.Level] != 0 {
|
||||
isfish = true
|
||||
}
|
||||
|
||||
if chapterconf, err = this.module.configure.getGameHeroupstoryChaptertxt(conf.Chapter); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if conf.Leveltype == 1 { //剧情关卡
|
||||
item.Level[req.Level] = req.Story
|
||||
} else if conf.Leveltype == 2 { //战斗管卡
|
||||
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
if !iswin {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: "battle no win!",
|
||||
}
|
||||
return
|
||||
}
|
||||
item.Level[req.Level] = 1
|
||||
} else if conf.Leveltype == 4 {
|
||||
item.Level[req.Level] = 1
|
||||
item.Chapter[conf.Chapter] = configure.Now().Unix()
|
||||
} else if conf.Leveltype == 5 {
|
||||
if req.Report != nil {
|
||||
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
if !iswin {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: "battle no win!",
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
item.Level[req.Level] = 1
|
||||
} else {
|
||||
item.Level[req.Level] = 1
|
||||
}
|
||||
|
||||
if !isfish {
|
||||
if errdata = this.module.DispenseRes(session, conf.Reward, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
award = make([]*pb.UserAssets, 0)
|
||||
for _, v := range conf.Reward {
|
||||
award = append(award, &pb.UserAssets{
|
||||
A: v.A,
|
||||
T: v.T,
|
||||
N: v.N,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
||||
"islands": info.Islands,
|
||||
})
|
||||
session.SendMsg(string(this.module.GetType()), "complete", &pb.StorylineCompleteResp{Level: req.Level, Story: req.Story, Award: award})
|
||||
return
|
||||
}
|
@ -27,11 +27,8 @@ func (this *modelHeroComp) Init(service core.IService, module core.IModule, comp
|
||||
|
||||
// 读取数据
|
||||
// 获取玩家的英雄列表
|
||||
func (this *modelHeroComp) getHeroList(uid string) []*pb.DBHero {
|
||||
heroes := make([]*pb.DBHero, 0)
|
||||
err := this.GetList(uid, &heroes)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return heroes
|
||||
func (this *modelHeroComp) getHeroList(uid string) (heros []*pb.DBHero, err error) {
|
||||
heros = make([]*pb.DBHero, 0)
|
||||
err = this.GetList(uid, &heros)
|
||||
return
|
||||
}
|
||||
|
@ -20,9 +20,10 @@ func NewModule() core.IModule {
|
||||
type IsLand struct {
|
||||
modules.ModuleBase
|
||||
service base.IRPCXService
|
||||
privilege comm.IPrivilege
|
||||
battle comm.IBattle
|
||||
api *apiComp
|
||||
model *modelComp
|
||||
modelhero *modelHeroComp
|
||||
configure *ConfigureComp
|
||||
}
|
||||
|
||||
@ -42,4 +43,18 @@ func (this *IsLand) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.model = this.RegisterComp(new(modelComp)).(*modelComp)
|
||||
this.modelhero = this.RegisterComp(new(modelHeroComp)).(*modelHeroComp)
|
||||
this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp)
|
||||
}
|
||||
|
||||
func (this *IsLand) Start() (err error) {
|
||||
if err = this.ModuleBase.Start(); err != nil {
|
||||
return
|
||||
}
|
||||
var module core.IModule
|
||||
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
||||
return
|
||||
}
|
||||
this.battle = module.(comm.IBattle)
|
||||
return
|
||||
}
|
||||
|
@ -97,10 +97,9 @@ func (this *apiComp) SwitchDefPer(session comm.IUserSession, req *pb.UserSwitchD
|
||||
}
|
||||
return
|
||||
}
|
||||
user.CurAction = req.CurAction
|
||||
change["curAction"] = req.CurAction
|
||||
}
|
||||
|
||||
user.CurAction = req.CurAction
|
||||
change["curAction"] = req.CurAction
|
||||
if req.CurBg != "" {
|
||||
if conf, err = this.module.configure.GetPlayerOverview(req.CurBg, user.Gender); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -129,9 +128,9 @@ func (this *apiComp) SwitchDefPer(session comm.IUserSession, req *pb.UserSwitchD
|
||||
}
|
||||
return
|
||||
}
|
||||
user.CurBg = req.CurBg
|
||||
change["curBg"] = req.CurBg
|
||||
}
|
||||
user.CurBg = req.CurBg
|
||||
change["curBg"] = req.CurBg
|
||||
if req.CurAframe != "" {
|
||||
if conf, err = this.module.configure.GetPlayerOverview(req.CurAframe, 0); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -160,9 +159,9 @@ func (this *apiComp) SwitchDefPer(session comm.IUserSession, req *pb.UserSwitchD
|
||||
}
|
||||
return
|
||||
}
|
||||
user.Curaframe = req.CurAframe
|
||||
change["curaframe"] = req.CurAframe
|
||||
}
|
||||
user.Curaframe = req.CurAframe
|
||||
change["curaframe"] = req.CurAframe
|
||||
if err = this.module.modelUser.Change(session.GetUserId(), change); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
|
Loading…
Reference in New Issue
Block a user