商队修改
This commit is contained in:
parent
8a00c3798b
commit
a8d8194605
@ -2,9 +2,8 @@ package caravan
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
@ -21,9 +20,9 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.CaravanGetListRe
|
||||
if errdata = this.GetListCheck(session, req); errdata != nil {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
list, err := this.module.modelCaravan.getCaravanList(session.GetUserId())
|
||||
|
||||
if configure.Now().Unix() >= list.Resettime || err == mgo.MongodbNil { // 初始化门票和虚拟币
|
||||
list, _ := this.module.modelCaravan.getCaravanList(session.GetUserId())
|
||||
endtime := utils.WeekIntervalTime()
|
||||
if list.Resettime != endtime { // 初始化门票和虚拟币
|
||||
if conf, err := this.module.configure.GetCaravanLv(list.Lv); err == nil {
|
||||
this.module.ModuleItems.CleanItemById(session, conf.Tickettop.T) // 清理之前的门票数据
|
||||
} else {
|
||||
@ -45,6 +44,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.CaravanGetListRe
|
||||
list.Profit = 0
|
||||
update["reward"] = list.Reward // 初始化利润奖励
|
||||
update["profit"] = list.Profit // 初始化商品利润
|
||||
list.Resettime = endtime
|
||||
update["resettime"] = list.Resettime
|
||||
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -47,11 +48,8 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err
|
||||
// 创建一条数据
|
||||
result.Id = primitive.NewObjectID().Hex()
|
||||
// 活动持续时间
|
||||
sTime := int64(this.module.ModuleTools.GetGlobalConf().BusinessRewardday * 24 * 3600) // 单位s
|
||||
openTime := this.module.service.GetOpentime().Unix() // 获取开服时间
|
||||
subTime := configure.Now().Unix() - openTime
|
||||
result.Resettime = configure.Now().Unix() - (subTime % sTime) + sTime
|
||||
//result.Resettime = +int64(this.module.ModuleTools.GetGlobalConf().BusinessRewardday * 24 * 3600)
|
||||
|
||||
result.Resettime = utils.WeekIntervalTime()
|
||||
result.Citystime = configure.Now().Unix()
|
||||
result.Rtime = configure.Now().Unix()
|
||||
|
||||
@ -63,9 +61,10 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err
|
||||
this.module.InitCaravanCityData(uid, result) // 初始1级
|
||||
this.module.InitCaravanItemData(uid, result)
|
||||
this.Add(uid, result)
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
|
||||
return result, err
|
||||
}
|
||||
func (this *modelCaravan) modifyCaravanDataByObjId(uid string, data map[string]interface{}) error {
|
||||
|
@ -122,6 +122,7 @@ func (this *Caravan) InitCaravanCityData(uid string, data *pb.DBCaravan) {
|
||||
city.NextexspecialPCT = v.Exspecialnum[int(comm.GetRandW(v.ExspecialnumWeight))] // 获取权重
|
||||
data.City[v.Id] = city
|
||||
}
|
||||
//data.Citystime = utils.GetZeroTime(configure.Now().Unix())
|
||||
data.Rtime = configure.Now().Unix() // 修改时间
|
||||
}
|
||||
|
||||
@ -167,7 +168,7 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) {
|
||||
changeTime = this.configure.GetCityRefreshTime() // 3分钟
|
||||
|
||||
// 刷新城市货物信息
|
||||
if !utils.IsToday(caravan.Citystime) {
|
||||
if !utils.IsNextToday(caravan.Citystime) {
|
||||
list := this.configure.GetAllCaravanCity()
|
||||
for _, conf := range list {
|
||||
if v, ok := caravan.City[conf.Id]; ok {
|
||||
@ -182,7 +183,7 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) {
|
||||
v.Special = append(v.Special, conf.Special...)
|
||||
}
|
||||
|
||||
if utils.IsToday(caravan.Citystime - 24*3600) {
|
||||
if utils.IsToday(caravan.Citystime) {
|
||||
v.Exspecial = make([]string, 0)
|
||||
v.Exspecial = append(v.Exspecial, v.Nextexspecial...)
|
||||
v.ExspecialPCT = v.NextexspecialPCT
|
||||
@ -215,17 +216,20 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) {
|
||||
}
|
||||
|
||||
}
|
||||
caravan.Citystime = configure.Now().Unix() // 设置今天的时间
|
||||
caravan.Citystime = utils.GetZeroTime(configure.Now().Unix()) // 设置第二天0点的时间
|
||||
update["city"] = caravan.City
|
||||
update["citystime"] = caravan.Citystime
|
||||
}
|
||||
if caravan.Itemtime == 0 {
|
||||
caravan.Itemtime = configure.Now().Unix()
|
||||
}
|
||||
subTime := int32(curTime - caravan.Itemtime)
|
||||
if subTime >= changeTime {
|
||||
bChange = true
|
||||
|
||||
icount := int32(subTime / changeTime) // 循环周期
|
||||
caravan.Itemtime += int64(changeTime * icount)
|
||||
update["citystime"] = caravan.Itemtime
|
||||
update["itemtime"] = caravan.Itemtime
|
||||
for k, v := range caravan.Goods {
|
||||
if c, err := this.configure.GetCaravanGoods(k); err == nil {
|
||||
caravan.Oldprice[k] = v.Price
|
||||
|
@ -62,7 +62,7 @@ func (this *modelRank) updateRank(guilds ...*pb.DBGuildGve) (err error) {
|
||||
)
|
||||
menbers = make([]*redis.Z, len(guilds))
|
||||
for i, v := range guilds {
|
||||
endtime := time.Unix(utils.WeekIntervalTime(0), 0)
|
||||
endtime := time.Unix(utils.WeekIntervalTime(), 0)
|
||||
start := time.Unix(v.Lastkilltime, 0)
|
||||
seconds := endtime.Sub(start).Seconds()
|
||||
Integral := float64(v.Kills)*float64(10000000000) + seconds
|
||||
|
@ -115,7 +115,7 @@ type sumy struct {
|
||||
func Test_Main(t *testing.T) {
|
||||
|
||||
value, err := strconv.Atoi("944005411")
|
||||
fmt.Printf("%v,%v", value, err)
|
||||
fmt.Printf("%v,%v,%d", value, err, utils.WeekIntervalTime())
|
||||
ids := utils.RandomNumbers(0, 10, 5)
|
||||
for _, v := range ids {
|
||||
fmt.Printf("%d", v)
|
||||
|
@ -40,7 +40,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.StonehengeGetLis
|
||||
update["hero"] = stone.Hero
|
||||
stone.Addweight = make(map[int32]int32, 0)
|
||||
update["addweight"] = stone.Addweight
|
||||
stone.Etime = utils.WeekIntervalTime(0)
|
||||
stone.Etime = utils.WeekIntervalTime()
|
||||
update["etime"] = stone.Etime
|
||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func (this *MStonehenge) GetStonehengeData(uid string) *pb.DBStonehenge {
|
||||
stone.Userbuff = make(map[int32]int32, 0)
|
||||
stone.Reward = make(map[int32]bool, 0)
|
||||
stone.Addweight = make(map[int32]int32, 0)
|
||||
stone.Etime = utils.WeekIntervalTime(0)
|
||||
stone.Etime = utils.WeekIntervalTime()
|
||||
stone.Hero = make(map[string]*pb.BattleRole)
|
||||
this.Add(uid, stone)
|
||||
|
||||
@ -78,13 +78,13 @@ func (this *MStonehenge) reLoadStoneBoos() (err error) {
|
||||
s := &pb.DBStoneBoss{}
|
||||
this.module.ModuleTools.GetGlobalData(StoneBossKey, s)
|
||||
|
||||
if len(s.Bossstage) == 0 || utils.WeekIntervalTime(0) != s.Rtime {
|
||||
if len(s.Bossstage) == 0 || utils.WeekIntervalTime() != s.Rtime {
|
||||
this.lock.Lock()
|
||||
this.bossStage = this.module.configure.CheckStage()
|
||||
this.lock.Unlock()
|
||||
this.module.ModuleTools.UpdateGlobalData(StoneBossKey, map[string]interface{}{
|
||||
"BossStage": this.bossStage,
|
||||
"rtime": utils.WeekIntervalTime(0),
|
||||
"rtime": utils.WeekIntervalTime(),
|
||||
})
|
||||
} else {
|
||||
this.lock.Lock()
|
||||
|
@ -40,7 +40,7 @@ func (this *MWorldBuff) GetStonehengeData(uid string) *pb.DBStonehenge {
|
||||
stone.Userbuff = make(map[int32]int32, 0)
|
||||
stone.Reward = make(map[int32]bool, 0)
|
||||
stone.Addweight = make(map[int32]int32, 0)
|
||||
stone.Etime = utils.WeekIntervalTime(0)
|
||||
stone.Etime = utils.WeekIntervalTime()
|
||||
this.Add(uid, stone)
|
||||
return nil
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func (this *CaravanRank) Start() (err error) {
|
||||
}
|
||||
|
||||
func (this *CaravanRank) TimerSeason() {
|
||||
endTime := utils.WeekIntervalTime(0)
|
||||
endTime := utils.WeekIntervalTime()
|
||||
this.module.Debugf("TimerSeason end: %d,cur time:%d", endTime, configure.Now().Unix())
|
||||
|
||||
if err := this.service.RpcCall(
|
||||
|
@ -15,6 +15,12 @@ func IsToday(d int64) bool {
|
||||
now := configure.Now()
|
||||
return tt.Year() == now.Year() && tt.Month() == now.Month() && tt.Day() == now.Day()
|
||||
}
|
||||
func IsNextToday(d int64) bool {
|
||||
d += 24 * 3600
|
||||
tt := time.Unix(d, 0)
|
||||
now := configure.Now()
|
||||
return tt.Year() == now.Year() && tt.Month() == now.Month() && tt.Day() == now.Day()
|
||||
}
|
||||
|
||||
// 判断是否是出于同一周
|
||||
func IsSameWeek(d int64) bool {
|
||||
@ -170,7 +176,7 @@ func DiffDays(t1, t2 int64) int {
|
||||
return diffDays
|
||||
}
|
||||
|
||||
func WeekIntervalTime(week int) (endTime int64) {
|
||||
func WeekIntervalTime() (endTime int64) {
|
||||
now := time.Now()
|
||||
offset := int(time.Monday - now.Weekday())
|
||||
//周日做特殊判断 因为time.Monday = 0
|
||||
@ -181,7 +187,7 @@ func WeekIntervalTime(week int) (endTime int64) {
|
||||
year, month, day := now.Date()
|
||||
thisWeek := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
|
||||
//startTime = thisWeek.AddDate(0, 0, offset+7*week).Unix()
|
||||
endTime = thisWeek.AddDate(0, 0, offset+6+7*week).Unix()
|
||||
endTime = thisWeek.AddDate(0, 0, offset+7).Unix()
|
||||
|
||||
return endTime
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ func TestIsSameWeek(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWeekIntervalTime(t *testing.T) {
|
||||
ti := utils.WeekIntervalTime(0)
|
||||
ti := utils.WeekIntervalTime()
|
||||
format := "2006-01-02 15:04:05"
|
||||
formattedTime := time.Unix(ti, 0).Format(format)
|
||||
fmt.Println(formattedTime)
|
||||
|
Loading…
Reference in New Issue
Block a user