refactor(common/cool/coolconfig): 修改RPC配置字段类型

将RPC字段从uint16类型更改为string类型的Address字段,
以支持更灵活的地址配置。同时更新了配置初始化逻辑,
从server.rpc改为server.address作为配置键。
```
This commit is contained in:
昔念
2026-01-25 03:40:29 +08:00
parent 392061df04
commit 32f57732fe
20 changed files with 166 additions and 196 deletions

View File

@@ -52,7 +52,7 @@ func processMonID(bm string) string {
// data: 包含挑战Boss信息的输入数据
// player: 当前玩家对象
// 返回: 战斗结果和错误码
func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !p.CanFight() {
return nil, errorcode.ErrorCodes.ErrPokemonNoStamina
}
@@ -153,7 +153,7 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *pla
// data: 包含战斗野怪信息的输入数据
// player: 当前玩家对象
// 返回: 战斗结果和错误码
func (h Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !p.CanFight() {
return nil, errorcode.ErrorCodes.ErrSystemError
}

View File

@@ -40,7 +40,7 @@ func cleanup() {
log.Println("执行优雅清理资源...")
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
value.Kick()
value.Kick(1)
return true
})

View File

@@ -15,7 +15,7 @@ import (
)
// Compare 比较两个1v1战斗动作的执行优先级核心逻辑
func (f *FightC) Compare(a, b action.BattleActionI) (action.BattleActionI, action.BattleActionI) {
func (*FightC) Compare(a, b action.BattleActionI) (action.BattleActionI, action.BattleActionI) {
// 动作本身的优先级比较
p1 := b.Priority() - a.Priority()
if p1 > 0 { // 对手优先级更高

View File

@@ -37,7 +37,7 @@ type SelectSkillAction struct {
}
// Priority 返回动作优先级
func (s *SelectSkillAction) Priority() int {
func (*SelectSkillAction) Priority() int {
return int(PlayerOperations.SelectSkill)
}
@@ -70,7 +70,7 @@ type ActiveSwitchAction struct {
}
// Priority 返回动作优先级
func (a *ActiveSwitchAction) Priority() int {
func (*ActiveSwitchAction) Priority() int {
return int(PlayerOperations.ActiveSwitch)
}
@@ -83,6 +83,6 @@ type UseItemAction struct {
}
// Priority 返回动作优先级
func (u *UseItemAction) Priority() int {
func (*UseItemAction) Priority() int {
return int(PlayerOperations.UsePotion)
}

View File

@@ -3,6 +3,8 @@ package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/input"
"github.com/alpacahq/alpacadecimal"
)
// 60.回复造成伤害的6%
@@ -20,7 +22,7 @@ func (e *NewSel700) Skill_Useed() bool {
}
e.Input.Heal(
e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage.Div(e.Args()[0]),
e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage.Div(e.Args()[0].Div(alpacadecimal.NewFromInt(100))),
)
return true
}

View File

@@ -4,6 +4,8 @@ import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/alpacahq/alpacadecimal"
)
// 可以抵挡n点伤害
@@ -20,16 +22,17 @@ func (e *Effect49) DamageSubEx(t *info.DamageZone) bool {
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
//fmt.Println("Effect49_o", t.Damage)
if t.Type == info.DamageType.Red {
if e.Args()[0].Cmp(t.Damage) == -1 {
t.Damage = t.Damage.Sub(e.Args()[0])
}
if t.Type != info.DamageType.Red {
return true
}
//fmt.Println("Effect49_n", t.Damage)
if t.Damage.Cmp(e.Args()[0]) > -1 {
t.Damage = t.Damage.Sub(e.Args()[0])
} else {
t.Damage = alpacadecimal.Zero
}
return true
}

View File

@@ -15,7 +15,7 @@ import (
)
// processSkillAttack 处理技能攻击逻辑
func (f *FightC) processSkillAttack(attacker, defender *input.Input, skill *info.SkillEntity) {
func (*FightC) processSkillAttack(attacker, defender *input.Input, skill *info.SkillEntity) {
skill.AttackTimeC(attacker.GetProp(5, true)) //计算命中
defender.Exec(func(effect input.Effect) bool { //计算闪避,然后修改对方命中),同时相当于计算属性无效这种
@@ -357,7 +357,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
f.Broadcast(func(fighter *input.Input) {
for _, switchAction := range f.Switch {
if fighter.Player.GetInfo().UserID != switchAction.Reason.UserId {
// println("切精灵", switchAction.Reason.UserId, switchAction.Reason.ID)
// println("切精灵", switchAction.Reason.UserId, switchAction.Reason.ID)
fighter.Player.SendPackCmd(2407, &switchAction.Reason)
}
}

View File

@@ -3,7 +3,6 @@ package info
import (
"blazing/common/data"
"blazing/modules/player/model"
"fmt"
"github.com/tnnmigga/enum"
)
@@ -259,11 +258,6 @@ type NoteReadyToFightInfo struct {
OpponentPetList []ReadyFightPetInfo `fieldDesc:"敌方的精灵信息 如果是野怪 那么再给客户端发送这个包体时就提前生成好了这只精灵的PetInfo,然后把从PetInfo中把部分信息写入到这个敌方的精灵信息中再发送这个包结构体" serialize:"lengthFirst,lengthType=uint16,type=structArray"`
}
// 当A和B都 这时候给双方回复开始战斗包
func (t *NoteReadyToFightInfo) onBothFinished() {
fmt.Println("A和B都已完成触发onBothFinished")
}
// ReadyFightPetInfo 准备战斗的精灵信息结构体ReadyFightPetInfo类
type ReadyFightPetInfo struct {
// 精灵ID@UInt long

View File

@@ -74,6 +74,7 @@ func (f *FightC) battleLoop() {
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC {
if f.Reason == info.BattleOverReason.Cacthok {
f.WinnerId = f.ownerID
f.Opp.Player.GetInfo().PetList[0].EffectInfo = nil //清空特性信息
f.Our.Player.(*player.Player).Service.Pet.PetAdd(&f.Opp.Player.GetInfo().PetList[0])
f.Our.Player.SendPackCmd(2409, &info.CatchMonsterOutboundInfo{

View File

@@ -221,12 +221,16 @@ func (p *Player) ItemAdd(ItemId, ItemCnt uint32) (result bool) {
return false
}
func (player1 *Player) Kick() {
func (player1 *Player) Kick(qtype int) {
if player1.IsLogin {
//取成功,否则创建
//player1.Save() //先保存数据再返回
head := common.NewTomeeHeader(1001, player1.Info.UserID)
head.Result = uint32(errorcode.ErrorCodes.ErrXinPlanSleepMode)
head.Result = uint32(errorcode.ErrorCodes.ErrAccountLoggedInElsewhere)
if qtype == 1 {
head.Result = uint32(errorcode.ErrorCodes.ErrXinPlanSleepMode)
}
//实际上这里有个问题,会造成重复保存问题
player1.SendPack(head.Pack(nil))

View File

@@ -34,11 +34,10 @@ func KickPlayer(userid uint32) error { //踢出玩家
//TODO 返回错误码
//var player *entity.Player
if player1, ok := Mainplayer.Load(userid); ok {
player1.Kick()
player1.Kick(0)
}
//return player
return nil
}