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
5a497198
Commit
5a497198
authored
Jan 07, 2019
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
929cdc00
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
20 deletions
+22
-20
game.go
plugin/dapp/pokerbull/commands/game.go
+1
-1
exec_local.go
plugin/dapp/pokerbull/executor/exec_local.go
+0
-0
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+19
-18
pokerbull.pb.go
plugin/dapp/pokerbull/types/pokerbull.pb.go
+2
-1
No files found.
plugin/dapp/pokerbull/commands/game.go
View file @
5a497198
...
...
@@ -162,7 +162,7 @@ func pokerbullPlay(cmd *cobra.Command, args []string) {
payload
:=
&
pkt
.
PBGamePlay
{
GameId
:
gameID
,
Value
:
int64
(
value
)
*
types
.
Coin
,
Value
:
int64
(
value
)
*
types
.
Coin
,
Round
:
int32
(
round
),
}
payload
.
Address
=
make
([]
string
,
len
(
address
))
...
...
plugin/dapp/pokerbull/executor/exec_local.go
View file @
5a497198
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
5a497198
...
...
@@ -9,14 +9,15 @@ import (
"sort"
"strconv"
"strings"
"time"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
"time"
"strings"
)
// Action 斗牛action结构
...
...
@@ -527,7 +528,7 @@ func (action *Action) newGame(gameID string, start *pkt.PBGameStart) (*pkt.Poker
// 筛选合适的牌局
func
(
action
*
Action
)
selectGameFromIds
(
ids
[]
string
,
value
int64
)
*
pkt
.
PokerBull
{
var
gameRet
*
pkt
.
PokerBull
for
num
:=
len
(
ids
)
-
1
;
num
>
-
1
;
num
--
{
for
num
:=
len
(
ids
)
-
1
;
num
>
-
1
;
num
--
{
id
:=
ids
[
num
]
game
,
err
:=
action
.
readGame
(
id
)
if
err
!=
nil
{
...
...
@@ -638,7 +639,7 @@ 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"
),
MatchTime
:
time
.
Unix
(
action
.
blocktime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
),
})
// 如果人数达标,则发牌计算斗牛结果
...
...
@@ -795,7 +796,7 @@ func (action *Action) GameQuit(pbend *pkt.PBGameQuit) (*types.Receipt, error) {
}
if
game
.
Status
==
pkt
.
PBGameActionQuit
{
logger
.
Error
(
"Quit pokerbull game"
,
"GameID"
,
pbend
.
GetGameId
(),
"value"
,
game
.
Value
,
"err"
,
"already game over"
)
logger
.
Error
(
"Quit pokerbull game"
,
"GameID"
,
pbend
.
GetGameId
(),
"value"
,
game
.
Value
,
"err"
,
"already game over"
)
return
nil
,
fmt
.
Errorf
(
"already game over"
)
}
...
...
@@ -859,15 +860,15 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) {
logger
.
Info
(
fmt
.
Sprintf
(
"Play pokerbull game %s, player:%s"
,
pbplay
.
GameId
,
strings
.
Join
(
pbplay
.
Address
,
","
)))
// 校验签名地址
if
action
.
fromaddr
!=
pkt
.
PlatformSignAddress
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"permission denied"
)
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"permission denied"
)
return
nil
,
fmt
.
Errorf
(
"game signing address not support"
)
}
// 检查玩家人数
if
len
(
pbplay
.
Address
)
<
pkt
.
MinPlayerNum
||
len
(
pbplay
.
Address
)
>
pkt
.
MaxPlayerNum
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"invalid player number"
)
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"invalid player number"
)
return
nil
,
fmt
.
Errorf
(
"Invalid player number"
)
}
...
...
@@ -880,23 +881,23 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) {
}
// 游戏存在则校验游戏状态,不存在则创建游戏
game
,
_
:=
action
.
readGame
(
pbplay
.
GetGameId
())
game
,
_
:=
action
.
readGame
(
pbplay
.
GetGameId
())
if
game
!=
nil
{
if
game
.
Status
==
pkt
.
PBGameActionQuit
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"already game over"
)
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"already game over"
)
return
nil
,
fmt
.
Errorf
(
"already game over"
)
}
if
game
.
Round
+
1
!=
pbplay
.
Round
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game round error"
)
if
game
.
Round
+
1
!=
pbplay
.
Round
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game round error"
)
return
nil
,
fmt
.
Errorf
(
"game round error"
)
}
if
game
.
Value
!=
pbplay
.
Value
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game value error"
)
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game value error"
)
return
nil
,
fmt
.
Errorf
(
"game value error"
)
}
...
...
@@ -909,7 +910,7 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) {
}
// 更新玩家信息
for
i
,
player
:=
range
game
.
Players
{
for
i
,
player
:=
range
game
.
Players
{
player
.
TxHash
=
rands
[
i
]
player
.
MatchTime
=
time
.
Unix
(
action
.
blocktime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
)
}
...
...
plugin/dapp/pokerbull/types/pokerbull.pb.go
View file @
5a497198
...
...
@@ -5,8 +5,9 @@ package types
import
(
fmt
"fmt"
proto
"github.com/golang/protobuf/proto"
math
"math"
proto
"github.com/golang/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
...
...
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