Openpoker源码分析

来源:互联网 发布:类似淘宝的购物网站 编辑:程序博客网 时间:2024/05/07 14:49

1。什么是Openpoer

http://erlang-china.org/study/erlang-mmorpg.html

2。现有的关于Openpoker的资料

如何运行和测试

http://blog.csdn.net/stephenxu111/archive和/2008/06/20/2570070.aspx

3。今天开始我们一起分析源码

获得源码

http://sourceforge.net/projects/openpoker/files/

4。从哪里入手

test.erl

 

%%% Copyright (C) 2005 Wager Labs, SA 
%%% 
%%% This file is part of OpenPoker. 
%%% 
%%% OpenPoker is free software; you can redistribute it and/or 
%%% modify it under the terms of the GNU General Public 
%%% License as published by the Free Software Foundation; either 
%%% version 2 of the License, or (at your option) any later version. 
%%% 
%%% This program is distributed in the hope that it will be useful, 
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of 
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
%%% General Public License for more details. 
%%% 
%%% You should have received a copy of the GNU General Public 
%%% License along with this library; if not, write to the Free Software 
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
%%% 
%%% Please visit 
http://wagerlabs.com or contact Joel Reymont 
%%% at joelr@well.com for more information.

-module(test).

-compile([export_all]).

-export([all/0, make_players/1, make_test_game/3, 
    make_player/1, install_trigger/3, kill_players/1]).

-include("proto.hrl"). 
-include("texas.hrl"). 
-include("common.hrl"). 
-include("schema.hrl"). 
-include("test.hrl").

-record(test, { 
      button_seat = none, 
      call = 0, 
      winners = none 
     }).

all() –>                     %%系统启动入口  
    mnesia:start(),            %%数据库启动 
    ok = mnesia:wait_for_tables([game_config], 10000), 
    %% make sure the basics work 
    db:test(),                 %%数据库管理模块 
    proto:test(),              %%协议编码解码模块 
    hand:test(),               %%牌面模块 
    pot:test(),                %%台面模块 
    player:test(),             %%用户模块 
    game:test(),               %%游戏模块 
    cardgame:test(),           %%纸牌游戏模块 
    deal_cards:test(),         %%处理纸牌模块 
    deck:test(),               %%牌桌模块 
    fixed_limit:test(),        %%固定限制模块 
    delayed_start:test(),      %%延迟启动模块 
    blinds:test(),             %% 
    betting:test(), 
    showdown:test(),           %%关闭模块 
    login:test(),              %%登陆模块 
    %% run tests 
    test10(), 
    test20(), 
    test30(), 
    test40(), 
    test50(), 
    test60(), 
    test70(), 
    test80(), 
    test90(), 
    test100(), 
    test110(), 
    test120(), 
    test130(), 
    test135(), 
    test140(), 
    test150(), 
    test160(), 
    test170(), 
    test180(), 
    ok.

%%% Create player

test10() -> 
    db:delete(player),            %删除原有用户   
    counter:reset(player),        %计数器重置 
    Nick = "P",                    
    %% player does not exist 
    ?match({error, {atomic, []}}, player:start("blah")), 
    {atomic, ID} = player:create(Nick, "foo", "", 100),      %创建新用户  
    ?match(1, ID), 
    {ok, Pid} = player:start(Nick),                          %启动新用户 
    ?match({atomic, Pid}, db:get(player, ID, pid)), 
    player:stop(Pid),                                        %停止新用户 
    timer:sleep(100), 
    ?match({atomic, none}, db:get(player, ID, pid)), 
    ok. 
%%% Create game

test20() -> 
    db:delete(game_xref),         %删除原有游戏 
    counter:reset(game),          %计数器重置 
    GameType = ?GT_IRC_TEXAS,     %游戏类型 
    LimitType = {?LT_FIXED_LIMIT, 10, 20}, 
    {ok, Game} = cardgame:start(GameType,           %启动新游戏 
                2, 
                LimitType), 
    ?match(1, cardgame:call(Game, 'ID')), 
    ?match(0, cardgame:call(Game, 'JOINED')), 
    ?match({atomic, Game}, db:get(game_xref, 1, pid)), 
    cardgame:stop(Game),                            %停止游戏 
    timer:sleep(100), 
    ?match({atomic, []}, db:find(game_xref, 1)), 
    ok.

%%% Basic seat query

test30() -> 
    db:delete(game_xref), 
    db:delete(player), 
    Players = [{Player, 1}] = make_players(1), 
    Game = make_game(2, Players), 
    X = cardgame:call(Game, 'SEAT QUERY'), 
    ?match([{1, ?SS_TAKEN, Player}, 
        {2, ?SS_EMPTY, none}], X), 
    Z = cardgame:call(Game, 'JOINED'), 
    ?match(1, Z), 
    cardgame:stop(Game), 
    kill_players(Players), 
    ok.

标签: delete游戏timer数据库killlibrary
 2980人阅读 评论(0) 收藏 举报
 分类:

转载:http://blog.csdn.net/chenyinggang/article/details/5566311


1。什么是Openpoer

http://erlang-china.org/study/erlang-mmorpg.html

2。现有的关于Openpoker的资料

如何运行和测试

http://blog.csdn.net/stephenxu111/archive和/2008/06/20/2570070.aspx

3。今天开始我们一起分析源码

获得源码

http://sourceforge.net/projects/openpoker/files/

4。从哪里入手

test.erl

 

%%% Copyright (C) 2005 Wager Labs, SA 
%%% 
%%% This file is part of OpenPoker. 
%%% 
%%% OpenPoker is free software; you can redistribute it and/or 
%%% modify it under the terms of the GNU General Public 
%%% License as published by the Free Software Foundation; either 
%%% version 2 of the License, or (at your option) any later version. 
%%% 
%%% This program is distributed in the hope that it will be useful, 
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of 
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
%%% General Public License for more details. 
%%% 
%%% You should have received a copy of the GNU General Public 
%%% License along with this library; if not, write to the Free Software 
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
%%% 
%%% Please visit 
http://wagerlabs.com or contact Joel Reymont 
%%% at joelr@well.com for more information.

-module(test).

-compile([export_all]).

-export([all/0, make_players/1, make_test_game/3, 
    make_player/1, install_trigger/3, kill_players/1]).

-include("proto.hrl"). 
-include("texas.hrl"). 
-include("common.hrl"). 
-include("schema.hrl"). 
-include("test.hrl").

-record(test, { 
      button_seat = none, 
      call = 0, 
      winners = none 
     }).

all() –>                     %%系统启动入口  
    mnesia:start(),            %%数据库启动 
    ok = mnesia:wait_for_tables([game_config], 10000), 
    %% make sure the basics work 
    db:test(),                 %%数据库管理模块 
    proto:test(),              %%协议编码解码模块 
    hand:test(),               %%牌面模块 
    pot:test(),                %%台面模块 
    player:test(),             %%用户模块 
    game:test(),               %%游戏模块 
    cardgame:test(),           %%纸牌游戏模块 
    deal_cards:test(),         %%处理纸牌模块 
    deck:test(),               %%牌桌模块 
    fixed_limit:test(),        %%固定限制模块 
    delayed_start:test(),      %%延迟启动模块 
    blinds:test(),             %% 
    betting:test(), 
    showdown:test(),           %%关闭模块 
    login:test(),              %%登陆模块 
    %% run tests 
    test10(), 
    test20(), 
    test30(), 
    test40(), 
    test50(), 
    test60(), 
    test70(), 
    test80(), 
    test90(), 
    test100(), 
    test110(), 
    test120(), 
    test130(), 
    test135(), 
    test140(), 
    test150(), 
    test160(), 
    test170(), 
    test180(), 
    ok.

%%% Create player

test10() -> 
    db:delete(player),            %删除原有用户   
    counter:reset(player),        %计数器重置 
    Nick = "P",                    
    %% player does not exist 
    ?match({error, {atomic, []}}, player:start("blah")), 
    {atomic, ID} = player:create(Nick, "foo", "", 100),      %创建新用户  
    ?match(1, ID), 
    {ok, Pid} = player:start(Nick),                          %启动新用户 
    ?match({atomic, Pid}, db:get(player, ID, pid)), 
    player:stop(Pid),                                        %停止新用户 
    timer:sleep(100), 
    ?match({atomic, none}, db:get(player, ID, pid)), 
    ok. 
%%% Create game

test20() -> 
    db:delete(game_xref),         %删除原有游戏 
    counter:reset(game),          %计数器重置 
    GameType = ?GT_IRC_TEXAS,     %游戏类型 
    LimitType = {?LT_FIXED_LIMIT, 10, 20}, 
    {ok, Game} = cardgame:start(GameType,           %启动新游戏 
                2, 
                LimitType), 
    ?match(1, cardgame:call(Game, 'ID')), 
    ?match(0, cardgame:call(Game, 'JOINED')), 
    ?match({atomic, Game}, db:get(game_xref, 1, pid)), 
    cardgame:stop(Game),                            %停止游戏 
    timer:sleep(100), 
    ?match({atomic, []}, db:find(game_xref, 1)), 
    ok.

%%% Basic seat query

test30() -> 
    db:delete(game_xref), 
    db:delete(player), 
    Players = [{Player, 1}] = make_players(1), 
    Game = make_game(2, Players), 
    X = cardgame:call(Game, 'SEAT QUERY'), 
    ?match([{1, ?SS_TAKEN, Player}, 
        {2, ?SS_EMPTY, none}], X), 
    Z = cardgame:call(Game, 'JOINED'), 
    ?match(1, Z), 
    cardgame:stop(Game), 
    kill_players(Players), 
    ok.

0 0
原创粉丝点击