mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-23 14:32:27 +08:00
配置表访问接口化,简化常量访问
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"hk4e/common/config"
|
||||
"hk4e/common/constant"
|
||||
"hk4e/common/mq"
|
||||
"hk4e/common/rpc"
|
||||
"hk4e/fight/engine"
|
||||
@@ -59,8 +58,6 @@ func Run(ctx context.Context, configFile string) error {
|
||||
logger.InitLogger("fight_" + APPID)
|
||||
logger.Warn("fight start, appid: %v", APPID)
|
||||
|
||||
constant.InitConstant()
|
||||
|
||||
messageQueue := mq.NewMessageQueue(api.FIGHT, APPID, client)
|
||||
defer messageQueue.Close()
|
||||
|
||||
|
||||
@@ -201,8 +201,8 @@ func (f *FightRoutine) onTickSecond(now int64) {
|
||||
if entity.uid == 0 {
|
||||
continue
|
||||
}
|
||||
entity.fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_ATTACK)] = 1000000
|
||||
entity.fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CRITICAL)] = 1.0
|
||||
entity.fightPropMap[uint32(constant.FIGHT_PROP_CUR_ATTACK)] = 1000000
|
||||
entity.fightPropMap[uint32(constant.FIGHT_PROP_CRITICAL)] = 1.0
|
||||
avatarFightPropNotify := &proto.AvatarFightPropNotify{
|
||||
AvatarGuid: entity.avatarGuid,
|
||||
FightPropMap: entity.fightPropMap,
|
||||
@@ -262,17 +262,17 @@ func (f *FightRoutine) attackHandle(gameMsg *mq.GameMsg) {
|
||||
_ = attackerId
|
||||
currHp := float32(0)
|
||||
if target.fightPropMap != nil {
|
||||
currHp = target.fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)]
|
||||
currHp = target.fightPropMap[uint32(constant.FIGHT_PROP_CUR_HP)]
|
||||
currHp -= damage
|
||||
if currHp < 0 {
|
||||
currHp = 0
|
||||
}
|
||||
target.fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = currHp
|
||||
target.fightPropMap[uint32(constant.FIGHT_PROP_CUR_HP)] = currHp
|
||||
}
|
||||
entityFightPropUpdateNotify := new(proto.EntityFightPropUpdateNotify)
|
||||
entityFightPropUpdateNotify.EntityId = target.entityId
|
||||
entityFightPropUpdateNotify.FightPropMap = make(map[uint32]float32)
|
||||
entityFightPropUpdateNotify.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = currHp
|
||||
entityFightPropUpdateNotify.FightPropMap[uint32(constant.FIGHT_PROP_CUR_HP)] = currHp
|
||||
for _, uid := range f.getAllPlayer(f.entityMap) {
|
||||
SendMsg(f.messageQueue, cmd.EntityFightPropUpdateNotify, uid, f.gateAppId, entityFightPropUpdateNotify)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user