109 lines
2.9 KiB
Go
109 lines
2.9 KiB
Go
package integral
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"go_dreamfactory/utils"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.IntegralGetListReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.IntegralGetListReq) (errdata *pb.ErrorData) {
|
|
|
|
var (
|
|
list *pb.DBIntegralBoss
|
|
err error
|
|
)
|
|
list, err = this.module.modelIntegral.getIntegralList(session)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
update := make(map[string]interface{})
|
|
curTime := configure.Now().Unix()
|
|
if !utils.IsToday(list.CTime) { // 不是今天 重置
|
|
|
|
list.Count = 0
|
|
update["count"] = list.Count
|
|
|
|
list.CTime = curTime
|
|
update["cTime"] = list.CTime
|
|
}
|
|
|
|
if curTime > list.Etime { // 更新赛季
|
|
szConf := this.module.configure.GetIntegralITime()
|
|
// 当前开服时间
|
|
//openTime := this.module.service.GetOpentime().Unix()
|
|
list.Hid = 0 // 重置活动id
|
|
list.Etime = 0
|
|
for _, v := range szConf {
|
|
//if curTime >= int64(v.Openday)+openTime && curTime <= int64(v.Endday)+openTime { // 暂时不校验天数
|
|
list.Hid = v.Hdid
|
|
list.Etime = int64(v.Endday) + curTime
|
|
break
|
|
//}
|
|
}
|
|
|
|
var conf *cfg.GameIntegralBossData
|
|
if conf, err = this.module.configure.GetStageBoss(list.Hid, 1); err == nil {
|
|
list.Itype = conf.Itype // 获取类型
|
|
update["itype"] = list.Itype
|
|
list.Nandu = 1 // 初始难度1
|
|
update["nandu"] = list.Nandu
|
|
}
|
|
// 相关数据重置
|
|
list.Maxscore = 0
|
|
list.Totalscore = 0
|
|
list.Reward1 = 0
|
|
list.Reward2 = 0
|
|
list.Buff = make(map[int32]int32)
|
|
list.Score = make(map[int32]int32)
|
|
update["hid"] = list.Hid
|
|
update["etime"] = list.Etime
|
|
update["maxscore"] = list.Maxscore
|
|
update["totalscore"] = list.Totalscore
|
|
update["reward1"] = list.Reward1
|
|
update["reward2"] = list.Reward2
|
|
update["buff"] = list.Buff
|
|
update["score"] = list.Score
|
|
|
|
if list.Itype == 2 {
|
|
var szTaskid []int32
|
|
for _, v := range this.module.configure.GetIntegralCondition() {
|
|
szTaskid = append(szTaskid, v.TaskId) // 获取任务id
|
|
}
|
|
if _, data, err := this.module.ModuleBuried.CheckCondition(session, szTaskid...); err == nil {
|
|
for _, v := range data {
|
|
|
|
if v.State == pb.BuriedItemFinishState_buried_finish {
|
|
if c, e := this.module.configure.GetIntegralConditionByTask(v.Conid); e == nil {
|
|
list.Buff[v.Conid] = c.Id
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(update) > 0 {
|
|
if err = this.module.modelIntegral.modifyIntegralData(session.GetUserId(), update); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "getlist", &pb.IntegralGetListResp{Data: list})
|
|
return
|
|
}
|