Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
8767e561ff
@ -1,29 +1,30 @@
|
|||||||
机器人总数: 1
|
机器人总数: 1000
|
||||||
成功数量: 1
|
成功数量: 1000
|
||||||
失败数量: 0
|
失败数量: 0
|
||||||
消息总吞吐量: 128
|
消息总吞吐量: 63807
|
||||||
---消息压测详情----------------------------------------------------------------------------------------------------
|
---消息压测详情----------------------------------------------------------------------------------------------------
|
||||||
消息名:hero.talentlist 请求次数:1 耗时最小:18 ms 耗时最大:18 ms 平均耗时:18.00ms 中位耗时:18.00ms
|
消息名:equipment.getlist 请求次数:978 耗时最小:14 ms 耗时最大:274 ms 平均耗时:21.18ms 中位耗时:21.00ms
|
||||||
消息名:gm.cmd 请求次数:2 耗时最小:0 ms 耗时最大:29 ms 平均耗时:14.50ms 中位耗时:14.50ms
|
消息名:gm.cmd 请求次数:1956 耗时最小:0 ms 耗时最大:233 ms 平均耗时:15.66ms 中位耗时:11.00ms
|
||||||
消息名:wtask.info 请求次数:1 耗时最小:40 ms 耗时最大:40 ms 平均耗时:40.00ms 中位耗时:40.00ms
|
消息名:wtask.info 请求次数:978 耗时最小:31 ms 耗时最大:295 ms 平均耗时:42.61ms 中位耗时:42.00ms
|
||||||
消息名:wtask.finish 请求次数:16 耗时最小:34 ms 耗时最大:73 ms 平均耗时:45.38ms 中位耗时:43.00ms
|
消息名:wtask.accept 请求次数:9081 耗时最小:17 ms 耗时最大:434 ms 平均耗时:30.73ms 中位耗时:30.00ms
|
||||||
消息名:wtask.battlefinish 请求次数:7 耗时最小:18 ms 耗时最大:109 ms 平均耗时:62.29ms 中位耗时:46.00ms
|
消息名:hero.drawcard 请求次数:1121 耗时最小:29 ms 耗时最大:278 ms 平均耗时:70.58ms 中位耗时:71.00ms
|
||||||
消息名:practice.info 请求次数:2 耗时最小:19 ms 耗时最大:30 ms 平均耗时:24.50ms 中位耗时:24.50ms
|
消息名:practice.practice 请求次数:978 耗时最小:14 ms 耗时最大:40 ms 平均耗时:21.13ms 中位耗时:21.00ms
|
||||||
消息名:sys.funcactivate 请求次数:2 耗时最小:16 ms 耗时最大:19 ms 平均耗时:17.50ms 中位耗时:17.50ms
|
消息名:user.create 请求次数:1000 耗时最小:14 ms 耗时最大:388 ms 平均耗时:81.90ms 中位耗时:83.00ms
|
||||||
消息名:user.create 请求次数:1 耗时最小:87 ms 耗时最大:87 ms 平均耗时:87.00ms 中位耗时:87.00ms
|
消息名:sys.funcgetlist 请求次数:978 耗时最小:42 ms 耗时最大:304 ms 平均耗时:62.18ms 中位耗时:62.00ms
|
||||||
消息名:mainline.info 请求次数:13 耗时最小:22 ms 耗时最大:32 ms 平均耗时:24.23ms 中位耗时:24.00ms
|
消息名:mainline.levelpass 请求次数:96 耗时最小:19 ms 耗时最大:31 ms 平均耗时:25.40ms 中位耗时:25.50ms
|
||||||
消息名:mainline.levelpass 请求次数:6 耗时最小:22 ms 耗时最大:25 ms 平均耗时:23.83ms 中位耗时:24.00ms
|
消息名:mainline.challengeover 请求次数:112 耗时最小:66 ms 耗时最大:202 ms 平均耗时:120.79ms 中位耗时:137.00ms
|
||||||
消息名:practice.practice 请求次数:1 耗时最小:24 ms 耗时最大:24 ms 平均耗时:24.00ms 中位耗时:24.00ms
|
消息名:user.login 请求次数:1000 耗时最小:56 ms 耗时最大:1071 ms 平均耗时:569.14ms 中位耗时:573.50ms
|
||||||
消息名:wtask.completecondi 请求次数:3 耗时最小:26 ms 耗时最大:28 ms 平均耗时:27.00ms 中位耗时:27.00ms
|
消息名:wtask.battlestart 请求次数:3957 耗时最小:14 ms 耗时最大:241 ms 平均耗时:21.10ms 中位耗时:21.00ms
|
||||||
消息名:chat.send 请求次数:10 耗时最小:14 ms 耗时最大:17 ms 平均耗时:15.70ms 中位耗时:15.50ms
|
消息名:practice.info 请求次数:994 耗时最小:15 ms 耗时最大:420 ms 平均耗时:34.18ms 中位耗时:33.00ms
|
||||||
消息名:shop.getlist 请求次数:10 耗时最小:16 ms 耗时最大:27 ms 平均耗时:19.50ms 中位耗时:19.00ms
|
消息名:sys.funcactivate 请求次数:2918 耗时最小:13 ms 耗时最大:278 ms 平均耗时:20.50ms 中位耗时:20.00ms
|
||||||
消息名:wtask.accept 请求次数:17 耗时最小:23 ms 耗时最大:36 ms 平均耗时:27.47ms 中位耗时:27.00ms
|
消息名:mainline.info 请求次数:208 耗时最小:18 ms 耗时最大:142 ms 平均耗时:25.69ms 中位耗时:25.00ms
|
||||||
消息名:sys.funcgetlist 请求次数:1 耗时最小:62 ms 耗时最大:62 ms 平均耗时:62.00ms 中位耗时:62.00ms
|
消息名:mainline.challenge 请求次数:112 耗时最小:37 ms 耗时最大:59 ms 平均耗时:48.48ms 中位耗时:48.00ms
|
||||||
消息名:hero.list 请求次数:1 耗时最小:29 ms 耗时最大:29 ms 平均耗时:29.00ms 中位耗时:29.00ms
|
消息名:shop.buy 请求次数:10 耗时最小:53 ms 耗时最大:60 ms 平均耗时:56.70ms 中位耗时:57.00ms
|
||||||
消息名:items.getlist 请求次数:1 耗时最小:23 ms 耗时最大:23 ms 平均耗时:23.00ms 中位耗时:23.00ms
|
消息名:hero.talentlist 请求次数:978 耗时最小:15 ms 耗时最大:254 ms 平均耗时:21.07ms 中位耗时:21.00ms
|
||||||
消息名:hero.drawcard 请求次数:10 耗时最小:50 ms 耗时最大:75 ms 平均耗时:62.90ms 中位耗时:60.00ms
|
消息名:wtask.finish 请求次数:7946 耗时最小:25 ms 耗时最大:479 ms 平均耗时:48.82ms 中位耗时:45.00ms
|
||||||
消息名:mainline.challenge 请求次数:7 耗时最小:48 ms 耗时最大:51 ms 平均耗时:49.71ms 中位耗时:50.00ms
|
消息名:wtask.completecondi 请求次数:2933 耗时最小:18 ms 耗时最大:358 ms 平均耗时:30.12ms 中位耗时:29.00ms
|
||||||
消息名:mainline.challengeover 请求次数:7 耗时最小:82 ms 耗时最大:166 ms 平均耗时:128.86ms 中位耗时:152.00ms
|
消息名:wtask.battlefinish 请求次数:3957 耗时最小:14 ms 耗时最大:539 ms 平均耗时:35.54ms 中位耗时:34.00ms
|
||||||
消息名:user.login 请求次数:1 耗时最小:764 ms 耗时最大:764 ms 平均耗时:764.00ms 中位耗时:764.00ms
|
消息名:chat.send 请求次数:9780 耗时最小:13 ms 耗时最大:261 ms 平均耗时:18.91ms 中位耗时:19.00ms
|
||||||
消息名:wtask.battlestart 请求次数:7 耗时最小:17 ms 耗时最大:29 ms 平均耗时:23.29ms 中位耗时:23.00ms
|
消息名:shop.getlist 请求次数:9780 耗时最小:14 ms 耗时最大:272 ms 平均耗时:22.05ms 中位耗时:22.00ms
|
||||||
消息名:equipment.getlist 请求次数:1 耗时最小:19 ms 耗时最大:19 ms 平均耗时:19.00ms 中位耗时:19.00ms
|
消息名:hero.list 请求次数:978 耗时最小:19 ms 耗时最大:70 ms 平均耗时:31.92ms 中位耗时:32.00ms
|
||||||
|
消息名:items.getlist 请求次数:978 耗时最小:18 ms 耗时最大:225 ms 平均耗时:26.04ms 中位耗时:26.00ms
|
||||||
|
@ -515,7 +515,9 @@ const (
|
|||||||
const (
|
const (
|
||||||
ResGold = "gold" //金币
|
ResGold = "gold" //金币
|
||||||
ResExp = "exp" //经验
|
ResExp = "exp" //经验
|
||||||
|
Lv = "lv" //等级
|
||||||
VipExp = "vipexp" //经验
|
VipExp = "vipexp" //经验
|
||||||
|
Vip = "vip" //vip
|
||||||
ResDiamond = "diamond" //钻石
|
ResDiamond = "diamond" //钻石
|
||||||
ResTaskActive = "taskActive" //任务活跃度
|
ResTaskActive = "taskActive" //任务活跃度
|
||||||
ResFriend = "friendPoint" //友情点
|
ResFriend = "friendPoint" //友情点
|
||||||
|
@ -173,8 +173,8 @@ type (
|
|||||||
// 批量处理
|
// 批量处理
|
||||||
AddAttributeValues(session IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData)
|
AddAttributeValues(session IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData)
|
||||||
//用户改变事件
|
//用户改变事件
|
||||||
EventUserChanged(session IUserSession)
|
// EventUserChanged(session IUserSession)
|
||||||
EventUserVipChanged(session IUserSession)
|
// EventUserVipChanged(session IUserSession)
|
||||||
//获取用户expand
|
//获取用户expand
|
||||||
GetUserExpand(uid string) (result *pb.DBUserExpand, err error)
|
GetUserExpand(uid string) (result *pb.DBUserExpand, err error)
|
||||||
//更新用户expand
|
//更新用户expand
|
||||||
|
@ -354,6 +354,7 @@ func (this *Privilege) CheckAllPrivilege(session comm.IUserSession) map[int32]*p
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Privilege) AddVipData(session comm.IUserSession, oldVip, newVip int32) {
|
func (this *Privilege) AddVipData(session comm.IUserSession, oldVip, newVip int32) {
|
||||||
|
defer this.PutUserSession(session)
|
||||||
if newVip <= oldVip {
|
if newVip <= oldVip {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -406,6 +407,7 @@ func (this *Privilege) AddVipData(session comm.IUserSession, oldVip, newVip int3
|
|||||||
})
|
})
|
||||||
|
|
||||||
session.SendMsg(string(this.GetType()), PrivilegeGetListResp, &pb.PrivilegeVipListResp{Data: vip})
|
session.SendMsg(string(this.GetType()), PrivilegeGetListResp, &pb.PrivilegeVipListResp{Data: vip})
|
||||||
|
session.Push()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送特权每日奖励
|
// 发送特权每日奖励
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
et "go_dreamfactory/lego/sys/event"
|
|
||||||
event_v2 "go_dreamfactory/lego/sys/event/v2"
|
event_v2 "go_dreamfactory/lego/sys/event/v2"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
@ -25,16 +24,16 @@ import (
|
|||||||
type ModelUser struct {
|
type ModelUser struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
module *User
|
module *User
|
||||||
EventApp *event_v2.App
|
// EventApp *event_v2.App
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.TableName = comm.TableUser
|
this.TableName = comm.TableUser
|
||||||
err = this.MCompModel.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.module = module.(*User)
|
this.module = module.(*User)
|
||||||
this.EventApp = event_v2.NewApp()
|
// this.EventApp = event_v2.NewApp()
|
||||||
this.EventApp.Listen(comm.EventUserVipChanged, this.ChangeVipExp)
|
// this.EventApp.Listen(comm.EventUserVipChanged, this.ChangeVipExp)
|
||||||
this.EventApp.Listen(comm.EventUserChanged, this.ChangeLevel)
|
// this.EventApp.Listen(comm.EventUserChanged, this.ChangeLevel)
|
||||||
// 通过uid创建索引
|
// 通过uid创建索引
|
||||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
@ -193,21 +192,17 @@ func (this *ModelUser) updateOfflineTime(uid string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// change vipexp
|
// change vipexp
|
||||||
func (this *ModelUser) ChangeVipExp(event interface{}, next func(event interface{})) {
|
func (this *ModelUser) changeVipExp(change *pb.UserResChangedPush) (lvchange bool) {
|
||||||
ul := event.(*UserListen)
|
|
||||||
var (
|
var (
|
||||||
curExp int64
|
curExp int64
|
||||||
bChange bool
|
|
||||||
)
|
)
|
||||||
vipExp := ul.vipexp
|
vipExp := change.Vipexp
|
||||||
vipLv := ul.viplv
|
vipLv := change.Vip
|
||||||
|
|
||||||
conf := this.module.configure.GetVipConfigureData(vipLv + 1)
|
conf := this.module.configure.GetVipConfigureData(vipLv + 1)
|
||||||
if conf == nil {
|
if conf == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
curExp = int64(conf.UpExp)
|
curExp = int64(conf.UpExp)
|
||||||
|
|
||||||
for vipExp >= curExp {
|
for vipExp >= curExp {
|
||||||
vipLv++
|
vipLv++
|
||||||
vipExp -= curExp
|
vipExp -= curExp
|
||||||
@ -218,48 +213,32 @@ func (this *ModelUser) ChangeVipExp(event interface{}, next func(event interface
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
curExp = int64(tmpConf.UpExp)
|
curExp = int64(tmpConf.UpExp)
|
||||||
bChange = true
|
lvchange = true
|
||||||
}
|
|
||||||
if bChange {
|
|
||||||
update := map[string]interface{}{
|
|
||||||
"vip": vipLv,
|
|
||||||
"vipexp": vipExp,
|
|
||||||
}
|
|
||||||
if err := this.module.modelUser.Change(ul.session.GetUserId(), update); err != nil {
|
|
||||||
this.module.Error("玩家Vip等级经验更新",
|
|
||||||
log.Field{Key: "uid", Value: ul.session.GetUserId()},
|
|
||||||
log.Field{Key: "vipLv", Value: vipLv},
|
|
||||||
log.Field{Key: "vipExp", Value: vipExp},
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ul.viplv != vipLv { // 新获得了vip
|
|
||||||
this.module.ModulePrivilege.AddVipData(ul.session, ul.viplv, vipLv)
|
|
||||||
}
|
|
||||||
// 推送玩家vip 经验变化
|
|
||||||
ul.session.SendMsg(string(this.module.GetType()), UserSubTypeVipChangedPush,
|
|
||||||
&pb.UserVipChangedPush{
|
|
||||||
Uid: ul.session.GetUserId(),
|
|
||||||
VipExp: int64(vipExp),
|
|
||||||
VipLv: vipLv,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// change level
|
// change level
|
||||||
func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{})) {
|
func (this *ModelUser) computeLevel(change *pb.UserResChangedPush) (lvchange bool, rewards []*cfg.Gameatn) {
|
||||||
ul := event.(*UserListen)
|
|
||||||
curLv := ul.lv
|
|
||||||
//下一等级配置
|
|
||||||
nextLvConf := this.module.configure.GetPlayerlvConf(curLv + 1)
|
|
||||||
var (
|
var (
|
||||||
rewards []*cfg.Gameatn
|
curLv int32 = change.Lv
|
||||||
curExp int64
|
nextLvConf *cfg.GamePlayerlvData
|
||||||
|
curExp int64 = change.Exp
|
||||||
|
res int64
|
||||||
)
|
)
|
||||||
|
//下一等级配置
|
||||||
curExp = ul.exp
|
nextLvConf = this.module.configure.GetPlayerlvConf(curLv + 1)
|
||||||
|
if nextLvConf == nil {
|
||||||
|
curLvConf := this.module.configure.GetPlayerlvConf(curLv)
|
||||||
|
reward := this.module.globalConf.OverexpReward
|
||||||
|
if curExp < int64(curLvConf.Exp) {
|
||||||
|
res = curExp * int64(reward.N)
|
||||||
|
} else {
|
||||||
|
yu := int32(curExp) - curLvConf.Exp
|
||||||
|
res = int64(yu * reward.N)
|
||||||
|
}
|
||||||
|
curExp = int64(curLvConf.Exp)
|
||||||
|
} else {
|
||||||
for nextLvConf != nil && curExp >= int64(nextLvConf.Exp) {
|
for nextLvConf != nil && curExp >= int64(nextLvConf.Exp) {
|
||||||
curExp = curExp - int64(nextLvConf.Exp)
|
curExp = curExp - int64(nextLvConf.Exp)
|
||||||
curLv++
|
curLv++
|
||||||
@ -267,114 +246,41 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
|
|||||||
rewards = append(rewards, nextLvConf.Reward...)
|
rewards = append(rewards, nextLvConf.Reward...)
|
||||||
nextLvConf = this.module.configure.GetPlayerlvConf(curLv + 1)
|
nextLvConf = this.module.configure.GetPlayerlvConf(curLv + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var res int32
|
|
||||||
if nextLvConf == nil {
|
|
||||||
curLvConf := this.module.configure.GetPlayerlvConf(curLv)
|
|
||||||
reward := this.module.globalConf.OverexpReward
|
|
||||||
|
|
||||||
if curExp < int64(curLvConf.Exp) {
|
|
||||||
res = int32(curExp) * reward.N
|
|
||||||
} else {
|
|
||||||
yu := int32(curExp) - curLvConf.Exp
|
|
||||||
res = yu * reward.N
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.module.DispenseRes(ul.session, []*cfg.Gameatn{{A: "attr", T: "gold", N: gold}}, true)
|
|
||||||
curExp = int64(curLvConf.Exp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 等级有递增时再更新
|
// 等级有递增时再更新
|
||||||
if curLv > ul.lv {
|
if curLv > change.Lv {
|
||||||
update := map[string]interface{}{
|
lvchange = true
|
||||||
"lv": curLv,
|
change.Lv = curLv
|
||||||
"exp": curExp,
|
change.Exp = curExp
|
||||||
|
} else {
|
||||||
|
if nextLvConf == nil {
|
||||||
|
change.Deposit += res
|
||||||
|
change.Exp = curExp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := this.module.modelUser.Change(ul.session.GetUserId(), update); err != nil {
|
|
||||||
this.module.Error("玩家等级经验更新",
|
|
||||||
log.Field{Key: "uid", Value: ul.session.GetUserId()},
|
|
||||||
log.Field{Key: "exp", Value: curExp},
|
|
||||||
log.Field{Key: "lv", Value: curLv},
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
module, err2 := this.module.service.GetModule(comm.ModuleSys)
|
|
||||||
if err2 == nil {
|
|
||||||
if isys, ok := module.(comm.ISys); ok {
|
|
||||||
var funcList []string
|
|
||||||
for _, conf := range this.module.configure.GetOpenCondConf() {
|
|
||||||
id := isys.ValidCond(ul.session.GetUserId(), conf)
|
|
||||||
if id != "" {
|
|
||||||
funcList = append(funcList, id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
et.TriggerEvent(comm.EventOpenCond, ul.session.GetUserId(), funcList)
|
func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64, name string, rewards []*cfg.Gameatn) {
|
||||||
isys.CheckOpenCond(ul.session, comm.OpencondTypePlatlv, curLv) // 校验新功能是否开启
|
defer this.module.PutUserSession(session)
|
||||||
}
|
if err := session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush,
|
||||||
}
|
&pb.UserLvChangedPush{Uid: session.GetUserId(), Exp: exp, Lv: lv}); err != nil {
|
||||||
if err := ul.session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush,
|
|
||||||
&pb.UserLvChangedPush{Uid: ul.session.GetUserId(), Exp: curExp, Lv: curLv}); err != nil {
|
|
||||||
this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败",
|
this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败",
|
||||||
log.Field{Key: "uid", Value: ul.session.GetUserId()},
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||||
log.Field{Key: "exp", Value: curExp},
|
log.Field{Key: "exp", Value: exp},
|
||||||
log.Field{Key: "lv", Value: curLv},
|
log.Field{Key: "lv", Value: lv},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if errdata := this.module.DispenseRes(ul.session, rewards, true); errdata != nil {
|
if errdata := this.module.DispenseRes(session, rewards, true); errdata != nil {
|
||||||
this.module.Error("资源发放",
|
this.module.Error("资源发放",
|
||||||
log.Field{Key: "uid", Value: ul.session.GetUserId()},
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||||
log.Field{Key: "rewards", Value: rewards},
|
log.Field{Key: "rewards", Value: rewards},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
this.module.chat.SendSysChatToUser(session, comm.ChatSystem12, lv, 0, name)
|
||||||
mc, err := this.module.service.GetModule(comm.ModuleChat)
|
this.module.sys.CheckOpenCond(session, comm.OpencondTypePlatlv, lv)
|
||||||
if err != nil {
|
session.Push()
|
||||||
return
|
|
||||||
}
|
|
||||||
if chat, ok := mc.(comm.IChat); ok {
|
|
||||||
chat.SendSysChatToUser(ul.session, comm.ChatSystem12, curLv, 0, ul.name)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if nextLvConf == nil {
|
|
||||||
update := map[string]interface{}{
|
|
||||||
"exp": curExp,
|
|
||||||
"deposit": res,
|
|
||||||
}
|
|
||||||
if err := this.module.modelUser.Change(ul.session.GetUserId(), update); err != nil {
|
|
||||||
this.module.Error("玩家经验更新",
|
|
||||||
log.Field{Key: "uid", Value: ul.session.GetUserId()},
|
|
||||||
log.Field{Key: "exp", Value: curExp},
|
|
||||||
log.Field{Key: "lv", Value: curLv},
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := ul.session.SendMsg(string(this.module.GetType()), "reschanged",
|
|
||||||
&pb.UserResChangedPush{
|
|
||||||
Gold: ul.Gold,
|
|
||||||
Ps: ul.Ps,
|
|
||||||
Vipexp: ul.vipexp,
|
|
||||||
Diamond: ul.Diamond,
|
|
||||||
Friend: ul.Friend,
|
|
||||||
Starcoin: ul.Starcoin,
|
|
||||||
Arenacoin: ul.Arenacoin,
|
|
||||||
Moongold: ul.Moongold,
|
|
||||||
Talent1: ul.Talent1,
|
|
||||||
Talent2: ul.Talent2,
|
|
||||||
Talent3: ul.Talent3,
|
|
||||||
Talent4: ul.Talent4,
|
|
||||||
Exp: curExp,
|
|
||||||
Merchantmoney: ul.Merchantmoney,
|
|
||||||
}); err != nil {
|
|
||||||
this.module.Error("玩家经验变化 UserResChangedPush推送失败",
|
|
||||||
log.Field{Key: "uid", Value: ul.session.GetUserId()},
|
|
||||||
log.Field{Key: "exp", Value: curExp},
|
|
||||||
log.Field{Key: "lv", Value: curLv},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelUser) CleanUserMerchantmoney(session comm.IUserSession) (err error) {
|
func (this *ModelUser) CleanUserMerchantmoney(session comm.IUserSession) (err error) {
|
||||||
|
@ -52,6 +52,8 @@ func NewModule() core.IModule {
|
|||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
|
chat comm.IChat
|
||||||
|
sys comm.ISys
|
||||||
api *apiComp
|
api *apiComp
|
||||||
modelUser *ModelUser
|
modelUser *ModelUser
|
||||||
modelSession *ModelSession
|
modelSession *ModelSession
|
||||||
@ -90,6 +92,16 @@ func (this *User) Start() (err error) {
|
|||||||
err = errors.New("global config not found")
|
err = errors.New("global config not found")
|
||||||
}
|
}
|
||||||
this.ResetSession()
|
this.ResetSession()
|
||||||
|
|
||||||
|
var module core.IModule
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleChat); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.chat = module.(comm.IChat)
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleSys); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.sys = module.(comm.ISys)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +403,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
|
|||||||
var (
|
var (
|
||||||
user *pb.DBUser
|
user *pb.DBUser
|
||||||
userEx *pb.DBUserExpand
|
userEx *pb.DBUserExpand
|
||||||
|
lvexpchange, vipexpchange bool
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -416,7 +429,9 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
|
|||||||
change = &pb.UserResChangedPush{
|
change = &pb.UserResChangedPush{
|
||||||
Gold: user.Gold,
|
Gold: user.Gold,
|
||||||
Exp: user.Exp,
|
Exp: user.Exp,
|
||||||
|
Lv: user.Lv,
|
||||||
Vipexp: user.Vipexp,
|
Vipexp: user.Vipexp,
|
||||||
|
Vip: user.Vip,
|
||||||
Diamond: user.Diamond,
|
Diamond: user.Diamond,
|
||||||
Friend: userEx.FriendPoint,
|
Friend: userEx.FriendPoint,
|
||||||
Starcoin: user.Starcoin,
|
Starcoin: user.Starcoin,
|
||||||
@ -456,6 +471,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
change.Exp += int64(add)
|
change.Exp += int64(add)
|
||||||
|
lvexpchange = true
|
||||||
case comm.VipExp:
|
case comm.VipExp:
|
||||||
if add < 0 {
|
if add < 0 {
|
||||||
if user.Vipexp+int64(add) < 0 {
|
if user.Vipexp+int64(add) < 0 {
|
||||||
@ -467,6 +483,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
change.Vipexp += int64(add)
|
change.Vipexp += int64(add)
|
||||||
|
vipexpchange = true
|
||||||
case comm.ResDiamond:
|
case comm.ResDiamond:
|
||||||
if add < 0 {
|
if add < 0 {
|
||||||
if user.Diamond+int64(add) < 0 {
|
if user.Diamond+int64(add) < 0 {
|
||||||
@ -644,12 +661,32 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if lvexpchange {
|
||||||
|
if ok, rewards := this.modelUser.computeLevel(change); ok {
|
||||||
|
go this.modelUser.changelv(session.Clone(), change.Lv, change.Exp, user.Name, rewards)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if vipexpchange {
|
||||||
|
if this.modelUser.changeVipExp(change) { //vip等级变化
|
||||||
|
session.SendMsg(string(this.GetType()), UserSubTypeVipChangedPush,
|
||||||
|
&pb.UserVipChangedPush{
|
||||||
|
Uid: session.GetUserId(),
|
||||||
|
VipExp: change.Exp,
|
||||||
|
VipLv: change.Lv,
|
||||||
|
})
|
||||||
|
go this.ModulePrivilege.AddVipData(session.Clone(), user.Vip, change.Vip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//user
|
//user
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
comm.ResGold: change.Gold,
|
comm.ResGold: change.Gold,
|
||||||
comm.ResDiamond: change.Diamond,
|
comm.ResDiamond: change.Diamond,
|
||||||
comm.ResExp: change.Exp,
|
comm.ResExp: change.Exp,
|
||||||
|
comm.Lv: change.Lv,
|
||||||
comm.VipExp: change.Vipexp,
|
comm.VipExp: change.Vipexp,
|
||||||
|
comm.Vip: change.Vip,
|
||||||
comm.StarCoin: change.Starcoin,
|
comm.StarCoin: change.Starcoin,
|
||||||
comm.ResPs: change.Ps,
|
comm.ResPs: change.Ps,
|
||||||
comm.Moongold: change.Moongold,
|
comm.Moongold: change.Moongold,
|
||||||
@ -713,8 +750,6 @@ func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add
|
|||||||
// 用户资源
|
// 用户资源
|
||||||
func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData) {
|
func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
expChange bool
|
|
||||||
vipExpChange bool
|
|
||||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||||
_change *pb.UserResChangedPush
|
_change *pb.UserResChangedPush
|
||||||
)
|
)
|
||||||
@ -723,11 +758,7 @@ func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string
|
|||||||
if errdata != nil {
|
if errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if key == comm.ResExp {
|
|
||||||
expChange = true
|
|
||||||
} else if key == comm.VipExp {
|
|
||||||
vipExpChange = true
|
|
||||||
}
|
|
||||||
if key == comm.ResPs && add < 0 { //消耗体力
|
if key == comm.ResPs && add < 0 { //消耗体力
|
||||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype213, -add))
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype213, -add))
|
||||||
}
|
}
|
||||||
@ -744,53 +775,13 @@ func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string
|
|||||||
if bPush { //推送玩家账号信息变化消息
|
if bPush { //推送玩家账号信息变化消息
|
||||||
session.SendMsg(string(this.GetType()), "reschanged", _change)
|
session.SendMsg(string(this.GetType()), "reschanged", _change)
|
||||||
}
|
}
|
||||||
if expChange {
|
|
||||||
this.ModuleUser.EventUserChanged(session)
|
|
||||||
}
|
|
||||||
if vipExpChange {
|
|
||||||
this.ModuleUser.EventUserVipChanged(session)
|
|
||||||
}
|
|
||||||
if len(tasks) > 0 {
|
if len(tasks) > 0 {
|
||||||
go this.ModuleBuried.TriggerBuried(session.Clone(), tasks...)
|
go this.ModuleBuried.TriggerBuried(session.Clone(), tasks...)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户事件变化
|
|
||||||
func (this *User) EventUserVipChanged(session comm.IUserSession) {
|
|
||||||
ul := new(UserListen)
|
|
||||||
user := this.GetUser(session.GetUserId())
|
|
||||||
if user != nil {
|
|
||||||
ul.session = session
|
|
||||||
ul.name = user.Name
|
|
||||||
ul.vipexp = user.Vipexp
|
|
||||||
ul.viplv = user.Vip
|
|
||||||
}
|
|
||||||
this.modelUser.EventApp.Dispatch(comm.EventUserVipChanged, ul)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户事件变化
|
|
||||||
func (this *User) EventUserChanged(session comm.IUserSession) {
|
|
||||||
ul := new(UserListen)
|
|
||||||
user := this.GetUser(session.GetUserId())
|
|
||||||
if user != nil {
|
|
||||||
ul.session = session
|
|
||||||
ul.exp = user.Exp
|
|
||||||
ul.lv = user.Lv
|
|
||||||
ul.name = user.Name
|
|
||||||
ul.Gold = user.Gold
|
|
||||||
ul.vipexp = user.Vipexp
|
|
||||||
ul.Ps = user.Ps
|
|
||||||
ul.Diamond = user.Diamond
|
|
||||||
ul.Merchantmoney = user.Merchantmoney
|
|
||||||
ul.Talent1 = user.Talent1
|
|
||||||
ul.Talent2 = user.Talent2
|
|
||||||
ul.Talent3 = user.Talent3
|
|
||||||
ul.Talent4 = user.Talent4
|
|
||||||
}
|
|
||||||
this.modelUser.EventApp.Dispatch(comm.EventUserChanged, ul)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *User) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
|
func (this *User) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
|
||||||
return this.modelExpand.GetUserExpand(uid)
|
return this.modelExpand.GetUserExpand(uid)
|
||||||
}
|
}
|
||||||
@ -958,23 +949,6 @@ func (this *User) BingoSetUserLv(session comm.IUserSession, lv int32) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (this *User) Update() {
|
|
||||||
// if this.IsCross() {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// cu, err := this.UserOnlineList()
|
|
||||||
// if err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for _, v := range cu {
|
|
||||||
// if isession, ok := this.ModuleBase.GetUserSession(v.Uid); ok {
|
|
||||||
// //del session
|
|
||||||
// log.Debug("del session", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "isLogin", Value: isession.IsLogin()})
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 玩家体力恢复
|
// 玩家体力恢复
|
||||||
func (this *User) RecoverUserPsStart(uid string) {
|
func (this *User) RecoverUserPsStart(uid string) {
|
||||||
go func(uid string) {
|
go func(uid string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user