Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
0c401767
Commit
0c401767
authored
Nov 20, 2018
by
pengjun
Committed by
vipwzw
Nov 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pokerbull代码的linter告警整改
parent
f2a39b71
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
139 additions
and
124 deletions
+139
-124
game.go
plugin/dapp/pokerbull/commands/game.go
+9
-4
exec.go
plugin/dapp/pokerbull/executor/exec.go
+3
-0
exec_del_local.go
plugin/dapp/pokerbull/executor/exec_del_local.go
+3
-0
exec_local.go
plugin/dapp/pokerbull/executor/exec_local.go
+3
-0
poker.go
plugin/dapp/pokerbull/executor/poker.go
+51
-40
pokerbull.go
plugin/dapp/pokerbull/executor/pokerbull.go
+6
-2
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+39
-44
query.go
plugin/dapp/pokerbull/executor/query.go
+4
-0
jrpc.go
plugin/dapp/pokerbull/rpc/jrpc.go
+4
-0
rpc.go
plugin/dapp/pokerbull/rpc/rpc.go
+1
-1
tx.go
plugin/dapp/pokerbull/rpc/tx.go
+0
-26
types.go
plugin/dapp/pokerbull/rpc/types.go
+3
-0
const.go
plugin/dapp/pokerbull/types/const.go
+8
-6
types.go
plugin/dapp/pokerbull/types/types.go
+5
-1
No files found.
plugin/dapp/pokerbull/commands/game.go
View file @
0c401767
...
...
@@ -14,6 +14,7 @@ import (
"github.com/spf13/cobra"
)
// PokerBullCmd 斗牛游戏命令行
func
PokerBullCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"pokerbull"
,
...
...
@@ -31,6 +32,7 @@ func PokerBullCmd() *cobra.Command {
return
cmd
}
// PokerBullStartRawTxCmd 生成开始交易命令行
func
PokerBullStartRawTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"start"
,
...
...
@@ -69,6 +71,7 @@ func pokerbullStart(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
}
// PokerBullContinueRawTxCmd 生成继续游戏命令行
func
PokerBullContinueRawTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"continue"
,
...
...
@@ -101,6 +104,7 @@ func pokerbullContinue(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
}
// PokerBullQuitRawTxCmd 生成继续游戏命令行
func
PokerBullQuitRawTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"quit"
,
...
...
@@ -133,6 +137,7 @@ func pokerbullQuit(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
}
// PokerBullQueryResultRawTxCmd 查询命令行
func
PokerBullQueryResultRawTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"query"
,
...
...
@@ -171,22 +176,22 @@ func pokerbullQuery(cmd *cobra.Command, args []string) {
}
params
.
Payload
=
req
if
gameID
!=
""
{
params
.
FuncName
=
pkt
.
FuncName
_
QueryGameById
params
.
FuncName
=
pkt
.
FuncNameQueryGameById
var
res
pkt
.
ReplyPBGame
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
else
if
address
!=
""
{
params
.
FuncName
=
pkt
.
FuncName
_
QueryGameByAddr
params
.
FuncName
=
pkt
.
FuncNameQueryGameByAddr
var
res
pkt
.
PBGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
else
if
statusStr
!=
""
{
params
.
FuncName
=
pkt
.
FuncName
_
QueryGameByStatus
params
.
FuncName
=
pkt
.
FuncNameQueryGameByStatus
var
res
pkt
.
PBGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
else
if
gameIDs
!=
""
{
params
.
FuncName
=
pkt
.
FuncName
_
QueryGameListByIds
params
.
FuncName
=
pkt
.
FuncNameQueryGameListByIds
var
gameIDsS
[]
string
gameIDsS
=
append
(
gameIDsS
,
gameIDs
)
gameIDsS
=
append
(
gameIDsS
,
gameIDs
)
...
...
plugin/dapp/pokerbull/executor/exec.go
View file @
0c401767
...
...
@@ -9,16 +9,19 @@ import (
pkt
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
)
// Exec_Start 开始游戏交易执行
func
(
c
*
PokerBull
)
Exec_Start
(
payload
*
pkt
.
PBGameStart
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameStart
(
payload
)
}
// Exec_Continue 继续游戏交易执行
func
(
c
*
PokerBull
)
Exec_Continue
(
payload
*
pkt
.
PBGameContinue
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameContinue
(
payload
)
}
// Exec_Quit 退出游戏交易执行
func
(
c
*
PokerBull
)
Exec_Quit
(
payload
*
pkt
.
PBGameQuit
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameQuit
(
payload
)
...
...
plugin/dapp/pokerbull/executor/exec_del_local.go
View file @
0c401767
...
...
@@ -42,14 +42,17 @@ func (g *PokerBull) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDB
return
dbSet
,
nil
}
// ExecDelLocal_Start 开始游戏交易回滚
func
(
g
*
PokerBull
)
ExecDelLocal_Start
(
payload
*
pkt
.
PBGameStart
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execDelLocal
(
receiptData
)
}
// ExecDelLocal_Continue 继续游戏交易回滚
func
(
g
*
PokerBull
)
ExecDelLocal_Continue
(
payload
*
pkt
.
PBGameContinue
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execDelLocal
(
receiptData
)
}
// ExecDelLocal_Quit 退出游戏交易回滚
func
(
g
*
PokerBull
)
ExecDelLocal_Quit
(
payload
*
pkt
.
PBGameQuit
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execDelLocal
(
receiptData
)
}
plugin/dapp/pokerbull/executor/exec_local.go
View file @
0c401767
...
...
@@ -73,14 +73,17 @@ func (c *PokerBull) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, er
return
dbSet
,
nil
}
// ExecLocal_Start 开始游戏交易local执行
func
(
c
*
PokerBull
)
ExecLocal_Start
(
payload
*
pkt
.
PBGameStart
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
c
.
execLocal
(
receiptData
)
}
// ExecLocal_Continue 继续游戏交易local执行
func
(
c
*
PokerBull
)
ExecLocal_Continue
(
payload
*
pkt
.
PBGameContinue
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
c
.
execLocal
(
receiptData
)
}
// ExecLocal_Quit 退出游戏交易local执行
func
(
c
*
PokerBull
)
ExecLocal_Quit
(
payload
*
pkt
.
PBGameQuit
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
c
.
execLocal
(
receiptData
)
}
plugin/dapp/pokerbull/executor/poker.go
View file @
0c401767
...
...
@@ -12,58 +12,67 @@ import (
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
)
var
POKER_CARD_NUM
=
52
//4 * 13 不带大小王
var
COLOR_OFFSET
uint32
=
8
var
COLOR_BIT_MAST
=
0xFF
var
COLOR_NUM
=
4
var
CARD_NUM_PER_COLOR
=
13
var
CARD_NUM_PER_GAME
=
5
// 牌数,4 * 13 不带大小王
var
PokerCardNum
=
52
// 牌花色偏移
var
ColorOffset
uint32
=
8
// 牌花色bit掩码
var
ColorBitMask
=
0xFF
// 每种花色的牌数
var
CardNumPerColor
=
13
// 一手牌的牌数
var
CardNumPerGame
=
5
const
(
P
OKERBULL_RESULT_
X1
=
1
P
OKERBULL_RESULT_
X2
=
2
P
OKERBULL_RESULT_
X3
=
3
P
OKERBULL_RESULT_
X4
=
4
P
OKERBULL_RESULT_
X5
=
5
P
OKERBULL_LEVERAGE_MAX
=
POKERBULL_RESULT_
X1
P
okerbullResult
X1
=
1
P
okerbullResult
X2
=
2
P
okerbullResult
X3
=
3
P
okerbullResult
X4
=
4
P
okerbullResult
X5
=
5
P
okerbullLeverageMax
=
PokerbullResult
X1
)
// NewPoker 创建一副牌
func
NewPoker
()
*
types
.
PBPoker
{
poker
:=
new
(
types
.
PBPoker
)
poker
.
Cards
=
make
([]
int32
,
P
OKER_CARD_NUM
)
poker
.
Pointer
=
int32
(
P
OKER_CARD_NUM
-
1
)
poker
.
Cards
=
make
([]
int32
,
P
okerCardNum
)
poker
.
Pointer
=
int32
(
P
okerCardNum
-
1
)
for
i
:=
0
;
i
<
P
OKER_CARD_NUM
;
i
++
{
color
:=
i
/
C
ARD_NUM_PER_COLOR
num
:=
i
%
C
ARD_NUM_PER_COLOR
+
1
poker
.
Cards
[
i
]
=
int32
(
color
<<
C
OLOR_OFFSET
+
num
)
for
i
:=
0
;
i
<
P
okerCardNum
;
i
++
{
color
:=
i
/
C
ardNumPerColor
num
:=
i
%
C
ardNumPerColor
+
1
poker
.
Cards
[
i
]
=
int32
(
color
<<
C
olorOffset
+
num
)
}
return
poker
}
// 洗牌
//
Shuffle
洗牌
func
Shuffle
(
poker
*
types
.
PBPoker
,
rng
int64
)
{
rndn
:=
rand
.
New
(
rand
.
NewSource
(
rng
))
for
i
:=
0
;
i
<
P
OKER_CARD_NUM
;
i
++
{
idx
:=
rndn
.
Intn
(
P
OKER_CARD_NUM
-
1
)
for
i
:=
0
;
i
<
P
okerCardNum
;
i
++
{
idx
:=
rndn
.
Intn
(
P
okerCardNum
-
1
)
tmpV
:=
poker
.
Cards
[
idx
]
poker
.
Cards
[
idx
]
=
poker
.
Cards
[
P
OKER_CARD_NUM
-
i
-
1
]
poker
.
Cards
[
P
OKER_CARD_NUM
-
i
-
1
]
=
tmpV
poker
.
Cards
[
idx
]
=
poker
.
Cards
[
P
okerCardNum
-
i
-
1
]
poker
.
Cards
[
P
okerCardNum
-
i
-
1
]
=
tmpV
}
poker
.
Pointer
=
int32
(
P
OKER_CARD_NUM
-
1
)
poker
.
Pointer
=
int32
(
P
okerCardNum
-
1
)
}
// 发牌
//
Deal
发牌
func
Deal
(
poker
*
types
.
PBPoker
,
rng
int64
)
[]
int32
{
if
poker
.
Pointer
<
int32
(
C
ARD_NUM_PER_GAME
)
{
logger
.
Error
(
fmt
.
Sprintf
(
"Wait to be shuffled: deal cards [%d], left [%d]"
,
C
ARD_NUM_PER_GAME
,
poker
.
Pointer
+
1
))
if
poker
.
Pointer
<
int32
(
C
ardNumPerGame
)
{
logger
.
Error
(
fmt
.
Sprintf
(
"Wait to be shuffled: deal cards [%d], left [%d]"
,
C
ardNumPerGame
,
poker
.
Pointer
+
1
))
Shuffle
(
poker
,
rng
+
int64
(
poker
.
Cards
[
0
]))
}
rndn
:=
rand
.
New
(
rand
.
NewSource
(
rng
))
res
:=
make
([]
int32
,
C
ARD_NUM_PER_GAME
)
for
i
:=
0
;
i
<
C
ARD_NUM_PER_GAME
;
i
++
{
res
:=
make
([]
int32
,
C
ardNumPerGame
)
for
i
:=
0
;
i
<
C
ardNumPerGame
;
i
++
{
idx
:=
rndn
.
Intn
(
int
(
poker
.
Pointer
))
tmpV
:=
poker
.
Cards
[
poker
.
Pointer
]
res
[
i
]
=
poker
.
Cards
[
idx
]
...
...
@@ -75,7 +84,7 @@ func Deal(poker *types.PBPoker, rng int64) []int32 {
return
res
}
// 计算斗牛结果
//
Result
计算斗牛结果
func
Result
(
cards
[]
int32
)
int32
{
temp
:=
0
r
:=
-
1
//是否有牛标志
...
...
@@ -125,45 +134,45 @@ func Result(cards []int32) int32 {
return
int32
(
result
[
0
])
}
// 计算结果倍数
//
Leverage
计算结果倍数
func
Leverage
(
hand
*
types
.
PBHand
)
int32
{
result
:=
hand
.
Result
// 小牛 [1, 6]
if
result
<
7
{
return
P
OKERBULL_RESULT_
X1
return
P
okerbullResult
X1
}
// 大牛 [7, 9]
if
result
>=
7
&&
result
<
10
{
return
P
OKERBULL_RESULT_
X2
return
P
okerbullResult
X2
}
var
flowers
=
0
if
result
==
10
{
for
_
,
card
:=
range
hand
.
Cards
{
if
(
int
(
card
)
&
C
OLOR_BIT_MAST
)
>
10
{
if
(
int
(
card
)
&
C
olorBitMask
)
>
10
{
flowers
++
}
}
// 牛牛
if
flowers
<
4
{
return
P
OKERBULL_RESULT_
X3
return
P
okerbullResult
X3
}
// 四花
if
flowers
==
4
{
return
P
OKERBULL_RESULT_
X4
return
P
okerbullResult
X4
}
// 五花
if
flowers
==
5
{
return
P
OKERBULL_RESULT_
X5
return
P
okerbullResult
X5
}
}
return
P
OKERBULL_RESULT_
X1
return
P
okerbullResult
X1
}
type
pokerCard
struct
{
...
...
@@ -193,14 +202,15 @@ func (p colorCardSlice) Less(i, j int) bool {
func
newcolorCard
(
a
[]
int32
)
colorCardSlice
{
var
cardS
[]
*
pokerCard
for
i
:=
0
;
i
<
len
(
a
);
i
++
{
num
:=
int
(
a
[
i
])
&
C
OLOR_BIT_MAST
color
:=
int
(
a
[
i
])
>>
C
OLOR_OFFSET
num
:=
int
(
a
[
i
])
&
C
olorBitMask
color
:=
int
(
a
[
i
])
>>
C
olorOffset
cardS
=
append
(
cardS
,
&
pokerCard
{
num
,
color
})
}
return
cardS
}
// CompareResult 两手牌比较结果
func
CompareResult
(
i
,
j
*
types
.
PBHand
)
bool
{
if
i
.
Result
<
j
.
Result
{
return
true
...
...
@@ -213,6 +223,7 @@ func CompareResult(i, j *types.PBHand) bool {
return
false
}
// Compare 比较两手牌的斗牛结果
func
Compare
(
a
[]
int32
,
b
[]
int32
)
bool
{
cardA
:=
newcolorCard
(
a
)
cardB
:=
newcolorCard
(
b
)
...
...
plugin/dapp/pokerbull/executor/pokerbull.go
View file @
0c401767
...
...
@@ -15,6 +15,7 @@ import (
var
logger
=
log
.
New
(
"module"
,
"execs.pokerbull"
)
// Init 执行器初始化
func
Init
(
name
string
,
sub
[]
byte
)
{
drivers
.
Register
(
newPBGame
()
.
GetName
(),
newPBGame
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
}
...
...
@@ -26,6 +27,7 @@ func init() {
ety
.
InitFuncList
(
types
.
ListMethod
(
&
PokerBull
{}))
}
// PokerBull 斗牛执行器结构
type
PokerBull
struct
{
drivers
.
DriverBase
}
...
...
@@ -37,10 +39,12 @@ func newPBGame() drivers.Driver {
return
t
}
// GetName 获取斗牛执行器名
func
GetName
()
string
{
return
newPBGame
()
.
GetName
()
}
// GetDriverName 获取斗牛执行器名
func
(
g
*
PokerBull
)
GetDriverName
()
string
{
return
pkt
.
PokerBullX
}
...
...
@@ -118,11 +122,11 @@ func delPBGameAddrIndexKey(addr string, index int64) *types.KeyValue {
return
kv
}
func
addPBGameStatusAndPlayer
(
status
int32
,
player
int32
,
value
,
index
int64
,
gameI
d
string
)
*
types
.
KeyValue
{
func
addPBGameStatusAndPlayer
(
status
int32
,
player
int32
,
value
,
index
int64
,
gameI
D
string
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcPBGameStatusAndPlayerKey
(
status
,
player
,
value
,
index
)
record
:=
&
pkt
.
PBGameIndexRecord
{
GameId
:
gameI
d
,
GameId
:
gameI
D
,
Index
:
index
,
}
kv
.
Value
=
types
.
Encode
(
record
)
...
...
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
0c401767
This diff is collapsed.
Click to expand it.
plugin/dapp/pokerbull/executor/query.go
View file @
0c401767
...
...
@@ -9,10 +9,12 @@ import (
pkt
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
)
// Query_QueryGameListByIds 根据id列表查询游戏
func
(
g
*
PokerBull
)
Query_QueryGameListByIds
(
in
*
pkt
.
QueryPBGameInfos
)
(
types
.
Message
,
error
)
{
return
Infos
(
g
.
GetStateDB
(),
in
)
}
// Query_QueryGameById 根据id查询游戏
func
(
g
*
PokerBull
)
Query_QueryGameById
(
in
*
pkt
.
QueryPBGameInfo
)
(
types
.
Message
,
error
)
{
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
in
.
GetGameId
())
if
err
!=
nil
{
...
...
@@ -21,6 +23,7 @@ func (g *PokerBull) Query_QueryGameById(in *pkt.QueryPBGameInfo) (types.Message,
return
&
pkt
.
ReplyPBGame
{
game
},
nil
}
// Query_QueryGameByAddr 根据地址查询游戏
func
(
g
*
PokerBull
)
Query_QueryGameByAddr
(
in
*
pkt
.
QueryPBGameInfo
)
(
types
.
Message
,
error
)
{
gameIds
,
err
:=
getGameListByAddr
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Index
)
if
err
!=
nil
{
...
...
@@ -30,6 +33,7 @@ func (g *PokerBull) Query_QueryGameByAddr(in *pkt.QueryPBGameInfo) (types.Messag
return
gameIds
,
nil
}
// Query_QueryGameByStatus 根据状态查询游戏
func
(
g
*
PokerBull
)
Query_QueryGameByStatus
(
in
*
pkt
.
QueryPBGameInfo
)
(
types
.
Message
,
error
)
{
gameIds
,
err
:=
getGameListByStatus
(
g
.
GetLocalDB
(),
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
...
...
plugin/dapp/pokerbull/rpc/jrpc.go
View file @
0c401767
...
...
@@ -12,6 +12,7 @@ import (
pb
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
)
// PokerBullStartTx 创建游戏开始交易
func
(
c
*
Jrpc
)
PokerBullStartTx
(
parm
*
pb
.
PBStartTxReq
,
result
*
interface
{})
error
{
if
parm
==
nil
{
return
types
.
ErrInvalidParam
...
...
@@ -28,6 +29,7 @@ func (c *Jrpc) PokerBullStartTx(parm *pb.PBStartTxReq, result *interface{}) erro
return
nil
}
// PokerBullContinueTx 创建游戏继续交易
func
(
c
*
Jrpc
)
PokerBullContinueTx
(
parm
*
pb
.
PBContinueTxReq
,
result
*
interface
{})
error
{
if
parm
==
nil
{
return
types
.
ErrInvalidParam
...
...
@@ -46,6 +48,7 @@ func (c *Jrpc) PokerBullContinueTx(parm *pb.PBContinueTxReq, result *interface{}
return
nil
}
// PokerBullQuitTx 创建游戏推出交易
func
(
c
*
Jrpc
)
PokerBullQuitTx
(
parm
*
pb
.
PBQuitTxReq
,
result
*
interface
{})
error
{
if
parm
==
nil
{
return
types
.
ErrInvalidParam
...
...
@@ -63,6 +66,7 @@ func (c *Jrpc) PokerBullQuitTx(parm *pb.PBQuitTxReq, result *interface{}) error
return
nil
}
// PokerBullQueryTx 创建游戏查询交易
func
(
c
*
Jrpc
)
PokerBullQueryTx
(
parm
*
pb
.
PBQueryReq
,
result
*
interface
{})
error
{
if
parm
==
nil
{
return
types
.
ErrInvalidParam
...
...
plugin/dapp/pokerbull/rpc/rpc.go
View file @
0c401767
...
...
@@ -14,7 +14,7 @@ import (
)
func
(
c
*
channelClient
)
Start
(
ctx
context
.
Context
,
head
*
pb
.
PBGameStart
)
(
*
types
.
UnsignTx
,
error
)
{
if
head
.
PlayerNum
>
executor
.
M
AX_PLAYER_NUM
{
if
head
.
PlayerNum
>
executor
.
M
axPlayerNum
{
return
nil
,
errors
.
New
(
"Player number should be maximum 5"
)
}
...
...
plugin/dapp/pokerbull/rpc/tx.go
deleted
100644 → 0
View file @
f2a39b71
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
rpc
type
PokerBullStartTx
struct
{
Value
int64
`json:"value"`
PlayerNum
int32
`json:"playerNum"`
Fee
int64
`json:"fee"`
}
type
PBContinueTxReq
struct
{
GameId
string
`json:"gameId"`
Fee
int64
`json:"fee"`
}
type
PBQuitTxReq
struct
{
GameId
string
`json:"gameId"`
Fee
int64
`json:"fee"`
}
type
PBQueryReq
struct
{
GameId
string
`json:"GameId"`
Fee
int64
`json:"fee"`
}
plugin/dapp/pokerbull/rpc/types.go
View file @
0c401767
...
...
@@ -8,10 +8,12 @@ import (
"github.com/33cn/chain33/rpc/types"
)
// Jrpc jrpc句柄
type
Jrpc
struct
{
cli
*
channelClient
}
// Grpc grpc句柄
type
Grpc
struct
{
*
channelClient
}
...
...
@@ -20,6 +22,7 @@ type channelClient struct {
types
.
ChannelClient
}
// Init 初始化rpc
func
Init
(
name
string
,
s
types
.
RPCServer
)
{
cli
:=
&
channelClient
{}
grpc
:=
&
Grpc
{
channelClient
:
cli
}
...
...
plugin/dapp/pokerbull/types/const.go
View file @
0c401767
...
...
@@ -13,12 +13,13 @@ const (
)
const
(
// PlayStyleDefault 游戏类型
PlayStyleDefault
=
iota
+
1
PlayStyleDealer
)
const
(
//log for PBgame
//
TyLogPBGameStart
log for PBgame
TyLogPBGameStart
=
721
TyLogPBGameContinue
=
722
TyLogPBGameQuit
=
723
...
...
@@ -35,9 +36,10 @@ var (
)
const
(
//查询方法名
FuncName_QueryGameListByIds
=
"QueryGameListByIds"
FuncName_QueryGameById
=
"QueryGameById"
FuncName_QueryGameByAddr
=
"QueryGameByAddr"
FuncName_QueryGameByStatus
=
"QueryGameByStatus"
// FuncNameQueryGameListByIds 根据id列表查询game列表
FuncNameQueryGameListByIds
=
"QueryGameListByIds"
// FuncNameQueryGameById 根据id查询game
FuncNameQueryGameById
=
"QueryGameById"
FuncNameQueryGameByAddr
=
"QueryGameByAddr"
FuncNameQueryGameByStatus
=
"QueryGameByStatus"
)
plugin/dapp/pokerbull/types/types.go
View file @
0c401767
...
...
@@ -17,21 +17,24 @@ func init() {
types
.
RegisterDappFork
(
PokerBullX
,
"Enable"
,
0
)
}
//
exec
//
PokerBullType 斗牛执行器类型
type
PokerBullType
struct
{
types
.
ExecTypeBase
}
// NewType 创建pokerbull执行器类型
func
NewType
()
*
PokerBullType
{
c
:=
&
PokerBullType
{}
c
.
SetChild
(
c
)
return
c
}
// GetPayload 获取payload
func
(
t
*
PokerBullType
)
GetPayload
()
types
.
Message
{
return
&
PBGameAction
{}
}
// GetTypeMap 获取类型map
func
(
t
*
PokerBullType
)
GetTypeMap
()
map
[
string
]
int32
{
return
map
[
string
]
int32
{
"Start"
:
PBGameActionStart
,
...
...
@@ -41,6 +44,7 @@ func (t *PokerBullType) GetTypeMap() map[string]int32 {
}
}
// GetLogMap 获取日志map
func
(
t
*
PokerBullType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
TyLogPBGameStart
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameStart"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment