62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
![]() |
package stub
|
|||
|
|
|||
|
import (
|
|||
|
"fmt"
|
|||
|
"samba/pkg/log"
|
|||
|
"samba/proto"
|
|||
|
)
|
|||
|
|
|||
|
const (
|
|||
|
Cacheta = "cacheta"
|
|||
|
Truco = "truco"
|
|||
|
)
|
|||
|
|
|||
|
type GamePlayType struct {
|
|||
|
Id int `json:"id"`
|
|||
|
Name string `json:"name"` // 玩法名称
|
|||
|
DecidingAgreePoint int `json:"point"` // 决胜手同意分
|
|||
|
TriggerDecidingPoint int `json:"trigger_point"` // 决胜手触发分数
|
|||
|
Draw int64 `json:"draw"` // 是否翻牌
|
|||
|
Raise int64 `json:"bet"` // 加分时是否加注
|
|||
|
}
|
|||
|
|
|||
|
var GamePlayTypes = map[int]*GamePlayType{
|
|||
|
10000: {
|
|||
|
Id: 1000,
|
|||
|
Name: "paulista-clean",
|
|||
|
DecidingAgreePoint: 3,
|
|||
|
TriggerDecidingPoint: 11,
|
|||
|
Draw: 1,
|
|||
|
Raise: 0,
|
|||
|
},
|
|||
|
}
|
|||
|
|
|||
|
func FindGamePlayTypeCnf(roomType int) (*GamePlayType, proto.ErrorCode) {
|
|||
|
if cnf, ok := GamePlayTypes[roomType]; ok {
|
|||
|
return cnf, proto.Ok
|
|||
|
}
|
|||
|
log.Error(fmt.Sprintf("roomType:%v is not exist", roomType))
|
|||
|
return nil, proto.Internal
|
|||
|
}
|
|||
|
|
|||
|
// FindPlayTypeCnfByGame 根据游戏名获取游戏类型的所有配置id
|
|||
|
func FindPlayTypeCnfByGame(name string) []int {
|
|||
|
rg := [2]int{}
|
|||
|
// 每种游戏的id值范围,左闭右开
|
|||
|
switch name {
|
|||
|
case Truco:
|
|||
|
rg[0], rg[1] = 1000, 1100
|
|||
|
case Cacheta:
|
|||
|
rg[0], rg[1] = 1100, 1200
|
|||
|
default:
|
|||
|
return nil
|
|||
|
}
|
|||
|
res := make([]int, 0)
|
|||
|
for id, _ := range GamePlayTypes {
|
|||
|
if id >= rg[0] && id < rg[1] {
|
|||
|
res = append(res, id)
|
|||
|
}
|
|||
|
}
|
|||
|
return res
|
|||
|
}
|