Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
8356aad4d6
5 files changed
+32
-43
No files matched your search
@@ -383,8 +383,8 @@ func (c *CommandManager) ItemCommand(content *CommandContent) bool {
|
||||
switch mode {
|
||||
case "add":
|
||||
if param1 == "all" {
|
||||
c.gmCmd.GMAddAllItem(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已添加所有道具,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
c.gmCmd.GMAddAllItem(content.AssignPlayer.PlayerId, count)
|
||||
content.SendSuccMessage(content.Executor, "已添加所有道具,指定UID:%v,数量:%v。", content.AssignPlayer.PlayerId, count)
|
||||
return true
|
||||
}
|
||||
itemId, err := strconv.ParseUint(param1, 10, 32)
|
||||
@@ -710,7 +710,7 @@ func (c *CommandManager) PointCommand(content *CommandContent) bool {
|
||||
if param1 == "all" {
|
||||
// 解锁当前场景所有锚点
|
||||
c.gmCmd.GMUnlockAllPoint(content.AssignPlayer.PlayerId, sceneId)
|
||||
content.SendSuccMessage(content.Executor, "已解锁所有锚点,指定UID:%v,场景ID:%v。", content.AssignPlayer.PlayerId, content.AssignPlayer.GetSceneId())
|
||||
content.SendSuccMessage(content.Executor, "已解锁所有锚点,指定UID:%v,场景ID:%v。", content.AssignPlayer.PlayerId, sceneId)
|
||||
return true
|
||||
}
|
||||
// 锚点id
|
||||
@@ -719,7 +719,7 @@ func (c *CommandManager) PointCommand(content *CommandContent) bool {
|
||||
return false
|
||||
}
|
||||
c.gmCmd.GMUnlockPoint(content.AssignPlayer.PlayerId, sceneId, uint32(pointId))
|
||||
content.SendSuccMessage(content.Executor, "已解锁锚点,指定UID:%v,场景ID:%v,锚点ID:%v。", content.AssignPlayer.PlayerId, content.AssignPlayer.GetSceneId(), pointId)
|
||||
content.SendSuccMessage(content.Executor, "已解锁锚点,指定UID:%v,场景ID:%v,锚点ID:%v。", content.AssignPlayer.PlayerId, sceneId, pointId)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -128,13 +128,13 @@ func (g *GMCmd) GMAddFlycloak(userId, flycloakId uint32) {
|
||||
}
|
||||
|
||||
// GMAddAllItem 添加玩家所有道具
|
||||
func (g *GMCmd) GMAddAllItem(userId uint32) {
|
||||
func (g *GMCmd) GMAddAllItem(userId uint32, itemCount uint32) {
|
||||
GAME.LogoutPlayer(userId)
|
||||
itemList := make([]*ChangeItem, 0)
|
||||
for itemId := range GAME.GetAllItemDataConfig() {
|
||||
itemList = append(itemList, &ChangeItem{
|
||||
ItemId: uint32(itemId),
|
||||
ChangeCount: 1,
|
||||
ChangeCount: itemCount,
|
||||
})
|
||||
}
|
||||
GAME.AddPlayerItem(userId, itemList, proto.ActionReasonType_ACTION_REASON_GM)
|
||||
@@ -180,7 +180,7 @@ func (g *GMCmd) GMAddAllFlycloak(userId uint32) {
|
||||
func (g *GMCmd) GMAddAll(userId uint32) {
|
||||
GAME.LogoutPlayer(userId)
|
||||
// 添加玩家所有道具
|
||||
g.GMAddAllItem(userId)
|
||||
g.GMAddAllItem(userId, 9999)
|
||||
// 添加玩家所有武器
|
||||
g.GMAddAllWeapon(userId, 1, 90, 6, 4)
|
||||
// 添加玩家所有圣遗物
|
||||
|
||||
@@ -222,26 +222,31 @@ func (c *CommandContent) Option(typeStr string, stepFunc CommandContentStepFunc)
|
||||
|
||||
// Execute 执行命令实际业务并返回结果
|
||||
func (c *CommandContent) Execute(thenFunc func() bool) bool {
|
||||
dynamicStepCount := 0 // 必填参数数量
|
||||
dynamicStepIndex := 0 // 必填参数最后的位置
|
||||
for i, step := range c.stepList {
|
||||
if step.StepType == CommandContentStepTypeDynamic {
|
||||
dynamicStepCount++
|
||||
dynamicStepIndex = i
|
||||
// 当前参数不能被执行的数量
|
||||
excludeParamCount := len(c.ParamList) - len(c.stepList)
|
||||
// 获取可选参数的数量
|
||||
optionStepCount := 0
|
||||
for _, step := range c.stepList {
|
||||
if step.StepType == CommandContentStepTypeOption {
|
||||
optionStepCount++
|
||||
}
|
||||
}
|
||||
// 可选参数可执行的数量
|
||||
optionExecCount := optionStepCount - excludeParamCount
|
||||
// 可选参数可执行的数量小于0代表肯定有个必填参数缺少
|
||||
if optionExecCount < 0 {
|
||||
return false
|
||||
}
|
||||
// 执行每个步骤
|
||||
for i, step := range c.stepList {
|
||||
switch step.StepType {
|
||||
case CommandContentStepTypeOption:
|
||||
// 可选参数 参数不足则不执行
|
||||
if i <= dynamicStepIndex {
|
||||
if len(c.ParamList) <= i+dynamicStepCount {
|
||||
continue
|
||||
}
|
||||
} else if len(c.ParamList) <= i {
|
||||
for _, step := range c.stepList {
|
||||
// 确保为可选参数 参数不足则不执行
|
||||
if step.StepType == CommandContentStepTypeOption {
|
||||
// 参数数量不足时跳过可选参数
|
||||
if optionExecCount <= 0 {
|
||||
continue
|
||||
}
|
||||
// 没有跳过代表后面会执行本次可选参数
|
||||
optionExecCount--
|
||||
}
|
||||
// 获取当前参数
|
||||
param, ok := c.getNextParam(step.ParamTypeStr)
|
||||
@@ -253,6 +258,7 @@ func (c *CommandContent) Execute(thenFunc func() bool) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
// 执行命令业务逻辑
|
||||
if thenFunc() {
|
||||
return true
|
||||
}
|
||||
@@ -536,7 +542,7 @@ func (c *CommandManager) ExecCommand(cmd *CommandMessage) {
|
||||
controller, ok := c.commandControllerMap[content.Name]
|
||||
if !ok {
|
||||
// 玩家可能会执行一些没有的命令仅做调试输出
|
||||
content.SendFailMessage(content.Executor, "命令 %v 不存在,输入 help 查看帮助。", cmd.Text)
|
||||
content.SendFailMessage(content.Executor, "命令 %v 不存在,你输入的命令 %v,输入 help 查看帮助。", content.Name, cmd.Text)
|
||||
return
|
||||
}
|
||||
// 设置控制器
|
||||
|
||||
@@ -300,26 +300,9 @@ func (p *PluginManager) DelPlugin(iPlugin IPlugin) {
|
||||
|
||||
// GetPlugin 获取插件实例
|
||||
func (p *PluginManager) GetPlugin(value IPlugin) (plugin IPlugin, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
switch x := r.(type) {
|
||||
case string:
|
||||
err = errors.New(x)
|
||||
case error:
|
||||
err = x
|
||||
default:
|
||||
err = errors.New("unknown panic")
|
||||
}
|
||||
}
|
||||
}()
|
||||
refValue := reflect.ValueOf(value)
|
||||
if refValue.Kind() != reflect.Pointer || refValue.IsNil() {
|
||||
return nil, errors.New("value is not pointer")
|
||||
}
|
||||
refType := refValue.Type()
|
||||
refType := reflect.TypeOf(value)
|
||||
// 校验插件是否注册
|
||||
exist := false
|
||||
plugin, exist = p.pluginMap[refType]
|
||||
plugin, exist := p.pluginMap[refType]
|
||||
if !exist {
|
||||
err = errors.New(fmt.Sprintf("plugin not exist, refType: %v", refType))
|
||||
return nil, err
|
||||
|
||||
@@ -1563,7 +1563,7 @@ func (g *Game) GetWeatherAreaClimate(weatherAreaId uint32) uint32 {
|
||||
for key := range weatherTemplateMap {
|
||||
weatherTemplateList = append(weatherTemplateList, key)
|
||||
}
|
||||
weather = random.GetRandomInt32(1, int32(len(weatherTemplateList)-1))
|
||||
weather = random.GetRandomInt32(1, int32(len(weatherTemplateList)))
|
||||
weatherTemplateConfig = weatherTemplateMap[weather]
|
||||
}
|
||||
// 确保指定的天气模版存在
|
||||
|
||||
Reference in new issue
Block a user