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
c18f93fb
Commit
c18f93fb
authored
Dec 29, 2018
by
pengjun
Committed by
vipwzw
Jan 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pokerbull添加play交易执行
parent
285f6717
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
87 additions
and
6 deletions
+87
-6
game.go
plugin/dapp/pokerbull/commands/game.go
+51
-2
exec.go
plugin/dapp/pokerbull/executor/exec.go
+6
-0
exec_local.go
plugin/dapp/pokerbull/executor/exec_local.go
+7
-1
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+0
-0
pokerbull.proto
plugin/dapp/pokerbull/proto/pokerbull.proto
+9
-0
jrpc_channel_test.go
plugin/dapp/pokerbull/rpc/jrpc_channel_test.go
+1
-1
const.go
plugin/dapp/pokerbull/types/const.go
+11
-2
pokerbull.pb.go
plugin/dapp/pokerbull/types/pokerbull.pb.go
+0
-0
types.go
plugin/dapp/pokerbull/types/types.go
+2
-0
No files found.
plugin/dapp/pokerbull/commands/game.go
View file @
c18f93fb
...
@@ -28,6 +28,7 @@ func PokerBullCmd() *cobra.Command {
...
@@ -28,6 +28,7 @@ func PokerBullCmd() *cobra.Command {
PokerBullContinueRawTxCmd
(),
PokerBullContinueRawTxCmd
(),
PokerBullQuitRawTxCmd
(),
PokerBullQuitRawTxCmd
(),
PokerBullQueryResultRawTxCmd
(),
PokerBullQueryResultRawTxCmd
(),
PokerBullPlayRawTxCmd
(),
)
)
return
cmd
return
cmd
...
@@ -45,7 +46,7 @@ func PokerBullStartRawTxCmd() *cobra.Command {
...
@@ -45,7 +46,7 @@ func PokerBullStartRawTxCmd() *cobra.Command {
}
}
func
addPokerbullStartFlags
(
cmd
*
cobra
.
Command
)
{
func
addPokerbullStartFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Uint64P
(
"value"
,
"
a
"
,
0
,
"value"
)
cmd
.
Flags
()
.
Uint64P
(
"value"
,
"
v
"
,
0
,
"value"
)
cmd
.
MarkFlagRequired
(
"value"
)
cmd
.
MarkFlagRequired
(
"value"
)
cmd
.
Flags
()
.
Uint32P
(
"playerCount"
,
"p"
,
0
,
"player count"
)
cmd
.
Flags
()
.
Uint32P
(
"playerCount"
,
"p"
,
0
,
"player count"
)
...
@@ -121,7 +122,7 @@ func pokerbullQuit(cmd *cobra.Command, args []string) {
...
@@ -121,7 +122,7 @@ func pokerbullQuit(cmd *cobra.Command, args []string) {
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
Create
q
uitTx
,
ActionName
:
pkt
.
Create
Q
uitTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
}
}
...
@@ -130,6 +131,54 @@ func pokerbullQuit(cmd *cobra.Command, args []string) {
...
@@ -130,6 +131,54 @@ func pokerbullQuit(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
// PokerBullPlayRawTxCmd 生成已匹配玩家游戏命令行
func
PokerBullPlayRawTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"play"
,
Short
:
"Play game"
,
Run
:
pokerbullPlay
,
}
addPokerbullPlayFlags
(
cmd
)
return
cmd
}
func
addPokerbullPlayFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"gameID"
,
"g"
,
""
,
"game ID"
)
cmd
.
MarkFlagRequired
(
"gameID"
)
cmd
.
Flags
()
.
Uint32P
(
"round"
,
"r"
,
0
,
"round"
)
cmd
.
MarkFlagRequired
(
"round"
)
cmd
.
Flags
()
.
Uint64P
(
"value"
,
"v"
,
0
,
"value"
)
cmd
.
MarkFlagRequired
(
"value"
)
cmd
.
Flags
()
.
StringArrayP
(
"address"
,
"a"
,
nil
,
"address"
)
cmd
.
MarkFlagRequired
(
"address"
)
}
func
pokerbullPlay
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
round
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"round"
)
value
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"value"
)
address
,
_
:=
cmd
.
Flags
()
.
GetStringArray
(
"address"
)
payload
:=
&
pkt
.
PBGamePlay
{
GameId
:
gameID
,
Value
:
int64
(
value
)
*
types
.
Coin
,
Round
:
int32
(
round
),
}
payload
.
Address
=
make
([]
string
,
len
(
address
))
copy
(
payload
.
Address
,
address
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreatePlayTx
,
Payload
:
types
.
MustPBToJSON
(
payload
),
}
var
res
string
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.CreateTransaction"
,
params
,
&
res
)
ctx
.
RunWithoutMarshal
()
}
// PokerBullQueryResultRawTxCmd 查询命令行
// PokerBullQueryResultRawTxCmd 查询命令行
func
PokerBullQueryResultRawTxCmd
()
*
cobra
.
Command
{
func
PokerBullQueryResultRawTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
...
plugin/dapp/pokerbull/executor/exec.go
View file @
c18f93fb
...
@@ -26,3 +26,9 @@ func (c *PokerBull) Exec_Quit(payload *pkt.PBGameQuit, tx *types.Transaction, in
...
@@ -26,3 +26,9 @@ func (c *PokerBull) Exec_Quit(payload *pkt.PBGameQuit, tx *types.Transaction, in
action
:=
NewAction
(
c
,
tx
,
index
)
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameQuit
(
payload
)
return
action
.
GameQuit
(
payload
)
}
}
// Exec_Play 已匹配玩家直接开始游戏
func
(
c
*
PokerBull
)
Exec_Play
(
payload
*
pkt
.
PBGamePlay
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GamePlay
(
payload
)
}
plugin/dapp/pokerbull/executor/exec_local.go
View file @
c18f93fb
...
@@ -57,7 +57,7 @@ func (c *PokerBull) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, er
...
@@ -57,7 +57,7 @@ func (c *PokerBull) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, er
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
item
:=
receipt
.
Logs
[
i
]
item
:=
receipt
.
Logs
[
i
]
if
item
.
Ty
==
pkt
.
TyLogPBGameStart
||
item
.
Ty
==
pkt
.
TyLogPBGameContinue
||
item
.
Ty
==
pkt
.
TyLogPBGameQuit
{
if
item
.
Ty
==
pkt
.
TyLogPBGameStart
||
item
.
Ty
==
pkt
.
TyLogPBGameContinue
||
item
.
Ty
==
pkt
.
TyLogPBGameQuit
||
item
.
Ty
==
pkt
.
TyLogPBGamePlay
{
var
Gamelog
pkt
.
ReceiptPBGame
var
Gamelog
pkt
.
ReceiptPBGame
err
:=
types
.
Decode
(
item
.
Log
,
&
Gamelog
)
err
:=
types
.
Decode
(
item
.
Log
,
&
Gamelog
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -84,3 +84,8 @@ func (c *PokerBull) ExecLocal_Continue(payload *pkt.PBGameContinue, tx *types.Tr
...
@@ -84,3 +84,8 @@ func (c *PokerBull) ExecLocal_Continue(payload *pkt.PBGameContinue, tx *types.Tr
func
(
c
*
PokerBull
)
ExecLocal_Quit
(
payload
*
pkt
.
PBGameQuit
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
PokerBull
)
ExecLocal_Quit
(
payload
*
pkt
.
PBGameQuit
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
c
.
execLocal
(
receiptData
)
return
c
.
execLocal
(
receiptData
)
}
}
// ExecLocal_Play 已匹配游戏交易local执行
func
(
c
*
PokerBull
)
ExecLocal_Play
(
payload
*
pkt
.
PBGamePlay
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
c
.
execLocal
(
receiptData
)
}
\ No newline at end of file
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
c18f93fb
This diff is collapsed.
Click to expand it.
plugin/dapp/pokerbull/proto/pokerbull.proto
View file @
c18f93fb
...
@@ -64,6 +64,7 @@ message PBGameAction {
...
@@ -64,6 +64,7 @@ message PBGameAction {
PBGameContinue
continue
=
2
;
PBGameContinue
continue
=
2
;
PBGameQuit
quit
=
3
;
PBGameQuit
quit
=
3
;
PBGameQuery
query
=
4
;
PBGameQuery
query
=
4
;
PBGamePlay
play
=
5
;
}
}
int32
ty
=
10
;
int32
ty
=
10
;
}
}
...
@@ -89,6 +90,14 @@ message PBGameQuery {
...
@@ -89,6 +90,14 @@ message PBGameQuery {
string
gameId
=
1
;
string
gameId
=
1
;
}
}
//已匹配玩家直接游戏
message
PBGamePlay
{
string
gameId
=
1
;
//游戏id
int32
round
=
2
;
//当前游戏回合数
int64
value
=
3
;
//当前游戏赌注
repeated
string
address
=
4
;
//玩家地址
}
//根据状态和游戏人数查找
//根据状态和游戏人数查找
message
QueryPBGameListByStatusAndPlayerNum
{
message
QueryPBGameListByStatusAndPlayerNum
{
int32
status
=
1
;
int32
status
=
1
;
...
...
plugin/dapp/pokerbull/rpc/jrpc_channel_test.go
View file @
c18f93fb
...
@@ -97,7 +97,7 @@ func testQuitRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
...
@@ -97,7 +97,7 @@ func testQuitRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
payload
:=
&
pty
.
PBGameQuit
{
GameId
:
"123"
}
payload
:=
&
pty
.
PBGameQuit
{
GameId
:
"123"
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
PokerBullX
),
Execer
:
types
.
ExecName
(
pty
.
PokerBullX
),
ActionName
:
pty
.
Create
q
uitTx
,
ActionName
:
pty
.
Create
Q
uitTx
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
var
res
string
var
res
string
...
...
plugin/dapp/pokerbull/types/const.go
View file @
c18f93fb
...
@@ -12,6 +12,7 @@ const (
...
@@ -12,6 +12,7 @@ const (
PBGameActionContinue
PBGameActionContinue
PBGameActionQuit
PBGameActionQuit
PBGameActionQuery
PBGameActionQuery
PBGameActionPlay
)
)
const
(
const
(
...
@@ -30,6 +31,8 @@ const (
...
@@ -30,6 +31,8 @@ const (
TyLogPBGameQuit
=
723
TyLogPBGameQuit
=
723
// TyLogPBGameQuery log for query PBgame
// TyLogPBGameQuery log for query PBgame
TyLogPBGameQuery
=
724
TyLogPBGameQuery
=
724
// TyLogPBGamePlay log for play PBgame
TyLogPBGamePlay
=
725
)
)
//包的名字可以通过配置文件来配置
//包的名字可以通过配置文件来配置
...
@@ -56,8 +59,10 @@ const (
...
@@ -56,8 +59,10 @@ const (
CreateStartTx
=
"Start"
CreateStartTx
=
"Start"
// CreateContinueTx 创建继续交易
// CreateContinueTx 创建继续交易
CreateContinueTx
=
"Continue"
CreateContinueTx
=
"Continue"
// CreatequitTx 创建退出交易
// CreateQuitTx 创建退出交易
CreatequitTx
=
"Quit"
CreateQuitTx
=
"Quit"
// CreatePlayTx 创建已匹配玩家交易
CreatePlayTx
=
"Play"
)
)
const
(
const
(
...
@@ -67,6 +72,8 @@ const (
...
@@ -67,6 +72,8 @@ const (
DefaultCount
=
int32
(
20
)
DefaultCount
=
int32
(
20
)
// MaxPlayerNum 最大玩家数
// MaxPlayerNum 最大玩家数
MaxPlayerNum
=
5
MaxPlayerNum
=
5
// MinPlayerNum 最小玩家数
MinPlayerNum
=
2
// MinPlayValue 最小赌注
// MinPlayValue 最小赌注
MinPlayValue
=
10
*
types
.
Coin
MinPlayValue
=
10
*
types
.
Coin
// DefaultStyle 默认游戏类型
// DefaultStyle 默认游戏类型
...
@@ -81,4 +88,6 @@ const (
...
@@ -81,4 +88,6 @@ const (
DeveloperFee
=
int64
(
0.005
*
float64
(
types
.
Coin
))
DeveloperFee
=
int64
(
0.005
*
float64
(
types
.
Coin
))
// WinnerReturn 赢家回报率
// WinnerReturn 赢家回报率
WinnerReturn
=
types
.
Coin
-
DeveloperFee
WinnerReturn
=
types
.
Coin
-
DeveloperFee
// PlatformSignAddress 平台签名地址
PlatformSignAddress
=
"1Geb4ppNiAwMKKyrJgcis3JA57FkqsXvdR"
)
)
plugin/dapp/pokerbull/types/pokerbull.pb.go
View file @
c18f93fb
This diff is collapsed.
Click to expand it.
plugin/dapp/pokerbull/types/types.go
View file @
c18f93fb
...
@@ -46,6 +46,7 @@ func (t *PokerBullType) GetTypeMap() map[string]int32 {
...
@@ -46,6 +46,7 @@ func (t *PokerBullType) GetTypeMap() map[string]int32 {
"Continue"
:
PBGameActionContinue
,
"Continue"
:
PBGameActionContinue
,
"Quit"
:
PBGameActionQuit
,
"Quit"
:
PBGameActionQuit
,
"Query"
:
PBGameActionQuery
,
"Query"
:
PBGameActionQuery
,
"Play"
:
PBGameActionPlay
,
}
}
}
}
...
@@ -56,5 +57,6 @@ func (t *PokerBullType) GetLogMap() map[int64]*types.LogInfo {
...
@@ -56,5 +57,6 @@ func (t *PokerBullType) GetLogMap() map[int64]*types.LogInfo {
TyLogPBGameContinue
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptPBGame
{}),
Name
:
"TyLogPBGameContinue"
},
TyLogPBGameContinue
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptPBGame
{}),
Name
:
"TyLogPBGameContinue"
},
TyLogPBGameQuit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptPBGame
{}),
Name
:
"TyLogPBGameQuit"
},
TyLogPBGameQuit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptPBGame
{}),
Name
:
"TyLogPBGameQuit"
},
TyLogPBGameQuery
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptPBGame
{}),
Name
:
"TyLogPBGameQuery"
},
TyLogPBGameQuery
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptPBGame
{}),
Name
:
"TyLogPBGameQuery"
},
TyLogPBGamePlay
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptPBGame
{}),
Name
:
"TyLogPBGamePlay"
},
}
}
}
}
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