上传门票道具下发
This commit is contained in:
parent
852f9056d3
commit
ff5e45cea8
@ -20,7 +20,7 @@ func (this *apiComp) BuyCheck(session comm.IUserSession, req *pb.ArenaBuyReq) (c
|
|||||||
///获取自己的排行榜信息
|
///获取自己的排行榜信息
|
||||||
func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
global *cfg.GameGlobalData
|
// global *cfg.GameGlobalData
|
||||||
info *pb.DBArenaUser
|
info *pb.DBArenaUser
|
||||||
challenge *cfg.GameArenaBuyChallengeData
|
challenge *cfg.GameArenaBuyChallengeData
|
||||||
need []*cfg.Gameatn
|
need []*cfg.Gameatn
|
||||||
@ -33,12 +33,12 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
|
|||||||
code = pb.ErrorCode_CacheReadError
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.modelArena.recoverTicket(info)
|
this.module.modelArena.recoverTicket(session, info)
|
||||||
global = this.module.configure.GetGlobalConf()
|
// global = this.module.configure.GetGlobalConf()
|
||||||
if info.Ticket+req.BuyNum > global.ArenaTicketMax {
|
// if info.Ticket+req.BuyNum > global.ArenaTicketMax {
|
||||||
code = pb.ErrorCode_ArenaTicketBuyUp
|
// code = pb.ErrorCode_ArenaTicketBuyUp
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
need = make([]*cfg.Gameatn, 0)
|
need = make([]*cfg.Gameatn, 0)
|
||||||
for i := int32(0); i < req.BuyNum; i++ {
|
for i := int32(0); i < req.BuyNum; i++ {
|
||||||
if challenge, err = this.module.configure.GetchallengeData(info.Buynum + i + 1); err != nil {
|
if challenge, err = this.module.configure.GetchallengeData(info.Buynum + i + 1); err != nil {
|
||||||
@ -56,11 +56,14 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
info.Buynum += req.BuyNum
|
info.Buynum += req.BuyNum
|
||||||
info.Ticket += req.BuyNum
|
if code = this.module.DispenseRes(session, []*cfg.Gameatn{{A: comm.ItemType, T: comm.ArenaTicket, N: req.BuyNum}}, true); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// info.Ticket += req.BuyNum
|
||||||
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), "buy", &pb.MoonfantasyBuyResp{Issucc: true, BattleNum: info.Ticket})
|
session.SendMsg(string(this.module.GetType()), "buy", &pb.MoonfantasyBuyResp{Issucc: true, BattleNum: info.Buynum})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package arena
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -50,13 +51,16 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge
|
|||||||
cd = pb.ErrorCode_DBError
|
cd = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.modelArena.recoverTicket(red)
|
this.module.modelArena.recoverTicket(session, red)
|
||||||
if red.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos {
|
if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.configure.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success {
|
||||||
red.Ticket -= this.module.configure.GetGlobalConf().ArenaTicketCos
|
|
||||||
} else {
|
|
||||||
code = pb.ErrorCode_ArenaTicketNotEnough
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// if red.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos {
|
||||||
|
// red.Ticket -= this.module.configure.GetGlobalConf().ArenaTicketCos
|
||||||
|
// } else {
|
||||||
|
// code = pb.ErrorCode_ArenaTicketNotEnough
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
if red.Attack != nil {
|
if red.Attack != nil {
|
||||||
for i, v := range req.Battle.Format {
|
for i, v := range req.Battle.Format {
|
||||||
|
@ -50,7 +50,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code
|
|||||||
Uid: session.GetUserId(),
|
Uid: session.GetUserId(),
|
||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
Integral: global.ArenaInitiaIntegral,
|
Integral: global.ArenaInitiaIntegral,
|
||||||
Ticket: global.ArenaTicketMax,
|
// Ticket: global.ArenaTicketMax,
|
||||||
Streak: 0,
|
Streak: 0,
|
||||||
Record: make([]*pb.DBArenaBattleRecord, 0),
|
Record: make([]*pb.DBArenaBattleRecord, 0),
|
||||||
Lastrtickettime: 0,
|
Lastrtickettime: 0,
|
||||||
@ -65,7 +65,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code
|
|||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.module.modelArena.recoverTicket(info)
|
this.module.modelArena.recoverTicket(session, info)
|
||||||
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
|
@ -57,13 +57,16 @@ func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (code
|
|||||||
cd = pb.ErrorCode_DBError
|
cd = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.modelArena.recoverTicket(info)
|
this.module.modelArena.recoverTicket(session, info)
|
||||||
if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos {
|
if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.configure.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success {
|
||||||
info.Ticket -= this.module.configure.GetGlobalConf().ArenaTicketCos
|
|
||||||
} else {
|
|
||||||
code = pb.ErrorCode_ArenaTicketNotEnough
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos {
|
||||||
|
// info.Ticket -= this.module.configure.GetGlobalConf().ArenaTicketCos
|
||||||
|
// } else {
|
||||||
|
// code = pb.ErrorCode_ArenaTicketNotEnough
|
||||||
|
// return
|
||||||
|
// }
|
||||||
if info.Npc[req.Pid] != nil {
|
if info.Npc[req.Pid] != nil {
|
||||||
ndata := info.Npc[req.Pid]
|
ndata := info.Npc[req.Pid]
|
||||||
if !configure.Now().After(time.Unix(ndata.Cd, 0)) { //已经过了cd时间
|
if !configure.Now().After(time.Unix(ndata.Cd, 0)) { //已经过了cd时间
|
||||||
|
@ -114,7 +114,7 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) {
|
|||||||
"integral": info.Integral,
|
"integral": info.Integral,
|
||||||
"dan": dan,
|
"dan": dan,
|
||||||
"rank": info.Rank,
|
"rank": info.Rank,
|
||||||
"ticket": info.Ticket,
|
// "ticket": info.Ticket,
|
||||||
"buynum": info.Buynum,
|
"buynum": info.Buynum,
|
||||||
"lastrtickettime": info.Lastrtickettime,
|
"lastrtickettime": info.Lastrtickettime,
|
||||||
"attack": info.Attack,
|
"attack": info.Attack,
|
||||||
@ -365,20 +365,26 @@ func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelArena) recoverTicket(info *pb.DBArenaUser) {
|
func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBArenaUser) {
|
||||||
var (
|
var (
|
||||||
duration time.Duration
|
duration time.Duration
|
||||||
|
ticket int32
|
||||||
ticketNum int32
|
ticketNum int32
|
||||||
)
|
)
|
||||||
global := this.module.configure.GetGlobalConf()
|
global := this.module.configure.GetGlobalConf()
|
||||||
if info.Ticket < global.ArenaTicketMax && info.Lastrtickettime > 0 {
|
ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.ArenaTicket))
|
||||||
|
if ticket < global.ArenaTicketMax && info.Lastrtickettime > 0 {
|
||||||
duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
|
duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
|
||||||
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
||||||
if ticketNum > 0 {
|
if ticketNum > 0 {
|
||||||
info.Ticket += ticketNum
|
if ticketNum+ticket > global.ArenaTicketMax {
|
||||||
if info.Ticket > global.ArenaTicketMax {
|
ticketNum = global.ArenaTicketMax - ticket
|
||||||
info.Ticket = global.ArenaTicketMax
|
|
||||||
}
|
}
|
||||||
|
this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{A: comm.ItemType, T: comm.ArenaTicket, N: ticketNum}}, true)
|
||||||
|
// info.Ticket += ticketNum
|
||||||
|
// if info.Ticket > global.ArenaTicketMax {
|
||||||
|
// info.Ticket = global.ArenaTicketMax
|
||||||
|
// }
|
||||||
info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -394,12 +400,13 @@ func (this *modelArena) reddot(session comm.IUserSession) bool {
|
|||||||
}
|
}
|
||||||
if err == mgo.MongodbNil {
|
if err == mgo.MongodbNil {
|
||||||
global := this.module.configure.GetGlobalConf()
|
global := this.module.configure.GetGlobalConf()
|
||||||
if global.ArenaTicketMax >= global.ArenaTicketCos {
|
if global.ArenaTicketMax >= global.ArenaTicketCos.N {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos {
|
ticket := int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.ArenaTicket))
|
||||||
|
if ticket > this.module.configure.GetGlobalConf().ArenaTicketCos.N {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -17,7 +17,7 @@ func (this *apiComp) BattleCheck(session comm.IUserSession, req *pb.MoonfantasyB
|
|||||||
func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattleReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattleReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
boss *cfg.GameDreamlandBoosData
|
boss *cfg.GameDreamlandBoosData
|
||||||
umfantasy *pb.DBUserMFantasy
|
// umfantasy *pb.DBUserMFantasy
|
||||||
mdata *pb.DBMoonFantasy
|
mdata *pb.DBMoonFantasy
|
||||||
record *pb.DBBattleRecord
|
record *pb.DBBattleRecord
|
||||||
cd pb.ErrorCode
|
cd pb.ErrorCode
|
||||||
@ -27,9 +27,9 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if cd == pb.ErrorCode_Success {
|
if cd == pb.ErrorCode_Success {
|
||||||
this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
// this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
||||||
"ticket": umfantasy.Ticket,
|
// "ticket": umfantasy.Ticket,
|
||||||
})
|
// })
|
||||||
this.module.modelDream.ChangeList("", mdata.Id, map[string]interface{}{
|
this.module.modelDream.ChangeList("", mdata.Id, map[string]interface{}{
|
||||||
"record": mdata.Record,
|
"record": mdata.Record,
|
||||||
})
|
})
|
||||||
@ -78,17 +78,20 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
|
|||||||
cd = pb.ErrorCode_MoonfantasyNoJoin
|
cd = pb.ErrorCode_MoonfantasyNoJoin
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
|
// if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
|
||||||
cd = pb.ErrorCode_CacheReadError
|
// cd = pb.ErrorCode_CacheReadError
|
||||||
}
|
// }
|
||||||
if umfantasy.Ticket < this.module.configure.GetGlobalConf().DreamlandCos {
|
if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.configure.GetGlobalConf().DreamlandCos}, true); cd != pb.ErrorCode_Success {
|
||||||
cd = pb.ErrorCode_MoonfantasyNotEnoughbattles
|
|
||||||
}
|
|
||||||
umfantasy.Ticket -= this.module.configure.GetGlobalConf().DreamlandCos
|
|
||||||
if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil {
|
|
||||||
cd = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// if umfantasy.Ticket < this.module.configure.GetGlobalConf().DreamlandCos {
|
||||||
|
// cd = pb.ErrorCode_MoonfantasyNotEnoughbattles
|
||||||
|
// }
|
||||||
|
// umfantasy.Ticket -= this.module.configure.GetGlobalConf().DreamlandCos
|
||||||
|
// if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil {
|
||||||
|
// cd = pb.ErrorCode_ConfigNoFound
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
if len(mdata.Join) >= int(mdata.Numup) {
|
if len(mdata.Join) >= int(mdata.Numup) {
|
||||||
cd = pb.ErrorCode_MoonfantasyJoinUp
|
cd = pb.ErrorCode_MoonfantasyJoinUp
|
||||||
|
@ -32,7 +32,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
|
|||||||
code = pb.ErrorCode_CacheReadError
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.modelUserMF.recoverTicket(info)
|
this.module.modelUserMF.recoverTicket(session,info)
|
||||||
need = make([]*cfg.Gameatn, 0)
|
need = make([]*cfg.Gameatn, 0)
|
||||||
for i := int32(0); i < req.BuyNum; i++ {
|
for i := int32(0); i < req.BuyNum; i++ {
|
||||||
if challengeD, err = this.module.configure.GetchallengeData(info.BuyNum + i + 1); err != nil {
|
if challengeD, err = this.module.configure.GetchallengeData(info.BuyNum + i + 1); err != nil {
|
||||||
@ -50,11 +50,14 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
info.BuyNum += req.BuyNum
|
info.BuyNum += req.BuyNum
|
||||||
info.Ticket += req.BuyNum
|
// info.Ticket += req.BuyNum
|
||||||
|
if code = this.module.DispenseRes(session, []*cfg.Gameatn{{A: comm.ItemType, T: comm.MoonFantasyTicket, N: req.BuyNum}}, true); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
||||||
"buyNum": info.BuyNum,
|
"buyNum": info.BuyNum,
|
||||||
"ticket": info.Ticket,
|
// "ticket": info.Ticket,
|
||||||
})
|
})
|
||||||
session.SendMsg(string(this.module.GetType()), "buy", &pb.MoonfantasyBuyResp{Issucc: true, BattleNum: info.Ticket})
|
session.SendMsg(string(this.module.GetType()), "buy", &pb.MoonfantasyBuyResp{Issucc: true, BattleNum: req.BuyNum})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,14 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetLi
|
|||||||
code = pb.ErrorCode_CacheReadError
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.modelUserMF.recoverTicket(info)
|
this.module.modelUserMF.recoverTicket(session, info)
|
||||||
if err = this.module.modelUserMF.updateUserInfo(info); err != nil {
|
if err = this.module.modelUserMF.updateUserInfo(info); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mfantasys, err = this.module.modelDream.querymfantasys(session.GetUserId())
|
mfantasys, err = this.module.modelDream.querymfantasys(session.GetUserId())
|
||||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{
|
session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{
|
||||||
BattleNum: info.Ticket,
|
// BattleNum: info.Ticket,
|
||||||
BuyNum: info.BuyNum,
|
BuyNum: info.BuyNum,
|
||||||
Dfantasys: mfantasys,
|
Dfantasys: mfantasys,
|
||||||
})
|
})
|
||||||
|
@ -100,7 +100,7 @@ func (this *modelDreamComp) trigger(session comm.IUserSession) {
|
|||||||
if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
|
if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.modelUserMF.recoverTicket(umfantasy)
|
this.module.modelUserMF.recoverTicket(session, umfantasy)
|
||||||
if umfantasy.TriggerNum >= globalconf.DreamlandTriggernum {
|
if umfantasy.TriggerNum >= globalconf.DreamlandTriggernum {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ func (this *modelUserMF) queryUsermfantasy(uId string) (info *pb.DBUserMFantasy,
|
|||||||
TriggerNum: 0,
|
TriggerNum: 0,
|
||||||
LastTrigger: 0,
|
LastTrigger: 0,
|
||||||
BuyNum: global.DreamlandFightnum,
|
BuyNum: global.DreamlandFightnum,
|
||||||
Ticket: global.DreamlandFightnum,
|
// Ticket: global.DreamlandFightnum,
|
||||||
Lastrtickettime: configure.Now().Unix(),
|
Lastrtickettime: configure.Now().Unix(),
|
||||||
}
|
}
|
||||||
if err = this.Add(uId, info); err != nil {
|
if err = this.Add(uId, info); err != nil {
|
||||||
@ -63,7 +64,7 @@ func (this *modelUserMF) queryUsermfantasy(uId string) (info *pb.DBUserMFantasy,
|
|||||||
func (this *modelUserMF) updateUserInfo(info *pb.DBUserMFantasy) (err error) {
|
func (this *modelUserMF) updateUserInfo(info *pb.DBUserMFantasy) (err error) {
|
||||||
this.Change(info.Uid, map[string]interface{}{
|
this.Change(info.Uid, map[string]interface{}{
|
||||||
"triggerNum": info.TriggerNum,
|
"triggerNum": info.TriggerNum,
|
||||||
"ticket": info.Ticket,
|
// "ticket": info.Ticket,
|
||||||
"buyNum": info.BuyNum,
|
"buyNum": info.BuyNum,
|
||||||
"lastTrigger": info.LastTrigger,
|
"lastTrigger": info.LastTrigger,
|
||||||
"lastrtickettime": info.Lastrtickettime,
|
"lastrtickettime": info.Lastrtickettime,
|
||||||
@ -71,9 +72,10 @@ func (this *modelUserMF) updateUserInfo(info *pb.DBUserMFantasy) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelUserMF) recoverTicket(info *pb.DBUserMFantasy) {
|
func (this *modelUserMF) recoverTicket(session comm.IUserSession, info *pb.DBUserMFantasy) {
|
||||||
var (
|
var (
|
||||||
duration time.Duration
|
duration time.Duration
|
||||||
|
ticket int32
|
||||||
ticketNum int32
|
ticketNum int32
|
||||||
)
|
)
|
||||||
if time.Unix(info.LastTrigger, 0).Day() < configure.Now().Day() {
|
if time.Unix(info.LastTrigger, 0).Day() < configure.Now().Day() {
|
||||||
@ -82,14 +84,15 @@ func (this *modelUserMF) recoverTicket(info *pb.DBUserMFantasy) {
|
|||||||
info.BuyNum = 0
|
info.BuyNum = 0
|
||||||
}
|
}
|
||||||
global := this.module.configure.GetGlobalConf()
|
global := this.module.configure.GetGlobalConf()
|
||||||
if info.Ticket < global.DreamlandFightnum && info.Lastrtickettime > 0 {
|
ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.MoonFantasyTicket))
|
||||||
|
if ticket < global.DreamlandFightnum && info.Lastrtickettime > 0 {
|
||||||
duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
|
duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
|
||||||
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
||||||
if ticketNum > 0 {
|
if ticketNum > 0 {
|
||||||
info.Ticket += ticketNum
|
if ticketNum+ticket > global.ArenaTicketMax {
|
||||||
if info.Ticket > global.ArenaTicketMax {
|
ticketNum = global.ArenaTicketMax - ticket
|
||||||
info.Ticket = global.ArenaTicketMax
|
|
||||||
}
|
}
|
||||||
|
this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{A: comm.ItemType, T: comm.MoonFantasyTicket, N: ticketNum}}, true)
|
||||||
info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user