samba/server/truco/room/trucoEnum.go
2025-06-04 09:51:39 +08:00

279 lines
5.7 KiB
Go

package room
import (
"fmt"
"samba/server/truco/poker"
. "samba/util/playtype"
"samba/util/util"
)
type ActType string
const (
AtUnknown ActType = "0" // 未操作
AtGiveUp ActType = "1" // 放弃
AtAgree ActType = "2" // 同意
AtTruco3 ActType = "3" // 叫分
AtP6 ActType = "6" // 6:同意并加注到p6
AtP9 ActType = "9" // 9:同意并加注到p9
AtP12 ActType = "12" // 12:同意并加注到p12
)
func (t ActType) String(playType int) string {
switch t {
case AtUnknown:
return "未操作"
case AtGiveUp:
return "放弃"
case AtAgree:
return "同意"
case AtTruco3:
if playType == int(PtPaulistaClean) || playType == int(PtPaulistaDirty) {
return "truco3"
} else {
return "truco4"
}
case AtP6:
return "p6"
case AtP9:
if playType == int(PtPaulistaClean) || playType == int(PtPaulistaDirty) {
return "p9"
} else {
return "p10"
}
case AtP12:
return "p12"
}
return ""
}
func IntToActType(raise int) ActType {
switch raise {
case 0:
return AtUnknown
case 1:
return AtGiveUp
case 2:
return AtAgree
case 3, 30, 4, 40:
return AtTruco3
case 6, 60:
return AtP6
case 9, 90, 10, 100:
return AtP9
case 12, 120:
return AtP12
default:
return AtUnknown
}
}
func (t ActType) ToInt(playType int) int {
switch t {
case AtUnknown:
return 0
case AtGiveUp:
return 1
case AtAgree:
return 2
case AtTruco3:
if playType == int(PtPaulistaClean) || playType == int(PtPaulistaDirty) {
return 30
} else {
return 40
}
case AtP6:
return 60
case AtP9:
if playType == int(PtPaulistaClean) || playType == int(PtPaulistaDirty) {
return 90
} else {
return 100
}
case AtP12:
return 120
default:
return 0
}
}
type TeamColor int
const (
TcUnknown TeamColor = -1
TcRed TeamColor = 0 // 红方
TcGreen TeamColor = 1 // 绿方
)
func (t TeamColor) String() string {
switch t {
case TcRed:
return "red"
case TcGreen:
return "green"
case TcUnknown:
return "unknown"
}
return ""
}
type GameLight int
const (
GlRed GameLight = 0 // 红灯
GlGreen GameLight = 1 // 绿灯
GlNormalYellow GameLight = 2 // 黄灯 普通平
GlRedYellow GameLight = 3 // 黄灯 红方喊的truco-特殊平
GlGreenYellow GameLight = 4 // 黄灯 绿方喊的truco-特殊平
)
func (c GameLight) String() string {
switch c {
case GlRed:
return "red"
case GlGreen:
return "green"
case GlNormalYellow:
return "normal-yellow"
case GlRedYellow:
return "red-yellow"
case GlGreenYellow:
return "green-yellow"
default:
return "unknown"
}
}
// 灯的颜色,只有三种,红,绿,黄
func (c GameLight) Color() GameLight {
switch c {
case GlRed:
return GlRed
case GlGreen:
return GlGreen
default:
return GlNormalYellow
}
}
type GameStep int
const (
GsWaitGame GameStep = -1 // 等待玩家进入
GsReadyGame GameStep = 0 // 游戏准备状态
GsDealPoker GameStep = 1 // 发牌
GsDecidingAct GameStep = 2 // 决胜局广播
GsPlayerAct GameStep = 3 // 玩家行动
GsCmpPoker GameStep = 4 // 回合比牌
GsGameSettle GameStep = 5 // 小局或大局结算
)
func (t GameStep) String() string {
switch t {
case GsWaitGame:
return "WaitGame"
case GsReadyGame:
return "ReadyGame"
case GsDealPoker:
return "DealPoker"
case GsDecidingAct:
return "DecidingAct"
case GsPlayerAct:
return "PlayerAct"
case GsCmpPoker:
return "CmpPoker"
case GsGameSettle:
return "GameSettle"
default:
return fmt.Sprintf("(%d)", int(t))
}
}
const (
PlayerPokersNum = 3
)
// Emote 表情
type Emote int
const (
EArrogant Emote = 4100 + iota // 傲慢
EUnhappy // 不高兴
ELaugh // 大笑
EProud // 得意
EDevilSmile // 恶魔笑
EFlyingKiss // 飞吻
EInfatuation // 花痴
ECry // 哭
ESunglassesSmile // 墨镜笑
EAngry // 怒
EKiss // 亲亲
EDisappointed // 失望
ETongueOut // 吐舌
ESmile // 微笑
ELaughCry // 笑哭
EWink // 眨眼
EGrin // 龇牙
)
// RandNormalEmote 随机一个普通表情
func RandNormalEmote() Emote {
return util.RandRange(EArrogant, EGrin)
}
const (
EA Emote = 4200 // A
E2 Emote = 4201 // 2
E3 Emote = 4202 // 3
ESpade Emote = 4205 // 黑
EHeart Emote = 4204 // 红
EClub Emote = 4203 // 梅
EDiamond Emote = 4206 // 方
EBigger Emote = 4207 // 大牌
ESmaller Emote = 4208 // 小牌
)
var emoteToStringMap = map[Emote]string{
EArrogant: "傲慢",
EUnhappy: "不高兴",
ELaugh: "大笑",
EProud: "得意",
EDevilSmile: "恶魔笑",
EFlyingKiss: "飞吻",
EInfatuation: "花痴",
ECry: "哭",
ESunglassesSmile: "墨镜笑",
EAngry: "怒",
EKiss: "亲亲",
EDisappointed: "失望",
ETongueOut: "吐舌",
ESmile: "微笑",
ELaughCry: "笑哭",
EWink: "眨眼",
EGrin: "龇牙",
EA: "A",
E2: "2",
E3: "3",
ESpade: poker.Spade.String(),
EHeart: poker.Heart.String(),
EClub: poker.Club.String(),
EDiamond: poker.Diamond.String(),
EBigger: "bigger",
ESmaller: "smaller",
}
// IsSecret 是否为暗号表情
func (e Emote) IsSecret() bool {
return e >= 4200
}
func (e Emote) String() string {
str, ok := emoteToStringMap[e]
if !ok {
str = "unknown"
}
return str
}