Ejemplo n.º 1
0
    def __init__(self, desk_id, custom_config=None, game_type="default"):
        self.desk_id = desk_id
        self.game_config = GameConfig(game_type=game_type)
        print "custom_config=", custom_config
        if custom_config:
            self.game_config.update_config(**custom_config)

        self.card_dealer = CardDealer(c_types=self.game_config.used_card_types)

        # 牌值分析器
        self.card_analyse = CardAnalyse(
            card_type_list=self.game_config.used_card_types,
            base_hu_type=self.game_config.used_hu_types)
        # 胡牌类型管理器
        self.hu_manager = HuTypeManager(self.game_config,
                                        card_analyse=self.card_analyse)

        self.game_status = GameStatus.WAIT_AGREE
        self.players = [
            Player(seat_id=i, game_data=self)
            for i in xrange(self.max_player_num)
        ]

        self.banker_seat_id = -1  # 庄家座位号
        self.hu_player_static = {}  # 当次已胡牌玩家统计(不存血战中当局的历史胡牌信息)
        # {seat_id:{type:[], is_zi_mo:0/1, source:int, card:int}, ...}

        self.last_chu_card_val = BLACK  # 最近一次出的牌
        self.cur_deal_card_val = BLACK  # 当前牌局上正在操作的那张牌
        self.last_chu_card_seat_id = -1  # 最近一次出牌玩家的位置
        self.last_get_card_val = [BLACK, BLACK, BLACK, BLACK]  # 最近一次某位置玩家获得的牌
        self.next_speaker_callback = {}  # 接下来玩家待进行的操作(其他玩家都选择过时)
        # {type: CallbackFuncType, seat_id: int, call_params: {}}

        self.cur_players_to_act = {}  # 当前所有玩家待进行的操作
        # {seat_id:{Act.HU:{}, Act.PENG:{}, ...}, seat_id: []}
        self.cur_players_acted = {}  # 当前出牌轮次所有玩家已经作出响应的玩家操作
        # {seat_id:{"act_type":Act.HU, "params":act_params},...}

        self.settle_data = {}  # 当局游戏输赢情况 {total_points:[],
        # detail:[{type:int, points:[,...,], params:{}}, ...]}

        self.yi_chu_card_vals = []  # 当局已出的牌, 所有玩家都可见的牌
        self.dealed_card_vals = []  #

        self.act_record_list = []  # 当局动作记录

        self.test_sure_next_card = [
            BLACK for _ in xrange(self.max_player_num)
        ]  # 测试接口使用:指定下一张牌

        self.round_info = RoundData(player_num=self.game_config.max_player_num)

        self.state_machine = StateMachine(self)
Ejemplo n.º 2
0
                k.append(peng_group)
        if hand_card.bu_gang_card_vals:
            for group in hand_card.bu_gang_card_vals:
                k.append([group[0], group[0], group[0]])
        if hand_card.an_gang_card_vals:
            for group in hand_card.an_gang_card_vals:
                k.append([group[0], group[0], group[0]])
        if hand_card.dian_gang_card_vals:
            for group in hand_card.dian_gang_card_vals:
                k.append([group[0], group[0], group[0]])

        return len(k) == 4

if __name__ == "__main__":
    pass
    card_analyse = CardAnalyse()
    hand_card = HandCard(0)
    # hand_card.hand_card_info = {
    #     1: [9, 1, 1, 1, 1, 1, 1, 1, 1, 1],  # 万
    #     2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # 条
    #     3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # 饼
    #     4: [2, 2, 0, 0, 0],                 # 风
    #     5: [3, 3, 0, 0],                    # 箭
    # }
    hand_card.hand_card_info = {
        1: [14, 0, 3, 3, 3, 2, 3, 0, 0, 0],  # 万
        2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # 条
        3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # 饼
        4: [0, 0, 0, 0, 0],                 # 风
        5: [0, 0, 0, 0],                    # 箭
    }
Ejemplo n.º 3
0
 def is_this_type(self, hand_card, card_analyse=CardAnalyse()):
     ret = card_analyse.get_can_pi_hu_info_by_val(hand_card.hand_card_vals)
     return 1 if ret else 0