Commit e22ff037 authored by 张振华's avatar 张振华

guess

parent af1ce4be
...@@ -14,12 +14,17 @@ func (c *Guess) Exec_Start(payload *pkt.GuessGameStart, tx *types.Transaction, i ...@@ -14,12 +14,17 @@ func (c *Guess) Exec_Start(payload *pkt.GuessGameStart, tx *types.Transaction, i
return action.GameStart(payload) return action.GameStart(payload)
} }
func (c *Guess) Exec_Continue(payload *pkt.PBGameContinue, tx *types.Transaction, index int) (*types.Receipt, error) { func (c *Guess) Exec_Bet(payload *pkt.GuessGameBet, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(c, tx, index) action := NewAction(c, tx, index)
return action.GameContinue(payload) return action.GameBet(payload)
} }
func (c *Guess) Exec_Quit(payload *pkt.PBGameQuit, tx *types.Transaction, index int) (*types.Receipt, error) { func (c *Guess) Exec_Publish(payload *pkt.GuessGamePublish, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(c, tx, index) action := NewAction(c, tx, index)
return action.GameQuit(payload) return action.GamePublish(payload)
}
func (c *Guess) Exec_Abort(payload *pkt.GuessGameAbort, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(c, tx, index)
return action.GameAbort(payload)
} }
\ No newline at end of file
This diff is collapsed.
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
func init() { func init() {
pluginmgr.Register(&pluginmgr.PluginBase{ pluginmgr.Register(&pluginmgr.PluginBase{
Name: types.PokerBullX, Name: types.GuessX,
ExecName: executor.GetName(), ExecName: executor.GetName(),
Exec: executor.Init, Exec: executor.Init,
Cmd: commands.GuessCmd, Cmd: commands.GuessCmd,
......
...@@ -14,7 +14,7 @@ message GuessGame { ...@@ -14,7 +14,7 @@ message GuessGame {
string category = 6; //分类 string category = 6; //分类
string options = 7; //选项 string options = 7; //选项
string maxTime = 8; //截止下注时间 string maxTime = 8; //截止下注时间
uint32 maxHeight = 9; //截止下注的块高 int64 maxHeight = 9; //截止下注的块高
string symbol = 10; //bty或者具体token string symbol = 10; //bty或者具体token
string exec = 11; //coins或者token string exec = 11; //coins或者token
uint32 oneBet = 12; //一注等于多少bty或者token uint32 oneBet = 12; //一注等于多少bty或者token
...@@ -23,17 +23,18 @@ message GuessGame { ...@@ -23,17 +23,18 @@ message GuessGame {
uint32 fee = 15; //收取费用,不带则表示不收费 uint32 fee = 15; //收取费用,不带则表示不收费
string feeAddr = 16; //收费地址 string feeAddr = 16; //收费地址
string expire = 17; //游戏过期时间 string expire = 17; //游戏过期时间
uint32 expireHeight = 18; //游戏过期区块高度 int64 expireHeight = 18; //游戏过期区块高度
string adminAddr = 19; //游戏创建者地址,只有该地址可以开奖 string adminAddr = 19; //游戏创建者地址,只有该地址可以开奖
uint32 betsNumber = 20; //已下注数,如果数量达到maxBetsNumber,则不允许再下注 uint32 betsNumber = 20; //已下注数,如果数量达到maxBetsNumber,则不允许再下注
repeated GuessPlayer plays = 21; //参与游戏下注的玩家投注信息 repeated GuessPlayer plays = 21; //参与游戏下注的玩家投注信息
string result = 22; string result = 22;
repeated GuessBet bets = 23; repeated GuessBet bets = 23;
int64 index = 24;
} }
message GuessPlayer { message GuessPlayer {
string addr = 1; string addr = 1;
repeated GuessBet bets = 2; GuessBet bet = 2;
} }
message GuessBet { message GuessBet {
...@@ -145,7 +146,7 @@ message GuessGameStart{ ...@@ -145,7 +146,7 @@ message GuessGameStart{
string options = 2; string options = 2;
string category = 3; string category = 3;
string maxTime = 4; string maxTime = 4;
uint32 maxHeight = 5; int64 maxHeight = 5;
string symbol = 6; string symbol = 6;
string exec = 7; string exec = 7;
uint32 oneBet = 8; uint32 oneBet = 8;
...@@ -154,7 +155,7 @@ message GuessGameStart{ ...@@ -154,7 +155,7 @@ message GuessGameStart{
uint64 fee = 11; uint64 fee = 11;
string feeAddr = 12; string feeAddr = 12;
string expire = 13; string expire = 13;
uint32 expireHeight = 14; int64 expireHeight = 14;
} }
//参与游戏下注 //参与游戏下注
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
pb "github.com/33cn/plugin/plugin/dapp/guess/types" pb "github.com/33cn/plugin/plugin/dapp/guess/types"
"github.com/33cn/plugin/plugin/dapp/pokerbull/executor" "github.com/33cn/plugin/plugin/dapp/guess/executor"
) )
func (c *channelClient) GuessStart(ctx context.Context, head *pb.GuessGameStart) (*types.UnsignTx, error) { func (c *channelClient) GuessStart(ctx context.Context, head *pb.GuessGameStart) (*types.UnsignTx, error) {
......
...@@ -13,8 +13,10 @@ const ( ...@@ -13,8 +13,10 @@ const (
GuessGameActionStart = iota + 1 GuessGameActionStart = iota + 1
GuessGameActionBet GuessGameActionBet
GuessGameActionStopBet
GuessGameActionAbort GuessGameActionAbort
GuessGameActionPublish GuessGameActionPublish
GuessGameActionTimeOut
) )
const ( const (
...@@ -31,8 +33,10 @@ const ( ...@@ -31,8 +33,10 @@ const (
TyLogGuessGameStart = 901 TyLogGuessGameStart = 901
TyLogGuessGameBet = 902 TyLogGuessGameBet = 902
TyLogGuessGameAbort = 903 TyLogGuessGameStopBet = 903
TyLogGuessGamePublish = 904 TyLogGuessGameAbort = 904
TyLogGuessGamePublish = 905
TyLogGuessGameTimeout = 906
) )
//包的名字可以通过配置文件来配置 //包的名字可以通过配置文件来配置
......
This diff is collapsed.
...@@ -18,40 +18,6 @@ func init() { ...@@ -18,40 +18,6 @@ func init() {
} }
// exec // exec
type PokerBullType struct {
types.ExecTypeBase
}
func NewType() *PokerBullType {
c := &PokerBullType{}
c.SetChild(c)
return c
}
func (t *PokerBullType) GetPayload() types.Message {
return &PBGameAction{}
}
func (t *PokerBullType) GetTypeMap() map[string]int32 {
return map[string]int32{
"Start": PBGameActionStart,
"Continue": PBGameActionContinue,
"Quit": PBGameActionQuit,
"Query": PBGameActionQuery,
}
}
func (t *PokerBullType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogPBGameStart: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameStart"},
TyLogPBGameContinue: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameContinue"},
TyLogPBGameQuit: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameQuit"},
TyLogPBGameQuery: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameQuery"},
}
}
// exec
type GuessType struct { type GuessType struct {
types.ExecTypeBase types.ExecTypeBase
} }
...@@ -68,20 +34,23 @@ func (t *GuessType) GetPayload() types.Message { ...@@ -68,20 +34,23 @@ func (t *GuessType) GetPayload() types.Message {
func (t *GuessType) GetTypeMap() map[string]int32 { func (t *GuessType) GetTypeMap() map[string]int32 {
return map[string]int32{ return map[string]int32{
"Start": PBGameActionStart, "Start": GuessGameActionStart,
"Continue": PBGameActionContinue, "Bet": GuessGameActionBet,
"Quit": PBGameActionQuit, "Abort": GuessGameActionAbort,
"Query": PBGameActionQuery, "Publish": GuessGameActionPublish,
} }
} }
func (t *PokerBullType) GetLogMap() map[int64]*types.LogInfo { func (t *GuessType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{ return map[int64]*types.LogInfo{
TyLogPBGameStart: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameStart"}, TyLogGuessGameStart: {reflect.TypeOf(ReceiptGuessGame{}), "TyLogGuessGameStart"},
TyLogPBGameContinue: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameContinue"}, TyLogGuessGameBet: {reflect.TypeOf(ReceiptGuessGame{}), "TyLogGuessGameBet"},
TyLogPBGameQuit: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameQuit"}, TyLogGuessGameStopBet: {reflect.TypeOf(ReceiptGuessGame{}), "TyLogGuessGameStopBet"},
TyLogPBGameQuery: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameQuery"}, TyLogGuessGameAbort: {reflect.TypeOf(ReceiptGuessGame{}), "TyLogGuessGameAbort"},
TyLogGuessGamePublish: {reflect.TypeOf(ReceiptGuessGame{}), "TyLogGuessGamePublish"},
TyLogGuessGameTimeout: {reflect.TypeOf(ReceiptGuessGame{}), "TyLogGuessGameTimeout"},
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment