上传道具代码
This commit is contained in:
parent
6e69b5fd9b
commit
df999ebbd3
@ -410,10 +410,10 @@ const (
|
||||
|
||||
// 门票
|
||||
const (
|
||||
ArenaTicket string = "100004" //竞技场入场券
|
||||
MoonFantasyTicket string = "100003" //梦境场入场券
|
||||
PhysicalMedicament string = "10017" //体力药剂
|
||||
UnifiedTicket string = "100100" //统一门票
|
||||
// ArenaTicket string = "100004" //竞技场入场券
|
||||
// MoonFantasyTicket string = "100003" //梦境场入场券
|
||||
// PhysicalMedicament string = "10017" //体力药剂
|
||||
// UnifiedTicket string = "100100" //统一门票
|
||||
)
|
||||
|
||||
// 红点枚举
|
||||
|
@ -21,6 +21,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
|
||||
var (
|
||||
// global *cfg.GameGlobalData
|
||||
info *pb.DBArenaUser
|
||||
ticketitem *cfg.Gameatn
|
||||
need []*cfg.Gameatn
|
||||
maxbuy, vipbuy int32
|
||||
err error
|
||||
@ -32,6 +33,15 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
|
||||
}
|
||||
return
|
||||
}
|
||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: comm.NewNotFoundConfErr(moduleName, "global.json", "ArenaTicketCos").Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
data = &pb.ErrorData{
|
||||
@ -73,7 +83,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
|
||||
return
|
||||
}
|
||||
info.Buynum += req.BuyNum
|
||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{{A: comm.ItemType, T: comm.ArenaTicket, N: req.BuyNum}}, true); code != pb.ErrorCode_Success {
|
||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{{A: ticketitem.A, T: ticketitem.T, N: req.BuyNum}}, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
// info.Ticket += req.BuyNum
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/lego/utils/container/id"
|
||||
"go_dreamfactory/modules"
|
||||
@ -397,11 +398,23 @@ func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) {
|
||||
func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBArenaUser) {
|
||||
var (
|
||||
duration time.Duration
|
||||
ticketitem *cfg.Gameatn
|
||||
ticket int32
|
||||
ticketNum int32
|
||||
)
|
||||
|
||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
|
||||
// code = pb.ErrorCode_ConfigNoFound
|
||||
// data = &pb.ErrorData{
|
||||
// Title: code.ToString(),
|
||||
// Message: comm.NewNotFoundConfErr(moduleName, "global.json", "ArenaTicketCos").Error(),
|
||||
// }
|
||||
this.module.Error("竞技场配置未找到!", log.Field{Key: "key", Value: "ArenaTicketCos"})
|
||||
return
|
||||
}
|
||||
|
||||
global := this.module.ModuleTools.GetGlobalConf()
|
||||
ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.ArenaTicket))
|
||||
ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, ticketitem.T))
|
||||
if ticket < global.ArenaTicketMax && info.Lastrtickettime > 0 {
|
||||
duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
|
||||
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
||||
@ -409,7 +422,7 @@ func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBAren
|
||||
if ticketNum+ticket > global.ArenaTicketMax {
|
||||
ticketNum = global.ArenaTicketMax - ticket
|
||||
}
|
||||
this.module.DispenseRes(session, []*cfg.Gameatn{{A: comm.ItemType, T: comm.ArenaTicket, N: ticketNum}}, true)
|
||||
this.module.DispenseRes(session, []*cfg.Gameatn{{A: ticketitem.A, T: ticketitem.T, N: ticketNum}}, true)
|
||||
// info.Ticket += ticketNum
|
||||
// if info.Ticket > global.ArenaTicketMax {
|
||||
// info.Ticket = global.ArenaTicketMax
|
||||
@ -422,6 +435,7 @@ func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBAren
|
||||
func (this *modelArena) reddot(session comm.IUserSession) bool {
|
||||
var (
|
||||
info *pb.DBArenaUser
|
||||
ticketitem *cfg.Gameatn
|
||||
err error
|
||||
)
|
||||
if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
||||
@ -434,7 +448,16 @@ func (this *modelArena) reddot(session comm.IUserSession) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
ticket := int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.ArenaTicket))
|
||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
|
||||
// code = pb.ErrorCode_ConfigNoFound
|
||||
// data = &pb.ErrorData{
|
||||
// Title: code.ToString(),
|
||||
// Message: comm.NewNotFoundConfErr(moduleName, "global.json", "ArenaTicketCos").Error(),
|
||||
// }
|
||||
this.module.Error("竞技场配置未找到!", log.Field{Key: "key", Value: "ArenaTicketCos"})
|
||||
return false
|
||||
}
|
||||
ticket := int32(this.module.ModuleItems.QueryItemAmount(info.Uid, ticketitem.T))
|
||||
if ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos.N {
|
||||
return true
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
||||
var (
|
||||
err error
|
||||
user *pb.DBUserExpand
|
||||
psitem *cfg.Gameatn
|
||||
needs []*cfg.Gameatn
|
||||
haveneeds []*cfg.Gameatn
|
||||
sale []*cfg.Gameatn
|
||||
@ -48,7 +49,14 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if psitem = this.module.ModuleTools.GetGlobalConf().PsItem; psitem == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: comm.NewNotFoundConfErr(modelName, "global.json", "PsItem").Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if time.Unix(user.PhysicalbuyLasttime, 0).Day() != time.Now().Day() { //不是同一天 重置购买次数
|
||||
user.Physicalbuynum = 0
|
||||
}
|
||||
@ -70,7 +78,7 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
||||
return
|
||||
}
|
||||
|
||||
sale = []*cfg.Gameatn{{A: comm.ItemType, T: comm.PhysicalMedicament, N: int32(req.Amount)}}
|
||||
sale = []*cfg.Gameatn{{A: psitem.A, T: psitem.T, N: int32(req.Amount)}}
|
||||
|
||||
if code = this.module.DispenseRes(session, sale, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
@ -81,6 +89,6 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
||||
"physicalbuynum": user.Physicalbuynum,
|
||||
"physicalbuyLasttime": user.PhysicalbuyLasttime,
|
||||
})
|
||||
session.SendMsg(string(this.module.GetType()), "buyphysical", &pb.ItemsBuyPhysicalResp{Issucc: true, PhysicalBuyNum: user.Physicalbuynum, Asets: []*pb.UserAssets{{A: comm.ItemType, T: comm.PhysicalMedicament, N: int32(req.Amount)}}})
|
||||
session.SendMsg(string(this.module.GetType()), "buyphysical", &pb.ItemsBuyPhysicalResp{Issucc: true, PhysicalBuyNum: user.Physicalbuynum, Asets: []*pb.UserAssets{{A: psitem.A, T: psitem.T, N: int32(req.Amount)}}})
|
||||
return
|
||||
}
|
||||
|
@ -531,10 +531,21 @@ func (this *ModelItemsComp) recoverTicket(session comm.IUserSession) (code pb.Er
|
||||
user *pb.DBUser
|
||||
info *pb.DBUserExpand
|
||||
duration time.Duration
|
||||
ticketitem *cfg.Gameatn
|
||||
ticket int32
|
||||
ticketNum int32
|
||||
err error
|
||||
)
|
||||
|
||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().CopsBuyGet; ticketitem == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
// data = &pb.ErrorData{
|
||||
// Title: code.ToString(),
|
||||
// Message: comm.NewNotFoundConfErr(modelName, "global.json", "PsItem").Error(),
|
||||
// }
|
||||
return
|
||||
}
|
||||
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
@ -549,7 +560,7 @@ func (this *ModelItemsComp) recoverTicket(session comm.IUserSession) (code pb.Er
|
||||
}
|
||||
global := this.module.ModuleTools.GetGlobalConf()
|
||||
playerlv := this.module.configure.GetPlayerlvConf(user.Lv)
|
||||
ticket = int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), comm.UnifiedTicket))
|
||||
ticket = int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), ticketitem.T))
|
||||
if ticket < global.DreamlandFightnum && info.Recovertimeunifiedticket > 0 {
|
||||
duration = configure.Now().Sub(time.Unix(info.Recovertimeunifiedticket, 0))
|
||||
ticketNum = int32(math.Floor(duration.Seconds() / float64(global.CopsRecoveryTime)))
|
||||
@ -557,7 +568,7 @@ func (this *ModelItemsComp) recoverTicket(session comm.IUserSession) (code pb.Er
|
||||
if ticketNum+ticket > playerlv.CopsPsCeiling {
|
||||
ticketNum = playerlv.CopsPsCeiling - ticket
|
||||
}
|
||||
this.module.DispenseRes(session, []*cfg.Gameatn{{A: comm.ItemType, T: comm.UnifiedTicket, N: ticketNum}}, true)
|
||||
this.module.DispenseRes(session, []*cfg.Gameatn{{A: ticketitem.A, T: ticketitem.T, N: ticketNum}}, true)
|
||||
info.Recovertimeunifiedticket = time.Unix(info.Recovertimeunifiedticket, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
|
||||
var (
|
||||
info *pb.DBUserMFantasy
|
||||
challengeD *cfg.GameDreamlandChallengeData
|
||||
ticketitem *cfg.Gameatn
|
||||
need []*cfg.Gameatn
|
||||
maxbuy, vipbuy int
|
||||
err error
|
||||
@ -27,6 +28,16 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
|
||||
if code = this.BuyCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().CopsBuyGet; ticketitem == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: comm.NewNotFoundConfErr(modelName, "global.json", "CopsBuyGet").Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if info, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
@ -57,7 +68,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
|
||||
}
|
||||
info.BuyNum += 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 {
|
||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{{A: ticketitem.A, T: ticketitem.T, N: req.BuyNum}}, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
||||
|
@ -7,8 +7,6 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -73,27 +71,27 @@ func (this *modelUserMF) updateUserInfo(info *pb.DBUserMFantasy) (err error) {
|
||||
|
||||
func (this *modelUserMF) recoverTicket(session comm.IUserSession, info *pb.DBUserMFantasy) {
|
||||
var (
|
||||
duration time.Duration
|
||||
ticket int32
|
||||
ticketNum int32
|
||||
// duration time.Duration
|
||||
// ticket int32
|
||||
// ticketNum int32
|
||||
)
|
||||
if time.Unix(info.LastTrigger, 0).Day() < configure.Now().Day() {
|
||||
info.TriggerNum = 0
|
||||
info.LastTrigger = configure.Now().Unix()
|
||||
info.BuyNum = 0
|
||||
}
|
||||
// this.module.ModuleItems.RecoverTicket(session)
|
||||
global := this.module.ModuleTools.GetGlobalConf()
|
||||
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))
|
||||
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
||||
if ticketNum > 0 {
|
||||
if ticketNum+ticket > global.ArenaTicketMax {
|
||||
ticketNum = global.ArenaTicketMax - ticket
|
||||
}
|
||||
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()
|
||||
}
|
||||
}
|
||||
this.module.ModuleItems.RecoverTicket(session)
|
||||
// global := this.module.ModuleTools.GetGlobalConf()
|
||||
// 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))
|
||||
// ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
||||
// if ticketNum > 0 {
|
||||
// if ticketNum+ticket > global.ArenaTicketMax {
|
||||
// ticketNum = global.ArenaTicketMax - ticket
|
||||
// }
|
||||
// // 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()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ import (
|
||||
"math/big"
|
||||
)
|
||||
|
||||
const modelName = "月之秘境"
|
||||
|
||||
/*
|
||||
模块名:月子秘境
|
||||
描述:随机世界副本
|
||||
|
@ -84,6 +84,7 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq)
|
||||
//判断是否要结束任务
|
||||
if ((len(curTaskConf.Completetask) == 1 && curTaskConf.Completetask[0] == 0) ||
|
||||
len(curTaskConf.Completetask) == 0) && curTaskConf.DeliverNpc == 0 {
|
||||
|
||||
//结束任务
|
||||
a.module.modelWorldtask.taskFinish(session, req.GroupId, req.TaskId, myWorldtask, curTaskConf)
|
||||
a.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf)
|
||||
|
Loading…
Reference in New Issue
Block a user