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
285f6717
Commit
285f6717
authored
Dec 25, 2018
by
pengjun
Committed by
vipwzw
Jan 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pokerbull add time log
parent
9b5c0ca6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
13 deletions
+18
-13
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+13
-10
pokerbull.proto
plugin/dapp/pokerbull/proto/pokerbull.proto
+5
-3
pokerbull.pb.go
plugin/dapp/pokerbull/types/pokerbull.pb.go
+0
-0
No files found.
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
285f6717
...
...
@@ -16,6 +16,7 @@ import (
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
"time"
)
// Action 斗牛action结构
...
...
@@ -484,7 +485,7 @@ func (action *Action) newGame(gameID string, start *pkt.PBGameStart) (*pkt.Poker
game
=
&
pkt
.
PokerBull
{
GameId
:
gameID
,
Status
:
pkt
.
PBGameActionStart
,
StartTime
:
action
.
blocktime
,
StartTime
:
time
.
Unix
(
action
.
blocktime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
)
,
StartTxHash
:
gameID
,
Value
:
start
.
GetValue
(),
Poker
:
NewPoker
(),
...
...
@@ -497,7 +498,7 @@ func (action *Action) newGame(gameID string, start *pkt.PBGameStart) (*pkt.Poker
}
Shuffle
(
game
.
Poker
,
action
.
blocktime
)
//洗牌
logger
.
Debug
(
fmt
.
Sprintf
(
"Start
a new game %s for player %s"
,
game
.
GameId
,
action
.
fromaddr
))
logger
.
Info
(
fmt
.
Sprintf
(
"Create
a new game %s for player %s"
,
game
.
GameId
,
action
.
fromaddr
))
return
game
,
nil
}
...
...
@@ -560,7 +561,7 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
logger
.
Debug
(
fmt
.
Sprintf
(
"Pokerbull game start
for %s"
,
action
.
fromaddr
))
logger
.
Info
(
fmt
.
Sprintf
(
"Pokerbull game match
for %s"
,
action
.
fromaddr
))
if
start
.
PlayerNum
>
pkt
.
MaxPlayerNum
{
logger
.
Error
(
"GameStart"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"err"
,
fmt
.
Sprintf
(
"The maximum player number is %d"
,
pkt
.
MaxPlayerNum
))
...
...
@@ -599,7 +600,7 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
return
nil
,
err
}
}
logger
.
Debug
(
fmt
.
Sprintf
(
"Match a new game %s for player %s"
,
game
.
GameId
,
action
.
fromaddr
))
logger
.
Info
(
fmt
.
Sprintf
(
"Match a new game %s for player %s"
,
game
.
GameId
,
action
.
fromaddr
))
}
//发牌随机数取txhash
...
...
@@ -613,11 +614,12 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
Address
:
action
.
fromaddr
,
TxHash
:
txrng
,
Ready
:
false
,
MatchTime
:
time
.
Unix
(
action
.
blocktime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
),
})
// 如果人数达标,则发牌计算斗牛结果
if
len
(
game
.
Players
)
==
int
(
game
.
PlayerNum
)
{
logger
.
Debug
(
fmt
.
Sprintf
(
"Game start: %s"
,
game
.
GameI
d
))
logger
.
Info
(
fmt
.
Sprintf
(
"Game starting: %s round: %d"
,
game
.
GameId
,
game
.
Roun
d
))
logsH
,
kvH
,
err
:=
action
.
settleAccount
(
action
.
fromaddr
,
game
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -631,7 +633,7 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
game
.
PreStatus
=
pkt
.
PBGameActionStart
game
.
IsWaiting
=
false
}
else
{
logger
.
Debug
(
fmt
.
Sprintf
(
"Game waiting: %s"
,
game
.
GameI
d
))
logger
.
Info
(
fmt
.
Sprintf
(
"Game waiting: %s round: %d"
,
game
.
GameId
,
game
.
Roun
d
))
receipt
,
err
:=
action
.
coinsAccount
.
ExecFrozen
(
action
.
fromaddr
,
action
.
execaddr
,
start
.
GetValue
()
*
PokerbullLeverageMax
)
//冻结子账户资金, 最后一位玩家不需要冻结
if
err
!=
nil
{
logger
.
Error
(
"GameCreate.ExecFrozen"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"amount"
,
start
.
GetValue
(),
"err"
,
err
.
Error
())
...
...
@@ -683,7 +685,7 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei
pbcontinue
.
GetGameId
())
return
nil
,
err
}
logger
.
Debug
(
fmt
.
Sprintf
(
"Pokerbull game %s continue for
%s"
,
game
.
GameId
,
action
.
fromaddr
))
logger
.
Info
(
fmt
.
Sprintf
(
"Continue pokerbull game %s from
%s"
,
game
.
GameId
,
action
.
fromaddr
))
// 检查余额,庄家检查闲家数量倍数的资金
checkValue
:=
game
.
GetValue
()
*
PokerbullLeverageMax
...
...
@@ -716,9 +718,10 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei
}
pbplayer
.
TxHash
=
txrng
pbplayer
.
Ready
=
true
pbplayer
.
MatchTime
=
time
.
Unix
(
action
.
blocktime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
)
if
getReadyPlayerNum
(
game
.
Players
)
==
int
(
game
.
PlayerNum
)
{
logger
.
Debug
(
fmt
.
Sprintf
(
"Game start: %s"
,
game
.
GameI
d
))
logger
.
Info
(
fmt
.
Sprintf
(
"Game starting: %s round: %d"
,
game
.
GameId
,
game
.
Roun
d
))
logsH
,
kvH
,
err
:=
action
.
settleAccount
(
action
.
fromaddr
,
game
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -730,7 +733,7 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei
game
.
IsWaiting
=
false
game
.
PreStatus
=
pkt
.
PBGameActionContinue
}
else
{
logger
.
Debug
(
fmt
.
Sprintf
(
"Game waiting: %s
"
,
game
.
GameId
))
logger
.
Info
(
fmt
.
Sprintf
(
"Game waiting: %s round: %d
"
,
game
.
GameId
))
// 回合数加一次
if
!
game
.
IsWaiting
{
game
.
Round
++
...
...
@@ -799,7 +802,7 @@ func (action *Action) GameQuit(pbend *pkt.PBGameQuit) (*types.Receipt, error) {
game
.
Status
=
pkt
.
PBGameActionQuit
game
.
PrevIndex
=
game
.
Index
game
.
Index
=
action
.
getIndex
(
game
)
game
.
QuitTime
=
action
.
blocktime
game
.
QuitTime
=
time
.
Unix
(
action
.
blocktime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
)
game
.
QuitTxHash
=
common
.
ToHex
(
action
.
txhash
)
receiptLog
:=
action
.
GetReceiptLog
(
game
)
...
...
plugin/dapp/pokerbull/proto/pokerbull.proto
View file @
285f6717
...
...
@@ -6,7 +6,7 @@ package types;
message
PokerBull
{
string
gameId
=
1
;
//默认是由创建这局游戏的txHash作为gameId
int32
status
=
2
;
// Start 1 -> Continue 2 -> Quit 3
int64
startTime
=
3
;
//开始时间
string
startTime
=
3
;
//开始时间
string
startTxHash
=
4
;
//游戏启动交易hash
int64
value
=
5
;
//赌注
PBPoker
poker
=
6
;
//扑克牌
...
...
@@ -15,7 +15,7 @@ message PokerBull {
repeated
PBResult
results
=
9
;
//游戏结果集
int64
index
=
10
;
//索引
int64
prevIndex
=
11
;
//上级索引
int64
quitTime
=
12
;
//游戏结束时间
string
quitTime
=
12
;
//游戏结束时间
string
quitTxHash
=
13
;
//游戏结束交易hash
string
dealerAddr
=
14
;
//下局庄家地址
bool
isWaiting
=
15
;
//游戏是否处于等待状态
...
...
@@ -30,6 +30,7 @@ message PBHand {
string
address
=
3
;
//玩家地址
bool
isWin
=
4
;
//是否赢庄家
int32
leverage
=
5
;
//赌注倍数
string
roundTime
=
6
;
//本回合开始时间
}
//玩家
...
...
@@ -37,7 +38,8 @@ message PBPlayer {
repeated
PBHand
hands
=
1
;
//历史发牌和斗牛结果
string
address
=
2
;
//玩家地址
int64
txHash
=
3
;
//发牌随机数因子txhash的整数格式
bool
ready
=
4
;
// continue状态下,是否ready
bool
ready
=
4
;
//continue状态下,是否ready
string
matchTime
=
5
;
//玩家匹配时间
}
//本局游戏结果
...
...
plugin/dapp/pokerbull/types/pokerbull.pb.go
View file @
285f6717
This diff is collapsed.
Click to expand it.
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