| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- package proto
- import (
- "context"
- "bet24.com/log"
- "bet24.com/servers/micros/common"
- "github.com/smallnest/rpcx/client"
- )
- const ServiceName = "cardlibrary"
- var consulAddr = common.Default_Consul_Addr
- func getClient() client.XClient {
- return common.GetClientPool().GetClient(ServiceName, consulAddr)
- }
- type Request struct {
- Name string
- LibraryType int
- ControlChair int
- FirstOutChair int
- Doublings int
- UserId int
- }
- type Response struct {
- Data string
- RetCode int
- Success bool
- ControlCards []int
- Library []BalootCardLibrary
- }
- type CardConf struct {
- ValueDesc string
- Count int
- }
- type ProjectConf struct {
- ProjectDesc string
- Count int
- IsShunZi bool
- }
- type BalootCardLibrary struct {
- Cards []CardConf
- Projects []ProjectConf
- SameTypeCount int
- PublicCard string
- }
- func SetConsulAddr(addr string) {
- consulAddr = addr
- }
- func SayHello(name string) string {
- xclient := getClient()
- args := &Request{
- Name: name,
- }
- reply := &Response{}
- err := xclient.Call(context.Background(), "SayHello", args, reply)
- if err != nil {
- log.Debug("waterpool failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return ""
- }
- log.Debug("SayHello return %s", reply.Data)
- return reply.Data
- }
- // 牌库类型
- const (
- Baloot_LibraryType_Scenario = iota // 剧情牌
- Baloot_LibraryType_Invincible // 无敌牌
- Baloot_LibraryType_HighScore // 高分牌
- Baloot_LibraryType_Doubling // 加倍场牌
- Baloot_LibraryType_NewUser // 新手牌
- Baloot_LibraryType_Doubling_Scenario // 加倍场多项目体验牌
- )
- func GetControlCards(libraryType, controlChair, firstOutCard, doublings int) (bool, []int) {
- xclient := getClient()
- args := &Request{
- LibraryType: libraryType,
- ControlChair: controlChair,
- FirstOutChair: firstOutCard,
- Doublings: doublings,
- }
- reply := &Response{}
- err := xclient.Call(context.Background(), "GetControlCards", args, reply)
- if err != nil {
- log.Debug("cardlibrary failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- }
- return reply.Success, reply.ControlCards
- }
- func GetUserControlCards(userId int) (bool, []BalootCardLibrary) {
- xclient := getClient()
- args := &Request{
- UserId: userId,
- }
- reply := &Response{}
- err := xclient.Call(context.Background(), "GetUserControlCards", args, reply)
- if err != nil {
- log.Debug("cardlibrary failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return false, []BalootCardLibrary{}
- }
- return reply.Success, reply.Library
- }
- func GetUserCardLibraryrWeightValue(userId int) int {
- xclient := getClient()
- args := &Request{
- UserId: userId,
- }
- reply := &Response{}
- err := xclient.Call(context.Background(), "GetUserCardLibraryrWeightValue", args, reply)
- if err != nil {
- log.Debug("cardlibrary failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return 0
- }
- return reply.RetCode
- }
|