role

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REASON_INIT                   = 1
	REASON_LOGIN                  = 1000
	REASON_GM                     = 1001
	REASON_CONSUME                = 1002
	REASON_MALL_BUY               = 1003
	REASON_INSTANCE               = 1005
	REASON_INSTANCE_FAIL          = 1006
	REASON_CHAPTOR_REWARD         = 1007
	REASON_RES_INSTANCE           = 1008
	REASON_INSTANCE_QUICK         = 1009
	REASON_RES_INSTANCE_QUICK     = 1010
	REASON_RENAME                 = 1011
	REASON_MAIL_ATTACH            = 1012
	REASON_RECRUIT                = 1013
	REASON_HERO_UPGRADE_LEVEL     = 1014
	REASON_HERO_UPGRADE_STAR      = 1015
	REASON_HERO_UPGRADE_SKILL     = 1016
	REASON_OPVP                   = 1017
	REASON_MEMOIR                 = 1018
	REASON_BUY_MEMOIR_TIMES       = 1019
	REASON_EQUIP_LEVEL_UP         = 1020
	REASON_RES_INSTANCE_BUY_TIMES = 1021
	REASON_COMPOSE                = 1022
	REASON_MACHINE_UNLOCK         = 1023
	REASON_MACHINE_LEVEL_UP       = 1024
	REASON_MACHINE_STAR_UP        = 1025
	REASON_MACHINE_REBORN         = 1026
	REASON_ARTIFACT_ADD_EXP       = 1027
	REASON_WORLD_BOSS_BUY_TIMES   = 1028
	REASON_BLACK_MARKET_BUY       = 1029
	REASON_BLACK_MARKET_REFRESH   = 1030
	REASON_MALL_PACKAGE           = 1031
	REASON_MALL_RECHARGE          = 1032
)

数据变化原因枚举

Variables

This section is empty.

Functions

This section is empty.

Types

type Reason

type Reason struct {
	Reason    int32
	SubReason int32
}

数据变化原因

type Role

type Role struct {
	sync.Mutex // Role的锁交由外部来控制
	PbRole     *g1_protocol.RoleInfo

	// 下面可以添加临时内存数据,不会持久化到数据库
	HeartBeatExpiryTime int32
	HeartBeatCount      int32
}

func NewRole

func NewRole(uid uint64) *Role

func (*Role) AfterLogin

func (r *Role) AfterLogin(now int32)

func (*Role) DebugDepthf

func (r *Role) DebugDepthf(depth int, format string, args ...interface{})

func (*Role) Debugf

func (r *Role) Debugf(format string, args ...interface{})

func (*Role) DiamondAdd

func (r *Role) DiamondAdd(count int32, reason *Reason) int

func (*Role) DiamondCheckEnough

func (r *Role) DiamondCheckEnough(count int32) int

func (*Role) DiamondReduce

func (r *Role) DiamondReduce(count int32, reason *Reason) int

func (*Role) Errorf

func (r *Role) Errorf(format string, args ...interface{})

日志

func (*Role) ExpAdd

func (r *Role) ExpAdd(exp int32)

func (*Role) FrameAdd

func (r *Role) FrameAdd(id int32, reason *Reason) int

func (*Role) FrameChange

func (r *Role) FrameChange(frameId int32) int

func (*Role) FrameGet

func (r *Role) FrameGet(id int32, addIfExist bool) *g1_protocol.PbFrame

func (*Role) FrameHas

func (r *Role) FrameHas(id int32) bool

func (*Role) FrameTouchRedPoint

func (r *Role) FrameTouchRedPoint(id int32) int

func (*Role) FuncIsOpen

func (r *Role) FuncIsOpen(openFuncId int32) bool

func (*Role) GetBriefInfo

func (r *Role) GetBriefInfo() *g1_protocol.PbRoleBriefInfo

玩家的简要信息,一般用于展示给其它玩家查看

func (*Role) GetItemCount

func (r *Role) GetItemCount(itemId int32) int32

获取道具数量

func (*Role) GetItemOutcomes

func (r *Role) GetItemOutcomes(itemId int32) *[]*g1_protocol.PbItem

TODO 道具使用后得到的新道具

func (*Role) GoldAdd

func (r *Role) GoldAdd(count int32, reason *Reason) int

func (*Role) GoldCheckEnough

func (r *Role) GoldCheckEnough(count int32) int

func (*Role) GoldReduce

func (r *Role) GoldReduce(count int32, reason *Reason) int

func (*Role) GuideCompleted

func (r *Role) GuideCompleted(id int32) int

func (*Role) GuideInProgress

func (r *Role) GuideInProgress(id int32) int

func (*Role) IconAdd

func (r *Role) IconAdd(id int32, reason *Reason) int

func (*Role) IconChange

func (r *Role) IconChange(iconId int32) int

func (*Role) IconGet

func (r *Role) IconGet(id int32, addIfExist bool) *g1_protocol.PbIcon

func (*Role) IconGetIconDesc

func (r *Role) IconGetIconDesc() *g1_protocol.PbIconDesc

func (*Role) IconHas

func (r *Role) IconHas(id int32) bool

func (*Role) IconTouchRedPoint

func (r *Role) IconTouchRedPoint(id int32) int

func (*Role) ImageChange

func (r *Role) ImageChange(imageId int32) int

func (*Role) Infof

func (r *Role) Infof(format string, args ...interface{})

func (*Role) IsOnline

func (r *Role) IsOnline() bool

func (*Role) ItemAdd

func (r *Role) ItemAdd(itemId, itemCount int32, reason *Reason) int

func (*Role) ItemCheckAdd

func (r *Role) ItemCheckAdd(itemId, itemCount int32) int

func (*Role) ItemCheckReduce

func (r *Role) ItemCheckReduce(itemId, itemCount int32) (*[]*g1_protocol.PbItem, int)

返回道具消耗后获得的新道具,比如开宝箱消耗一个宝箱,获得宝箱内的道具

func (*Role) ItemExchange

func (r *Role) ItemExchange(consumeID, consumeCnt, productId, productCnt int32, reason *Reason) int

func (*Role) ItemGetCountRef

func (r *Role) ItemGetCountRef(itemId int32) *int32

获得道具数量的引用

func (*Role) ItemReduce

func (r *Role) ItemReduce(itemId, itemCount int32, reason *Reason) (*[]*g1_protocol.PbItem, int)

反回实际添加的东西

func (*Role) ItemRemove

func (r *Role) ItemRemove(itemId int32) int

当item数量为0时删除item

func (*Role) ItemSee

func (r *Role) ItemSee(item *g1_protocol.PbItem) *[]*g1_protocol.PbItem

生成掉落(如果输入列表里面有drop类型的道具,则展开drop)

func (*Role) ItemsAdd

func (r *Role) ItemsAdd(items *[]*g1_protocol.PbItem, reason *Reason) int

func (*Role) ItemsCheckAdd

func (r *Role) ItemsCheckAdd(items *[]*g1_protocol.PbItem) int

func (*Role) ItemsCheckReduce

func (r *Role) ItemsCheckReduce(items *[]*g1_protocol.PbItem) (*[]*g1_protocol.PbItem, int)

func (*Role) ItemsReduce

func (r *Role) ItemsReduce(items *[]*g1_protocol.PbItem, reason *Reason) (*[]*g1_protocol.PbItem, int)

func (*Role) ItemsSee

func (r *Role) ItemsSee(in *[]*g1_protocol.PbItem) *[]*g1_protocol.PbItem

生成掉落(如果输入列表里面有drop类型的道具,则展开drop)

func (*Role) LoginByTaskCheck

func (r *Role) LoginByTaskCheck()

func (*Role) MailAdd

func (r *Role) MailAdd(c cmd_handler.IContext, mailType int32, confID int32, attach *[]*g1_protocol.PbItem) int

添加邮件,这里一般是在trans中执行的,所以要加上cmd_handle参数

func (*Role) MallAddBuyCount

func (r *Role) MallAddBuyCount(confId int32)

func (*Role) MallCheckBuyCondition

func (r *Role) MallCheckBuyCondition(confId int32) int

func (*Role) MallDailyRefresh

func (r *Role) MallDailyRefresh()

func (*Role) MallGetItem

func (r *Role) MallGetItem(confId int32) *g1_protocol.PbMallItem

func (*Role) Now

func (r *Role) Now() int32

func (*Role) NowMs

func (r *Role) NowMs() int64

func (*Role) OnClientHeartbeat

func (r *Role) OnClientHeartbeat(now int32)

客户端会每隔几秒发送一次心跳包到服务器 服务器根据时间来驱动玩家的周期性事件

func (*Role) OnLogin

func (r *Role) OnLogin(now int32)

func (*Role) OnRoleCreate

func (r *Role) OnRoleCreate()

func (*Role) RoleInitField

func (r *Role) RoleInitField(uid uint64)

Role的初始化函数 新增成员以后记得加上去

func (*Role) SaveToDB

func (r *Role) SaveToDB(trans cmd_handler.IContext) error

func (*Role) SaveToDBIgnoreRsp

func (r *Role) SaveToDBIgnoreRsp()

保存玩家数据,不等待返回结果。只在特殊情况下使用。比如:RoleMgr::removeExpiredRoles中

func (*Role) SaveToMysql

func (r *Role) SaveToMysql(trans cmd_handler.IContext) error

func (*Role) SinewAdd

func (r *Role) SinewAdd(count int32, reason *Reason) int

func (*Role) SinewCheckEnough

func (r *Role) SinewCheckEnough(count int32) int

func (*Role) SinewReduce

func (r *Role) SinewReduce(count int32, reason *Reason) int

func (*Role) SyncDataToClient

func (r *Role) SyncDataToClient(dataFlag g1_protocol.ERoleSectionFlag) error

这里服务端主动同步数据到客户端 理论上每次玩家数据有变动,都要将相应的数据段同步过去 通过Flag控制同步有改变的数据段,减少数据的同步量

func (*Role) SyncOpenFuncData

func (r *Role) SyncOpenFuncData()

同步功能开放

func (*Role) Uid

func (r *Role) Uid() uint64

func (*Role) UpdateBriefInfo

func (r *Role) UpdateBriefInfo() error

更新玩家简要信息到数据库

func (*Role) Warningf

func (r *Role) Warningf(format string, args ...interface{})

func (*Role) Zone

func (r *Role) Zone() int32

type RoleMgr

type RoleMgr struct {
	// contains filtered or unexported fields
}

func NewRoleMgr

func NewRoleMgr() *RoleMgr

func (*RoleMgr) DeleteRole

func (m *RoleMgr) DeleteRole(uid uint64)

func (*RoleMgr) GetOrLoadOrCreateRole

func (m *RoleMgr) GetOrLoadOrCreateRole(uid uint64, trans cmd_handler.IContext) *Role

func (*RoleMgr) GetOrLoadRole

func (m *RoleMgr) GetOrLoadRole(uid uint64, trans cmd_handler.IContext) *Role

func (*RoleMgr) GetRole

func (m *RoleMgr) GetRole(uid uint64) *Role

func (*RoleMgr) Tick

func (m *RoleMgr) Tick()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL