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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
28 deletions
+29
-28
game.go
plugin/dapp/pokerbull/commands/game.go
+1
-1
exec_local.go
plugin/dapp/pokerbull/executor/exec_local.go
+1
-2
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+25
-24
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) {
...
@@ -162,7 +162,7 @@ func pokerbullPlay(cmd *cobra.Command, args []string) {
payload
:=
&
pkt
.
PBGamePlay
{
payload
:=
&
pkt
.
PBGamePlay
{
GameId
:
gameID
,
GameId
:
gameID
,
Value
:
int64
(
value
)
*
types
.
Coin
,
Value
:
int64
(
value
)
*
types
.
Coin
,
Round
:
int32
(
round
),
Round
:
int32
(
round
),
}
}
payload
.
Address
=
make
([]
string
,
len
(
address
))
payload
.
Address
=
make
([]
string
,
len
(
address
))
...
...
plugin/dapp/pokerbull/executor/exec_local.go
View file @
5a497198
...
@@ -88,4 +88,4 @@ func (c *PokerBull) ExecLocal_Quit(payload *pkt.PBGameQuit, tx *types.Transactio
...
@@ -88,4 +88,4 @@ func (c *PokerBull) ExecLocal_Quit(payload *pkt.PBGameQuit, tx *types.Transactio
// ExecLocal_Play 已匹配游戏交易local执行
// ExecLocal_Play 已匹配游戏交易local执行
func
(
c
*
PokerBull
)
ExecLocal_Play
(
payload
*
pkt
.
PBGamePlay
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
PokerBull
)
ExecLocal_Play
(
payload
*
pkt
.
PBGamePlay
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
c
.
execLocal
(
receiptData
)
return
c
.
execLocal
(
receiptData
)
}
}
\ No newline at end of file
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
5a497198
...
@@ -9,14 +9,15 @@ import (
...
@@ -9,14 +9,15 @@ import (
"sort"
"sort"
"strconv"
"strconv"
"strings"
"time"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
pkt
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
"time"
"strings"
)
)
// Action 斗牛action结构
// Action 斗牛action结构
...
@@ -527,11 +528,11 @@ func (action *Action) newGame(gameID string, start *pkt.PBGameStart) (*pkt.Poker
...
@@ -527,11 +528,11 @@ func (action *Action) newGame(gameID string, start *pkt.PBGameStart) (*pkt.Poker
// 筛选合适的牌局
// 筛选合适的牌局
func
(
action
*
Action
)
selectGameFromIds
(
ids
[]
string
,
value
int64
)
*
pkt
.
PokerBull
{
func
(
action
*
Action
)
selectGameFromIds
(
ids
[]
string
,
value
int64
)
*
pkt
.
PokerBull
{
var
gameRet
*
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
]
id
:=
ids
[
num
]
game
,
err
:=
action
.
readGame
(
id
)
game
,
err
:=
action
.
readGame
(
id
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"Poker bull game start"
,
"GameID"
,
id
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
logger
.
Error
(
"Poker bull game start"
,
"GameID"
,
id
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
"err"
,
err
)
"get game failed"
,
"err"
,
err
)
continue
continue
}
}
...
@@ -635,10 +636,10 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
...
@@ -635,10 +636,10 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
//加入当前玩家信息
//加入当前玩家信息
game
.
Players
=
append
(
game
.
Players
,
&
pkt
.
PBPlayer
{
game
.
Players
=
append
(
game
.
Players
,
&
pkt
.
PBPlayer
{
Address
:
action
.
fromaddr
,
Address
:
action
.
fromaddr
,
TxHash
:
txrng
,
TxHash
:
txrng
,
Ready
:
false
,
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) {
...
@@ -795,7 +796,7 @@ func (action *Action) GameQuit(pbend *pkt.PBGameQuit) (*types.Receipt, error) {
}
}
if
game
.
Status
==
pkt
.
PBGameActionQuit
{
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"
)
return
nil
,
fmt
.
Errorf
(
"already game over"
)
}
}
...
@@ -859,15 +860,15 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) {
...
@@ -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
,
","
)))
logger
.
Info
(
fmt
.
Sprintf
(
"Play pokerbull game %s, player:%s"
,
pbplay
.
GameId
,
strings
.
Join
(
pbplay
.
Address
,
","
)))
// 校验签名地址
// 校验签名地址
if
action
.
fromaddr
!=
pkt
.
PlatformSignAddress
{
if
action
.
fromaddr
!=
pkt
.
PlatformSignAddress
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"permission denied"
)
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"permission denied"
)
return
nil
,
fmt
.
Errorf
(
"game signing address not support"
)
return
nil
,
fmt
.
Errorf
(
"game signing address not support"
)
}
}
// 检查玩家人数
// 检查玩家人数
if
len
(
pbplay
.
Address
)
<
pkt
.
MinPlayerNum
||
len
(
pbplay
.
Address
)
>
pkt
.
MaxPlayerNum
{
if
len
(
pbplay
.
Address
)
<
pkt
.
MinPlayerNum
||
len
(
pbplay
.
Address
)
>
pkt
.
MaxPlayerNum
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"invalid player number"
)
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"invalid player number"
)
return
nil
,
fmt
.
Errorf
(
"Invalid player number"
)
return
nil
,
fmt
.
Errorf
(
"Invalid player number"
)
}
}
...
@@ -880,23 +881,23 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) {
...
@@ -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
!=
nil
{
if
game
.
Status
==
pkt
.
PBGameActionQuit
{
if
game
.
Status
==
pkt
.
PBGameActionQuit
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"already game over"
)
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"already game over"
)
return
nil
,
fmt
.
Errorf
(
"already game over"
)
return
nil
,
fmt
.
Errorf
(
"already game over"
)
}
}
if
game
.
Round
+
1
!=
pbplay
.
Round
{
if
game
.
Round
+
1
!=
pbplay
.
Round
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game round error"
)
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game round error"
)
return
nil
,
fmt
.
Errorf
(
"game round error"
)
return
nil
,
fmt
.
Errorf
(
"game round error"
)
}
}
if
game
.
Value
!=
pbplay
.
Value
{
if
game
.
Value
!=
pbplay
.
Value
{
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
logger
.
Error
(
"Pokerbull game play"
,
"GameID"
,
pbplay
.
GetGameId
(),
"round"
,
pbplay
.
Round
,
"value"
,
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game value error"
)
pbplay
.
Value
,
"players"
,
strings
.
Join
(
pbplay
.
Address
,
","
),
"err"
,
"game value error"
)
return
nil
,
fmt
.
Errorf
(
"game value error"
)
return
nil
,
fmt
.
Errorf
(
"game value error"
)
}
}
...
@@ -909,7 +910,7 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, 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
.
TxHash
=
rands
[
i
]
player
.
MatchTime
=
time
.
Unix
(
action
.
blocktime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
)
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
...
@@ -5,8 +5,9 @@ package types
import
(
import
(
fmt
"fmt"
fmt
"fmt"
proto
"github.com/golang/protobuf/proto"
math
"math"
math
"math"
proto
"github.com/golang/protobuf/proto"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// 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