机器人互动表情

This commit is contained in:
sk 2024-04-28 10:13:38 +08:00
parent 864074490b
commit 4d9fee9b11
13 changed files with 1354 additions and 18 deletions

View File

@ -613,6 +613,10 @@ const (
ItemIDWeekScore = 100004 // 周活跃积分
ItemIDGiftBox = 50001 // 碎片礼盒
ItemIDCollectBox = 50002 // 集卡礼盒
ItemIDLike = 100007 // 点赞
ItemIDCoffee = 100008 // 咖啡
ItemIDBucket = 100009 // 水桶
ItemIDSlippers = 100010 // 拖鞋
)
func ToItemId(id int32) int32 {

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,5 +1,5 @@
6т├у├ж├в├с├"║█ю└=
6у├ж├в├ст"║█ю└=
.؆Ù†Ú†Û†"¡<>À„=
Wы├з├ш├у├ж├в├с├т├ь" ║█─╜Б
]э├с├ж├з├ш├ы├т├у├в├ь"╒█Т
Wш├у├в├ь├з├с├т├ж├ы" ║█─╜Б
]ш├с├т├у├ь├э├ж├в├ы├з"╒█Т

Binary file not shown.

View File

@ -2987,3 +2987,32 @@ func GetASliceInt32NotInB(a []int32, b []int32) []int32 {
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

@ -1 +1 @@
Subproject commit 85842faf03f62e89cc711b3d150bc73ca68b64b7
Subproject commit a7fc5af077865e1daf27c8e04ff3247aa643a815

58
robot/base/interaction.go Normal file
View File

@ -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)
}

View File

@ -8,6 +8,7 @@ import (
"mongo.games.com/game/common"
"mongo.games.com/game/gamerule/tienlen"
"mongo.games.com/game/proto"
"mongo.games.com/game/protocol/gamehall"
proto_tienlen "mongo.games.com/game/protocol/tienlen"
"mongo.games.com/game/robot/base"
"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 {
switch scTienLenOp.GetOpCode() {
case tienlen.TienLenPlayerOpPlay:
delC := []int32{}
delCards := scTienLenOp.GetOpParam()
for _, delcard := range delCards {
for i, card := range me.Cards {
if card != tienlen.InvalideCard && card == int32(delcard) {
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:
me.PassTimes++
if me.PassTimes >= 2 {
me.PassTimes = 0
// 机器人过牌两次
base.SendEmote(s, me, base.Emote2)
}
}
} else { //操作失败
switch scTienLenOp.GetOpCode() {
case tienlen.TienLenPlayerOpPlay: //出牌操作失败,改为过
@ -440,6 +460,10 @@ func (this *SCTienLenCurOpPosHandler) Process(s *netlib.Session, packid int, pac
exDelayTs = notExDelayTs
minS = notExDelayminS
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}...)
}
@ -573,6 +597,45 @@ func (this *SCTienLenAIHandler) Process(s *netlib.Session, packid int, pack inte
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() {
//SCTienLenRoomInfo
netlib.RegisterHandler(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenRoomInfo), &SCTienLenRoomInfoHandler{})
@ -598,4 +661,6 @@ func init() {
//SCTienLenAIData
netlib.RegisterHandler(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenAI), &SCTienLenAIHandler{})
netlib.RegisterFactory(int(proto_tienlen.TienLenPacketID_PACKET_SCTienLenAI), &SCTienLenAIPacketFactory{})
// SCRoomEvent
netlib.Register(int(gamehall.GameHallPacketID_PACKET_SCRoomEvent), gamehall.SCRoomEvent{}, SCRoomEvent)
}

View File

@ -12,7 +12,8 @@ var TienLenNilPlayer *TienLenPlayer = nil
type TienLenPlayer struct {
base.BasePlayer
*proto_tienlen.TienLenPlayerData
data *tienlenApi.PredictRequest
data *tienlenApi.PredictRequest
PassTimes int
}
func NewTienLenPlayer(data *proto_tienlen.TienLenPlayerData) *TienLenPlayer {
@ -26,7 +27,7 @@ func (p *TienLenPlayer) Init() {
}
func (p *TienLenPlayer) Clear() {
p.PassTimes = 0
}
func (p *TienLenPlayer) MarkFlag(flag int32) {

View File

@ -13,7 +13,10 @@ import (
type TienLenScene struct {
base.BaseScene
*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)
@ -47,6 +50,7 @@ func (s *TienLenScene) GetIsAllAi() bool {
return i == 4
}
func (s *TienLenScene) Clear() {
s.FirstWinSnid = 0
for _, p := range s.players {
p.Clear()
}

Binary file not shown.