庆典活动调整
This commit is contained in:
parent
a8b73f3b34
commit
ca4f0faed5
@ -86,7 +86,7 @@ func (this *modelHdList) getHdInfoByType(itype pb.HdType) (activity *pb.DBHuodon
|
|||||||
activity, ok = this.activity[itype]
|
activity, ok = this.activity[itype]
|
||||||
this.hlock.RUnlock()
|
this.hlock.RUnlock()
|
||||||
if ok {
|
if ok {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
"go_dreamfactory/utils"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
@ -206,41 +205,41 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
|
|||||||
update := make(map[string]interface{})
|
update := make(map[string]interface{})
|
||||||
bChange := false
|
bChange := false
|
||||||
// 查询玩家活动记录
|
// 查询玩家活动记录
|
||||||
if data, err := this.modelhdData.getHddataByOid(session.GetUserId(), activity.Id); err == nil {
|
if list, err := this.modelhdData.getHddataByOid(session.GetUserId(), activity.Id); err == nil {
|
||||||
// 注意 Gotarr:map[int32]int32 key value 已经挑战的次数
|
// 注意 Gotarr:map[int32]int32 key value 已经挑战的次数
|
||||||
if !utils.IsToday(data.Lasttime) { // 不是今天重置
|
|
||||||
data.Lasttime = configure.Now().Unix()
|
if list.Lasttime < configure.Now().Unix() || list.Val == 0 { // 不是今天重置
|
||||||
data.Gotarr = make(map[int32]int32)
|
list.Gotarr = make(map[int32]int32)
|
||||||
// 计算进度
|
update := make(map[string]interface{})
|
||||||
data.Val = int32((configure.Now().Unix()-activity.Stime)/24*3600) + 1
|
|
||||||
update["lasttime"] = data.Lasttime
|
update["gotarr"] = list.Gotarr
|
||||||
update["val"] = data.Val
|
|
||||||
update["gotarr"] = data.Gotarr
|
|
||||||
bChange = true
|
|
||||||
}
|
|
||||||
if data.Val == 0 {
|
|
||||||
var pos int32
|
|
||||||
var maxday int32
|
var maxday int32
|
||||||
_days := this.configure.GetHDCelebrationData()
|
_days := this.configure.GetHDCelebrationData()
|
||||||
for _, v := range _days { // 开启循环
|
for _, v := range _days { // 开启循环
|
||||||
maxday += v
|
maxday += v
|
||||||
}
|
}
|
||||||
|
var pos int32
|
||||||
_sub := int32((configure.Now().Unix() - activity.Stime) / (24 * 3600))
|
_sub := int32((configure.Now().Unix() - activity.Stime) / (24 * 3600))
|
||||||
_sub = _sub%maxday + 1
|
|
||||||
for index, v := range _days {
|
for index, v := range _days {
|
||||||
|
find := false
|
||||||
for i := 0; i < int(v); i++ {
|
for i := 0; i < int(v); i++ {
|
||||||
pos++
|
pos++
|
||||||
if _sub == pos {
|
if _sub%maxday+1 == pos {
|
||||||
data.Val = int32(index) + 1 // 计算val 值
|
list.Val = int32(index) + 1 // 计算val 值
|
||||||
update["val"] = data.Val
|
update["val"] = list.Val
|
||||||
|
find = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if find { // 找到剩余的天数
|
||||||
|
list.Lasttime = activity.Stime + int64(_sub+pos%v+1)*24*3600
|
||||||
|
update["lasttime"] = list.Lasttime
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.Val = 1
|
if conf, err := this.configure.GetHDCelebration(list.Val); err == nil {
|
||||||
}
|
|
||||||
|
|
||||||
if conf, err := this.configure.GetHDCelebration(data.Val); err == nil {
|
|
||||||
for _, v1 := range conf.Bosstype {
|
for _, v1 := range conf.Bosstype {
|
||||||
if v1 == 0 { // bosstype 为0 表示所有的boss 类型都算
|
if v1 == 0 { // bosstype 为0 表示所有的boss 类型都算
|
||||||
bosstype = 0
|
bosstype = 0
|
||||||
@ -248,7 +247,7 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.Systemtype == systemtype {
|
if conf.Systemtype == systemtype {
|
||||||
data.Gotarr[bosstype] += 1
|
list.Gotarr[bosstype] += 1
|
||||||
// 天数
|
// 天数
|
||||||
var idays int32
|
var idays int32
|
||||||
for i, v1 := range conf.Bosstype {
|
for i, v1 := range conf.Bosstype {
|
||||||
@ -258,9 +257,9 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更新信息
|
// 更新信息
|
||||||
update["gotarr"] = data.Gotarr
|
update["gotarr"] = list.Gotarr
|
||||||
bChange = true
|
bChange = true
|
||||||
if data.Gotarr[bosstype] <= idays {
|
if list.Gotarr[bosstype] <= idays {
|
||||||
bDouble = true
|
bDouble = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,9 +267,9 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
|
|||||||
|
|
||||||
if bChange {
|
if bChange {
|
||||||
var sz []*pb.DBActivityData
|
var sz []*pb.DBActivityData
|
||||||
this.modelhdData.ModifyActivityList(session.GetUserId(), data.Id, update)
|
this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
||||||
// 推送活动数据进度变化
|
// 推送活动数据进度变化
|
||||||
sz = append(sz, data)
|
sz = append(sz, list)
|
||||||
session.SendMsg(string(this.GetType()), "datachange", &pb.ActivityDataChangePush{
|
session.SendMsg(string(this.GetType()), "datachange", &pb.ActivityDataChangePush{
|
||||||
Data: sz,
|
Data: sz,
|
||||||
})
|
})
|
||||||
@ -294,42 +293,19 @@ func (this *Activity) GetHdData(session comm.IUserSession, oids []string) (resul
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if activity.Itype == pb.HdType_HdCelebration || activity.Itype == pb.HdType_HdLevel || activity.Itype == pb.HdType_HdTypeSign {
|
if activity.Itype == pb.HdType_HdCelebration {
|
||||||
list, _ = this.modelhdData.getHddataByOid(session.GetUserId(), id)
|
list, _ = this.modelhdData.getHddataByOid(session.GetUserId(), id)
|
||||||
if activity.Itype == pb.HdType_HdTypeSign {
|
|
||||||
if list.Val == 0 || !utils.IsToday(list.Lasttime) {
|
|
||||||
list.Lasttime = curTime
|
|
||||||
list.Val += 1
|
|
||||||
update := make(map[string]interface{})
|
|
||||||
update["lasttime"] = list.Lasttime
|
|
||||||
update["val"] = list.Val
|
|
||||||
this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 开服等级活动
|
|
||||||
if activity.Itype == pb.HdType_HdLevel {
|
|
||||||
if user, err := this.ModuleUser.GetUser(session.GetUserId()); err == nil {
|
|
||||||
if list.Val != user.Lv {
|
|
||||||
list.Val = user.Lv
|
|
||||||
list.Lasttime = curTime
|
|
||||||
update := make(map[string]interface{})
|
|
||||||
update["lasttime"] = list.Lasttime
|
|
||||||
update["val"] = list.Val
|
|
||||||
this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 获取开服庆典活动
|
// 获取开服庆典活动
|
||||||
if activity.Itype == pb.HdType_HdCelebration {
|
if activity.Itype == pb.HdType_HdCelebration {
|
||||||
// key := fmt.Sprintf("%s-%s", session.GetUserId(), id)
|
// key := fmt.Sprintf("%s-%s", session.GetUserId(), id)
|
||||||
if list, err = this.modelhdData.getHddataByOid(session.GetUserId(), id); err == nil {
|
if list, err = this.modelhdData.getHddataByOid(session.GetUserId(), id); err == nil {
|
||||||
|
|
||||||
if !utils.IsToday(list.Lasttime) || list.Val == 0 { // 不是今天重置
|
if list.Lasttime < configure.Now().Unix() || list.Val == 0 { // 不是今天重置
|
||||||
list.Lasttime = configure.Now().Unix()
|
//list.Lasttime = configure.Now().Unix()
|
||||||
list.Gotarr = make(map[int32]int32)
|
list.Gotarr = make(map[int32]int32)
|
||||||
update := make(map[string]interface{})
|
update := make(map[string]interface{})
|
||||||
// 计算进度
|
// 计算进度
|
||||||
update["lasttime"] = list.Lasttime
|
|
||||||
|
|
||||||
update["gotarr"] = list.Gotarr
|
update["gotarr"] = list.Gotarr
|
||||||
var maxday int32
|
var maxday int32
|
||||||
@ -339,16 +315,23 @@ func (this *Activity) GetHdData(session comm.IUserSession, oids []string) (resul
|
|||||||
}
|
}
|
||||||
var pos int32
|
var pos int32
|
||||||
_sub := int32((configure.Now().Unix() - activity.Stime) / (24 * 3600))
|
_sub := int32((configure.Now().Unix() - activity.Stime) / (24 * 3600))
|
||||||
_sub = _sub%maxday + 1
|
|
||||||
for index, v := range _days {
|
for index, v := range _days {
|
||||||
|
find := false
|
||||||
for i := 0; i < int(v); i++ {
|
for i := 0; i < int(v); i++ {
|
||||||
pos++
|
pos++
|
||||||
if _sub == pos {
|
if _sub%maxday+1 == pos {
|
||||||
list.Val = int32(index) + 1 // 计算val 值
|
list.Val = int32(index) + 1 // 计算val 值
|
||||||
update["val"] = list.Val
|
update["val"] = list.Val
|
||||||
|
find = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if find { // 找到剩余的天数
|
||||||
|
list.Lasttime = activity.Stime + int64(_sub+pos%v+1)*24*3600
|
||||||
|
update["lasttime"] = list.Lasttime
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user