|
|
@ -52,10 +52,6 @@ func (h *ZhgmangGameLogic) WithCmdParserLogic(p []cmd.Pattern) LogicOption {
|
|
|
|
Prefix: "m",
|
|
|
|
Prefix: "m",
|
|
|
|
Alias: []string{"莽"},
|
|
|
|
Alias: []string{"莽"},
|
|
|
|
ContentMaxLen: 0,
|
|
|
|
ContentMaxLen: 0,
|
|
|
|
}, {
|
|
|
|
|
|
|
|
Prefix: "s",
|
|
|
|
|
|
|
|
Alias: []string{"升级"},
|
|
|
|
|
|
|
|
ContentMaxLen: 0,
|
|
|
|
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
Prefix: "n",
|
|
|
|
Prefix: "n",
|
|
|
|
ContentMaxLen: 8,
|
|
|
|
ContentMaxLen: 8,
|
|
|
@ -73,7 +69,6 @@ func (h *ZhgmangGameLogic) WithCmdHandlers() LogicOption {
|
|
|
|
logic.RegisterCMDHandler(h.handleJoinGame, "j")
|
|
|
|
logic.RegisterCMDHandler(h.handleJoinGame, "j")
|
|
|
|
logic.RegisterCMDHandler(h.handleAddUnit, "c")
|
|
|
|
logic.RegisterCMDHandler(h.handleAddUnit, "c")
|
|
|
|
logic.RegisterCMDHandler(h.handleWai, "w")
|
|
|
|
logic.RegisterCMDHandler(h.handleWai, "w")
|
|
|
|
logic.RegisterCMDHandler(h.handleLevelUp, "s")
|
|
|
|
|
|
|
|
logic.RegisterCMDHandler(h.handleMockGift, "n")
|
|
|
|
logic.RegisterCMDHandler(h.handleMockGift, "n")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -148,19 +143,6 @@ func (h *ZhgmangGameLogic) handleWai(liveRoom *LiveRoom, _ string, _ []rune, use
|
|
|
|
room.Broadcast(pb.PushZhgmangWai, &pbGameZhgMang.Wai{User: user})
|
|
|
|
room.Broadcast(pb.PushZhgmangWai, &pbGameZhgMang.Wai{User: user})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (h *ZhgmangGameLogic) handleLevelUp(liveRoom *LiveRoom, _ string, _ []rune, user *pbCommon.PbUser) {
|
|
|
|
|
|
|
|
room, err := manager.GameManager.RoomByLiveRoom(liveRoom.RoomId, liveRoom.Platform)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.SLog.Debugf("用户 [%s] 基地升级", user.Username)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
room.Broadcast(pb.PushZhgmangLevelUp, &pbGameZhgMang.LevelUp{
|
|
|
|
|
|
|
|
User: user,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (h *ZhgmangGameLogic) handleMockGift(liveRoom *LiveRoom, _ string, content []rune, user *pbCommon.PbUser) {
|
|
|
|
func (h *ZhgmangGameLogic) handleMockGift(liveRoom *LiveRoom, _ string, content []rune, user *pbCommon.PbUser) {
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
room, err := manager.GameManager.RoomByLiveRoom(liveRoom.RoomId, liveRoom.Platform)
|
|
|
|
room, err := manager.GameManager.RoomByLiveRoom(liveRoom.RoomId, liveRoom.Platform)
|
|
|
@ -202,11 +184,11 @@ func (h *ZhgmangGameLogic) handleMockGift(liveRoom *LiveRoom, _ string, content
|
|
|
|
case "lt":
|
|
|
|
case "lt":
|
|
|
|
h.goldSpeedUp(room, user, float64(count)*0.1)
|
|
|
|
h.goldSpeedUp(room, user, float64(count)*0.1)
|
|
|
|
case "qp":
|
|
|
|
case "qp":
|
|
|
|
h.clearScreen(room, user)
|
|
|
|
h.clearScreen(room, user, int(count))
|
|
|
|
case "rd":
|
|
|
|
case "rd":
|
|
|
|
h.randomAddon(room, user)
|
|
|
|
h.randomAddon(room, user, int(count))
|
|
|
|
case "hb":
|
|
|
|
case "hb":
|
|
|
|
h.redPackAddon(room, user)
|
|
|
|
h.redPackAddon(room, user, int(count))
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
h.goldSpeedUp(room, user, float64(count))
|
|
|
|
h.goldSpeedUp(room, user, float64(count))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -228,27 +210,21 @@ func (h *ZhgmangGameLogic) handleGift(liveRoom *LiveRoom, user *pbCommon.PbUser,
|
|
|
|
case config.ZhgmangGiftFree:
|
|
|
|
case config.ZhgmangGiftFree:
|
|
|
|
h.goldSpeedUp(room, user, float64(gift.GiftNum)*0.1)
|
|
|
|
h.goldSpeedUp(room, user, float64(gift.GiftNum)*0.1)
|
|
|
|
case config.ZhgmangGiftClearScreen:
|
|
|
|
case config.ZhgmangGiftClearScreen:
|
|
|
|
for i := 0; i < int(gift.GiftNum); i++ {
|
|
|
|
h.clearScreen(room, user, int(gift.GiftNum))
|
|
|
|
h.clearScreen(room, user)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case config.ZhgmangGiftRandomAddon:
|
|
|
|
case config.ZhgmangGiftRandomAddon:
|
|
|
|
for i := 0; i < int(gift.GiftNum); i++ {
|
|
|
|
h.randomAddon(room, user, int(gift.GiftNum))
|
|
|
|
h.randomAddon(room, user)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
h.goldSpeedUp(room, user, float64(gift.GiftNum*gift.Price)*0.01)
|
|
|
|
h.goldSpeedUp(room, user, float64(gift.GiftNum*gift.Price)*0.01)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case pbMq.MqGift_PACK:
|
|
|
|
case pbMq.MqGift_PACK:
|
|
|
|
if cfgGiftType == config.ZhgmangGiftClearScreen {
|
|
|
|
if cfgGiftType == config.ZhgmangGiftClearScreen {
|
|
|
|
for i := 0; i < int(gift.GiftNum); i++ {
|
|
|
|
h.clearScreen(room, user, int(gift.GiftNum))
|
|
|
|
h.clearScreen(room, user)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
h.goldSpeedUp(room, user, float64(gift.GiftNum)*0.01)
|
|
|
|
h.goldSpeedUp(room, user, float64(gift.GiftNum)*0.01)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case pbMq.MqGift_RED_PACK:
|
|
|
|
case pbMq.MqGift_RED_PACK:
|
|
|
|
// 红包
|
|
|
|
// 红包
|
|
|
|
h.redPackAddon(room, user)
|
|
|
|
h.redPackAddon(room, user, int(gift.GiftNum))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -259,20 +235,26 @@ func (h *ZhgmangGameLogic) goldSpeedUp(room *manager.Room, user *pbCommon.PbUser
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (h *ZhgmangGameLogic) clearScreen(room *manager.Room, user *pbCommon.PbUser) {
|
|
|
|
func (h *ZhgmangGameLogic) clearScreen(room *manager.Room, user *pbCommon.PbUser, count int) {
|
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
room.Broadcast(pb.PushZhgmangClearScreen, &pbGameZhgMang.ClearScreen{
|
|
|
|
room.Broadcast(pb.PushZhgmangClearScreen, &pbGameZhgMang.ClearScreen{
|
|
|
|
User: user,
|
|
|
|
User: user,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (h *ZhgmangGameLogic) randomAddon(room *manager.Room, user *pbCommon.PbUser) {
|
|
|
|
func (h *ZhgmangGameLogic) randomAddon(room *manager.Room, user *pbCommon.PbUser, count int) {
|
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
room.Broadcast(pb.PushZhgmangRandomAddon, &pbGameZhgMang.RandomAddon{
|
|
|
|
room.Broadcast(pb.PushZhgmangRandomAddon, &pbGameZhgMang.RandomAddon{
|
|
|
|
User: user,
|
|
|
|
User: user,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (h *ZhgmangGameLogic) redPackAddon(room *manager.Room, user *pbCommon.PbUser) {
|
|
|
|
func (h *ZhgmangGameLogic) redPackAddon(room *manager.Room, user *pbCommon.PbUser, count int) {
|
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
room.Broadcast(pb.PushZhgmangRedPackAddon, &pbGameZhgMang.RedPackAddon{
|
|
|
|
room.Broadcast(pb.PushZhgmangRedPackAddon, &pbGameZhgMang.RedPackAddon{
|
|
|
|
User: user,
|
|
|
|
User: user,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|