Compare commits
4 Commits
1a9ea12307
...
9a02223aa3
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9a02223aa3 | ||
![]() |
2ce71b7a2c | ||
![]() |
f4db5a7d3b | ||
![]() |
3aa08943b2 |
4
go.mod
4
go.mod
@ -4,14 +4,14 @@ go 1.24
|
||||
|
||||
require (
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/oylshe1314/framework v1.0.19
|
||||
github.com/oylshe1314/framework v1.0.21
|
||||
github.com/xuri/excelize/v2 v2.9.1
|
||||
go.mongodb.org/mongo-driver v1.17.4
|
||||
golang.org/x/crypto v0.39.0
|
||||
google.golang.org/protobuf v1.36.6
|
||||
)
|
||||
|
||||
replace github.com/oylshe1314/framework v1.0.19 => D:\sk\projects\golang\framework-1.0.19
|
||||
replace github.com/oylshe1314/framework v1.0.21 => D:\sk\projects\golang\framework-1.0.21
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
|
@ -21,5 +21,5 @@ func CheckChannel(channel uint32) bool {
|
||||
}
|
||||
|
||||
func CheckAttrType(attrType int) bool {
|
||||
return pb.AttrType(attrType) > pb.AttrType_AttrTypeNone && pb.AttrType(attrType) < pb.AttrType_Nums
|
||||
return pb.AttrType(attrType) > pb.AttrType_AttrTypeNone && pb.AttrType(attrType) < pb.AttrType_AttrNums
|
||||
}
|
||||
|
@ -279,8 +279,8 @@ const (
|
||||
// TipMailNotFound 找不到邮件
|
||||
TipMailNotFound StringTipError = "MailNotFound"
|
||||
|
||||
// TipMailNoReward 邮件无奖励
|
||||
TipMailNoReward StringTipError = "MailNoReward"
|
||||
// TipMailNoItems 邮件无奖励
|
||||
TipMailNoItems StringTipError = "MailNoItems"
|
||||
|
||||
// ----------------------- 任务模块 -----------------------
|
||||
|
||||
|
@ -324,32 +324,64 @@ enum UpgradeMasterType {
|
||||
MasterTreasureRefine = 4;
|
||||
}
|
||||
|
||||
|
||||
// MailType 邮件类型
|
||||
enum MailType {
|
||||
MailTypeNone = 0;
|
||||
|
||||
// 普通邮件
|
||||
MailNormal = 1;
|
||||
|
||||
// 特殊邮件
|
||||
MailSpecial = 2;
|
||||
|
||||
// 后台邮件
|
||||
MailBackground = 3;
|
||||
|
||||
// 全服邮件
|
||||
MailAllRegion = 4;
|
||||
}
|
||||
|
||||
enum MailStatus {
|
||||
|
||||
//未读
|
||||
Unread = 0;
|
||||
|
||||
//已读
|
||||
HasRead = 1;
|
||||
|
||||
//已领取
|
||||
Received = 2;
|
||||
|
||||
//已删除
|
||||
Deleted = 3;
|
||||
}
|
||||
|
||||
enum AttrType {
|
||||
AttrTypeNone = 0; //无属性
|
||||
Attack = 1; //攻击
|
||||
Hp = 2; //生命
|
||||
AttrPhysicalDefense = 3; //物防
|
||||
AttrMagicDefense = 4; //法防
|
||||
AttrAttackRatio = 5; //攻击加成
|
||||
AttrHpRatio = 6; //生命加成
|
||||
AttrPhysicalDefenseRatio = 7; //物防加成
|
||||
AttrMagicDefenseRatio = 8; //法防加成
|
||||
AttrDamageRatio = 9; //伤害加成
|
||||
AttrDamageRelief = 10; //伤害减免
|
||||
AttrCriticalRatio = 11; //暴击几率
|
||||
AttrCriticalResistance = 12; //抗暴几率
|
||||
AttrCriticalDamage = 13; //暴击伤害
|
||||
AttrCriticalDamageRelief = 14; //暴伤减免
|
||||
AttrHitRate = 15; //命中几率
|
||||
AttrDodgeRate = 16; //闪避几率
|
||||
AttrTreatRatio = 17; //治疗加成
|
||||
AttrByTreatedRatio = 18; //被治疗率
|
||||
AttrFinalDamageRatio = 19; //最终增伤
|
||||
AttrFinalDamageRelief = 20; //最终减伤
|
||||
AttrBlockRate = 21; //格挡
|
||||
AttrBlockResistance = 22; //抗格挡
|
||||
AttrSpeed = 23; //速度
|
||||
Nums = 24; //属性总数量
|
||||
PhysicalDefense = 3; //物防
|
||||
MagicDefense = 4; //法防
|
||||
AttackRatio = 5; //攻击加成
|
||||
HpRatio = 6; //生命加成
|
||||
PhysicalDefenseRatio = 7; //物防加成
|
||||
MagicDefenseRatio = 8; //法防加成
|
||||
DamageRatio = 9; //伤害加成
|
||||
DamageRelief = 10; //伤害减免
|
||||
CriticalRate = 11; //暴击几率
|
||||
CriticalResistance = 12; //抗暴几率
|
||||
CriticalDamage = 13; //暴击伤害
|
||||
CriticalDamageRelief = 14; //暴伤减免
|
||||
HitRate = 15; //命中几率
|
||||
DodgeRate = 16; //闪避几率
|
||||
TreatRatio = 17; //治疗加成
|
||||
ByTreatedRate = 18; //被治疗率
|
||||
FinalDamageRatio = 19; //最终增伤
|
||||
FinalDamageRelief = 20; //最终减伤
|
||||
BlockRate = 21; //格挡
|
||||
BlockResistance = 22; //抗格挡
|
||||
AttrNums = 23; //属性总数量
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,15 +8,33 @@ import "mod_item.proto";
|
||||
// 战斗模块消息定义
|
||||
// 如果定义的消息内没有字段或者消息被注释掉了,说明该请求不需要参数,发送消息时仅发送包头即可,包体可为空, 返回的消息亦是如此。
|
||||
|
||||
//战斗单位
|
||||
// MsgId.ModBattleEnter = 4001;
|
||||
//进入战斗请求
|
||||
message BattleEnterReq {
|
||||
uint32 SceneId = 1; //场景ID
|
||||
}
|
||||
|
||||
//战斗Buff
|
||||
message BattleBuff {
|
||||
uint32 Skill = 1; //Buff技能
|
||||
uint32 Layers = 2; //Buff层数
|
||||
}
|
||||
|
||||
//战斗数值
|
||||
message BattleValue {
|
||||
int64 Value = 1; //数值集合,负数是伤害,正数回血
|
||||
uint64 Hp = 2; //受数值影响后的当前血量
|
||||
uint32 Status = 3; //0.正常, 1.暴击, 2.闪避,3.无敌,4.格挡,5.吸收, 6.反弹, 7.免疫
|
||||
}
|
||||
|
||||
//战斗目标
|
||||
message BattleTarget {
|
||||
uint32 Type = 1; //目标类型, 1.英雄(自己人),2.怪物(敌人)
|
||||
uint64 Id = 2; //目标ID
|
||||
uint32 Position = 2; //目标位置索引1-6
|
||||
uint64 HpMax = 3; //最大血量
|
||||
uint32 Rage = 4; //当前怒气
|
||||
repeated uint32 Status = 5; //目标状态(待定,如眩晕、击飞等)
|
||||
repeated uint64 Value = 6; //数值集合,可以是伤害,回血等
|
||||
repeated uint64 Hp = 7; //元素个数与上面的数值元素个数一致,元素值为受每个数值影响后的当前血量
|
||||
repeated BattleBuff BuffList = 5; //目标DeBuff状态ID(待定,如眩晕、击飞等)
|
||||
repeated BattleValue ValueList = 6; //数值集合,负数是伤害,正数回血
|
||||
}
|
||||
|
||||
//战斗动作
|
||||
@ -33,10 +51,10 @@ message BattleRound {
|
||||
repeated BattleAction ActionList = 2; //动作列表
|
||||
}
|
||||
|
||||
//战斗单位
|
||||
message BattleUnit {
|
||||
uint64 UnitId = 1;
|
||||
uint64 UnitId = 1; //自己是英雄唯一ID,敌人是怪物表ID,敌对玩家是英雄表ID
|
||||
uint32 SuitId = 2; //时装ID
|
||||
//
|
||||
}
|
||||
|
||||
// MsgId.ModBattleEnter = 4001;
|
||||
|
@ -12,13 +12,6 @@ message SceneEnterAck {
|
||||
uint32 SceneId = 1;//场景ID
|
||||
}
|
||||
|
||||
// MsgId.ModLevelEnter: 3001
|
||||
// 进入关卡返回
|
||||
message LevelEnterAck {
|
||||
uint32 CopyType = 1; //副本类型
|
||||
uint32 LevelId = 2; //关卡ID
|
||||
}
|
||||
|
||||
// CopyStatus 副本状态
|
||||
message CopyStatus {
|
||||
uint32 CopyType = 1; // 副本类型,场景表中的副本类型
|
||||
@ -46,6 +39,14 @@ message LevelEnterReq {
|
||||
uint32 LevelId = 2; //关卡ID
|
||||
}
|
||||
|
||||
// MsgId.ModLevelEnter = 3004;
|
||||
// 进入关卡返回
|
||||
//message LevelEnterAck {
|
||||
// uint32 CopyType = 1; //副本类型
|
||||
// uint32 LevelId = 2; //关卡ID
|
||||
// uint32 SceneId = 3; //场景ID
|
||||
//}
|
||||
|
||||
// MsgId.ModLevelSweep = 3005;
|
||||
// 进入扫荡请求
|
||||
message LevelSweepReq {
|
||||
|
90
proto/idl/mod_mail.proto
Normal file
90
proto/idl/mod_mail.proto
Normal file
@ -0,0 +1,90 @@
|
||||
syntax = "proto3";
|
||||
package Pb;
|
||||
option go_package = "pb/";
|
||||
|
||||
import "enums.proto";
|
||||
import "mod_item.proto";
|
||||
|
||||
// ModId.ModuleMail = 8000;
|
||||
// 邮件模块消息定义
|
||||
// 如果定义的消息内没有字段或者消息被注释掉了,说明该请求不需要参数,发送消息时仅发送包头即可,包体可为空, 返回的消息亦是如此。
|
||||
|
||||
message Mail {
|
||||
uint64 Uid = 1; //唯一ID
|
||||
MailType Type = 2; //邮件类型,见MailType
|
||||
string title = 3; //标题
|
||||
string content = 4; //内容
|
||||
int64 CreateTime = 5; //创建时间
|
||||
int64 Expiration = 6; //过期时间,0不过期
|
||||
MailStatus Status = 7; //邮件状态,见MailStatus
|
||||
repeated string Args = 8; //邮件参数,用于替换内容中的占符
|
||||
repeated Item ItemList = 9; //物品列表, 没有物品为空
|
||||
}
|
||||
|
||||
message MailChange {
|
||||
uint64 Uid = 1; //唯一ID
|
||||
MailStatus Status = 7; //邮件状态,见MailStatus
|
||||
}
|
||||
|
||||
// MsgId.ModMailList = 8001;
|
||||
// MsgId.ModMailSend = 8002;
|
||||
// 邮件列表返回
|
||||
message MailListAck {
|
||||
repeated Mail MailList = 1;
|
||||
}
|
||||
|
||||
// MsgId.ModMailSend = 8002;
|
||||
// 邮件发送请求
|
||||
message MailSendReq {
|
||||
uint64 UserId = 1; //用户ID
|
||||
uint32 AreaId = 2; //区ID(服务器ID)
|
||||
uint64 RoleId = 3; //角色ID
|
||||
Mail Mail = 4; //邮件
|
||||
}
|
||||
|
||||
// MsgId.ModMailSend = 8002;
|
||||
// 邮件发送返回
|
||||
message MailSendAck {
|
||||
Mail Mail = 1;
|
||||
}
|
||||
|
||||
// MsgId.ModMailChange = 8003;
|
||||
// 邮件为变更列表返回
|
||||
message MailChangeListAck {
|
||||
repeated MailChange ChangeList = 1;
|
||||
}
|
||||
|
||||
// MsgId.ModMailRead = 8004;
|
||||
// 邮件读取请求
|
||||
message MailReadReq {
|
||||
uint64 Uid = 1; //唯一ID
|
||||
}
|
||||
|
||||
// MsgId.ModMailReceive = 8005;
|
||||
// 邮件物品领取请求
|
||||
message MailReceiveReq {
|
||||
uint64 Uid = 1; //唯一ID
|
||||
}
|
||||
|
||||
// MsgId.ModMailReceiveAll = 8006;
|
||||
// 邮件物品领取所有
|
||||
message MailReceiveAllReq {
|
||||
}
|
||||
|
||||
// MsgId.ModMailReceive = 8005;
|
||||
// MsgId.ModMailReceiveAll = 8006;
|
||||
// 邮件物品领取返回
|
||||
message MailReceiveAck {
|
||||
repeated Item ItemList = 1;
|
||||
}
|
||||
|
||||
// MsgId.ModMailDelete = 8007;
|
||||
// 邮件删除请求
|
||||
message MailDeleteReq {
|
||||
uint64 Uid = 1; //唯一ID
|
||||
}
|
||||
|
||||
// MsgId.ModMailDeleteAll = 8008;
|
||||
// 邮件删除所有请求
|
||||
message MailDeleteAllReq {
|
||||
}
|
@ -120,6 +120,13 @@ message LineupHeroPositionReq {
|
||||
repeated uint32 PositionList = 3; // 阵容英雄列表中前,6个英雄新布阵位置,布阵位置的顺序和阵容英雄列表是不一样的,布阵位置调整不影响英雄在阵容列表中的顺序。
|
||||
}
|
||||
|
||||
// MsgId.ModRoleLineupHeroPosition = 2008;
|
||||
// 阵容英雄布阵位置变更返回
|
||||
message LineupHeroPositionAck {
|
||||
uint64 LineupUid = 1;
|
||||
repeated uint32 PositionList = 3; // 阵容英雄列表中前,6个英雄新布阵位置,布阵位置的顺序和阵容英雄列表是不一样的,布阵位置调整不影响英雄在阵容列表中的顺序。
|
||||
}
|
||||
|
||||
// MsgId.ModRoleLineupHeroEquip = 2009;
|
||||
// 阵容英雄装备变更请求
|
||||
message LineupHeroEquipReq {
|
||||
|
@ -178,7 +178,7 @@ enum MsgId {
|
||||
//-------------------------------------------------------------------------- 英雄模块 --------------------------------------------------------------------------
|
||||
ModHeroList = 5001;
|
||||
|
||||
// 英雄升级
|
||||
// 英雄变更
|
||||
ModHeroChange = 5002;
|
||||
|
||||
// 英雄升级
|
||||
@ -208,7 +208,7 @@ enum MsgId {
|
||||
// 英雄名将册激活
|
||||
ModHeroBookActivate = 5011;
|
||||
|
||||
// ModItem begin -----------------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------- 物品模块 --------------------------------------------------------------------------
|
||||
// 物品列表
|
||||
ModItemList = 6001;
|
||||
|
||||
@ -245,10 +245,35 @@ enum MsgId {
|
||||
// 装备升级
|
||||
ModItemTreasureRefine = 6024;
|
||||
|
||||
//ModCounter begin -----------------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------- 计数模块 --------------------------------------------------------------------------
|
||||
// 计数器列表
|
||||
ModCounterList = 7001;
|
||||
|
||||
// 计数器变更
|
||||
ModCounterChange = 7002;
|
||||
|
||||
//-------------------------------------------------------------------------- 邮件模块 --------------------------------------------------------------------------
|
||||
// 邮件列表
|
||||
ModMailList = 8001;
|
||||
|
||||
// 邮件发送
|
||||
ModMailSend = 8002;
|
||||
|
||||
// 邮件状态改变
|
||||
ModMailChange = 8003;
|
||||
|
||||
// 邮件已读
|
||||
ModMailRead = 8004;
|
||||
|
||||
// 邮件物品领取
|
||||
ModMailReceive = 8005;
|
||||
|
||||
// 邮件物品领取
|
||||
ModMailReceiveAll = 8006;
|
||||
|
||||
// 邮件删除
|
||||
ModMailDelete = 8007;
|
||||
|
||||
// 邮件删除
|
||||
ModMailDeleteAll = 8008;
|
||||
}
|
141
servers/game/data/drop.go
Normal file
141
servers/game/data/drop.go
Normal file
@ -0,0 +1,141 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
json "github.com/json-iterator/go"
|
||||
"github.com/oylshe1314/framework/util"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type Drop struct {
|
||||
Id int `json:"id"`
|
||||
DropId int `json:"drop_id"`
|
||||
BoxId int `json:"box_id"`
|
||||
BoxRate int `json:"box_rate"`
|
||||
MinNum int `json:"min_num"`
|
||||
MaxNum int `json:"max_num"`
|
||||
ItemId int `json:"item_id"`
|
||||
ItemNum int `json:"item_num"`
|
||||
ItemRate int `json:"item_rate"`
|
||||
}
|
||||
|
||||
type dropItem struct {
|
||||
drop *Drop
|
||||
}
|
||||
|
||||
type dropBox struct {
|
||||
boxId int
|
||||
rate int
|
||||
min int
|
||||
max int
|
||||
rates int
|
||||
items []*dropItem
|
||||
}
|
||||
|
||||
type dropStore struct {
|
||||
dropId int
|
||||
boxes map[int]*dropBox
|
||||
}
|
||||
|
||||
type DropTable struct {
|
||||
l []*Drop
|
||||
m map[int]*dropStore
|
||||
}
|
||||
|
||||
func (this *DropTable) load(buf []byte) error {
|
||||
var err = json.Unmarshal(buf, &this.l)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
this.m = make(map[int]*dropStore)
|
||||
for _, drop := range this.l {
|
||||
var item = &dropItem{drop}
|
||||
|
||||
var store = this.m[item.drop.DropId]
|
||||
if store == nil {
|
||||
store = &dropStore{
|
||||
dropId: drop.DropId,
|
||||
boxes: map[int]*dropBox{
|
||||
item.drop.BoxId: {
|
||||
boxId: item.drop.BoxId,
|
||||
rate: item.drop.BoxRate,
|
||||
min: item.drop.MinNum,
|
||||
max: item.drop.MaxNum,
|
||||
rates: item.drop.ItemRate,
|
||||
items: []*dropItem{item},
|
||||
},
|
||||
},
|
||||
}
|
||||
this.m[drop.DropId] = store
|
||||
} else {
|
||||
var box = store.boxes[item.drop.BoxId]
|
||||
if box == nil {
|
||||
box = &dropBox{
|
||||
boxId: item.drop.BoxId,
|
||||
rate: item.drop.BoxRate,
|
||||
min: item.drop.MinNum,
|
||||
max: item.drop.MaxNum,
|
||||
rates: item.drop.ItemRate,
|
||||
items: []*dropItem{item},
|
||||
}
|
||||
store.boxes[item.drop.BoxId] = box
|
||||
} else {
|
||||
box.rates += item.drop.ItemRate
|
||||
box.items = append(box.items, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, store := range this.m {
|
||||
for _, box := range store.boxes {
|
||||
sort.Slice(box.items, func(i, j int) bool {
|
||||
return box.items[i].drop.Id < box.items[j].drop.Id
|
||||
})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Drop 掉落算法
|
||||
func (this *DropTable) Drop(dropId int, times int) [][2]int {
|
||||
if dropId <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if times <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var store = this.m[dropId]
|
||||
if store == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var rd = util.NewRand()
|
||||
var result [][2]int
|
||||
for range times {
|
||||
for _, box := range store.boxes {
|
||||
if len(box.items) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if rd.Float64()*10000.0 > float64(box.rate) {
|
||||
continue
|
||||
}
|
||||
|
||||
var dropNum = box.min
|
||||
if box.max > dropNum {
|
||||
dropNum += rd.IntN(box.max - box.min)
|
||||
}
|
||||
var rates = float64(box.rates)
|
||||
var factor = rd.Float64() * rates
|
||||
for _, item := range box.items {
|
||||
rates -= float64(item.drop.ItemRate)
|
||||
if factor >= rates {
|
||||
result = append(result, [2]int{item.drop.ItemId, item.drop.ItemNum * dropNum})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
@ -4,7 +4,10 @@ import json "github.com/json-iterator/go"
|
||||
|
||||
type Monster struct {
|
||||
Id int `json:"id"`
|
||||
Gender int `json:"gender"`
|
||||
Country int `json:"country"`
|
||||
Level int `json:"level"`
|
||||
Speed int `json:"speed"`
|
||||
AttackSkills []int `json:"attack_skills"`
|
||||
PassiveSkills []int `json:"passive_skills"`
|
||||
AttrValue1 int `json:"attr_value1"`
|
||||
|
@ -21,8 +21,8 @@ type Scene struct {
|
||||
Monster6 int `json:"monster6"`
|
||||
EnterTimes int `json:"enter_times"`
|
||||
RestTimes int `json:"rest_times"`
|
||||
PassExpRate int `json:"pass_exp_rate"`
|
||||
PassCoinRate int `json:"pass_coin_rate"`
|
||||
ExpMultiple int `json:"exp_multiple"`
|
||||
CoinMultiple int `json:"coin_multiple"`
|
||||
FirstDrop int `json:"first_drop"`
|
||||
PassDrop int `json:"pass_drop"`
|
||||
Star1Type int `json:"star1_type"`
|
||||
|
@ -3,9 +3,10 @@ package data
|
||||
import json "github.com/json-iterator/go"
|
||||
|
||||
type Skill struct {
|
||||
Id int `json:"id"`
|
||||
SkillType int `json:"skill_type"`
|
||||
SkillBuff []int `json:"skill_buff"`
|
||||
Id int `json:"id"`
|
||||
SkillType int `json:"skill_type"`
|
||||
RageConsume int `json:"rage_consume"`
|
||||
SkillBuff []int `json:"skill_buff"`
|
||||
}
|
||||
|
||||
type SkillTable struct {
|
||||
|
@ -3,9 +3,22 @@ package data
|
||||
import json "github.com/json-iterator/go"
|
||||
|
||||
type SkillBuff struct {
|
||||
Id int `json:"id"`
|
||||
SkillBuffType int `json:"SkillBuff_type"`
|
||||
SkillBuffBuff []int `json:"SkillBuff_buff"`
|
||||
Id int `json:"id"`
|
||||
TargetType int `json:"target_type"`
|
||||
TargetArgs []int `json:"target_args"`
|
||||
RangeType int `json:"range_type"`
|
||||
RangeNum int `json:"range_num"`
|
||||
PriorityType []int `json:"priority_type"`
|
||||
PriorityArgs []int `json:"priority_args"`
|
||||
BuffType int `json:"buff_type"`
|
||||
BuffArgs []int `json:"buff_args"`
|
||||
DurationType int `json:"durationType"`
|
||||
Duration int `json:"duration"`
|
||||
EffectId string `json:"effectId"`
|
||||
CanMerge bool `json:"can_merge"`
|
||||
CanCover bool `json:"can_cover"`
|
||||
CanStack bool `json:"can_stack"`
|
||||
CanClean bool `json:"can_clean"`
|
||||
}
|
||||
|
||||
type SkillBuffTable struct {
|
||||
|
@ -19,6 +19,7 @@ type Tables struct {
|
||||
|
||||
Copy CopyTable
|
||||
CopyMain CopyMainTable
|
||||
Drop DropTable
|
||||
Equip EquipTable
|
||||
EquipLevel EquipLevelTable
|
||||
EquipRefine EquipRefineTable
|
||||
|
@ -71,7 +71,7 @@ func (this *PlayerHandler) GmCommand(player *logic.Player, msg *net.Message) {
|
||||
money.Value = 0
|
||||
player.SaveModel(money)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleMoneyChange), &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyChange, &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
} else {
|
||||
amount, err := strconv.Atoi(args[0])
|
||||
if err != nil {
|
||||
@ -99,7 +99,7 @@ func (this *PlayerHandler) GmCommand(player *logic.Player, msg *net.Message) {
|
||||
player.Item = map[uint32]*logic.PlayerItem{}
|
||||
player.SaveField("item", player.Item)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemList), player.BuildMsgItemListAck())
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemList, player.BuildMsgItemListAck())
|
||||
return
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ func (this *PlayerHandler) GmCommand(player *logic.Player, msg *net.Message) {
|
||||
delete(player.Item, uint32(itemId))
|
||||
player.WipeModel(item)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemChange, &pb.ItemChangeListAck{
|
||||
ChangeList: []*pb.ItemChange{{ChangeType: pb.ChangeType_Delete, Item: item.BuildMsgItem(true)}},
|
||||
})
|
||||
return
|
||||
@ -154,7 +154,7 @@ func (this *PlayerHandler) GmCommand(player *logic.Player, msg *net.Message) {
|
||||
}
|
||||
|
||||
if len(args) > 1 && args[1] == "clear" {
|
||||
var heroes map[uint64]*logic.PlayerHero
|
||||
var heroes = map[uint64]*logic.PlayerHero{}
|
||||
for _, hero := range player.Hero {
|
||||
if hero.Id == uint32(heroId) {
|
||||
heroes[hero.Uid] = hero
|
||||
@ -162,6 +162,9 @@ func (this *PlayerHandler) GmCommand(player *logic.Player, msg *net.Message) {
|
||||
}
|
||||
player.ReduceHeroes(heroes, logic.LogTypeNone)
|
||||
} else {
|
||||
if heroId == this.tables.ServerConfig.GetInitRole(0) || heroId == this.tables.ServerConfig.GetInitRole(1) {
|
||||
_ = player.TipNotice(proto.StringTipError("主角不能添加"))
|
||||
}
|
||||
player.AddHero(uint32(heroId))
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ func (this *PlayerHandler) HeroUpgrade(player *logic.Player, msg *net.Message) {
|
||||
|
||||
player.ReduceItems(consumeItems, logic.LogTypeItemConsumeByHeroUpgrade)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: []*pb.HeroChange{{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()}},
|
||||
})
|
||||
|
||||
@ -376,7 +376,7 @@ func (this *PlayerHandler) HeroSoul(player *logic.Player, msg *net.Message) {
|
||||
|
||||
player.SaveModel(hero)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: []*pb.HeroChange{{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()}},
|
||||
})
|
||||
}
|
||||
@ -386,7 +386,7 @@ func (this *PlayerHandler) HeroSoul(player *logic.Player, msg *net.Message) {
|
||||
|
||||
player.SaveModel(hero)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: []*pb.HeroChange{{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()}},
|
||||
})
|
||||
|
||||
@ -454,7 +454,7 @@ func (this *PlayerHandler) HeroBookActivate(player *logic.Player, msg *net.Messa
|
||||
}
|
||||
}
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroBookChange), &pb.HeroBookListAck{
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroBookChange, &pb.HeroBookListAck{
|
||||
BookList: []*pb.HeroBook{heroBook.BuildMsgHeroBook()},
|
||||
})
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ func (this *PlayerHandler) EquipUpgrade(player *logic.Player, msg *net.Message)
|
||||
|
||||
player.SaveModel(equip)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipChange), pb.EquipChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipChange, pb.EquipChangeListAck{
|
||||
ChangeList: []*pb.EquipChange{{Equip: equip.BuildMsgEquip(), ChangeType: pb.ChangeType_Add}},
|
||||
})
|
||||
|
||||
@ -289,7 +289,7 @@ func (this *PlayerHandler) EquipRefine(player *logic.Player, msg *net.Message) {
|
||||
|
||||
player.SaveModel(equip)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipChange), &pb.EquipChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipChange, &pb.EquipChangeListAck{
|
||||
ChangeList: []*pb.EquipChange{{ChangeType: pb.ChangeType_Changed, Equip: equip.BuildMsgEquip()}},
|
||||
})
|
||||
|
||||
@ -427,7 +427,7 @@ func (this *PlayerHandler) TreasureUpgrade(player *logic.Player, msg *net.Messag
|
||||
|
||||
player.SaveModel(treasure)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureChange, &pb.TreasureChangeListAck{
|
||||
ChangeList: []*pb.TreasureChange{{ChangeType: pb.ChangeType_Changed, Treasure: treasure.BuildMsgTreasure()}},
|
||||
})
|
||||
|
||||
@ -502,7 +502,7 @@ func (this *PlayerHandler) TreasureRefine(player *logic.Player, msg *net.Message
|
||||
|
||||
player.SaveModel(equip)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), pb.TreasureChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureChange, pb.TreasureChangeListAck{
|
||||
ChangeList: []*pb.TreasureChange{{Treasure: equip.BuildMsgTreasure(), ChangeType: pb.ChangeType_Add}},
|
||||
})
|
||||
|
||||
|
@ -9,14 +9,14 @@ import (
|
||||
)
|
||||
|
||||
func (this *PlayerHandler) checkLevelConsume(sceneTable *data.Scene, player *logic.Player, times uint32) proto.TipError {
|
||||
var consume = map[uint32]uint32{}
|
||||
var consumeItems = map[uint32]uint32{}
|
||||
for i := range sceneTable.ConsumeItems {
|
||||
consume[uint32(sceneTable.ConsumeItems[i])] += uint32(sceneTable.ConsumeNums[i]) * times
|
||||
consumeItems[uint32(sceneTable.ConsumeItems[i])] += uint32(sceneTable.ConsumeNums[i]) * times
|
||||
}
|
||||
for i := range sceneTable.SuConsumeItems {
|
||||
consume[uint32(sceneTable.SuConsumeItems[i])] += uint32(sceneTable.SuConsumeNums[i]) * times
|
||||
consumeItems[uint32(sceneTable.SuConsumeItems[i])] += uint32(sceneTable.SuConsumeNums[i]) * times
|
||||
}
|
||||
for itemId, itemNum := range consume {
|
||||
for itemId, itemNum := range consumeItems {
|
||||
if ok, tip := player.CheckItem(itemId, itemNum); !ok {
|
||||
return tip
|
||||
}
|
||||
|
@ -1,194 +1,251 @@
|
||||
package handler
|
||||
|
||||
//func (this *PlayerHandler) MailRead(player *logic.Player, msg *net.Message) {
|
||||
// var req = new(proto.MsgMailReadReq)
|
||||
// var err = msg.Read(req)
|
||||
// if err != nil {
|
||||
// this.logger.Error("Read message failed, ", err)
|
||||
// _ = player.TipNotice(proto.ErrMessageError)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if req.Id == 0 {
|
||||
// this.logger.Error("Parameter error, req.Id == 0")
|
||||
// _ = player.TipNotice(proto.ErrParameterError)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// var mail = player.Mail[req.Id]
|
||||
// if mail == nil {
|
||||
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
|
||||
// _ = player.TipNotice(proto.ErrMailNotFound)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusHasRead {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// mail.Status = uint32(proto.MailStatusHasRead)
|
||||
//
|
||||
// player.SaveModel(mail)
|
||||
//
|
||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailRead, &proto.MsgMailReadAck{MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status}})
|
||||
//
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailRead, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
//}
|
||||
//
|
||||
//func (this *PlayerHandler) MailReceive(player *logic.Player, msg *net.Message) {
|
||||
// var req = new(proto.MsgMailReceiveReq)
|
||||
// var err = msg.Read(req)
|
||||
// if err != nil {
|
||||
// this.logger.Error("Read message failed, ", err)
|
||||
// _ = player.TipNotice(proto.ErrMessageError)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if req.Id == 0 {
|
||||
// this.logger.Error("Parameter error, req.Id == 0")
|
||||
// _ = player.TipNotice(proto.ErrParameterError)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// var mail = player.Mail[req.Id]
|
||||
// if mail == nil {
|
||||
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
|
||||
// _ = player.TipNotice(proto.ErrMailNotFound)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusReceived {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if len(mail.ItemId) == 0 || len(mail.ItemNum) == 0 {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// var rewardList []*proto.ItemPair
|
||||
// for i := range mail.ItemId {
|
||||
// _ = player.AddItem(mail.ItemId[i], mail.ItemNum[i], logic.LogTypeItemObtainByMail)
|
||||
// rewardList = append(rewardList, &proto.ItemPair{ItemId: mail.ItemId[i], ItemNum: mail.ItemNum[i]})
|
||||
// }
|
||||
//
|
||||
// mail.Status = uint32(proto.MailStatusReceived)
|
||||
//
|
||||
// player.SaveModel(mail)
|
||||
//
|
||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailReceive, &proto.MsgMailReceiveAck{
|
||||
// MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList},
|
||||
// MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status},
|
||||
// })
|
||||
//
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailReward, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
//}
|
||||
//
|
||||
//func (this *PlayerHandler) MailReceiveAll(player *logic.Player, _ *net.Message) {
|
||||
// var rewardList []*proto.ItemPair
|
||||
// var changeList []*proto.MailChange
|
||||
// var itemPair = map[uint32]uint32{}
|
||||
// for id, mail := range player.Mail {
|
||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusReceived {
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// if len(mail.ItemId) == 0 || len(mail.ItemNum) == 0 {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// for i := range mail.ItemId {
|
||||
// itemPair[mail.ItemId[i]] += mail.ItemNum[i]
|
||||
// }
|
||||
//
|
||||
// mail.Status = uint32(proto.MailStatusReceived)
|
||||
// player.SaveModel(mail)
|
||||
//
|
||||
// changeList = append(changeList, &proto.MailChange{Id: id, Status: mail.Status})
|
||||
//
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailReward, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
// }
|
||||
//
|
||||
// for itemId, itemNum := range itemPair {
|
||||
// _ = player.AddItem(itemId, itemNum, logic.LogTypeItemObtainByMail)
|
||||
// rewardList = append(rewardList, &proto.ItemPair{ItemId: itemId, ItemNum: itemNum})
|
||||
// }
|
||||
//
|
||||
// if len(changeList) > 0 {
|
||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailReceiveAll, &proto.MsgMailReceiveAllAck{
|
||||
// MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList},
|
||||
// ChangeList: changeList,
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *PlayerHandler) MailDelete(player *logic.Player, msg *net.Message) {
|
||||
// var req = new(proto.MsgMailDeleteReq)
|
||||
// var err = msg.Read(req)
|
||||
// if err != nil {
|
||||
// this.logger.Error("Read message failed, ", err)
|
||||
// _ = player.TipNotice(proto.ErrMessageError)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if req.Id == 0 {
|
||||
// this.logger.Error("Parameter error, req.Id == 0")
|
||||
// _ = player.TipNotice(proto.ErrParameterError)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// var mail = player.Mail[req.Id]
|
||||
// if mail == nil {
|
||||
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
|
||||
// _ = player.TipNotice(proto.ErrMailNotFound)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if proto.MailType(mail.Type) == proto.MailTypeRegion {
|
||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
|
||||
// return
|
||||
// }
|
||||
// mail.Status = uint32(proto.MailStatusDeleted)
|
||||
// player.SaveModel(mail)
|
||||
// } else {
|
||||
// delete(player.Mail, req.Id)
|
||||
// player.WipeModel(mail)
|
||||
// }
|
||||
//
|
||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailDelete, &proto.MsgMailDeleteAck{MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status}})
|
||||
//
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
//}
|
||||
//
|
||||
//func (this *PlayerHandler) MailDeleteAll(player *logic.Player, _ *net.Message) {
|
||||
// var changeList []*proto.MailChange
|
||||
// for id, mail := range player.Mail {
|
||||
// if proto.MailStatus(mail.Status) < proto.MailStatusHasRead {
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// if len(mail.ItemId) > 0 {
|
||||
// if proto.MailStatus(mail.Status) < proto.MailStatusReceived {
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if proto.MailType(mail.Type) == proto.MailTypeRegion {
|
||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
|
||||
// continue
|
||||
// }
|
||||
// mail.Status = uint32(proto.MailStatusDeleted)
|
||||
// player.SaveModel(mail)
|
||||
// } else {
|
||||
// delete(player.Mail, id)
|
||||
// player.WipeModel(mail)
|
||||
// }
|
||||
//
|
||||
// changeList = append(changeList, &proto.MailChange{Id: id, Status: uint32(proto.MailStatusDeleted)})
|
||||
//
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
// }
|
||||
//
|
||||
// if len(changeList) > 0 {
|
||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailDeleteAll, &proto.MsgMailDeleteAllAck{ChangeList: changeList})
|
||||
// }
|
||||
//}
|
||||
import (
|
||||
"ecs/proto"
|
||||
"ecs/proto/pb"
|
||||
"ecs/servers/game/logic"
|
||||
"github.com/oylshe1314/framework/net"
|
||||
)
|
||||
|
||||
func (this *PlayerHandler) MailSend(player *logic.Player, msg *net.Message) {
|
||||
var req = new(pb.MailSendReq)
|
||||
var err = msg.Read(req)
|
||||
if err != nil {
|
||||
this.logger.Error("Read message failed, ", err)
|
||||
_ = player.TipNotice(proto.TipMessageError)
|
||||
return
|
||||
}
|
||||
|
||||
if req.UserId == 0 {
|
||||
this.logger.Error("Parameter error, req.UserId == 0")
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
}
|
||||
|
||||
if req.AreaId == 0 {
|
||||
this.logger.Error("Parameter error, req.AreaId == 0")
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
}
|
||||
|
||||
if req.RoleId == 0 {
|
||||
this.logger.Error("Parameter error, req.RoleId == 0")
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Mail == nil {
|
||||
this.logger.Error("Parameter error, req.Mail == nil")
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
}
|
||||
|
||||
_ = player.TipNotice(proto.TipServerError)
|
||||
}
|
||||
|
||||
func (this *PlayerHandler) MailRead(player *logic.Player, msg *net.Message) {
|
||||
var req = new(pb.MailReadReq)
|
||||
var err = msg.Read(req)
|
||||
if err != nil {
|
||||
this.logger.Error("Read message failed, ", err)
|
||||
_ = player.TipNotice(proto.TipMessageError)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Uid == 0 {
|
||||
this.logger.Error("Parameter error, req.Uid == 0")
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
}
|
||||
|
||||
var mail = player.Mail[req.Uid]
|
||||
if mail == nil {
|
||||
this.logger.Error("Parameter error, player 'Mail' was not found, req.Uid: ", req.Uid)
|
||||
_ = player.TipNotice(proto.TipMailNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
if pb.MailStatus(mail.Status) >= pb.MailStatus_HasRead {
|
||||
return
|
||||
}
|
||||
|
||||
mail.Status = uint32(pb.MailStatus_HasRead)
|
||||
|
||||
player.SaveModel(mail)
|
||||
|
||||
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailRead, &pb.MailChangeListAck{
|
||||
ChangeList: []*pb.MailChange{{Uid: mail.Uid, Status: pb.MailStatus(mail.Status)}},
|
||||
})
|
||||
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailRead, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
}
|
||||
|
||||
func (this *PlayerHandler) MailReceive(player *logic.Player, msg *net.Message) {
|
||||
var req = new(pb.MailReceiveReq)
|
||||
var err = msg.Read(req)
|
||||
if err != nil {
|
||||
this.logger.Error("Read message failed, ", err)
|
||||
_ = player.TipNotice(proto.TipMessageError)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Uid == 0 {
|
||||
this.logger.Error("Parameter error, req.Uid == 0")
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
}
|
||||
|
||||
var mail = player.Mail[req.Uid]
|
||||
if mail == nil {
|
||||
this.logger.Error("Parameter error, player 'Mail' was not found, req.Uid: ", req.Uid)
|
||||
_ = player.TipNotice(proto.TipMailNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
if len(mail.Items) == 0 {
|
||||
this.logger.Error("Parameter error, len(mail.Items) == 0, req.Uid: ", req.Uid)
|
||||
_ = player.TipNotice(proto.TipMailNoItems)
|
||||
return
|
||||
}
|
||||
|
||||
if pb.MailStatus(mail.Status) >= pb.MailStatus_Received {
|
||||
return
|
||||
}
|
||||
|
||||
var itemList []*pb.Item
|
||||
for i := range mail.Items {
|
||||
_ = player.AddItem(mail.Items[i][0], mail.Items[i][1], logic.LogTypeItemObtainByMail)
|
||||
itemList = append(itemList, &pb.Item{ItemId: mail.Items[i][0], ItemNum: mail.Items[i][1]})
|
||||
}
|
||||
|
||||
mail.Status = uint32(pb.MailStatus_Received)
|
||||
|
||||
player.SaveModel(mail)
|
||||
|
||||
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailReceive, &pb.MailReceiveAck{
|
||||
ItemList: itemList,
|
||||
})
|
||||
|
||||
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{
|
||||
ChangeList: []*pb.MailChange{{Uid: mail.Uid, Status: pb.MailStatus(mail.Status)}},
|
||||
})
|
||||
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailReward, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
}
|
||||
|
||||
func (this *PlayerHandler) MailReceiveAll(player *logic.Player, _ *net.Message) {
|
||||
var changeList []*pb.MailChange
|
||||
var mailItems = map[uint32]uint32{}
|
||||
for uid, mail := range player.Mail {
|
||||
if pb.MailStatus(mail.Status) >= pb.MailStatus_Received {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(mail.Items) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
for i := range mail.Items {
|
||||
mailItems[mail.Items[i][0]] += mail.Items[i][1]
|
||||
}
|
||||
|
||||
mail.Status = uint32(pb.MailStatus_Received)
|
||||
player.SaveModel(mail)
|
||||
|
||||
changeList = append(changeList, &pb.MailChange{Uid: uid, Status: pb.MailStatus(mail.Status)})
|
||||
|
||||
//this.eventManager.PlayerMailLog(player, logic.LogTypeMailReward, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
}
|
||||
|
||||
var itemList []*pb.Item
|
||||
for itemId, itemNum := range mailItems {
|
||||
_ = player.AddItem(itemId, itemNum, logic.LogTypeItemObtainByMail)
|
||||
itemList = append(itemList, &pb.Item{ItemId: itemId, ItemNum: itemNum})
|
||||
}
|
||||
|
||||
if len(itemList) > 0 {
|
||||
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailReceiveAll, &pb.MailReceiveAck{
|
||||
ItemList: itemList,
|
||||
})
|
||||
}
|
||||
|
||||
if len(changeList) > 0 {
|
||||
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{
|
||||
ChangeList: changeList,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (this *PlayerHandler) MailDelete(player *logic.Player, msg *net.Message) {
|
||||
var req = new(pb.MailDeleteReq)
|
||||
var err = msg.Read(req)
|
||||
if err != nil {
|
||||
this.logger.Error("Read message failed, ", err)
|
||||
_ = player.TipNotice(proto.TipMessageError)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Uid == 0 {
|
||||
this.logger.Error("Parameter error, req.Uid == 0")
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
}
|
||||
|
||||
var mail = player.Mail[req.Uid]
|
||||
if mail == nil {
|
||||
//this.logger.Error("Parameter error, Player 'Mail' was not found, req.Uid: ", req.Uid)
|
||||
//_ = player.TipNotice(proto.TipMailNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
if pb.MailType(mail.Type) == pb.MailType_MailAllRegion {
|
||||
if pb.MailStatus(mail.Status) >= pb.MailStatus_Deleted {
|
||||
return
|
||||
}
|
||||
mail.Status = uint32(pb.MailStatus_Deleted)
|
||||
player.SaveModel(mail)
|
||||
} else {
|
||||
delete(player.Mail, req.Uid)
|
||||
player.WipeModel(mail)
|
||||
}
|
||||
|
||||
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{
|
||||
ChangeList: []*pb.MailChange{{Uid: mail.Uid, Status: pb.MailStatus(mail.Status)}},
|
||||
})
|
||||
|
||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
}
|
||||
|
||||
func (this *PlayerHandler) MailDeleteAll(player *logic.Player, _ *net.Message) {
|
||||
var changeList []*pb.MailChange
|
||||
for id, mail := range player.Mail {
|
||||
if pb.MailStatus(mail.Status) < pb.MailStatus_HasRead {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(mail.Items) > 0 {
|
||||
if pb.MailStatus(mail.Status) < pb.MailStatus_Received {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if pb.MailType(mail.Type) == pb.MailType_MailAllRegion {
|
||||
if pb.MailStatus(mail.Status) >= pb.MailStatus_Deleted {
|
||||
continue
|
||||
}
|
||||
mail.Status = uint32(pb.MailStatus_Deleted)
|
||||
player.SaveModel(mail)
|
||||
} else {
|
||||
delete(player.Mail, id)
|
||||
player.WipeModel(mail)
|
||||
}
|
||||
|
||||
changeList = append(changeList, &pb.MailChange{Uid: id, Status: pb.MailStatus_Deleted})
|
||||
|
||||
//this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
}
|
||||
|
||||
if len(changeList) > 0 {
|
||||
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{ChangeList: changeList})
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ func (this *PlayerHandler) RoleChangeLanguage(player *logic.Player, msg *net.Mes
|
||||
player.SaveField("language", player.Language)
|
||||
}
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleChangeLanguage), &pb.RoleChangeLanguageAck{Language: player.Language})
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleChangeLanguage, &pb.RoleChangeLanguageAck{Language: player.Language})
|
||||
return
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ func (this *PlayerHandler) RoleChangeName(player *logic.Player, msg *net.Message
|
||||
player.SaveField("role_name", player.RoleName)
|
||||
}
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleChangeRoleName), &pb.RoleChangeRoleNameAck{RoleName: player.RoleName})
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleChangeRoleName, &pb.RoleChangeRoleNameAck{RoleName: player.RoleName})
|
||||
return
|
||||
}
|
||||
|
||||
@ -195,10 +195,10 @@ func (this *PlayerHandler) LineupHeroChange(player *logic.Player, msg *net.Messa
|
||||
|
||||
//TODO lineup hero capacity
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
|
||||
})
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: heroChangeList,
|
||||
})
|
||||
}
|
||||
@ -227,7 +227,11 @@ func (this *PlayerHandler) LineupHeroPosition(player *logic.Player, msg *net.Mes
|
||||
|
||||
var setups [7]bool
|
||||
for i := range req.PositionList {
|
||||
if req.PositionList[i] < 1 || req.PositionList[i] > 6 {
|
||||
if req.PositionList[i] == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if req.PositionList[i] > 6 {
|
||||
this.logger.Errorf("Parameter error, req.PositionList[%d]: %d", i, req.PositionList[i])
|
||||
_ = player.TipNotice(proto.TipParameterError)
|
||||
return
|
||||
@ -242,15 +246,19 @@ func (this *PlayerHandler) LineupHeroPosition(player *logic.Player, msg *net.Mes
|
||||
setups[req.PositionList[i]] = true
|
||||
}
|
||||
|
||||
var ack = &pb.LineupHeroPositionAck{LineupUid: lineup.Uid, PositionList: make([]uint32, 6)}
|
||||
for i := range 6 {
|
||||
if lineup.Heroes[i] != nil {
|
||||
lineup.Heroes[i].Position = req.PositionList[i]
|
||||
ack.PositionList[i] = lineup.Heroes[i].Position
|
||||
}
|
||||
}
|
||||
|
||||
player.SaveField("lineup.heroes", lineup.Heroes)
|
||||
player.SaveModelField(lineup, "heroes", lineup.Heroes)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroPosition, ack)
|
||||
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
|
||||
})
|
||||
}
|
||||
@ -379,11 +387,11 @@ func (this *PlayerHandler) LineupHeroEquip(player *logic.Player, msg *net.Messag
|
||||
})
|
||||
}
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
|
||||
})
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipChange), &pb.EquipChangeListAck{ChangeList: equipChangeList})
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{ChangeList: heroChangeList})
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipChange, &pb.EquipChangeListAck{ChangeList: equipChangeList})
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{ChangeList: heroChangeList})
|
||||
return
|
||||
}
|
||||
|
||||
@ -512,11 +520,11 @@ func (this *PlayerHandler) LineupHeroTreasure(player *logic.Player, msg *net.Mes
|
||||
})
|
||||
}
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
|
||||
})
|
||||
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{ChangeList: equipChangeList})
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{ChangeList: heroChangeList})
|
||||
_ = player.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureChange, &pb.TreasureChangeListAck{ChangeList: equipChangeList})
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{ChangeList: heroChangeList})
|
||||
return
|
||||
}
|
||||
|
||||
@ -589,10 +597,10 @@ func (this *PlayerHandler) LineupHelperChange(player *logic.Player, msg *net.Mes
|
||||
|
||||
player.SaveModel(lineup)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
|
||||
})
|
||||
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: heroChangeList,
|
||||
})
|
||||
player.SendLineupHeroChange(lineup)
|
||||
@ -660,7 +668,7 @@ func (this *PlayerHandler) LineupCreate(player *logic.Player, msg *net.Message)
|
||||
|
||||
changeList = append(changeList, &pb.LineupChange{ChangeType: pb.ChangeType_Add, Lineup: newLineup.BuildMsgLineup()})
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{ChangeList: changeList})
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{ChangeList: changeList})
|
||||
}
|
||||
|
||||
func (this *PlayerHandler) LineupChangeName(player *logic.Player, msg *net.Message) {
|
||||
@ -695,7 +703,7 @@ func (this *PlayerHandler) LineupChangeName(player *logic.Player, msg *net.Messa
|
||||
|
||||
player.SaveModel(lineup)
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Add, Lineup: lineup.BuildMsgLineup()}},
|
||||
})
|
||||
}
|
||||
@ -745,7 +753,7 @@ func (this *PlayerHandler) LineupActivate(player *logic.Player, msg *net.Message
|
||||
player.SaveModel(lineup)
|
||||
lineupChangeList = append(lineupChangeList, &pb.LineupChange{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()})
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
|
||||
})
|
||||
|
||||
@ -802,7 +810,7 @@ func (this *PlayerHandler) LineupDelete(player *logic.Player, msg *net.Message)
|
||||
player.WipeModel(lineup)
|
||||
lineupChangeList = append(lineupChangeList, &pb.LineupChange{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()})
|
||||
|
||||
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
|
||||
_ = player.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChange, &pb.LineupChangeListAck{
|
||||
ChangeList: lineupChangeList,
|
||||
})
|
||||
|
||||
|
@ -2,6 +2,7 @@ package logic
|
||||
|
||||
import (
|
||||
"ecs/proto"
|
||||
"ecs/proto/pb"
|
||||
"ecs/servers/game/data"
|
||||
"github.com/oylshe1314/framework/client/db"
|
||||
"github.com/oylshe1314/framework/errors"
|
||||
@ -246,8 +247,8 @@ func (this *PlayerManager) NewPlayer() *Player {
|
||||
Equip: map[uint64]*PlayerEquip{},
|
||||
//GiftPack: map[uint32]*PlayerGiftPack{},
|
||||
Lineup: map[uint64]*PlayerLineup{},
|
||||
//Mail: map[uint64]*PlayerMail{},
|
||||
Money: map[uint32]*PlayerMoney{},
|
||||
Mail: map[uint64]*PlayerMail{},
|
||||
Money: map[uint32]*PlayerMoney{},
|
||||
//MonthlyCard: map[uint32]*PlayerMonthlyCard{},
|
||||
//Planet: map[uint32]*PlayerPlanet{},
|
||||
//RawStone: map[uint32]*PlayerRawStone{},
|
||||
@ -523,8 +524,8 @@ func (this *PlayerManager) Unban(player *Player) {
|
||||
this.storeChanges(player)
|
||||
}
|
||||
|
||||
func (this *PlayerManager) Handler(modId, msgId uint16, handler MessageHandler) {
|
||||
this.messageHandlers[util.Compose2uint16(modId, msgId)] = handler
|
||||
func (this *PlayerManager) Handler(modId pb.ModId, msgId pb.MsgId, handler MessageHandler) {
|
||||
this.messageHandlers[util.Compose2uint16(uint16(modId), uint16(msgId))] = handler
|
||||
}
|
||||
|
||||
func (this *PlayerManager) Handle(player *Player, msg *net.Message) {
|
||||
|
@ -74,8 +74,8 @@ type Player struct {
|
||||
Equip map[uint64]*PlayerEquip `bson:"equip"`
|
||||
//GiftPack map[uint32]*PlayerGiftPack `bson:"gift_pack"`
|
||||
Lineup map[uint64]*PlayerLineup `bson:"lineup"`
|
||||
//Mail map[uint64]*PlayerMail `bson:"mail"`
|
||||
Money map[uint32]*PlayerMoney `bson:"money"`
|
||||
Mail map[uint64]*PlayerMail `bson:"mail"`
|
||||
Money map[uint32]*PlayerMoney `bson:"money"`
|
||||
//MonthlyCard map[uint32]*PlayerMonthlyCard `bson:"monthly_card"`
|
||||
//Planet map[uint32]*PlayerPlanet `bson:"planet"`
|
||||
//RawStone map[uint32]*PlayerRawStone `bson:"raw_stone"`
|
||||
@ -119,11 +119,11 @@ func (this *Player) Uid() uint64 {
|
||||
return this.RoleId
|
||||
}
|
||||
|
||||
func (this *Player) Send(modId, msgId uint16, msg interface{}) (err error) {
|
||||
func (this *Player) Send(modId pb.ModId, msgId pb.MsgId, msg interface{}) (err error) {
|
||||
if this.conn == nil {
|
||||
return nil
|
||||
}
|
||||
return this.conn.Send(modId, msgId, msg)
|
||||
return this.conn.Send(uint16(modId), uint16(msgId), msg)
|
||||
}
|
||||
|
||||
func (this *Player) TipNotice(err proto.TipError) error {
|
||||
@ -142,12 +142,12 @@ func (this *Player) unlock() {
|
||||
func (this *Player) sync() {
|
||||
|
||||
//Role module
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleProperty), this.BuildMsgRolePropertyAck())
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleMoneyList), this.BuildMsgMoneyListAck())
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupList), this.BuildMsgLineupListAck())
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleProperty, this.BuildMsgRolePropertyAck())
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyList, this.BuildMsgMoneyListAck())
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupList, this.BuildMsgLineupListAck())
|
||||
|
||||
//Level module
|
||||
_ = this.Send(uint16(pb.ModId_ModuleLevel), uint16(pb.MsgId_ModLevelCopyStatusList), this.BuildMsgCopyStatusListAck())
|
||||
_ = this.Send(pb.ModId_ModuleLevel, pb.MsgId_ModLevelCopyStatusList, this.BuildMsgCopyStatusListAck())
|
||||
//_ = this.Send(proto.ModIdLevel, proto.MsgIdCopySpeedStatusList, this.BuildMsgCopySpeedStatusListAck())
|
||||
//_ = this.Send(proto.ModIdLevel, proto.MsgIdPlanetList, this.BuildMsgPlanetListAck())
|
||||
//_ = this.Send(proto.ModIdLevel, proto.MsgIdPlanetRawStoneStatus, this.BuildMsgPlanetRawStoneStatusListAck())
|
||||
@ -157,8 +157,8 @@ func (this *Player) sync() {
|
||||
//_ = this.Send(proto.ModIdBattle, proto.MsgIdIdleBattleStatus, this.BuildMsgIdleBattleStatusAck())
|
||||
|
||||
//Hero module
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroList), this.BuildMsgHeroListAck())
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroBookList), this.BuildMsgHeroBookListAck())
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroList, this.BuildMsgHeroListAck())
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroBookList, this.BuildMsgHeroBookListAck())
|
||||
//_ = this.Send(proto.ModIdRig, proto.MsgIdRigComponentList, this.BuildMsgRigComponentListAck())
|
||||
//_ = this.Send(proto.ModIdRig, proto.MsgIdRigEquipList, this.BuildMsgRigEquipListAck())
|
||||
//_ = this.Send(proto.ModIdRig, proto.MsgIdRigRemainsList, this.BuildMsgRigRemainsListAck())
|
||||
@ -171,12 +171,12 @@ func (this *Player) sync() {
|
||||
//_ = this.Send(proto.ModIdRig, proto.MsgIdRigWarshipList, this.BuildMsgWarshipListAck())
|
||||
|
||||
//Item module
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemList), this.BuildMsgItemListAck())
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipList), this.BuildMsgEquipListAck())
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureList), this.BuildMsgTreasureListAck())
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemList, this.BuildMsgItemListAck())
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipList, this.BuildMsgEquipListAck())
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureList, this.BuildMsgTreasureListAck())
|
||||
|
||||
//Counter module
|
||||
_ = this.Send(uint16(pb.ModId_ModuleCounter), uint16(pb.MsgId_ModCounterList), this.BuildMsgCounterListAck())
|
||||
_ = this.Send(pb.ModId_ModuleCounter, pb.MsgId_ModCounterList, this.BuildMsgCounterListAck())
|
||||
|
||||
////Mail module
|
||||
//_ = this.Send(proto.ModIdMail, proto.MsgIdMailList, this.BuildMsgMailListAck())
|
||||
@ -297,7 +297,7 @@ func (this *Player) exit() {
|
||||
}
|
||||
|
||||
func (this *Player) kick(message string) {
|
||||
_ = this.Send(uint16(pb.ModId_ModuleLogin), uint16(pb.MsgId_ModLoginKickOut), &pb.KickOutAck{Message: message})
|
||||
_ = this.Send(pb.ModId_ModuleLogin, pb.MsgId_ModLoginKickOut, &pb.KickOutAck{Message: message})
|
||||
this.exit()
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ func (this *Player) SaveArray(field string, index int, value interface{}) {
|
||||
this.SaveField(fmt.Sprint(field, ".", index), value)
|
||||
}
|
||||
|
||||
func (this *Player) SaveModel(model interface{}, fields ...string) {
|
||||
func (this *Player) SaveModel(model interface{}) {
|
||||
key, err := this.modelKey(model)
|
||||
if err != nil {
|
||||
this.manager.logger.Error("Failed to get the key of the model that will be saved, ", err)
|
||||
@ -387,12 +387,21 @@ func (this *Player) SaveModel(model interface{}, fields ...string) {
|
||||
this.SaveField(key, model)
|
||||
}
|
||||
|
||||
func (this *Player) WipeField(field string, value interface{}) {
|
||||
this.wipe[field] = value
|
||||
func (this *Player) SaveModelField(model interface{}, field string, value interface{}) {
|
||||
key, err := this.modelKey(model)
|
||||
if err != nil {
|
||||
this.manager.logger.Error("Failed to get the key of the model that will be saved, ", err)
|
||||
return
|
||||
}
|
||||
this.SaveField(fmt.Sprint(key, ".", field), value)
|
||||
}
|
||||
|
||||
func (this *Player) WipeArray(field string, index int, value interface{}) {
|
||||
this.WipeField(fmt.Sprint(field, ".", index), value)
|
||||
func (this *Player) WipeField(field string) {
|
||||
this.wipe[field] = 1
|
||||
}
|
||||
|
||||
func (this *Player) WipeArray(field string, index int) {
|
||||
this.WipeField(fmt.Sprint(field, ".", index))
|
||||
}
|
||||
|
||||
func (this *Player) WipeModel(model interface{}) {
|
||||
@ -402,5 +411,5 @@ func (this *Player) WipeModel(model interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
this.WipeField(key, model)
|
||||
this.WipeField(key)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"ecs/proto/pb"
|
||||
"ecs/servers/game/data"
|
||||
"github.com/oylshe1314/framework/util"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func (this *Player) EnterBattle(sceneTable *data.Scene) {
|
||||
@ -32,25 +33,66 @@ func (this *Player) copyBattle(sceneTable *data.Scene) {
|
||||
this.PassedCopy(sceneTable, ack.Score)
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleBattle), uint16(pb.MsgId_ModBattleEnter), ack)
|
||||
_ = this.Send(pb.ModId_ModuleBattle, pb.MsgId_ModBattleEnter, ack)
|
||||
}
|
||||
|
||||
type _BattleBuff struct {
|
||||
id uint32
|
||||
id uint32
|
||||
targetType uint32
|
||||
targetArgs []uint32
|
||||
rangeType uint32
|
||||
rangeNum uint32
|
||||
priorityType []uint32
|
||||
priorityArgs []uint32
|
||||
buffType uint32
|
||||
buffArgs []int64
|
||||
durationType uint32
|
||||
duration uint32
|
||||
canMerge bool
|
||||
canCover bool
|
||||
canStack bool
|
||||
canClean bool
|
||||
}
|
||||
|
||||
type _BattleSkill struct {
|
||||
id uint32
|
||||
tipe uint32
|
||||
rage uint32
|
||||
buffs []*_BattleBuff
|
||||
}
|
||||
|
||||
type _BattleUnit struct {
|
||||
id uint64
|
||||
attrs Attrs
|
||||
id uint64
|
||||
position uint32
|
||||
gender uint32
|
||||
country uint32
|
||||
hp uint64
|
||||
rage uint32
|
||||
speed uint32
|
||||
baseSpeed uint32
|
||||
posSpeed uint32
|
||||
amuletSpeed uint32
|
||||
harnessSpeed uint32
|
||||
|
||||
attrs Attrs
|
||||
|
||||
role *_BattleRole
|
||||
|
||||
buffs []*_BattleBuff
|
||||
deBuffs []*_BattleBuff
|
||||
|
||||
attackSkills []*_BattleSkill
|
||||
passiveSkills []*_BattleSkill
|
||||
}
|
||||
|
||||
type _BattleRole struct {
|
||||
attacker bool
|
||||
addSpeed uint32
|
||||
capacity uint64
|
||||
unitList []*_BattleUnit
|
||||
//sellList []*_BattleUnit
|
||||
}
|
||||
|
||||
func (this *Player) virtualBattle(sceneTable *data.Scene) (ack *pb.BattleEnterAck, tip proto.TipError) {
|
||||
var lineup = util.MapFindValue(this.Lineup, func(lineup *PlayerLineup) bool {
|
||||
return lineup.Active
|
||||
@ -59,110 +101,177 @@ func (this *Player) virtualBattle(sceneTable *data.Scene) (ack *pb.BattleEnterAc
|
||||
return nil, proto.TipLineupNotFound
|
||||
}
|
||||
|
||||
var heroes = make([]*_BattleUnit, 6)
|
||||
for i := range 6 {
|
||||
if lineup.Heroes[i] != nil {
|
||||
if hero := this.Hero[lineup.Heroes[i].HeroUid]; hero != nil {
|
||||
heroes[lineup.Heroes[i].Position-1] = &_BattleUnit{
|
||||
id: lineup.Heroes[i].HeroUid,
|
||||
attrs: hero.Attrs(),
|
||||
}
|
||||
}
|
||||
}
|
||||
var me = &_BattleRole{attacker: true}
|
||||
me.capacity, me.unitList, tip = this.loadHeroes(me, lineup)
|
||||
if tip != nil {
|
||||
_ = this.TipNotice(tip)
|
||||
return
|
||||
}
|
||||
|
||||
var enemies []*_BattleUnit
|
||||
//sort.Slice(me.unitList, func(i, j int) bool {
|
||||
// return me.unitList[i].pos < me.unitList[j].pos
|
||||
//})
|
||||
|
||||
var he = &_BattleRole{attacker: false}
|
||||
if pb.CopyType(sceneTable.CopyType) == pb.CopyType_CopyArena {
|
||||
|
||||
} else {
|
||||
enemies, tip = this.loadMonsters([]int{sceneTable.Monster1, sceneTable.Monster2, sceneTable.Monster3, sceneTable.Monster4, sceneTable.Monster5, sceneTable.Monster6})
|
||||
he.capacity, he.unitList, tip = this.loadMonsters(he, []int{sceneTable.Monster1, sceneTable.Monster2, sceneTable.Monster3, sceneTable.Monster4, sceneTable.Monster5, sceneTable.Monster6})
|
||||
if tip != nil {
|
||||
_ = this.TipNotice(tip)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//sort.Slice(he.unitList, func(i, j int) bool {
|
||||
// return he.unitList[i].pos < he.unitList[j].pos
|
||||
//})
|
||||
|
||||
ack = &pb.BattleEnterAck{
|
||||
SceneId: uint32(sceneTable.Id),
|
||||
RewardList: nil,
|
||||
SceneId: uint32(sceneTable.Id),
|
||||
}
|
||||
|
||||
ack.Heroes = make([]*pb.BattleUnit, 6)
|
||||
ack.Enemies = make([]*pb.BattleUnit, 6)
|
||||
for i := range 6 {
|
||||
if heroes[i] != nil {
|
||||
ack.Heroes[i] = &pb.BattleUnit{UnitId: heroes[i].id}
|
||||
}
|
||||
if enemies[i] != nil {
|
||||
ack.Enemies[i] = &pb.BattleUnit{UnitId: enemies[i].id}
|
||||
for i := range me.unitList {
|
||||
if me.unitList[i] != nil {
|
||||
ack.Heroes[i] = &pb.BattleUnit{
|
||||
UnitId: me.unitList[i].id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ack.Succeed, ack.Score, ack.RoundList = this.calcBattle(heroes, enemies)
|
||||
ack.BattleRounds = uint32(len(ack.RoundList))
|
||||
ack.Enemies = make([]*pb.BattleUnit, 6)
|
||||
for i := range he.unitList {
|
||||
if he.unitList[i] != nil {
|
||||
ack.Enemies[i] = &pb.BattleUnit{
|
||||
UnitId: he.unitList[i].id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(me.unitList) == 0 {
|
||||
ack.Succeed = false
|
||||
ack.Score = 0
|
||||
} else if len(he.unitList) == 0 {
|
||||
ack.Succeed = true
|
||||
ack.Score = 3
|
||||
} else {
|
||||
var calculator = &_BattleCalculator{
|
||||
rd: util.NewRand(),
|
||||
me: me,
|
||||
he: he,
|
||||
}
|
||||
ack.Succeed, ack.RoundList = calculator.calcBattle(sceneTable.BattleRound, me, he)
|
||||
ack.BattleRounds = uint32(len(ack.RoundList))
|
||||
|
||||
if ack.Succeed {
|
||||
//TODO calc stars
|
||||
ack.Score = 2
|
||||
if me.unitList[0].hp > 0 {
|
||||
ack.Score = 3
|
||||
}
|
||||
|
||||
this.addExp(this.RoleLevel*uint32(sceneTable.ExpMultiple), LogTypeItemObtainByCopy)
|
||||
this.addMoney(pb.MoneyType_Coin, this.RoleLevel*uint32(sceneTable.CoinMultiple), LogTypeItemObtainByCopy)
|
||||
|
||||
//TODO calc reward
|
||||
var rewardItems = map[uint32]uint32{}
|
||||
if this.GetCopyPassed(pb.CopyType(sceneTable.CopyType), uint32(sceneTable.CopyId)) == 0 {
|
||||
var dropResult = this.manager.tables.Drop.Drop(sceneTable.FirstDrop, 1)
|
||||
for _, items := range dropResult {
|
||||
rewardItems[uint32(items[0])] += uint32(items[1])
|
||||
ack.RewardList = append(ack.RewardList, &pb.Item{
|
||||
ItemId: uint32(items[0]),
|
||||
ItemNum: uint32(items[1]),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var dropResult = this.manager.tables.Drop.Drop(sceneTable.PassDrop, 1)
|
||||
for _, items := range dropResult {
|
||||
rewardItems[uint32(items[0])] += uint32(items[1])
|
||||
ack.RewardList = append(ack.RewardList, &pb.Item{
|
||||
ItemId: uint32(items[0]),
|
||||
ItemNum: uint32(items[1]),
|
||||
})
|
||||
}
|
||||
|
||||
this.AddItems(rewardItems, LogTypeItemObtainByCopy)
|
||||
}
|
||||
}
|
||||
|
||||
return ack, nil
|
||||
}
|
||||
|
||||
func (this *Player) calcBattle(heroes, enemies []*_BattleUnit) (bool, int32, []*pb.BattleRound) {
|
||||
return true, 3, []*pb.BattleRound{
|
||||
{
|
||||
BattleRound: 1,
|
||||
ActionList: []*pb.BattleAction{
|
||||
{
|
||||
Caster: &pb.BattleTarget{
|
||||
Type: 1,
|
||||
Id: heroes[0].id,
|
||||
HpMax: heroes[0].attrs[pb.AttrType_Hp],
|
||||
Rage: 0,
|
||||
Status: nil,
|
||||
Value: nil,
|
||||
Hp: nil,
|
||||
},
|
||||
Type: 0,
|
||||
SkillId: 100021,
|
||||
TargetList: []*pb.BattleTarget{
|
||||
{
|
||||
Type: 2,
|
||||
Id: enemies[0].id,
|
||||
HpMax: enemies[0].attrs[pb.AttrType_Hp],
|
||||
Rage: 0,
|
||||
Status: nil,
|
||||
Value: []uint64{heroes[0].attrs[pb.AttrType_Attack]},
|
||||
Hp: []uint64{enemies[0].attrs[pb.AttrType_Hp] - heroes[0].attrs[pb.AttrType_Attack]},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Caster: &pb.BattleTarget{
|
||||
Type: 2,
|
||||
Id: enemies[1].id,
|
||||
HpMax: enemies[1].attrs[pb.AttrType_Hp],
|
||||
Rage: 0,
|
||||
Status: nil,
|
||||
Value: nil,
|
||||
Hp: nil,
|
||||
},
|
||||
Type: 0,
|
||||
SkillId: 100191,
|
||||
TargetList: []*pb.BattleTarget{
|
||||
{
|
||||
Type: 1,
|
||||
Id: heroes[0].id,
|
||||
HpMax: heroes[0].attrs[pb.AttrType_Hp],
|
||||
Rage: 0,
|
||||
Status: nil,
|
||||
Value: []uint64{enemies[1].attrs[pb.AttrType_Attack]},
|
||||
Hp: []uint64{heroes[0].attrs[pb.AttrType_Hp] - enemies[1].attrs[pb.AttrType_Attack]},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
func (this *Player) calcAttrsCapacity(attrs Attrs) uint64 {
|
||||
return uint64((float64(attrs[pb.AttrType_Attack]) * 2) +
|
||||
(float64(attrs[pb.AttrType_Hp]) * 0.2) +
|
||||
(float64(attrs[pb.AttrType_PhysicalDefense]) * 6) +
|
||||
(float64(attrs[pb.AttrType_MagicDefense]) * 6) +
|
||||
(float64(attrs[pb.AttrType_DamageRatio]) * 12) +
|
||||
(float64(attrs[pb.AttrType_DamageRelief]) * 12) +
|
||||
(float64(attrs[pb.AttrType_CriticalRate]) * 12) +
|
||||
(float64(attrs[pb.AttrType_CriticalResistance]) * 12) +
|
||||
(float64(attrs[pb.AttrType_CriticalDamage]) * 12) +
|
||||
(float64(attrs[pb.AttrType_CriticalDamageRelief]) * 12) +
|
||||
(float64(attrs[pb.AttrType_HitRate]) * 12) +
|
||||
(float64(attrs[pb.AttrType_DodgeRate]) * 12) +
|
||||
(float64(attrs[pb.AttrType_TreatRatio]) * 12) +
|
||||
(float64(attrs[pb.AttrType_ByTreatedRate]) * 12) +
|
||||
(float64(attrs[pb.AttrType_FinalDamageRatio]) * 12))
|
||||
}
|
||||
|
||||
func (this *Player) loadMonsters(monsterIds []int) (unitList []*_BattleUnit, tip proto.TipError) {
|
||||
unitList = make([]*_BattleUnit, len(monsterIds))
|
||||
func (this *Player) loadHeroes(role *_BattleRole, lineup *PlayerLineup) (capacity uint64, unitList []*_BattleUnit, tip proto.TipError) {
|
||||
unitList = make([]*_BattleUnit, 6)
|
||||
|
||||
var heroIndex = 0
|
||||
for i := range 6 {
|
||||
if lineup.Heroes[i] != nil {
|
||||
if hero := this.Hero[lineup.Heroes[i].HeroUid]; hero != nil {
|
||||
capacity += lineup.Heroes[i].Capacity
|
||||
var unit = &_BattleUnit{
|
||||
id: lineup.Heroes[i].HeroUid,
|
||||
position: lineup.Heroes[i].Position,
|
||||
attrs: hero.Attrs(),
|
||||
role: role,
|
||||
}
|
||||
|
||||
var heroTable = this.manager.tables.Hero.Find1(int(hero.Id))
|
||||
if heroTable == nil {
|
||||
return 0, nil, proto.TipDataTablesError
|
||||
}
|
||||
|
||||
unit.gender = uint32(heroTable.Sex)
|
||||
unit.country = uint32(heroTable.Country)
|
||||
|
||||
unit.attackSkills, tip = this.loadSkills(heroTable.Skill)
|
||||
if tip != nil {
|
||||
return
|
||||
}
|
||||
|
||||
sort.Slice(unit.attackSkills, func(i, j int) bool {
|
||||
return unit.attackSkills[i].tipe > unit.attackSkills[j].tipe
|
||||
})
|
||||
|
||||
unit.hp = unit.attrs[pb.AttrType_Hp]
|
||||
unit.rage = 4
|
||||
unit.baseSpeed = 100
|
||||
unit.posSpeed = uint32(20 - 4*heroIndex)
|
||||
unit.amuletSpeed = 0 //TODO calc speed
|
||||
unit.harnessSpeed = 0 //TODO calc speed
|
||||
|
||||
//TODO load hero passive skills, from equip, break, soul
|
||||
|
||||
unitList[lineup.Heroes[i].Position-1] = unit
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Player) loadMonsters(role *_BattleRole, monsterIds []int) (capacity uint64, unitList []*_BattleUnit, tip proto.TipError) {
|
||||
unitList = make([]*_BattleUnit, 6)
|
||||
var monsterIndex uint64 = 0
|
||||
for i, monsterId := range monsterIds {
|
||||
if monsterId == 0 {
|
||||
continue
|
||||
@ -170,16 +279,26 @@ func (this *Player) loadMonsters(monsterIds []int) (unitList []*_BattleUnit, tip
|
||||
|
||||
var monsterTable = this.manager.tables.Monster.Find(int(monsterId))
|
||||
if monsterTable == nil {
|
||||
return nil, proto.TipDataTablesError
|
||||
return 0, nil, proto.TipDataTablesError
|
||||
}
|
||||
|
||||
var unit = &_BattleUnit{id: uint64(monsterTable.Id)}
|
||||
var unit = &_BattleUnit{
|
||||
id: uint64(monsterTable.Id),
|
||||
position: uint32(i + 1),
|
||||
gender: uint32(monsterTable.Gender),
|
||||
country: uint32(monsterTable.Country),
|
||||
role: role,
|
||||
}
|
||||
|
||||
unit.attackSkills, tip = this.loadSkills(monsterTable.AttackSkills)
|
||||
if tip != nil {
|
||||
return
|
||||
}
|
||||
|
||||
sort.Slice(unit.attackSkills, func(i, j int) bool {
|
||||
return unit.attackSkills[i].tipe > unit.attackSkills[j].tipe
|
||||
})
|
||||
|
||||
unit.passiveSkills, tip = this.loadSkills(monsterTable.PassiveSkills)
|
||||
if tip != nil {
|
||||
return
|
||||
@ -187,24 +306,34 @@ func (this *Player) loadMonsters(monsterIds []int) (unitList []*_BattleUnit, tip
|
||||
|
||||
unit.attrs[pb.AttrType_Attack] = uint64(monsterTable.AttrValue1)
|
||||
unit.attrs[pb.AttrType_Hp] = uint64(monsterTable.AttrValue2)
|
||||
unit.attrs[pb.AttrType_AttrPhysicalDefense] = uint64(monsterTable.AttrValue3)
|
||||
unit.attrs[pb.AttrType_AttrMagicDefense] = uint64(monsterTable.AttrValue4)
|
||||
unit.attrs[pb.AttrType_AttrAttackRatio] = uint64(monsterTable.AttrValue5)
|
||||
unit.attrs[pb.AttrType_AttrHpRatio] = uint64(monsterTable.AttrValue6)
|
||||
unit.attrs[pb.AttrType_AttrPhysicalDefenseRatio] = uint64(monsterTable.AttrValue7)
|
||||
unit.attrs[pb.AttrType_AttrMagicDefenseRatio] = uint64(monsterTable.AttrValue8)
|
||||
unit.attrs[pb.AttrType_AttrDamageRatio] = uint64(monsterTable.AttrValue9)
|
||||
unit.attrs[pb.AttrType_AttrDamageRelief] = uint64(monsterTable.AttrValue10)
|
||||
unit.attrs[pb.AttrType_AttrCriticalRatio] = uint64(monsterTable.AttrValue11)
|
||||
unit.attrs[pb.AttrType_AttrCriticalResistance] = uint64(monsterTable.AttrValue12)
|
||||
unit.attrs[pb.AttrType_AttrCriticalDamage] = uint64(monsterTable.AttrValue13)
|
||||
unit.attrs[pb.AttrType_AttrCriticalDamageRelief] = uint64(monsterTable.AttrValue14)
|
||||
unit.attrs[pb.AttrType_AttrHitRate] = uint64(monsterTable.AttrValue15)
|
||||
unit.attrs[pb.AttrType_AttrDodgeRate] = uint64(monsterTable.AttrValue16)
|
||||
unit.attrs[pb.AttrType_AttrTreatRatio] = uint64(monsterTable.AttrValue17)
|
||||
unit.attrs[pb.AttrType_AttrByTreatedRatio] = uint64(monsterTable.AttrValue18)
|
||||
unit.attrs[pb.AttrType_AttrFinalDamageRatio] = uint64(monsterTable.AttrValue19)
|
||||
unit.attrs[pb.AttrType_AttrFinalDamageRelief] = uint64(monsterTable.AttrValue20)
|
||||
unit.attrs[pb.AttrType_PhysicalDefense] = uint64(monsterTable.AttrValue3)
|
||||
unit.attrs[pb.AttrType_MagicDefense] = uint64(monsterTable.AttrValue4)
|
||||
unit.attrs[pb.AttrType_AttackRatio] = uint64(monsterTable.AttrValue5)
|
||||
unit.attrs[pb.AttrType_HpRatio] = uint64(monsterTable.AttrValue6)
|
||||
unit.attrs[pb.AttrType_PhysicalDefenseRatio] = uint64(monsterTable.AttrValue7)
|
||||
unit.attrs[pb.AttrType_MagicDefenseRatio] = uint64(monsterTable.AttrValue8)
|
||||
unit.attrs[pb.AttrType_DamageRatio] = uint64(monsterTable.AttrValue9)
|
||||
unit.attrs[pb.AttrType_DamageRelief] = uint64(monsterTable.AttrValue10)
|
||||
unit.attrs[pb.AttrType_CriticalRate] = uint64(monsterTable.AttrValue11)
|
||||
unit.attrs[pb.AttrType_CriticalResistance] = uint64(monsterTable.AttrValue12)
|
||||
unit.attrs[pb.AttrType_CriticalDamage] = uint64(monsterTable.AttrValue13)
|
||||
unit.attrs[pb.AttrType_CriticalDamageRelief] = uint64(monsterTable.AttrValue14)
|
||||
unit.attrs[pb.AttrType_HitRate] = uint64(monsterTable.AttrValue15)
|
||||
unit.attrs[pb.AttrType_DodgeRate] = uint64(monsterTable.AttrValue16)
|
||||
unit.attrs[pb.AttrType_TreatRatio] = uint64(monsterTable.AttrValue17)
|
||||
unit.attrs[pb.AttrType_ByTreatedRate] = uint64(monsterTable.AttrValue18)
|
||||
unit.attrs[pb.AttrType_FinalDamageRatio] = uint64(monsterTable.AttrValue19)
|
||||
unit.attrs[pb.AttrType_FinalDamageRelief] = uint64(monsterTable.AttrValue20)
|
||||
monsterIndex += 1
|
||||
|
||||
unit.hp = unit.attrs[pb.AttrType_Hp]
|
||||
unit.rage = 4
|
||||
unit.baseSpeed = 0
|
||||
unit.posSpeed = uint32(20 - 4*monsterIndex)
|
||||
unit.amuletSpeed = 0 //TODO calc speed
|
||||
unit.harnessSpeed = 0 //TODO calc speed
|
||||
|
||||
capacity += this.calcAttrsCapacity(unit.attrs)
|
||||
|
||||
unitList[i] = unit
|
||||
}
|
||||
@ -212,7 +341,7 @@ func (this *Player) loadMonsters(monsterIds []int) (unitList []*_BattleUnit, tip
|
||||
}
|
||||
|
||||
func (this *Player) loadSkills(skillIds []int) (skillList []*_BattleSkill, tip proto.TipError) {
|
||||
skillList = make([]*_BattleSkill, len(skillIds))
|
||||
skillList = make([]*_BattleSkill, 0, len(skillIds))
|
||||
for _, skillId := range skillIds {
|
||||
var skillTable = this.manager.tables.Skill.Find(skillId)
|
||||
if skillTable == nil {
|
||||
@ -220,30 +349,48 @@ func (this *Player) loadSkills(skillIds []int) (skillList []*_BattleSkill, tip p
|
||||
}
|
||||
|
||||
var skill = &_BattleSkill{
|
||||
id: uint32(skillId),
|
||||
id: uint32(skillId),
|
||||
tipe: uint32(skillTable.SkillType),
|
||||
rage: uint32(skillTable.RageConsume),
|
||||
}
|
||||
|
||||
skill.buffs, tip = this.loadSkillsBuff(skillTable.SkillBuff)
|
||||
if tip != nil {
|
||||
return
|
||||
}
|
||||
|
||||
skillList = append(skillList, skill)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Player) loadSkillsBuff(buffIds []int) (buffList []*_BattleBuff, tip proto.TipError) {
|
||||
buffList = make([]*_BattleBuff, len(buffIds))
|
||||
for i, skillId := range buffIds {
|
||||
var buff = this.manager.tables.SkillBuff.Find(skillId)
|
||||
if buff == nil {
|
||||
buffList = make([]*_BattleBuff, 0, len(buffIds))
|
||||
for _, buffId := range buffIds {
|
||||
var buffTable = this.manager.tables.SkillBuff.Find(buffId)
|
||||
if buffTable == nil {
|
||||
return nil, proto.TipDataTablesError
|
||||
}
|
||||
|
||||
var battleBuff = &_BattleBuff{
|
||||
id: uint32(skillId),
|
||||
var buff = &_BattleBuff{
|
||||
id: uint32(buffId),
|
||||
targetType: uint32(buffTable.TargetType),
|
||||
targetArgs: util.NumbersConvert2(buffTable.TargetArgs, uint32(0)),
|
||||
rangeType: uint32(buffTable.RangeType),
|
||||
rangeNum: uint32(buffTable.RangeNum),
|
||||
priorityType: util.NumbersConvert2(buffTable.PriorityType, uint32(0)),
|
||||
priorityArgs: util.NumbersConvert2(buffTable.PriorityArgs, uint32(0)),
|
||||
buffType: uint32(buffTable.BuffType),
|
||||
buffArgs: util.NumbersConvert2(buffTable.BuffArgs, int64(0)),
|
||||
durationType: uint32(buffTable.DurationType),
|
||||
duration: uint32(buffTable.Duration),
|
||||
canMerge: buffTable.CanMerge,
|
||||
canCover: buffTable.CanCover,
|
||||
canStack: buffTable.CanStack,
|
||||
canClean: buffTable.CanClean,
|
||||
}
|
||||
|
||||
buffList[i] = battleBuff
|
||||
buffList = append(buffList, buff)
|
||||
}
|
||||
return buffList, nil
|
||||
}
|
||||
|
490
servers/game/logic/player_battle_calculator.go
Normal file
490
servers/game/logic/player_battle_calculator.go
Normal file
@ -0,0 +1,490 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"ecs/proto/pb"
|
||||
"github.com/oylshe1314/framework/util"
|
||||
"math/rand/v2"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type _BattleCalculator struct {
|
||||
rd *rand.Rand
|
||||
|
||||
me *_BattleRole
|
||||
he *_BattleRole
|
||||
}
|
||||
|
||||
func (tnis *_BattleCalculator) calcNextCaster(lastIndex int, unitList []*_BattleUnit) (dead bool, newIndex int, caster *_BattleUnit) {
|
||||
dead = true
|
||||
var posIndex = 0
|
||||
for i, unit := range unitList {
|
||||
if i == lastIndex || unit == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if unit.hp > 0 {
|
||||
dead = false
|
||||
posIndex += 1
|
||||
unit.posSpeed = uint32(20 - (4 * posIndex))
|
||||
unit.speed = unit.baseSpeed + unit.posSpeed + unit.amuletSpeed + unit.harnessSpeed
|
||||
|
||||
if lastIndex < 0 || unit.speed <= unitList[lastIndex].speed {
|
||||
if caster == nil || unit.speed > caster.speed {
|
||||
caster = unit
|
||||
newIndex = i
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *_BattleCalculator) calcBattle(rounds int, me, he *_BattleRole) (succeed bool, roundList []*pb.BattleRound) {
|
||||
var roles = [2]*_BattleRole{me, he}
|
||||
|
||||
var ri = 0
|
||||
if he.capacity > me.capacity {
|
||||
ri = 1
|
||||
}
|
||||
|
||||
var dead bool
|
||||
var index = [2]int{-1, -1}
|
||||
var caster, aCaster, bCaster *_BattleUnit
|
||||
for i, unit := range roles[ri].unitList {
|
||||
if unit != nil {
|
||||
unit.speed = unit.baseSpeed + unit.posSpeed + unit.amuletSpeed + unit.harnessSpeed
|
||||
if aCaster == nil || unit.speed > aCaster.speed {
|
||||
aCaster = unit
|
||||
index[ri] = i
|
||||
}
|
||||
}
|
||||
}
|
||||
caster = aCaster
|
||||
for round := range rounds {
|
||||
var battleRound = &pb.BattleRound{BattleRound: uint32(round) + 1}
|
||||
|
||||
dead = false
|
||||
for {
|
||||
var ai, bi = ri, (ri + 1) % 2
|
||||
var battleAction = &pb.BattleAction{}
|
||||
|
||||
battleRound.ActionList = append(battleRound.ActionList, battleAction)
|
||||
|
||||
battleAction.Caster, battleAction.SkillId, battleAction.TargetList = this.calcSkill(caster, roles[ai], roles[bi])
|
||||
|
||||
dead, index[bi], bCaster = this.calcNextCaster(index[bi], roles[bi].unitList)
|
||||
if dead {
|
||||
succeed = bi != 0
|
||||
break
|
||||
}
|
||||
|
||||
dead, index[ai], aCaster = this.calcNextCaster(index[ai], roles[ai].unitList)
|
||||
if dead {
|
||||
succeed = ai != 0
|
||||
break
|
||||
}
|
||||
|
||||
if bCaster == nil {
|
||||
if aCaster == nil {
|
||||
index[ai] = -1
|
||||
index[bi] = -1
|
||||
break
|
||||
} else {
|
||||
caster = aCaster
|
||||
}
|
||||
} else {
|
||||
if aCaster == nil {
|
||||
caster = bCaster
|
||||
ri = bi
|
||||
} else {
|
||||
if aCaster.speed > bCaster.speed {
|
||||
caster = aCaster
|
||||
} else {
|
||||
caster = bCaster
|
||||
ri = bi
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
roundList = append(roundList, battleRound)
|
||||
if dead {
|
||||
break
|
||||
}
|
||||
}
|
||||
return succeed, roundList
|
||||
}
|
||||
|
||||
func (this *_BattleCalculator) calcSkill(unit *_BattleUnit, a, b *_BattleRole) (caster *pb.BattleTarget, skillId uint32, targetList []*pb.BattleTarget) {
|
||||
for _, skill := range unit.attackSkills {
|
||||
if unit.rage < skill.rage {
|
||||
continue
|
||||
}
|
||||
|
||||
switch skill.tipe {
|
||||
case skillTypeAttack:
|
||||
skillId = skill.id
|
||||
caster, targetList = this.calcBuff(unit, skill, a, b)
|
||||
unit.rage += 2
|
||||
case skillTypeActive:
|
||||
skillId = skill.id
|
||||
unit.rage -= skill.rage
|
||||
caster, targetList = this.calcBuff(unit, skill, a, b)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *_BattleCalculator) calcBuff(unit *_BattleUnit, skill *_BattleSkill, a, b *_BattleRole) (caster *pb.BattleTarget, targetList []*pb.BattleTarget) {
|
||||
caster = &pb.BattleTarget{Type: uint32(util.If(unit.role.attacker, 1, 2)), Position: unit.position}
|
||||
|
||||
caster.HpMax = unit.attrs[pb.AttrType_Hp]
|
||||
caster.Rage = unit.rage
|
||||
|
||||
var targetMap = map[uint32]*pb.BattleTarget{}
|
||||
for _, buff := range skill.buffs {
|
||||
if buff.buffType == buffTypeNone || len(buff.buffArgs) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
//switch buff.targetType {
|
||||
//case targetTypeSelf:
|
||||
// targets = []*_BattleUnit{unit}
|
||||
//case targetTypeTeammate:
|
||||
//case targetTypeEnemy:
|
||||
//case targetTypeTeammateGender:
|
||||
// if len(buff.targetArgs) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// for _, teammate := range a.unitList {
|
||||
// if teammate != nil {
|
||||
// if slices.Contains(buff.targetArgs, teammate.gender) {
|
||||
// targets = append(targets, teammate)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//case targetTypeEnemyGender:
|
||||
// if len(buff.targetArgs) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// for _, enemy := range b.unitList {
|
||||
// if enemy != nil {
|
||||
// if slices.Contains(buff.targetArgs, enemy.gender) {
|
||||
// targets = append(targets, enemy)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//case targetTypeTeammateCountry:
|
||||
// if len(buff.targetArgs) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// for _, teammate := range a.unitList {
|
||||
// if teammate != nil {
|
||||
// if slices.Contains(buff.targetArgs, teammate.country) {
|
||||
// targets = append(targets, teammate)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//case targetTypeEnemyCountry:
|
||||
// if len(buff.targetArgs) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// for _, enemy := range b.unitList {
|
||||
// if enemy != nil {
|
||||
// if slices.Contains(buff.targetArgs, enemy.country) {
|
||||
// targets = append(targets, enemy)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//case targetTypeTeammateStatus:
|
||||
// if len(buff.targetArgs) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// for _, teammate := range a.unitList {
|
||||
// if teammate != nil {
|
||||
// if slices.ContainsFunc(buff.targetArgs, func(targetArg uint32) bool {
|
||||
// return slices.ContainsFunc(teammate.deBuffs, func(buff *_BattleBuff) bool {
|
||||
// return buff.id == targetArg
|
||||
// })
|
||||
// }) {
|
||||
// targets = append(targets, teammate)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//case targetTypeEnemyStatus:
|
||||
// if len(buff.targetArgs) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// for _, enemy := range b.unitList {
|
||||
// if enemy != nil {
|
||||
// if slices.ContainsFunc(buff.targetArgs, func(targetArg uint32) bool {
|
||||
// return slices.ContainsFunc(enemy.deBuffs, func(buff *_BattleBuff) bool {
|
||||
// return buff.id == targetArg
|
||||
// })
|
||||
// }) {
|
||||
// targets = append(targets, enemy)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//case targetTypeAttackRate:
|
||||
//}
|
||||
|
||||
var targets []*_BattleUnit
|
||||
switch buff.buffType {
|
||||
case buffTypePhysicalDamage:
|
||||
if buff.targetType != targetTypeEnemy {
|
||||
continue
|
||||
}
|
||||
targets = this.calcAttackTarget(b.unitList, buff.priorityType, buff.priorityArgs, buff.rangeType, buff.rangeNum)
|
||||
for _, target := range targets {
|
||||
var damage = this.calcDamage(buff, unit, target)
|
||||
this.calcHp(target, damage, targetMap)
|
||||
}
|
||||
case buffTypeMagicDamage:
|
||||
if buff.targetType != targetTypeEnemy {
|
||||
continue
|
||||
}
|
||||
targets = this.calcAttackTarget(b.unitList, buff.priorityType, buff.priorityArgs, buff.rangeType, buff.rangeNum)
|
||||
for _, target := range targets {
|
||||
var damage = this.calcDamage(buff, unit, target)
|
||||
this.calcHp(target, damage, targetMap)
|
||||
}
|
||||
case buffTypeStatusAbnormal:
|
||||
case buffTypeChangeAttr:
|
||||
case buffTypeRevive:
|
||||
case buffTypeDamageReturn:
|
||||
case buffTypeBisect:
|
||||
case buffTypeShield:
|
||||
case buffTypeChangeHp:
|
||||
case buffTypeSteal:
|
||||
case buffTypeAddRage:
|
||||
case buffTypeImmune:
|
||||
case buffTypeUndead:
|
||||
case buffTypeDamageShare:
|
||||
case buffTypeEffectAbnormal:
|
||||
}
|
||||
}
|
||||
for _, target := range targetMap {
|
||||
targetList = append(targetList, target)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *_BattleCalculator) calcHp(unit *_BattleUnit, damage int64, targetMap map[uint32]*pb.BattleTarget) {
|
||||
var newHp = int64(unit.hp) + damage
|
||||
if newHp < 0 {
|
||||
newHp = 0
|
||||
}
|
||||
unit.hp = uint64(newHp)
|
||||
|
||||
var target = targetMap[unit.position]
|
||||
if target == nil {
|
||||
target = &pb.BattleTarget{
|
||||
Type: uint32(util.If(unit.role.attacker, 1, 2)),
|
||||
Position: unit.position,
|
||||
HpMax: unit.attrs[pb.AttrType_Hp],
|
||||
Rage: unit.rage,
|
||||
BuffList: nil,
|
||||
ValueList: nil,
|
||||
}
|
||||
targetMap[target.Position] = target
|
||||
}
|
||||
|
||||
target.ValueList = append(target.ValueList, &pb.BattleValue{
|
||||
Value: damage,
|
||||
Hp: unit.hp,
|
||||
})
|
||||
}
|
||||
|
||||
func (this *_BattleCalculator) calcAttackTarget(unitList []*_BattleUnit, priorityType, priorityArgs []uint32, rangeType, rangeNum uint32) []*_BattleUnit {
|
||||
var targets []*_BattleUnit
|
||||
if len(priorityType) == 0 {
|
||||
for ui := range unitList {
|
||||
if unitList[ui] != nil && unitList[ui].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
return util.RandomSelect(this.rd, targets, util.If(rangeType == rangeTypeSingle, 1, util.If(rangeNum > 0, int(rangeNum), len(targets))))
|
||||
}
|
||||
|
||||
for i := range priorityType {
|
||||
if len(priorityArgs) <= i {
|
||||
continue
|
||||
}
|
||||
switch priorityType[i] {
|
||||
case priorityTypeNone:
|
||||
if len(priorityType) == 0 {
|
||||
for ui := range unitList {
|
||||
if unitList[ui] != nil && unitList[ui].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
return util.RandomSelect(this.rd, targets, util.If(rangeType == rangeTypeSingle, 1, util.If(rangeNum > 0, int(rangeNum), len(targets))))
|
||||
}
|
||||
case priorityTypePosition:
|
||||
switch priorityArgs[i] {
|
||||
case priorityArgFront:
|
||||
for ui := range []int{0, 1, 2} {
|
||||
if unitList[ui] != nil && unitList[i].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
if len(targets) == 0 {
|
||||
continue
|
||||
}
|
||||
case priorityArgBack:
|
||||
for ui := range []int{3, 4, 5} {
|
||||
if unitList[ui] != nil && unitList[i].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
if len(targets) == 0 {
|
||||
continue
|
||||
}
|
||||
case priorityArgColumn:
|
||||
var columns [][]*_BattleUnit
|
||||
for _, ui := range []int{0, 1, 2} {
|
||||
var column []*_BattleUnit
|
||||
if unitList[ui] != nil && unitList[i].hp > 0 {
|
||||
column = append(column, unitList[ui])
|
||||
}
|
||||
if unitList[ui+3] != nil && unitList[i].hp > 0 {
|
||||
column = append(column, unitList[ui+3])
|
||||
}
|
||||
if len(column) > 0 {
|
||||
columns = append(columns, column)
|
||||
}
|
||||
}
|
||||
for _, column := range util.RandomSelect(this.rd, columns, int(rangeNum)) {
|
||||
for ui := range column {
|
||||
targets = append(targets, column[ui])
|
||||
}
|
||||
}
|
||||
return targets
|
||||
}
|
||||
case priorityTypeHp:
|
||||
for ui := range unitList {
|
||||
if unitList[ui] != nil && unitList[i].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
sort.Slice(targets, func(i, j int) bool {
|
||||
if priorityArgs[i] == priorityArgMin {
|
||||
return targets[i].hp < targets[j].hp
|
||||
} else {
|
||||
return targets[i].hp > targets[j].hp
|
||||
}
|
||||
})
|
||||
break
|
||||
case priorityTypeGender:
|
||||
for ui := range unitList {
|
||||
if unitList[ui] == nil || unitList[ui].hp == 0 || unitList[ui].gender != priorityArgs[i] {
|
||||
continue
|
||||
}
|
||||
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
if len(targets) == 0 {
|
||||
continue
|
||||
}
|
||||
case priorityTypeRage:
|
||||
for ui := range unitList {
|
||||
if unitList[ui] != nil && unitList[i].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
sort.Slice(targets, func(i, j int) bool {
|
||||
if priorityArgs[i] == priorityArgMin {
|
||||
return targets[i].rage < targets[j].rage
|
||||
} else {
|
||||
return targets[i].rage > targets[j].rage
|
||||
}
|
||||
})
|
||||
break
|
||||
case priorityTypeAttack:
|
||||
for ui := range unitList {
|
||||
if unitList[ui] != nil && unitList[i].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
sort.Slice(targets, func(i, j int) bool {
|
||||
if priorityArgs[i] == priorityArgMin {
|
||||
return float64(unitList[i].attrs[pb.AttrType_Attack])*(1.0+float64(unitList[i].attrs[pb.AttrType_AttackRatio])*ratioIn) < float64(unitList[j].attrs[pb.AttrType_Attack])*(1.0+float64(unitList[j].attrs[pb.AttrType_AttackRatio])*ratioIn)
|
||||
} else {
|
||||
return float64(unitList[i].attrs[pb.AttrType_Attack])*(1.0+float64(unitList[i].attrs[pb.AttrType_AttackRatio])*ratioIn) > float64(unitList[j].attrs[pb.AttrType_Attack])*(1.0+float64(unitList[j].attrs[pb.AttrType_AttackRatio])*ratioIn)
|
||||
}
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(targets) == 0 {
|
||||
for ui := range unitList {
|
||||
if unitList[ui] != nil && unitList[ui].hp > 0 {
|
||||
targets = append(targets, unitList[ui])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if rangeType == rangeTypeSingle {
|
||||
return targets[:1]
|
||||
} else {
|
||||
if uint32(len(targets)) <= rangeNum {
|
||||
return targets
|
||||
} else {
|
||||
return targets[:rangeNum]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *_BattleCalculator) calcDamage(buff *_BattleBuff, unit *_BattleUnit, target *_BattleUnit) int64 {
|
||||
var defense float64
|
||||
switch buff.buffType {
|
||||
case buffTypePhysicalDamage:
|
||||
defense = float64(target.attrs[pb.AttrType_PhysicalDefense]) * (1.0 + float64(target.attrs[pb.AttrType_PhysicalDefenseRatio])*ratioIn)
|
||||
case buffTypeMagicDamage:
|
||||
defense = float64(target.attrs[pb.AttrType_MagicDefense]) * (1.0 + float64(target.attrs[pb.AttrType_MagicDefenseRatio])*ratioIn)
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
|
||||
if len(buff.buffArgs) < 2 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var attack = float64(unit.attrs[pb.AttrType_Attack]) * (1.0 + float64(unit.attrs[pb.AttrType_AttackRatio])*ratioIn)
|
||||
|
||||
var damage float64
|
||||
if buff.buffArgs[0] == 1 {
|
||||
damage = float64(buff.buffArgs[1])
|
||||
} else {
|
||||
damage = attack * (float64(buff.buffArgs[1]) * ratioIn)
|
||||
}
|
||||
|
||||
var damageRatio = 1.0 + float64(unit.attrs[pb.AttrType_DamageRatio]-target.attrs[pb.AttrType_DamageRelief])*ratioIn
|
||||
var finalDamageRatio = 1.0 + float64(unit.attrs[pb.AttrType_FinalDamageRatio])*ratioIn
|
||||
var finalDamageRelief = 1.0 - float64(target.attrs[pb.AttrType_FinalDamageRelief])*ratioIn
|
||||
|
||||
var criticalRate = (float64(unit.attrs[pb.AttrType_CriticalRate]) - float64(target.attrs[pb.AttrType_CriticalResistance])) * ratioIn
|
||||
|
||||
var factor = this.rd.Float64()
|
||||
|
||||
if factor <= criticalRate {
|
||||
var criticalDamage = float64(unit.attrs[pb.AttrType_CriticalDamage]) * ratioIn
|
||||
var criticalDamageRelief = float64(unit.attrs[pb.AttrType_CriticalDamageRelief]) * ratioIn
|
||||
damage = ((damage - defense) * damageRatio * 2) * (criticalDamage - criticalDamageRelief) * finalDamageRatio * finalDamageRelief
|
||||
} else {
|
||||
damage = (damage - defense) * damageRatio * finalDamageRatio * finalDamageRelief
|
||||
if damage <= 0 {
|
||||
damage = 1
|
||||
}
|
||||
}
|
||||
return int64(-damage)
|
||||
}
|
||||
|
||||
func (this *_BattleCalculator) calcTreat(buff _BattleBuff, unit *_BattleUnit, target *_BattleUnit) int64 {
|
||||
return 0
|
||||
}
|
76
servers/game/logic/player_battle_define.go
Normal file
76
servers/game/logic/player_battle_define.go
Normal file
@ -0,0 +1,76 @@
|
||||
package logic
|
||||
|
||||
const (
|
||||
targetTypeSelf = 0 //自身
|
||||
targetTypeTeammate = 1 //友方
|
||||
targetTypeEnemy = 2 //敌方
|
||||
targetTypeTeammateGender = 3 //友方特定性别
|
||||
targetTypeEnemyGender = 4 //敌方特定性别
|
||||
targetTypeTeammateCountry = 5 //友方特定国家
|
||||
targetTypeEnemyCountry = 6 //敌方特定国家
|
||||
targetTypeTeammateStatus = 7 //友方异常目标
|
||||
targetTypeEnemyStatus = 8 //敌方异常目标
|
||||
targetTypeAttackRate = 9 //击中数量少于目标数量万分比
|
||||
)
|
||||
|
||||
const (
|
||||
countryNone = 0 //无国家
|
||||
countryWei = 1 //魏
|
||||
countryShu = 2 //蜀
|
||||
countryMouse = 3 //鼠辈
|
||||
countryCrowd = 4 //群雄
|
||||
)
|
||||
|
||||
const (
|
||||
rangeTypeSingle = 0 //单个
|
||||
rangeTypeMulti = 0 //多个
|
||||
)
|
||||
|
||||
const (
|
||||
priorityTypeNone = 0 //没有优先
|
||||
priorityTypePosition = 1 //位置优先
|
||||
priorityTypeHp = 2 //血量优先
|
||||
priorityTypeGender = 3 //性别优先
|
||||
priorityTypeRage = 4 //怒气优先
|
||||
priorityTypeAttack = 5 //攻击力优先
|
||||
)
|
||||
|
||||
const (
|
||||
priorityArgFront = 0 //前排
|
||||
priorityArgBack = 1 //后排
|
||||
priorityArgColumn = 2 //纵排
|
||||
priorityArgFemale = 0 //女性
|
||||
priorityArgMale = 1 //男性
|
||||
priorityArgMin = 0 //最低
|
||||
priorityArgMax = 1 //最高
|
||||
)
|
||||
|
||||
const (
|
||||
buffTypeNone = 0
|
||||
buffTypePhysicalDamage = 1 //物理伤害
|
||||
buffTypeMagicDamage = 2 //法术伤害
|
||||
buffTypeStatusAbnormal = 3 //异常状态(无法攻击,无法移动等)
|
||||
buffTypeChangeAttr = 4 //改变属性
|
||||
buffTypeRevive = 5 //复活
|
||||
buffTypeDamageReturn = 6 //伤害反弹
|
||||
buffTypeBisect = 7 //伤害平摊(分担)
|
||||
buffTypeShield = 8 //护盾
|
||||
buffTypeChangeHp = 9 //改变血量
|
||||
buffTypeSteal = 10 //窃取属性
|
||||
buffTypeAddRage = 11 //增加怒气
|
||||
buffTypeImmune = 12 //免疫
|
||||
buffTypeUndead = 13 //不死
|
||||
buffTypeDamageShare = 14 //伤害共享(共享)
|
||||
buffTypeEffectAbnormal = 15 //异常效果(DeBuff)
|
||||
)
|
||||
|
||||
const (
|
||||
skillTypeAttack = 1 //普击
|
||||
skillTypeActive = 2 //主动
|
||||
skillTypePassive = 3 //被动
|
||||
)
|
||||
|
||||
const (
|
||||
ratioIn float64 = 0.0001
|
||||
ratioOut float64 = 10000
|
||||
)
|
@ -76,10 +76,10 @@ func (this *Player) checkCorrectModules(cur *GameTime) {
|
||||
this.Lineup = make(map[uint64]*PlayerLineup)
|
||||
this.SaveField("money", this.Lineup)
|
||||
}
|
||||
//if this.Mail == nil {
|
||||
// this.Mail = make(map[uint64]*PlayerMail)
|
||||
// this.SaveField("mail", this.Mail)
|
||||
//}
|
||||
if this.Mail == nil {
|
||||
this.Mail = make(map[uint64]*PlayerMail)
|
||||
this.SaveField("mail", this.Mail)
|
||||
}
|
||||
if this.Money == nil {
|
||||
this.Money = make(map[uint32]*PlayerMoney)
|
||||
this.SaveField("money", this.Money)
|
||||
@ -222,20 +222,27 @@ func (this *Player) initLineup(cur *GameTime) {
|
||||
this.SaveModel(lineup)
|
||||
}
|
||||
|
||||
// func (this *Player) initMails(cur *GameTime) {
|
||||
// var cfgTable = this.manager.tables.ServerCfg.Get("init_mails")
|
||||
// if cfgTable == nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// itemIds, itemNums, err := util.SplitItemNums(cfgTable.Value1, cfgTable.Value2, 1)
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// this.AddMail(proto.MailTypeNormal, proto.MailTitleSystem, proto.MailContentSystem, nil, itemIds, itemNums, cur.Timestamp)
|
||||
// }
|
||||
//
|
||||
func (this *Player) initMails(cur *GameTime) {
|
||||
var mails = this.manager.tables.ServerConfig.GetInitMails()
|
||||
for i := range mails {
|
||||
var titleId, contentId, itemIds, itemNums = this.manager.tables.ServerConfig.GetInitMail(i)
|
||||
var items = make([][2]uint32, len(itemIds))
|
||||
for ii := range itemIds {
|
||||
items[ii][0] = uint32(itemIds[ii])
|
||||
items[ii][1] = uint32(itemNums[ii])
|
||||
}
|
||||
this.AddMail(util.RandomUid(),
|
||||
pb.MailType_MailNormal,
|
||||
util.IntegerToString(titleId),
|
||||
util.IntegerToString(contentId),
|
||||
util.Unix(),
|
||||
0,
|
||||
nil,
|
||||
items,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// func (this *Player) initTasks(cur *GameTime) {
|
||||
// var cfgTable = this.manager.tables.ServerCfg.Get("init_tasks")
|
||||
// if cfgTable == nil {
|
||||
@ -267,7 +274,7 @@ func (this *Player) checkCorrectFirstLogin(cur *GameTime) {
|
||||
this.initHeroes(cur)
|
||||
this.initItems(cur)
|
||||
this.initLineup(cur)
|
||||
//this.initMails(cur)
|
||||
this.initMails(cur)
|
||||
//this.initTasks(cur)
|
||||
this.initPower(cur)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (this *Player) checkRecoveryPower(login bool, pre, cur *GameTime) {
|
||||
this.ChangeProperty(util.NewPair(pb.RolePropertyType_PowerNextTime, cur.Timestamp+int64(RolePowerCycle)))
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleMoneyChange), &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyChange, &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
}
|
||||
|
||||
func (this *Player) checkAcrossTime(login bool, pre, cur *GameTime, handles ...func(login bool, pre, cur *GameTime) bool) bool {
|
||||
|
@ -47,7 +47,7 @@ func (this *Player) PassedCopyMain(copyMainTable *data.CopyMain, maxScore int32)
|
||||
//this.CopyMainSceneId = uint32(copyChapterTable.SceneId)
|
||||
//this.SaveField("role.mainline_scene_id", this.Role.CopyMainSceneId)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleLevel), uint16(pb.MsgId_ModLevelCopyStatusChange), &pb.MsgCopyStatusChangeAck{Status: copyStatus.BuildMsgCopyStatus()})
|
||||
_ = this.Send(pb.ModId_ModuleLevel, pb.MsgId_ModLevelCopyStatusChange, &pb.MsgCopyStatusChangeAck{Status: copyStatus.BuildMsgCopyStatus()})
|
||||
|
||||
//var copyMainRanking = this.manager.arenaManager.copyMainRanking
|
||||
//if copyMainRanking != nil {
|
||||
|
@ -39,7 +39,7 @@ func (this *Player) AddCounter(tipe pb.CounterType, key uint64, value uint32) {
|
||||
|
||||
this.SaveModel(counter)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleCounter), uint16(pb.MsgId_ModCounterChange), &pb.CounterListAck{
|
||||
_ = this.Send(pb.ModId_ModuleCounter, pb.MsgId_ModCounterChange, &pb.CounterListAck{
|
||||
CounterList: []*pb.Counter{counter.BuildMsgCounter()},
|
||||
})
|
||||
}
|
||||
@ -55,7 +55,7 @@ func (this *Player) SetCounter(tipe pb.CounterType, key uint64, value uint32, on
|
||||
|
||||
this.SaveModel(counter)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleCounter), uint16(pb.MsgId_ModCounterChange), &pb.CounterListAck{
|
||||
_ = this.Send(pb.ModId_ModuleCounter, pb.MsgId_ModCounterChange, &pb.CounterListAck{
|
||||
CounterList: []*pb.Counter{counter.BuildMsgCounter()},
|
||||
})
|
||||
}
|
||||
@ -76,7 +76,7 @@ func (this *Player) ResetCounterDaily(tipe pb.CounterType, key uint64) bool {
|
||||
|
||||
this.SaveModel(counter)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleCounter), uint16(pb.MsgId_ModCounterChange), &pb.CounterListAck{
|
||||
_ = this.Send(pb.ModId_ModuleCounter, pb.MsgId_ModCounterChange, &pb.CounterListAck{
|
||||
CounterList: []*pb.Counter{counter.BuildMsgCounter()},
|
||||
})
|
||||
return true
|
||||
|
@ -53,7 +53,7 @@ func (this *Player) AddEquip(equipId uint32, logType LogType) bool {
|
||||
this.Equip[equip.Uid] = equip
|
||||
this.SaveModel(equip)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipChange), &pb.EquipChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipChange, &pb.EquipChangeListAck{
|
||||
ChangeList: []*pb.EquipChange{{Equip: equip.BuildMsgEquip(), ChangeType: pb.ChangeType_Add}},
|
||||
})
|
||||
|
||||
@ -96,7 +96,7 @@ func (this *Player) AddEquips(equipId, nums uint32, logType LogType) bool {
|
||||
//this.CheckAchievement(proto.AchievementTypeEquipLevel, uint32(equipTable.Level), 1)
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipChange), &pb.EquipChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipChange, &pb.EquipChangeListAck{
|
||||
ChangeList: changeList,
|
||||
})
|
||||
return true
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"github.com/oylshe1314/framework/util"
|
||||
)
|
||||
|
||||
type Attrs [pb.AttrType_Nums]uint64
|
||||
type Attrs [pb.AttrType_AttrNums]uint64
|
||||
|
||||
type PlayerHero struct {
|
||||
Uid uint64 `json:"uid" key:"1"`
|
||||
@ -69,10 +69,12 @@ func (this *Player) AddHero(heroId uint32) bool {
|
||||
hero.Level = 1
|
||||
}
|
||||
|
||||
this.updateHeroAttrs(hero, nil, nil)
|
||||
|
||||
this.Hero[hero.Uid] = hero
|
||||
this.SaveModel(hero)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: []*pb.HeroChange{{ChangeType: pb.ChangeType_Add, Hero: hero.BuildMsgHero()}},
|
||||
})
|
||||
|
||||
@ -100,6 +102,8 @@ func (this *Player) AddHeroes(heroId, nums uint32) bool {
|
||||
Level: level,
|
||||
}
|
||||
|
||||
this.updateHeroAttrs(hero, nil, nil)
|
||||
|
||||
this.Hero[hero.Uid] = hero
|
||||
this.SaveModel(hero)
|
||||
|
||||
@ -108,7 +112,7 @@ func (this *Player) AddHeroes(heroId, nums uint32) bool {
|
||||
//this.CheckAchievement(proto.AchievementTypeEquipLevel, uint32(equipTable.Level), 1)
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: changeList,
|
||||
})
|
||||
|
||||
@ -133,7 +137,7 @@ func (this *Player) ReduceHeroes(heroes map[uint64]*PlayerHero, logType LogType)
|
||||
for _, hero := range heroes {
|
||||
changeList = append(changeList, this.reduceHero(hero, logType))
|
||||
}
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{ChangeList: changeList})
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{ChangeList: changeList})
|
||||
}
|
||||
|
||||
func (this *Player) BuildMsgHeroListAck() *pb.HeroListAck {
|
||||
|
@ -298,14 +298,6 @@ func (this *Player) calcHeroArtifactAttrs(hero *PlayerHero, lineup *PlayerLineup
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Player) calcHeroSpeedAttrs(hero *PlayerHero, lineup *PlayerLineup, lineupHero *PlayerLineupHero) (attrs Attrs) {
|
||||
if lineup == nil || lineupHero == nil {
|
||||
return
|
||||
}
|
||||
hero.attrs[pb.AttrType_AttrSpeed] = 100 + uint64(20-(4*((lineupHero.Position-1)%3)))
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Player) calcHeroAttrs(hero *PlayerHero, attrsList ...Attrs) bool {
|
||||
var newAttrs Attrs
|
||||
for _, attrs := range attrsList {
|
||||
@ -333,7 +325,6 @@ func (this *Player) updateHeroAttrs(hero *PlayerHero, lineup *PlayerLineup, line
|
||||
this.calcHeroTreasuresAttrs(hero, lineup, lineupHero),
|
||||
this.calcHeroMountsAttrs(hero, lineup, lineupHero),
|
||||
this.calcHeroArtifactAttrs(hero, lineup, lineupHero),
|
||||
this.calcHeroSpeedAttrs(hero, lineup, lineupHero),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ func (this *Player) addHeroBook(heroId uint32) {
|
||||
this.HeroBook[heroBook.HeroId] = heroBook
|
||||
this.SaveModel(heroBook)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroBookChange), &pb.HeroBookListAck{
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroBookChange, &pb.HeroBookListAck{
|
||||
BookList: append(this.refreshHeroBook(heroBook.HeroId), heroBook.BuildMsgHeroBook()),
|
||||
})
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ func (this *Player) AddItem(itemId, itemNum uint32, logType LogType) bool {
|
||||
|
||||
itemChange, ok := this.addItem(itemTable, itemNum, logType)
|
||||
if itemChange != nil {
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{ChangeList: []*pb.ItemChange{itemChange}})
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemChange, &pb.ItemChangeListAck{ChangeList: []*pb.ItemChange{itemChange}})
|
||||
}
|
||||
return ok
|
||||
}
|
||||
@ -131,7 +131,7 @@ func (this *Player) AddItems(itemMap map[uint32]uint32, logType LogType) {
|
||||
}
|
||||
|
||||
if len(changeList) > 0 {
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{ChangeList: changeList})
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemChange, &pb.ItemChangeListAck{ChangeList: changeList})
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ func (this *Player) reduceItem(itemId, itemNum uint32, logType LogType) {
|
||||
changeType = pb.ChangeType_Changed
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{ChangeList: []*pb.ItemChange{{Item: item.BuildMsgItem(deleted), ChangeType: changeType}}})
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemChange, &pb.ItemChangeListAck{ChangeList: []*pb.ItemChange{{Item: item.BuildMsgItem(deleted), ChangeType: changeType}}})
|
||||
|
||||
//if logType > LogTypeNone {
|
||||
// this.manager.eventManager.PlayerItemConsume(this, logType, itemId, itemNum)
|
||||
|
@ -74,7 +74,7 @@ func (this *Player) SendLineupHeroChange(lineups ...*PlayerLineup) {
|
||||
}
|
||||
}
|
||||
if len(heroChangeList) > 0 {
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), pb.HeroChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, pb.HeroChangeListAck{
|
||||
ChangeList: heroChangeList,
|
||||
})
|
||||
}
|
||||
@ -178,10 +178,10 @@ func (this *Player) SendUpgradeMaster(masterType pb.UpgradeMasterType, preLevel,
|
||||
ack.PreLevel = uint32(preMasterTable.Level)
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleUpgradeMaster), ack)
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleUpgradeMaster, ack)
|
||||
|
||||
if this.updateHeroAttrs(hero, lineup, lineupHero) {
|
||||
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), pb.HeroChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, pb.HeroChangeListAck{
|
||||
ChangeList: []*pb.HeroChange{{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()}},
|
||||
})
|
||||
}
|
||||
|
@ -49,23 +49,5 @@ func (this *Player) UpdateBattleHeroCapacity(lineupHero *PlayerLineupHero) {
|
||||
return
|
||||
}
|
||||
|
||||
var attrs = hero.Attrs()
|
||||
|
||||
var capacity = (float64(attrs[pb.AttrType_Attack]) * 2) +
|
||||
(float64(attrs[pb.AttrType_Hp]) * 0.2) +
|
||||
(float64(attrs[pb.AttrType_AttrPhysicalDefense]) * 6) +
|
||||
(float64(attrs[pb.AttrType_AttrMagicDefense]) * 6) +
|
||||
(float64(attrs[pb.AttrType_AttrDamageRatio]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrDamageRelief]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrCriticalRatio]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrCriticalResistance]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrCriticalDamage]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrCriticalDamageRelief]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrHitRate]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrDodgeRate]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrTreatRatio]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrByTreatedRatio]) * 12) +
|
||||
(float64(attrs[pb.AttrType_AttrFinalDamageRatio]) * 12)
|
||||
|
||||
lineupHero.Capacity = uint64(capacity)
|
||||
lineupHero.Capacity = this.calcAttrsCapacity(hero.attrs)
|
||||
}
|
||||
|
@ -1,84 +1,71 @@
|
||||
package logic
|
||||
|
||||
//type PlayerMail struct {
|
||||
// Id uint64 `bson:"id" key:"1"`
|
||||
// Type uint32 `bson:"type"`
|
||||
// Title string `bson:"title"`
|
||||
// Content string `bson:"content"`
|
||||
// Args []string `bson:"args"`
|
||||
// Status uint32 `bson:"status"`
|
||||
// ItemId []uint32 `bson:"item_id"`
|
||||
// ItemNum []uint32 `bson:"item_num"`
|
||||
// CreateTime int64 `bson:"create_time"`
|
||||
// Expiration int64 `bson:"expiration"`
|
||||
//}
|
||||
//
|
||||
//func (this *PlayerMail) BuildMsgMail() *proto.Mail {
|
||||
// var itemList []*proto.ItemPair
|
||||
// for i, itemId := range this.ItemId {
|
||||
// itemList = append(itemList, &proto.ItemPair{ItemId: itemId, ItemNum: this.ItemNum[i]})
|
||||
// }
|
||||
// return &proto.Mail{
|
||||
// Id: this.Id,
|
||||
// Type: this.Type,
|
||||
// Title: this.Title,
|
||||
// Content: this.Content,
|
||||
// Args: this.Args,
|
||||
// Status: this.Status,
|
||||
// ItemList: itemList,
|
||||
// CreateTime: this.CreateTime,
|
||||
// Expiration: this.Expiration,
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *Player) AddMail(tipe proto.MailType, title, content string, args []string, itemId, itemNum []uint32, createTime int64, expiration ...int64) {
|
||||
// counter, err := this.manager.mongoClient.Counter("mail_id", 1)
|
||||
// if err != nil {
|
||||
// this.manager.logger.Error("Get counter failed, ", err)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// this.addMail(util.EncryptUid(counter), tipe, title, content, args, itemId, itemNum, createTime, expiration...)
|
||||
//}
|
||||
//
|
||||
//func (this *Player) addMail(mailId uint64, tipe proto.MailType, title, content string, args []string, itemId, itemNum []uint32, createTime int64, expiration ...int64) {
|
||||
// var mail = &PlayerMail{
|
||||
// Id: mailId,
|
||||
// Type: uint32(tipe),
|
||||
// Title: title,
|
||||
// Content: content,
|
||||
// Args: args,
|
||||
// Status: uint32(proto.MailStatusUnread),
|
||||
// ItemId: itemId,
|
||||
// ItemNum: itemNum,
|
||||
// CreateTime: createTime,
|
||||
// }
|
||||
//
|
||||
// if len(expiration) > 0 {
|
||||
// mail.Expiration = expiration[0]
|
||||
// } else {
|
||||
// mail.Expiration = mail.CreateTime + util.DayTotalSeconds*30
|
||||
// }
|
||||
//
|
||||
// this.Mail[mail.Id] = mail
|
||||
// this.SaveModel(mail)
|
||||
//
|
||||
// _ = this.Send(proto.ModIdMail, proto.MsgIdMailSend, &proto.MsgMailSendAck{Mail: mail.BuildMsgMail()})
|
||||
//
|
||||
// this.manager.eventManager.PlayerMailLog(this, LogTypeMailGet, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
//}
|
||||
//
|
||||
//func (this *Player) BuildMsgMailListAck() *proto.MsgMailListAck {
|
||||
// var mailList []*proto.Mail
|
||||
// for _, mail := range this.Mail {
|
||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
|
||||
// continue
|
||||
// }
|
||||
// var itemList []*proto.ItemPair
|
||||
// for i := range mail.ItemId {
|
||||
// itemList = append(itemList, &proto.ItemPair{ItemId: mail.ItemId[i], ItemNum: mail.ItemNum[i]})
|
||||
// }
|
||||
// mailList = append(mailList, mail.BuildMsgMail())
|
||||
// }
|
||||
// return &proto.MsgMailListAck{List: mailList}
|
||||
//}
|
||||
import (
|
||||
"ecs/proto/pb"
|
||||
)
|
||||
|
||||
type PlayerMail struct {
|
||||
Uid uint64 `bson:"uid" key:"1"`
|
||||
Type uint32 `bson:"type"`
|
||||
Title string `bson:"title"`
|
||||
Content string `bson:"content"`
|
||||
Status uint32 `bson:"status"`
|
||||
CreateTime int64 `bson:"create_time"`
|
||||
Expiration int64 `bson:"expiration"`
|
||||
Args []string `bson:"args"`
|
||||
Items [][2]uint32 `bson:"items"`
|
||||
}
|
||||
|
||||
func (this *PlayerMail) BuildMsgMail() *pb.Mail {
|
||||
var itemList []*pb.Item
|
||||
for i := range this.Items {
|
||||
itemList = append(itemList, &pb.Item{ItemId: this.Items[i][0], ItemNum: this.Items[i][1]})
|
||||
}
|
||||
return &pb.Mail{
|
||||
Uid: this.Uid,
|
||||
Type: pb.MailType(this.Type),
|
||||
Title: this.Title,
|
||||
Content: this.Content,
|
||||
CreateTime: this.CreateTime,
|
||||
Expiration: this.Expiration,
|
||||
Status: pb.MailStatus(this.Status),
|
||||
Args: this.Args,
|
||||
ItemList: itemList,
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Player) AddMail(uid uint64, tipe pb.MailType, title, content string, createTime, expiration int64, args []string, items [][2]uint32) {
|
||||
var mail = &PlayerMail{
|
||||
Uid: uid,
|
||||
Type: uint32(tipe),
|
||||
Title: title,
|
||||
Content: content,
|
||||
Status: uint32(pb.MailStatus_Unread),
|
||||
CreateTime: createTime,
|
||||
Expiration: expiration,
|
||||
Args: args,
|
||||
Items: items,
|
||||
}
|
||||
|
||||
this.Mail[mail.Uid] = mail
|
||||
this.SaveModel(mail)
|
||||
|
||||
_ = this.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailSend, &pb.MailSendAck{Mail: mail.BuildMsgMail()})
|
||||
|
||||
//this.manager.eventManager.PlayerMailLog(this, LogTypeMailGet, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||
}
|
||||
|
||||
func (this *Player) BuildMsgMailListAck() *pb.MailListAck {
|
||||
var mailList []*pb.Mail
|
||||
for _, mail := range this.Mail {
|
||||
if pb.MailStatus(mail.Status) >= pb.MailStatus_Deleted {
|
||||
continue
|
||||
}
|
||||
var itemList []*pb.Item
|
||||
for i := range mail.Items {
|
||||
itemList = append(itemList, &pb.Item{ItemId: mail.Items[i][0], ItemNum: mail.Items[i][1]})
|
||||
}
|
||||
mailList = append(mailList, mail.BuildMsgMail())
|
||||
}
|
||||
return &pb.MailListAck{MailList: mailList}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func (this *Player) addMoney(moneyType pb.MoneyType, value uint32, logType LogTy
|
||||
money.Value += value
|
||||
this.SaveModel(money)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleMoneyChange), &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyChange, &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
|
||||
//if logType != LogTypeNone {
|
||||
// this.manager.eventManager.PlayerMoneyObtain(this, logType, uint32(moneyType), value, money.Value)
|
||||
@ -98,7 +98,7 @@ func (this *Player) reduceMoney(moneyType pb.MoneyType, value uint32, logType Lo
|
||||
money.Value -= value
|
||||
this.SaveModel(money)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleMoneyChange), &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyChange, &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
|
||||
//if logType != LogTypeNone {
|
||||
// this.manager.eventManager.PlayerMoneyConsume(this, logType, uint32(moneyType), value, money.Value)
|
||||
@ -140,7 +140,7 @@ func (this *Player) addExp(value uint32, logType LogType) {
|
||||
this.SaveField("role_exp", this.RoleExp)
|
||||
this.SaveField("role_level", this.RoleLevel)
|
||||
|
||||
_ = this.Send(uint16(pb.MsgId_ModHeroChange), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleHero, pb.MsgId_ModHeroChange, &pb.HeroChangeListAck{
|
||||
ChangeList: []*pb.HeroChange{{ChangeType: pb.ChangeType_Changed, Hero: roleHero.BuildMsgHero()}},
|
||||
})
|
||||
|
||||
@ -154,7 +154,7 @@ func (this *Player) addPower(value uint32, logType LogType) {
|
||||
money.Value += value
|
||||
this.SaveModel(money)
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleMoneyChange), &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyChange, &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
|
||||
if money.Value >= uint32(RolePowerMax) && this.PowerNextTime > 0 {
|
||||
this.ChangeProperty(util.NewPair(pb.RolePropertyType_PowerNextTime, int64(0)))
|
||||
@ -180,7 +180,7 @@ func (this *Player) reducePower(value uint32, logType LogType) {
|
||||
this.ChangeProperty(util.NewPair(pb.RolePropertyType_PowerNextTime, util.Unix()+int64(RolePowerCycle)))
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleMoneyChange), &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyChange, &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}})
|
||||
|
||||
//if logType != LogTypeNone {
|
||||
// this.manager.eventManager.PlayerMoneyConsume(this, logType, uint32(proto.MoneyTypePower), value, money.Value)
|
||||
|
@ -60,7 +60,7 @@ func (this *Player) ChangeProperty(properties ...*util.Pair[pb.RolePropertyType,
|
||||
}
|
||||
ack.PropertyList = append(ack.PropertyList, &pb.RoleProperty{Type: property.Key, Value: property.Value})
|
||||
}
|
||||
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRolePropertyChange), ack)
|
||||
_ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRolePropertyChange, ack)
|
||||
}
|
||||
|
||||
func (this *Player) BuildMsgRolePropertyChangeAck(types ...pb.RolePropertyType) *pb.RolePropertyChangeAck {
|
||||
|
@ -46,7 +46,7 @@ func (this *Player) enterScene(sceneId uint32) {
|
||||
this.Temp.PreScene = this.Temp.CurScene
|
||||
this.Temp.CurScene = sceneId
|
||||
}
|
||||
_ = this.Send(uint16(pb.ModId_ModuleLevel), uint16(pb.MsgId_ModLevelSceneEnter), &pb.SceneEnterAck{SceneId: this.Temp.CurScene})
|
||||
_ = this.Send(pb.ModId_ModuleLevel, pb.MsgId_ModLevelSceneEnter, &pb.SceneEnterAck{SceneId: this.Temp.CurScene})
|
||||
}
|
||||
|
||||
//func (this *Player) CheckRequestTime(reqType int) bool {
|
||||
|
@ -76,7 +76,7 @@ func (this *Player) AddTreasures(treasureId, nums uint32, logType LogType) bool
|
||||
//this.CheckAchievement(proto.AchievementTypeEquipLevel, uint32(treasureTable.Level), 1)
|
||||
}
|
||||
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureChange, &pb.TreasureChangeListAck{
|
||||
ChangeList: changeList,
|
||||
})
|
||||
return true
|
||||
@ -110,7 +110,7 @@ func (this *Player) ReduceTreasures(treasures map[uint64]*PlayerTreasure, logTyp
|
||||
for _, treasure := range treasures {
|
||||
changeList = append(changeList, this.reduceTreasure(treasure, logType))
|
||||
}
|
||||
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{ChangeList: changeList})
|
||||
_ = this.Send(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureChange, &pb.TreasureChangeListAck{ChangeList: changeList})
|
||||
}
|
||||
|
||||
func (this *Player) ReduceTreasure(treasureId uint32, nums uint32, logType LogType) {
|
||||
|
@ -148,33 +148,33 @@ func (this *gameServer) Init() (err error) {
|
||||
this.ExterServer.DefaultHandler(this.messageHandler.Message)
|
||||
|
||||
//Register player common module message handlers
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleCommon), uint16(pb.MsgId_ModCommonGmCommand), this.playerHandler.GmCommand)
|
||||
this.playerManager.Handler(pb.ModId_ModuleCommon, pb.MsgId_ModCommonGmCommand, this.playerHandler.GmCommand)
|
||||
//
|
||||
////Register player role model message handlers
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleChangeLanguage), this.playerHandler.RoleChangeLanguage)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleChangeRoleName), this.playerHandler.RoleChangeName)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRolePropertyChange), this.playerHandler.RolePropertyChange)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroChange), this.playerHandler.LineupHeroChange)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroPosition), this.playerHandler.LineupHeroPosition)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroEquip), this.playerHandler.LineupHeroEquip)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroTreasure), this.playerHandler.LineupHeroTreasure)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroArtifact), this.playerHandler.LineupHeroArtifact)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroMounts), this.playerHandler.LineupHeroMounts)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroGeneral), this.playerHandler.LineupHeroGeneral)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroOrnament), this.playerHandler.LineupHeroOrnament)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHelperChange), this.playerHandler.LineupHelperChange)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupEquipInlay), this.playerHandler.LineupEquipInlay)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupTreasureInlay), this.playerHandler.LineupTreasureInlay)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupCreate), this.playerHandler.LineupCreate)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChangeName), this.playerHandler.LineupChangeName)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupActivate), this.playerHandler.LineupActivate)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupDelete), this.playerHandler.LineupDelete)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleChangeLanguage, this.playerHandler.RoleChangeLanguage)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleChangeRoleName, this.playerHandler.RoleChangeName)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRolePropertyChange, this.playerHandler.RolePropertyChange)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroChange, this.playerHandler.LineupHeroChange)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroPosition, this.playerHandler.LineupHeroPosition)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroEquip, this.playerHandler.LineupHeroEquip)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroTreasure, this.playerHandler.LineupHeroTreasure)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroArtifact, this.playerHandler.LineupHeroArtifact)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroMounts, this.playerHandler.LineupHeroMounts)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroGeneral, this.playerHandler.LineupHeroGeneral)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHeroOrnament, this.playerHandler.LineupHeroOrnament)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupHelperChange, this.playerHandler.LineupHelperChange)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupEquipInlay, this.playerHandler.LineupEquipInlay)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupTreasureInlay, this.playerHandler.LineupTreasureInlay)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupCreate, this.playerHandler.LineupCreate)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupChangeName, this.playerHandler.LineupChangeName)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupActivate, this.playerHandler.LineupActivate)
|
||||
this.playerManager.Handler(pb.ModId_ModuleRole, pb.MsgId_ModRoleLineupDelete, this.playerHandler.LineupDelete)
|
||||
//this.playerManager.Handler(proto.ModIdRole, proto.MsgIdRoleTalentUpgrade, this.playerHandler.RoleTalentUpgrade)
|
||||
//this.playerManager.Handler(proto.ModIdRole, proto.MsgIdRoleTalentReset, this.playerHandler.RoleTalentReset)
|
||||
//
|
||||
////Register player level module message handlers
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleLevel), uint16(pb.MsgId_ModLevelEnter), this.playerHandler.LevelEnter)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleLevel), uint16(pb.MsgId_ModLevelSweep), this.playerHandler.LevelSweep)
|
||||
this.playerManager.Handler(pb.ModId_ModuleLevel, pb.MsgId_ModLevelEnter, this.playerHandler.LevelEnter)
|
||||
this.playerManager.Handler(pb.ModId_ModuleLevel, pb.MsgId_ModLevelSweep, this.playerHandler.LevelSweep)
|
||||
//this.playerManager.Handler(proto.ModIdLevel, proto.MsgIdCopySpeedGetReward, this.playerHandler.CopySpeedGetReward)
|
||||
//this.playerManager.Handler(proto.ModIdLevel, proto.MsgIdCopySpeedRankList, this.playerHandler.CopySpeedRankList)
|
||||
//this.playerManager.Handler(proto.ModIdLevel, proto.MsgIdArenaPlayerDetail, this.playerHandler.ArenaPlayerDetail)
|
||||
@ -193,7 +193,7 @@ func (this *gameServer) Init() (err error) {
|
||||
//this.playerManager.Handler(proto.ModIdLevel, proto.MsgIdCopyMainlineRankList, this.playerHandler.CopyMainlineRankList)
|
||||
|
||||
//Register player battle module message handlers
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleBattle), uint16(pb.MsgId_ModBattleEnd), this.playerHandler.BattleEnd)
|
||||
this.playerManager.Handler(pb.ModId_ModuleBattle, pb.MsgId_ModBattleEnd, this.playerHandler.BattleEnd)
|
||||
//this.playerManager.Handler(proto.ModIdBattle, proto.MsgIdBattleResult, this.playerHandler.BattleResult)
|
||||
//this.playerManager.Handler(proto.ModIdBattle, proto.MsgIdIdleBattleGetReward, this.playerHandler.IdleBattleGetReward)
|
||||
//this.playerManager.Handler(proto.ModIdBattle, proto.MsgIdIdleQuickBattle, this.playerHandler.IdleQuickBattle)
|
||||
@ -201,29 +201,30 @@ func (this *gameServer) Init() (err error) {
|
||||
//this.playerManager.Handler(proto.ModIdBattle, proto.MsgIdBattleRadarUse, this.playerHandler.BattleRadarUse)
|
||||
|
||||
//Register player hero module message handlers
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroUpgrade), this.playerHandler.HeroUpgrade)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroBreak), this.playerHandler.HeroBreak)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroAwaken), this.playerHandler.HeroAwaken)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroSoul), this.playerHandler.HeroSoul)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroFateBreak), this.playerHandler.HeroFateBreak)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroQuality), this.playerHandler.HeroQuality)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroBookActivate), this.playerHandler.HeroBookActivate)
|
||||
this.playerManager.Handler(pb.ModId_ModuleHero, pb.MsgId_ModHeroUpgrade, this.playerHandler.HeroUpgrade)
|
||||
this.playerManager.Handler(pb.ModId_ModuleHero, pb.MsgId_ModHeroBreak, this.playerHandler.HeroBreak)
|
||||
this.playerManager.Handler(pb.ModId_ModuleHero, pb.MsgId_ModHeroAwaken, this.playerHandler.HeroAwaken)
|
||||
this.playerManager.Handler(pb.ModId_ModuleHero, pb.MsgId_ModHeroSoul, this.playerHandler.HeroSoul)
|
||||
this.playerManager.Handler(pb.ModId_ModuleHero, pb.MsgId_ModHeroFateBreak, this.playerHandler.HeroFateBreak)
|
||||
this.playerManager.Handler(pb.ModId_ModuleHero, pb.MsgId_ModHeroQuality, this.playerHandler.HeroQuality)
|
||||
this.playerManager.Handler(pb.ModId_ModuleHero, pb.MsgId_ModHeroBookActivate, this.playerHandler.HeroBookActivate)
|
||||
|
||||
//Register player item module message handlers
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemUse), this.playerHandler.ItemUse)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemSale), this.playerHandler.ItemSale)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipUpgrade), this.playerHandler.EquipUpgrade)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipRefine), this.playerHandler.EquipRefine)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureUpgrade), this.playerHandler.TreasureUpgrade)
|
||||
this.playerManager.Handler(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureRefine), this.playerHandler.TreasureRefine)
|
||||
this.playerManager.Handler(pb.ModId_ModuleItem, pb.MsgId_ModItemUse, this.playerHandler.ItemUse)
|
||||
this.playerManager.Handler(pb.ModId_ModuleItem, pb.MsgId_ModItemSale, this.playerHandler.ItemSale)
|
||||
this.playerManager.Handler(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipUpgrade, this.playerHandler.EquipUpgrade)
|
||||
this.playerManager.Handler(pb.ModId_ModuleItem, pb.MsgId_ModItemEquipRefine, this.playerHandler.EquipRefine)
|
||||
this.playerManager.Handler(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureUpgrade, this.playerHandler.TreasureUpgrade)
|
||||
this.playerManager.Handler(pb.ModId_ModuleItem, pb.MsgId_ModItemTreasureRefine, this.playerHandler.TreasureRefine)
|
||||
|
||||
//Register player mail module message handlers
|
||||
this.playerManager.Handler(pb.ModId_ModuleMail, pb.MsgId_ModMailSend, this.playerHandler.MailSend)
|
||||
this.playerManager.Handler(pb.ModId_ModuleMail, pb.MsgId_ModMailRead, this.playerHandler.MailRead)
|
||||
this.playerManager.Handler(pb.ModId_ModuleMail, pb.MsgId_ModMailReceive, this.playerHandler.MailReceive)
|
||||
this.playerManager.Handler(pb.ModId_ModuleMail, pb.MsgId_ModMailReceiveAll, this.playerHandler.MailReceiveAll)
|
||||
this.playerManager.Handler(pb.ModId_ModuleMail, pb.MsgId_ModMailDeleteAll, this.playerHandler.MailDelete)
|
||||
this.playerManager.Handler(pb.ModId_ModuleMail, pb.MsgId_ModMailDeleteAll, this.playerHandler.MailDeleteAll)
|
||||
|
||||
////Register player mail module message handlers
|
||||
//this.playerManager.Handler(proto.ModIdMail, proto.MsgIdMailRead, this.playerHandler.MailRead)
|
||||
//this.playerManager.Handler(proto.ModIdMail, proto.MsgIdMailReceive, this.playerHandler.MailReceive)
|
||||
//this.playerManager.Handler(proto.ModIdMail, proto.MsgIdMailReceiveAll, this.playerHandler.MailReceiveAll)
|
||||
//this.playerManager.Handler(proto.ModIdMail, proto.MsgIdMailDelete, this.playerHandler.MailDelete)
|
||||
//this.playerManager.Handler(proto.ModIdMail, proto.MsgIdMailDeleteAll, this.playerHandler.MailDeleteAll)
|
||||
//
|
||||
////Register player achievement module message handlers
|
||||
//this.playerManager.Handler(proto.ModIdAchievement, proto.MsgIdAchievementGetReward, this.playerHandler.AchievementGetReward)
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user