机器人互动表情
This commit is contained in:
parent
864074490b
commit
4d9fee9b11
|
@ -613,6 +613,10 @@ const (
|
||||||
ItemIDWeekScore = 100004 // 周活跃积分
|
ItemIDWeekScore = 100004 // 周活跃积分
|
||||||
ItemIDGiftBox = 50001 // 碎片礼盒
|
ItemIDGiftBox = 50001 // 碎片礼盒
|
||||||
ItemIDCollectBox = 50002 // 集卡礼盒
|
ItemIDCollectBox = 50002 // 集卡礼盒
|
||||||
|
ItemIDLike = 100007 // 点赞
|
||||||
|
ItemIDCoffee = 100008 // 咖啡
|
||||||
|
ItemIDBucket = 100009 // 水桶
|
||||||
|
ItemIDSlippers = 100010 // 拖鞋
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToItemId(id int32) int32 {
|
func ToItemId(id int32) int32 {
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
6т├у├ж├в├с├"║█ю└=
|
6у├ж├в├с├т├"║█ю└=
|
||||||
.؆نچۆ"¡<>À„=
|
.؆نچۆ"¡<>À„=
|
||||||
Wы├з├ш├у├ж├в├с├т├ь├" ║█─╜Б
|
Wш├у├в├ь├з├с├т├ж├ы├" ║█─╜Б
|
||||||
]э├с├ж├з├ш├ы├т├у├в├ь├"╒█Т
|
]ш├с├т├у├ь├э├ж├в├ы├з├"╒█Т
|
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
@ -2987,3 +2987,32 @@ func GetASliceInt32NotInB(a []int32, b []int32) []int32 {
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsTwo(a []int32) bool {
|
||||||
|
if len(a) != 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return Value(a[0]) == 12 // 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsBomb 是否炸弹
|
||||||
|
// isClass 是否经典版
|
||||||
|
func IsBomb(a []int32, isClass bool) bool {
|
||||||
|
var n int
|
||||||
|
var has bool
|
||||||
|
if isClass {
|
||||||
|
has, n = RulePopEnable(a)
|
||||||
|
} else {
|
||||||
|
has, n = RulePopEnable_yl(a)
|
||||||
|
}
|
||||||
|
if !has {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch n {
|
||||||
|
case Straight_Twin, Four_Bomb:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
2
public
2
public
|
@ -1 +1 @@
|
||||||
Subproject commit 85842faf03f62e89cc711b3d150bc73ca68b64b7
|
Subproject commit a7fc5af077865e1daf27c8e04ff3247aa643a815
|
|
@ -0,0 +1,58 @@
|
||||||
|
package base
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"mongo.games.com/game/protocol/gamehall"
|
||||||
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 机器人互动操作
|
||||||
|
|
||||||
|
const (
|
||||||
|
none = -1
|
||||||
|
weixiao_01 = iota - 1
|
||||||
|
kaixin_02
|
||||||
|
kuqi_03
|
||||||
|
nanweiren_04
|
||||||
|
aini_05
|
||||||
|
dengyan_06
|
||||||
|
ganga_07
|
||||||
|
dahan_08
|
||||||
|
fahuo_09
|
||||||
|
maren_10
|
||||||
|
mihu_11
|
||||||
|
wulianxiao_12
|
||||||
|
shuashuai_13
|
||||||
|
haixiu_14
|
||||||
|
aixin_15
|
||||||
|
buai_16
|
||||||
|
zan_17
|
||||||
|
daozan_18
|
||||||
|
woshou_19
|
||||||
|
ok_20
|
||||||
|
fo_21
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Emote1 = []int{fahuo_09, dahan_08, nanweiren_04, dengyan_06, mihu_11, none}
|
||||||
|
Emote2 = []int{weixiao_01, dengyan_06, mihu_11, mihu_11, none}
|
||||||
|
Emote3 = []int{dengyan_06, fahuo_09, ganga_07, none}
|
||||||
|
Emote4 = []int{aini_05, wulianxiao_12, shuashuai_13, none}
|
||||||
|
Emote5 = []int{shuashuai_13, wulianxiao_12, none}
|
||||||
|
)
|
||||||
|
|
||||||
|
// SendEmote 随机表情
|
||||||
|
func SendEmote(s *netlib.Session, p IPlayer, arr []int) {
|
||||||
|
e := arr[rand.Intn(len(arr))] // 随机一个表情
|
||||||
|
if e == -1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := &gamehall.CSRoomEvent{
|
||||||
|
Tp: 2,
|
||||||
|
Content: "",
|
||||||
|
Param: []int32{int32(e)},
|
||||||
|
}
|
||||||
|
|
||||||
|
DelaySendSecond(s, int(gamehall.GameHallPacketID_PACKET_CSRoomEvent), pack, 2, 3)
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/gamerule/tienlen"
|
"mongo.games.com/game/gamerule/tienlen"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
|
"mongo.games.com/game/protocol/gamehall"
|
||||||
proto_tienlen "mongo.games.com/game/protocol/tienlen"
|
proto_tienlen "mongo.games.com/game/protocol/tienlen"
|
||||||
"mongo.games.com/game/robot/base"
|
"mongo.games.com/game/robot/base"
|
||||||
"mongo.games.com/goserver/core/basic"
|
"mongo.games.com/goserver/core/basic"
|
||||||
|
@ -79,16 +80,35 @@ func (this *SCTienLenPlayerOpHandler) Process(s *netlib.Session, packid int, pac
|
||||||
if int(scTienLenOp.GetOpRetCode()) == 0 {
|
if int(scTienLenOp.GetOpRetCode()) == 0 {
|
||||||
switch scTienLenOp.GetOpCode() {
|
switch scTienLenOp.GetOpCode() {
|
||||||
case tienlen.TienLenPlayerOpPlay:
|
case tienlen.TienLenPlayerOpPlay:
|
||||||
|
delC := []int32{}
|
||||||
delCards := scTienLenOp.GetOpParam()
|
delCards := scTienLenOp.GetOpParam()
|
||||||
for _, delcard := range delCards {
|
for _, delcard := range delCards {
|
||||||
for i, card := range me.Cards {
|
for i, card := range me.Cards {
|
||||||
if card != tienlen.InvalideCard && card == int32(delcard) {
|
if card != tienlen.InvalideCard && card == int32(delcard) {
|
||||||
me.Cards[i] = tienlen.InvalideCard
|
me.Cards[i] = tienlen.InvalideCard
|
||||||
|
delC = append(delC, card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastPlayer := scene.GetPlayerBySnid(scene.LastOpSnid)
|
||||||
|
if lastPlayer != nil && lastPlayer.IsRobot() && me.SnId != lastPlayer.GetSnId() &&
|
||||||
|
(tienlen.IsTwo(scene.LastCards) || tienlen.IsBomb(scene.LastCards, !common.IsTienLenYuLe(int(scene.GetGameId())))) {
|
||||||
|
// 机器人出2/炸弹被压制
|
||||||
|
base.SendEmote(base.PlayerMgrSingleton.GetPlayerSession(scene.LastOpSnid), lastPlayer, base.Emote1)
|
||||||
|
}
|
||||||
|
scene.LastCards = delC
|
||||||
|
scene.LastOpSnid = me.SnId
|
||||||
|
me.PassTimes = 0
|
||||||
case tienlen.TienLenPlayerOpPass:
|
case tienlen.TienLenPlayerOpPass:
|
||||||
|
me.PassTimes++
|
||||||
|
if me.PassTimes >= 2 {
|
||||||
|
me.PassTimes = 0
|
||||||
|
// 机器人过牌两次
|
||||||
|
base.SendEmote(s, me, base.Emote2)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else { //操作失败
|
} else { //操作失败
|
||||||
switch scTienLenOp.GetOpCode() {
|
switch scTienLenOp.GetOpCode() {
|
||||||
case tienlen.TienLenPlayerOpPlay: //出牌操作失败,改为过
|
case tienlen.TienLenPlayerOpPlay: //出牌操作失败,改为过
|
||||||
|
@ -440,6 +460,10 @@ func (this *SCTienLenCurOpPosHandler) Process(s *netlib.Session, packid int, pac
|
||||||
exDelayTs = notExDelayTs
|
exDelayTs = notExDelayTs
|
||||||
minS = notExDelayminS
|
minS = notExDelayminS
|
||||||
maxS = notExDelaymaxS
|
maxS = notExDelaymaxS
|
||||||
|
if scene.FirstWinSnid == 0 {
|
||||||
|
base.SendEmote(s, p, base.Emote5)
|
||||||
|
scene.FirstWinSnid = me.SnId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
base.DelaySendMillisecond(s, int(proto_tienlen.TienLenPacketID_PACKET_CSTienLenPlayerOp), packOp, []int{exDelayTs + minS, exDelayTs + maxS}...)
|
base.DelaySendMillisecond(s, int(proto_tienlen.TienLenPacketID_PACKET_CSTienLenPlayerOp), packOp, []int{exDelayTs + minS, exDelayTs + maxS}...)
|
||||||
}
|
}
|
||||||
|
@ -573,6 +597,45 @@ func (this *SCTienLenAIHandler) Process(s *netlib.Session, packid int, pack inte
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SCRoomEvent(s *netlib.Session, packid int, pack interface{}) error {
|
||||||
|
logger.Logger.Tracef("SCRoomEvent %v", pack)
|
||||||
|
msg, ok := pack.(*gamehall.SCRoomEvent)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if msg.Content == "" || len(msg.Param) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
scene, ok := base.GetScene(s).(*TienLenScene)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
p := scene.GetMe(s)
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pos, err := strconv.Atoi(msg.GetContent())
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if p.GetPos() != int32(pos) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
switch msg.Param[0] {
|
||||||
|
case common.ItemIDBucket, common.ItemIDSlippers:
|
||||||
|
base.SendEmote(s, p, base.Emote3)
|
||||||
|
case common.ItemIDLike, common.ItemIDCoffee:
|
||||||
|
base.SendEmote(s, p, base.Emote4)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
//SCTienLenRoomInfo
|
//SCTienLenRoomInfo
|
||||||
netlib.RegisterHandler(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenRoomInfo), &SCTienLenRoomInfoHandler{})
|
netlib.RegisterHandler(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenRoomInfo), &SCTienLenRoomInfoHandler{})
|
||||||
|
@ -598,4 +661,6 @@ func init() {
|
||||||
//SCTienLenAIData
|
//SCTienLenAIData
|
||||||
netlib.RegisterHandler(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenAI), &SCTienLenAIHandler{})
|
netlib.RegisterHandler(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenAI), &SCTienLenAIHandler{})
|
||||||
netlib.RegisterFactory(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenAI), &SCTienLenAIPacketFactory{})
|
netlib.RegisterFactory(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenAI), &SCTienLenAIPacketFactory{})
|
||||||
|
// SCRoomEvent
|
||||||
|
netlib.Register(int(gamehall.GameHallPacketID_PACKET_SCRoomEvent), gamehall.SCRoomEvent{}, SCRoomEvent)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ type TienLenPlayer struct {
|
||||||
base.BasePlayer
|
base.BasePlayer
|
||||||
*proto_tienlen.TienLenPlayerData
|
*proto_tienlen.TienLenPlayerData
|
||||||
data *tienlenApi.PredictRequest
|
data *tienlenApi.PredictRequest
|
||||||
|
PassTimes int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTienLenPlayer(data *proto_tienlen.TienLenPlayerData) *TienLenPlayer {
|
func NewTienLenPlayer(data *proto_tienlen.TienLenPlayerData) *TienLenPlayer {
|
||||||
|
@ -26,7 +27,7 @@ func (p *TienLenPlayer) Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *TienLenPlayer) Clear() {
|
func (p *TienLenPlayer) Clear() {
|
||||||
|
p.PassTimes = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *TienLenPlayer) MarkFlag(flag int32) {
|
func (p *TienLenPlayer) MarkFlag(flag int32) {
|
||||||
|
|
|
@ -14,6 +14,9 @@ type TienLenScene struct {
|
||||||
base.BaseScene
|
base.BaseScene
|
||||||
*proto_tienlen.SCTienLenRoomInfo
|
*proto_tienlen.SCTienLenRoomInfo
|
||||||
players map[int32]*TienLenPlayer
|
players map[int32]*TienLenPlayer
|
||||||
|
LastCards []int32 // 上一个机器人出的牌
|
||||||
|
LastOpSnid int32 // 上一个出牌的机器人
|
||||||
|
FirstWinSnid int32 // 第一个出完牌的玩家id
|
||||||
}
|
}
|
||||||
type filterFunc func(*TienLenScene, *TienLenPlayer, []int32, []int32, []int32, bool) (bool, []int32)
|
type filterFunc func(*TienLenScene, *TienLenPlayer, []int32, []int32, []int32, bool) (bool, []int32)
|
||||||
|
|
||||||
|
@ -47,6 +50,7 @@ func (s *TienLenScene) GetIsAllAi() bool {
|
||||||
return i == 4
|
return i == 4
|
||||||
}
|
}
|
||||||
func (s *TienLenScene) Clear() {
|
func (s *TienLenScene) Clear() {
|
||||||
|
s.FirstWinSnid = 0
|
||||||
for _, p := range s.players {
|
for _, p := range s.players {
|
||||||
p.Clear()
|
p.Clear()
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue