You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
4.0 KiB
Go
150 lines
4.0 KiB
Go
package live_logic
|
|
|
|
//type (
|
|
// ZhghzGameLogic struct {
|
|
// *liveLogic
|
|
//
|
|
// // giftLogics 礼物处理 platform-cmd:logic
|
|
// giftLogics map[string]GiftLogic
|
|
// }
|
|
//)
|
|
//
|
|
//func NewZhghzLiveGameLogic() *ZhghzGameLogic {
|
|
// resp := &ZhghzGameLogic{
|
|
// giftLogics: make(map[string]GiftLogic),
|
|
// liveLogic: NewLiveGameLogic(pbRoom.GameType_ZHGHZ, cmd.NewCMDParser(cmd.Pattern{
|
|
// Prefix: "j",
|
|
// Alias: nil,
|
|
// ContentMaxLen: 0,
|
|
// }, cmd.Pattern{
|
|
// Prefix: "t",
|
|
// Alias: nil,
|
|
// ContentMaxLen: 1,
|
|
// }, cmd.Pattern{
|
|
// Prefix: "m",
|
|
// Alias: nil,
|
|
// ContentMaxLen: 1,
|
|
// }, cmd.Pattern{
|
|
// Prefix: "f",
|
|
// Alias: nil,
|
|
// ContentMaxLen: 0,
|
|
// }, cmd.Pattern{
|
|
// Prefix: "w",
|
|
// Alias: []string{"我在哪"},
|
|
// ContentMaxLen: 0,
|
|
// })),
|
|
// }
|
|
// resp.RegisterCMDHandler(resp.handleJoinGame, "j")
|
|
// resp.RegisterCMDHandler(resp.handleJoinGame, "t")
|
|
// resp.RegisterCMDHandler(resp.handleMove, "m")
|
|
// resp.RegisterCMDHandler(resp.handleShoot, "f")
|
|
// resp.RegisterCMDHandler(resp.handleWai, "w")
|
|
// // gift | game.chargeShield | game.giftShoot
|
|
// resp.RegisterGiftHandler(resp.handleGift)
|
|
// return resp
|
|
//}
|
|
//
|
|
//func (h *ZhghzGameLogic) handleJoinGame(roomId int64, _ string, content []rune, user *pbCommon.PbUser) {
|
|
// room, err := manager.GameManager.RoomByLiveRoom(roomId)
|
|
// if err != nil {
|
|
// return
|
|
// }
|
|
//
|
|
// var team int32
|
|
// if len(content) > 0 {
|
|
// v, _ := strconv.Atoi(string(content[0]))
|
|
// team = int32(v)
|
|
// }
|
|
// room.Broadcast("game.join", &pbGameZhghz.JoinGame{
|
|
// User: user,
|
|
// Team: team,
|
|
// })
|
|
//}
|
|
//
|
|
//func (h *ZhghzGameLogic) handleMove(roomId int64, _ string, content []rune, user *pbCommon.PbUser) {
|
|
// room, err := manager.GameManager.RoomByLiveRoom(roomId)
|
|
// if err != nil {
|
|
// return
|
|
// }
|
|
//
|
|
// if len(content) < 1 {
|
|
// return
|
|
// }
|
|
// v, _ := strconv.Atoi(string(content[0]))
|
|
//
|
|
// room.Broadcast("game.move", &pbGameZhghz.Move{
|
|
// User: user,
|
|
// Direction: int32(v),
|
|
// })
|
|
//}
|
|
//
|
|
//func (h *ZhghzGameLogic) handleShoot(roomId int64, _ string, _ []rune, user *pbCommon.PbUser) {
|
|
// room, err := manager.GameManager.RoomByLiveRoom(roomId)
|
|
// if err != nil {
|
|
// return
|
|
// }
|
|
// room.Broadcast("game.shoot", &pbGameZhghz.Shoot{
|
|
// User: user,
|
|
// })
|
|
//}
|
|
//
|
|
//func (h *ZhghzGameLogic) handleWai(roomId int64, _ string, _ []rune, user *pbCommon.PbUser) {
|
|
// room, err := manager.GameManager.RoomByLiveRoom(roomId)
|
|
// if err != nil {
|
|
// return
|
|
// }
|
|
// room.Broadcast("game.wai", &pbGameZhghz.Where{User: user})
|
|
//}
|
|
//
|
|
//func (h *ZhghzGameLogic) handleGiftLogic(cmd string, roomId int64, user *pbCommon.PbUser, gift *pbMq.MqGift) bool {
|
|
// if gl, ok := h.giftLogics[cmd]; ok {
|
|
// for _, id := range gl.GiftIds {
|
|
// if gift.GiftId == id {
|
|
// gl.Fn(roomId, user, gift)
|
|
// return true
|
|
// }
|
|
// }
|
|
// return true
|
|
// } else {
|
|
// return false
|
|
// }
|
|
//}
|
|
//
|
|
//func (h *ZhghzGameLogic) handleGift(roomId int64, user *pbCommon.PbUser, gift *pbMq.MqGift) {
|
|
// room, err := manager.GameManager.RoomByLiveRoom(roomId)
|
|
// if err != nil {
|
|
// return
|
|
// }
|
|
//
|
|
// // bilibili
|
|
// {
|
|
// logicKey := fmt.Sprintf("%s-game.chargeShield", gift.Platform)
|
|
// if ok := h.handleGiftLogic(logicKey, roomId, user, gift); !ok {
|
|
// // 1 辣条 | 30607 小心心 > 魔法护盾
|
|
// h.giftLogics[logicKey] = GiftLogic{
|
|
// GiftIds: []int64{1, 30607},
|
|
// Fn: func(roomId int64, user *pbCommon.PbUser, gift *pbMq.MqGift) {
|
|
// room.Broadcast("game.chargeShield", &pbGameZhghz.ChargeShield{
|
|
// User: user,
|
|
// Points: int32(gift.GiftNum * 1),
|
|
// })
|
|
// },
|
|
// }
|
|
// }
|
|
//
|
|
// logicKey = fmt.Sprintf("%s-game.giftShoot", gift.Platform)
|
|
// if ok := h.handleGiftLogic(logicKey, roomId, user, gift); !ok {
|
|
// // 31036 小花花 | 31039 牛哇牛哇 > 魔法飞弹
|
|
// h.giftLogics[logicKey] = GiftLogic{
|
|
// GiftIds: []int64{31036, 31039},
|
|
// Fn: func(roomId int64, user *pbCommon.PbUser, gift *pbMq.MqGift) {
|
|
// room.Broadcast("game.giftShoot", &pbGameZhghz.ChargeShield{
|
|
// User: user,
|
|
// Points: int32(gift.GiftNum * 1),
|
|
// })
|
|
// },
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|