コード例 #1
0
ファイル: player_action.py プロジェクト: jinguoyang/biji
def show_card_dealer(player, proto):
    """ 地主二次明牌
    """
    step = proto.step
    s1, s2 = divmod(step, 10)
    if s1 and s1 != 3:
        return

    for k, v in player.table.player_dict.iteritems():
        if k == player.uuid:
            continue
        proto = game_pb2.ShowCardResponse()
        proto.code = 0
        proto.player = k
        proto.step = step
        if step != 0:
            for c in player.cards_in_hand:
                card = proto.cards.add()
                card.card = c
        send(SHOWCARD, proto, v.session)

    player.show_card = step
    multiple = player.table.conf.show_card_config['double'].get(step, 1)
    if multiple > player.table.max_show_multiple:
        player.table.max_show_multiple = multiple
    # 刷新面板分
    for i in player.table.player_dict.values():
        score_proto = game_pb2.PokerScoreResponse()
        score_proto.multiple = i.table.get_multiple(i)
        send(POKER_SCORE, score_proto, i.session)
    player.table.replay["procedure"].append({"show_card": [player.seat]})
    from rules.player_rules.manager import PlayerRulesManager
    PlayerRulesManager().condition(player, PLAYER_RULE_SHOWCARD_DEALER)
    player.dumps()
コード例 #2
0
 def enter(self, owner):
     super(HaiDiState, self).enter(owner)
     # TableRulesManager().condition(owner, TABLE_RULE_END)
     owner.haidi_pre_seat = owner.active_seat
     owner.reset_proto(HAIDI)
     # 按顺序发牌
     for i in range(owner.chairs):
         active_player = owner.seat_dict[owner.active_seat]
         owner.active_seat = active_player.next_seat
         player = owner.seat_dict[owner.active_seat]
         proto = game_pb2.QH_HaiDiResponse()
         proto.cards_rest_num = 0
         card = owner.cards_on_desk.pop()
         player.draw_card = card
         player.cards_ready_hand = is_ready_hand(player)
         player.cards_in_hand.append(card)
         # player.proto.p = copy(proto)
         proto.card.card = card
         send(HAIDI, proto, player.session)
         player.dumps()
         cards_rest_num = len(owner.cards_on_desk)
         owner.replay["procedure"].append(
             {"draw": [player.seat, card, cards_rest_num]})
     for player in owner.player_dict.values():
         from rules.player_rules.manager import PlayerRulesManager
         PlayerRulesManager().condition(player, PLAYER_RULE_MOON)
     if not owner.player_prompts:
         # 没有提示
         owner.machine.trigger(EndState())
コード例 #3
0
ファイル: draw_concealed_kong.py プロジェクト: Joe9607/Pickup
    def enter(self, owner):
        super(DrawConcealedKongState, self).enter(owner)
        #print "cards_kong_concealed", owner.action_ref_cards, owner.cards_in_hand
        for card in owner.action_ref_cards:
            owner.cards_in_hand.remove(card)
        owner.cards_kong_concealed.extend(owner.action_ref_cards)
        owner.cards_group.extend(owner.action_ref_cards)
        owner.table.active_seat = owner.seat

        proto = game_pb2.ActionResponse()
        for card in owner.action_ref_cards:
            cards = proto.card.add()
            cards.card = card
        proto.active_type = PLAYER_ACTION_TYPE_KONG_CONCEALED
        proto.player = owner.uuid
        proto.trigger_seat = owner.seat
        proto.active_card.card = 0
        for player in owner.table.player_dict.values():
            send(ACTION, proto, player.session)
        owner.table.logger.info("player {0} kong {1}".format(owner.seat, owner.action_ref_cards))
        # 修改杠上开花
        owner.last_gang_card = owner.table.active_card
        owner.add_gang_num(0, 0, 1, 0)
        owner.table.discard_seat = -1
        # owner.table.check_bao_change()
        from rules.player_rules.manager import PlayerRulesManager
        from rules.define import PLAYER_RULE_TING_KONG
        owner.table.reset_proto(PROMPT)
        PlayerRulesManager().condition(owner,PLAYER_RULE_TING_KONG)
コード例 #4
0
    def enter(self, owner):
        super(DealerChooseState, self).enter(owner)
        # 初始化阵营
        owner.init_camp()
        if owner.dealer_seat == owner.spy_chair:
            proto = game_pb2.PokerDealerChooseInitResponse()
            proto.dealer_seat = owner.dealer_seat
            for e_player in owner.player_dict.values():
                proto.flag = -1
                if e_player.seat == owner.dealer_seat:
                    # 只给地主返回是否拿了狗腿8,其他玩家返回-1
                    # proto.flag = 1 if owner.dealer_seat == owner.spy_chair else -1
                    proto.flag = 1
                send(POKER_DEALER_CHOOSE_INIT, proto, e_player.session)
        else:
            from rules.player_rules.manager import PlayerRulesManager
            for player in owner.player_dict.values():
                PlayerRulesManager().condition(player, PLAYER_RULE_CHOOSE)
        # 计时器控制时间,中间的所有请求都可以接收,这个时间是控制死必须延迟这个时间
        # 2018.5.17取消计时器
        # owner.choose_begin_time = time.time()
        # owner.temp_timer = IOLoop().instance().add_timeout(owner.choose_begin_time + choose_delay, self.after_delay,
        #                                                    owner)

        owner.dumps()
コード例 #5
0
ファイル: show_card.py プロジェクト: jinguoyang/biji
    def show_step2(self, owner):
        if owner.temp_timer:
            IOLoop().instance().remove_timeout(owner.temp_timer)
            owner.temp_timer = None
        last_show_player = owner.seat_dict[owner.show_card_seat]
        # 超时未进行选择默认不明牌,取消计时器之后这段代码怕是不会走了
        if not last_show_player.has_chosen_ming:
            proto_req = game_pb2.PokerShowCardRequest()
            proto_req.flag = 2
            from logic.player_action import show_card
            show_card(last_show_player, proto_req)

        # 发给前端明牌结果
        proto_show_res = game_pb2.PokerShowCardResponse()
        proto_show_res.seat = owner.show_card_seat
        if last_show_player.show_card == 1:
            # 明牌发现狗腿直接暴露
            if owner.spy_card in last_show_player.cards_in_hand and last_show_player.seat != owner.dealer_seat:
                owner.notify_goutui()
        for card in last_show_player.cards_in_hand:
            show_card = proto_show_res.show_cards.add()
            # 如果明牌就返回真实牌型,否则返回空字符串
            show_card.card = card if last_show_player.show_card == 1 else ""
        for e_player in owner.player_dict.values():
            send(POKER_SHOW_CARDS_RESULT, proto_show_res, e_player.session)

        # 接下来就是各种骚操作看好了!
        from rules.player_rules.manager import PlayerRulesManager
        from rules.define import PLAYER_RULE_SHOWCARD
        PlayerRulesManager().condition(last_show_player, PLAYER_RULE_SHOWCARD)
コード例 #6
0
 def enter(self, owner):
     super(AfterKongState, self).enter(owner)
     owner.table.clear_prompt()
     owner.table.clear_actions()
     for i in owner.table.player_dict.values():
         PlayerRulesManager().condition(i, PLAYER_RULE_KG_AFTER)
     if not owner.table.player_prompts:
         owner.table.machine.trigger(StepState())
コード例 #7
0
    def enter(self, owner):
        super(DrawExposedKongState, self).enter(owner)

        active_card = owner.action_ref_cards[0]
        owner.draw_kong_exposed_card = active_card
        #print "cards_draw_kong_exposed", owner.action_ref_cards, owner.cards_in_hand

        owner.cards_in_hand.remove(active_card)
        owner.cards_kong_exposed.extend([active_card] * 4)
        owner.cards_pong.remove(active_card)
        owner.cards_pong.remove(active_card)
        owner.cards_pong.remove(active_card)
        owner.add_gang_num(0, 1, 0, 0)
        insert_index = owner.cards_group.index(active_card)
        owner.cards_group.insert(insert_index, active_card)
        owner.table.active_seat = owner.seat
        owner.table.last_oper_seat = owner.seat
        owner.table.active_card = active_card
        proto = game_pb2.ActionResponse()
        for card in owner.action_ref_cards:
            cards = proto.card.add()
            cards.card = card
        proto.active_type = PLAYER_ACTION_TYPE_KONG_PONG
        proto.player = owner.uuid
        proto.trigger_seat = owner.seat
        proto.active_card.card = 0
        owner.table.discard_seat = owner.seat
        owner.table.logger.info("player {0} kong {1}".format(
            owner.seat, active_card))
        #owner.table.reset_proto(ACTION)
        # 修改杠上开花
        owner.last_gang_card = owner.table.active_card
        if owner.table.conf.is_qg():
            owner.table.reset_proto(ACTION)
            owner.table.clear_prompt()
            owner.table.clear_actions()
            for player in owner.table.player_dict.values():
                player.proto.p = copy(proto)
                if player.uuid != owner.uuid:
                    player.machine.cur_state.execute(player, "other_kong")
                player.proto.send()

            if owner.table.player_prompts:
                #print "when pong kong ", owner.table.player_prompts
                owner.machine.trigger(PauseState())
                return
        else:
            owner.table.reset_proto(ACTION)
            for player in owner.table.player_dict.values():
                player.proto.p = copy(proto)
                player.proto.send()
        # for player in owner.table.player_dict.values():
        #     player.proto.p = copy(proto)
        #     player.proto.send()
        from rules.player_rules.manager import PlayerRulesManager
        from rules.define import PLAYER_RULE_TING_KONG
        owner.table.reset_proto(PROMPT)
        PlayerRulesManager().condition(owner, PLAYER_RULE_TING_KONG)
コード例 #8
0
ファイル: player_action.py プロジェクト: jinguoyang/biji
def dealer_choose(player, proto):
    if player.seat == player.table.dealer_seat and player.seat == player.table.spy_chair:
        choose_code = proto.choose_code
        if choose_code not in [1, 2]:
            player.table.logger.fatal(
                "choose_code : {0} wrong".format(choose_code))
        else:
            player.table.land_lord_chairs = []
            player.table.farmer_chairs = []
            player.table.land_lord_chairs.append(player.seat)
            if choose_code == 1:
                # 一打四
                player.table.spy_chair = -1
            elif choose_code == 2:
                # 叫狗腿
                # 换狗腿牌
                result = player.table.change_spy_card()
                if result:
                    # 换狗腿座位
                    player.table.change_spy_chair()
                    # 地主阵营
                    player.table.land_lord_chairs.append(
                        player.table.spy_chair)
                else:
                    player.table.logger.fatal("Change spy_card Wrong")
                    # 要是实在是找不到狗腿牌就直接判定为一打四
                    player.table.spy_chair = -1
            if player.table.spy_chair == -1:
                player.table.replay["procedure"].append({"dealer_choose": 1})
            else:
                player.table.replay["procedure"].append({"dealer_choose": 2})
            for e_player in player.table.player_dict.values():
                if e_player.seat not in player.table.land_lord_chairs:
                    # 农民阵营
                    player.table.farmer_chairs.append(e_player.seat)

            # 发送选择结果
            if player.table.spy_card != "8G":
                proto_res = game_pb2.PokerDealerChooseResponse()
                proto_res.choose_code = 2
                proto_res.spy_card = player.table.spy_card
                player.table.replay["procedure"].append(
                    {"change_goutui": player.table.spy_card})
                for e_player in player.table.player_dict.values():
                    send(POKER_DEALER_CHOOSE, proto_res, e_player.session)
            from rules.player_rules.manager import PlayerRulesManager
            for player in player.table.player_dict.values():
                PlayerRulesManager().condition(player, PLAYER_RULE_CHOOSE)
コード例 #9
0
    def enter(self, owner):
        super(DrawExposedKongKGState, self).enter(owner)

        active_card = owner.action_op_card
        #print self.name, owner.action_ref_cards, owner.cards_in_hand

        owner.cards_in_hand.remove(active_card)
        owner.cards_kong_exposed.extend([active_card] * 4)
        owner.cards_pong.remove(active_card)
        owner.cards_pong.remove(active_card)
        owner.cards_pong.remove(active_card)
        insert_index = owner.cards_group.index(active_card)
        owner.cards_group.insert(insert_index, active_card)
        owner.table.active_seat = owner.seat
        owner.table.active_card = active_card
        owner.add_gang_num(0, 1, 0, 0)
        proto = game_pb2.ActionCSResponse()
        for card in owner.action_ref_cards:
            cards = proto.ref_card.add()
            cards.card = card
        proto.active_type = PLAYER_ACTION_TYPE_KONG_PONG_KG
        proto.player = owner.uuid
        proto.trigger_seat = owner.seat
        proto.active_card.card = 0
        owner.table.reset_proto(ACTION_CS)

        owner.table.clear_prompt()
        owner.table.clear_actions()

        for player in owner.table.player_dict.values():
            # send(ACTION_CS, proto, player.session)
            player.proto.p = copy(proto)
            if player.uuid != owner.uuid:
                PlayerRulesManager().condition(player, PLAYER_RULE_KONG)
                calculate_final_score(player, owner, SCORE_MING_GANG)
            player.proto.send()
        owner.table.discard_seat = -1
        owner.table.logger.info("player {0} kong {1}".format(owner.seat, active_card))
        owner.table.logger.debug("clear all prompt and action at DrawExposedKongKGState state")

        if owner.table.player_prompts:
            #print "when pong kong ", owner.table.player_prompts
            return
コード例 #10
0
ファイル: draw_after_kong.py プロジェクト: Joe9607/Pickup
    def enter(self, owner):
        super(DrawAfterKongState, self).enter(owner)

        # 清除桌子提示和动作
        owner.miss_win_cards = []
        owner.miss_pong_cards = []
        owner.table.clear_prompt()
        owner.table.clear_actions()
        # 重新更新听牌提示,在上家打牌点过后这个需要重新计算
        # 杠次数加一
        owner.kong_times += 1
        card = owner.table.cards_on_desk.pop(0)
        # 换显示的杠牌
        owner.table.change_kong_card()
        owner.draw_card = card
        owner.cards_ready_hand = is_ready_hand(owner)
        owner.cards_in_hand.append(card)
        # 增加剩余可抓牌
        cards_rest_num = len(owner.table.cards_on_desk)
        owner.table.replay["procedure"].append({"draw": [owner.seat, card, cards_rest_num]})
        proto = game_pb2.DrawResponse()
        proto.player = owner.uuid

        proto.cards_rest_num = cards_rest_num
        # print cards_rest_num
        owner.table.reset_proto(DRAW)
        owner.table.last_draw = owner.seat
        owner.draw_cnt += 1
        for player in owner.table.player_dict.values():
            player.proto.p = copy(proto)
            if player.uuid == owner.uuid:
                player.proto.p.card.card = card
                from rules.player_rules.manager import PlayerRulesManager
                PlayerRulesManager().condition(owner, PLAYER_RULE_DRAW)
            else:
                player.proto.p.card.card = 0
            player.proto.send()
        owner.table.logger.info("player {0} draw card {1}".format(owner.seat, card))
        owner.dumps()
        owner.table.logger.info("draw after dumps")
コード例 #11
0
ファイル: chow.py プロジェクト: Joe9607/Pickup
    def enter(self, owner):
        super(ChowState, self).enter(owner)

        for card in owner.action_ref_cards:
            owner.cards_in_hand.remove(card)
        active_card = owner.table.active_card
        action_cards = owner.action_ref_cards
        action_cards.append(active_card)
        owner.cards_chow.extend(action_cards)
        owner.cards_group.extend(action_cards)

        trigger_seat = owner.table.active_seat
        trigger_player = owner.table.seat_dict[trigger_seat]
        trigger_player.cards_discard.remove(active_card)
        trigger_player.machine.trigger(WaitState())
        owner.table.active_seat = owner.seat

        proto = game_pb2.ActionResponse()
        for card in owner.action_ref_cards:
            cards = proto.card.add()
            cards.card = card
        proto.active_card.card = active_card
        proto.trigger_seat = trigger_seat
        proto.active_type = PLAYER_ACTION_TYPE_CHOW
        proto.player = owner.uuid
        # for player in owner.table.player_dict.values():
        #     send(ACTION, proto, player.session)
        owner.table.reset_proto(ACTION)
        for player in owner.table.player_dict.values():
            player.proto.p = copy(proto)
            if player.uuid == owner.uuid:
                PlayerRulesManager().condition(owner, PLAYER_RULE_CHOW)
            player.proto.send()
        owner.table.logger.info("player {0} chow {1}".format(
            owner.seat, active_card))
        # 吃完后检测杠
        owner.table.discard_seat = -1
        # owner.table.check_bao_change()
        owner.dumps()
コード例 #12
0
ファイル: dealer_choose.py プロジェクト: jinguoyang/pokerrrr
 def after_delay(self, owner):
     # 取消计时器之后这个方法就不会走了
     if owner.temp_timer:
         IOLoop().instance().remove_timeout(owner.temp_timer)
         owner.temp_timer = None
     if owner.dealer_seat == owner.spy_chair:
         # 默认叫狗腿
         dealer = owner.seat_dict[owner.dealer_seat]
         proto_req = game_pb2.PokerDealerChooseRequest()
         proto_req.choose_code = 2
         dealer_choose(dealer, proto_req)
     # 只有指定狗腿时返回
     if owner.spy_card != "8G":
         proto_res = game_pb2.PokerDealerChooseResponse()
         proto_res.choose_code = 2
         proto_res.spy_card = owner.spy_card
         owner.replay["procedure"].append({"change_goutui": owner.spy_card})
         for e_player in owner.player_dict.values():
             send(POKER_DEALER_CHOOSE, proto_res, e_player.session)
     from rules.player_rules.manager import PlayerRulesManager
     for player in owner.player_dict.values():
         PlayerRulesManager().condition(player, PLAYER_RULE_CHOOSE)
コード例 #13
0
    def enter(self, owner):
        super(PongState, self).enter(owner)
        #print 'enter pong state,', owner.action_ref_cards
        for card in owner.action_ref_cards:
            owner.cards_in_hand.remove(card)
        active_card = owner.table.active_card
        action_cards = [active_card] * 3
        owner.cards_pong.extend(action_cards)
        owner.cards_group.extend(action_cards)
        if active_card in owner.miss_pong_cards:
            owner.miss_pong_cards.remove(active_card)
        trigger_seat = owner.table.active_seat
        trigger_player = owner.table.seat_dict[trigger_seat]
        trigger_player.cards_discard.remove(active_card)
        trigger_player.machine.trigger(WaitState())
        owner.table.active_seat = owner.seat

        proto = game_pb2.ActionResponse()
        for card in owner.action_ref_cards:
            cards = proto.card.add()
            cards.card = card
        proto.active_card.card = active_card
        proto.trigger_seat = trigger_seat
        proto.active_type = PLAYER_ACTION_TYPE_PONG
        proto.player = owner.uuid
        # for player in owner.table.player_dict.values():
        #     send(ACTION, proto, player.session)
        owner.table.reset_proto(ACTION)
        for player in owner.table.player_dict.values():
            player.proto.p = copy(proto)
            if player.uuid == owner.uuid:
                PlayerRulesManager().condition(owner, PLAYER_RULE_PONG)
            player.proto.send()
        owner.table.logger.info("player {0} pong {1}".format(
            owner.seat, active_card))
        owner.table.discard_seat = -1
        #owner.table.reset_proto(ACTION)
        owner.dumps()
コード例 #14
0
    def enter(self, owner):
        super(DiscardExposedKongState, self).enter(owner)
        for card in owner.action_ref_cards:
            owner.cards_in_hand.remove(card)

        active_card = owner.table.active_card
        action_cards = [active_card] * 4
        owner.cards_kong_exposed.extend(action_cards)
        owner.cards_group.extend(action_cards)

        trigger_seat = owner.table.active_seat
        trigger_player = owner.table.seat_dict[trigger_seat]
        trigger_player.cards_discard.remove(active_card)
        trigger_player.machine.trigger(WaitState())
        owner.table.active_seat = owner.seat
        trigger_player.add_gang_num(0, 0, 0, 1)
        owner.add_gang_num(1, 0, 0, 0)

        proto = game_pb2.ActionResponse()
        for card in owner.action_ref_cards:
            cards = proto.card.add()
            cards.card = card
        proto.active_card.card = active_card
        proto.trigger_seat = trigger_seat
        proto.active_type = PLAYER_ACTION_TYPE_KONG_EXPOSED
        proto.player = owner.uuid
        for player in owner.table.player_dict.values():
            send(ACTION, proto, player.session)
        owner.last_gang_card = active_card
        owner.table.logger.info("player {0} kong {1}".format(
            owner.seat, active_card))
        owner.table.discard_seat = -1
        from rules.player_rules.manager import PlayerRulesManager
        from rules.define import PLAYER_RULE_TING_KONG
        owner.table.reset_proto(PROMPT)
        PlayerRulesManager().condition(owner, PLAYER_RULE_TING_KONG)
コード例 #15
0
    def enter(self, owner):
        super(DealState, self).enter(owner)

        PlayerRulesManager().condition(owner, PLAYER_RULE_DEAL)
        owner.dumps()
コード例 #16
0
ファイル: player_action.py プロジェクト: Joe9607/Pickup
def other_kong(player):
    from rules.player_rules.manager import PlayerRulesManager
    PlayerRulesManager().condition(player, PLAYER_RULE_KONG)
コード例 #17
0
ファイル: player_action.py プロジェクト: jinguoyang/pokerrrr
def discard(player, proto):
    from state.player_state.wait import WaitState

    if player.seat != player.table.active_seat:
        return
    type = proto.type
    cards = []
    for i in proto.cards:
        cards.append(i.card)
    # print set(cards)
    if set(cards) - set(player.cards_in_hand):
        # 出不存在的牌的时候同步手牌
        proto = game_pb2.PokerSynchroniseCardsResponse()
        for i in player.cards_in_hand:
            c = proto.card.add()
            c.card = i
        send(POKER_SYNCHRONISE_CARDS, proto, player.session)
        player.table.logger.warn(
            "player {0} discard {1} not exist in hand".format(
                player.seat, cards))
        return
    # 强制地主出牌如果走到这说明作弊了

    if player.table.step == 0 and not cards:
        proto = game_pb2.PokerDiscardResponse()
        proto.player = player.uuid
        proto.code = -2
        proto.rest_cards_count = len(player.cards_in_hand)
        player.table.reset_proto(POKER_DISCARD)
        player.proto.p = copy(proto)
        player.proto.send()
        player.table.logger.warn(
            "player {0} is landlord and does not discard".format(
                player.seat, cards))
        return

    if player.state == "PromptState":
        player.del_prompt()
        player.table.clear_prompt()
        player.machine.next_state()
        player.table.logger.fatal(
            "{0} client send discard event without pass".format(player.uuid))

    proto = game_pb2.PokerDiscardResponse()
    proto.player = player.uuid
    proto.code = 2
    if cards and type == 1:
        card_type = match_type(cards, game_id)
        if card_type:
            proto.card_type = card_type
            # 其余两家要不起之后可以出任意牌
            if player.table.last_discard_seat == player.seat:
                rcode = 1
            else:
                rcode = compare(player, cards, card_type=card_type)
            if rcode != 1:
                proto.code = rcode
                # proto.rest_cards_count = len(player.cards_in_hand) - len(cards)
                proto.rest_cards_count = len(player.cards_in_hand)
                player.table.reset_proto(POKER_DISCARD)
                player.proto.p = copy(proto)
                player.proto.send()
                return
        else:
            proto.code = -2
            proto.rest_cards_count = len(player.cards_in_hand)
            player.table.reset_proto(POKER_DISCARD)
            player.proto.p = copy(proto)
            player.proto.send()
            return

        player.table.last_discard_seat = player.seat
        player.table.active_card = cards
        player.table.active_seat = player.seat
        player.table.active_card_type = card_type
        if card_type in ['bomb', 'jackBomb']:
            player.bomb_cnt += 1
            player.table.boom_num += 1
            # 喜钱
            player.table.calculate_reward_points()

        for i in cards:
            player.cards_in_hand.remove(i)
            c = proto.cards.add()
            c.card = i
        proto.rest_cards_count = len(player.cards_in_hand)

    else:
        # 过滤重复点过
        if type == 2 and player.table.last_discard_seat == player.seat:
            proto.code = -2
            proto.rest_cards_count = len(player.cards_in_hand)
            player.table.reset_proto(POKER_DISCARD)
            player.proto.p = copy(proto)
            player.proto.send()
            return
        # 出牌列表为空
        if type == 1 and not cards:
            proto.code = -2
            proto.rest_cards_count = len(player.cards_in_hand)
            player.table.reset_proto(POKER_DISCARD)
            player.proto.p = copy(proto)
            player.proto.send()
            return

    player.table.replay["procedure"].append({"discard": [player.uuid, cards]})
    player.table.logger.info("player {0} discard {1}".format(
        player.seat, cards))
    if player.table.spy_card in cards and player.seat != player.table.dealer_seat and not player.table.baolu:
        player.table.notify_goutui()
    # player.table.last_oper_seat = player.seat
    player.table.discard_seat = player.seat
    player.last_cards_discard = cards[:]
    if cards:
        player.cards_discard.append(cards)
    player.table.step += 1

    player.table.reset_proto(POKER_DISCARD)
    for i in player.table.player_dict.values():
        # if i.uuid == player.uuid:
        #     continue
        i.proto.p = copy(proto)
        if i.machine.cur_state.name == 'PromptDiscardState':
            i.machine.trigger(WaitState())

        if i.uuid != player.uuid:
            i.machine.cur_state.execute(i, "other_discard")
        i.proto.send()

    if player.table.player_prompts:
        player.machine.trigger(PauseState())
    else:
        # player.machine.next_state()
        from rules.player_rules.manager import PlayerRulesManager
        PlayerRulesManager().condition(player, PLAYER_RULE_WIN)
コード例 #18
0
ファイル: player_action.py プロジェクト: jinguoyang/biji
def discard(player, proto):
    # 最后一个玩家不让弃牌
    if len(player.table.abandon_list
           ) == player.table.player_num - 1 and proto.code == 0:
        proto = game_pb2.CockDiscardResponse()
        proto.code = -3
        send(POKER_DISCARD, proto, player.session)
        player.table.logger.warn(
            "player {0} is last abandon player, reject to abandon cards".
            format(player.seat))
        return
    joker_group = []  # 大小王所在牌组额外存放
    card_group = []  # 前台传过来的牌
    group_type = []  # 后台判断的牌型
    cards = []  # 前台传过来的牌
    send_type = []  # 前台传送过来的牌型
    if proto.code == 1:  # 出牌
        for i in proto.cards:
            card_group.append(list(i.cards))
            cards.extend(list(i.cards))
        for i in proto.cards_type:
            send_type.append(i)

        if set(cards) - set(player.cards_in_hand) or len(set(cards)) != 9:
            # 出不存在的牌的时候同步手牌
            proto = game_pb2.PokerSynchroniseCardsResponse()
            for i in player.cards_in_hand:
                c = proto.card.add()
                c.card = i
            send(POKER_SYNCHRONISE_CARDS, proto, player.session)
            player.table.logger.warn(
                "player {0} discard {1} not exist in hand cards {2}".format(
                    player.seat, cards, player.cards_in_hand))
            return

        # 判断玩家三墩牌的牌型
        for i in card_group:
            vv, s = judgetype(i)
            group_type.append(vv)
            if s == 1:
                joker_group.append(i)

        # 牌型不匹配时,返给前台
        if group_type != send_type:
            proto = game_pb2.CockDiscardResponse()
            proto.code = -2
            # 此处可添加自动配牌的返回
            send(POKER_DISCARD, proto, player.session)
            player.table.logger.warn(
                "player {0} discard {1}.Type is {2} not match the send type {3}"
                .format(player.seat, card_group, group_type, send_type))
            return

        # 第三墩牌大于第二墩大于第一墩
        if limit(card_group, group_type):
            proto = game_pb2.CockDiscardResponse()
            proto.code = -1
            # 此处可添加自动配牌的返回
            send(POKER_DISCARD, proto, player.session)
            player.table.logger.warn(
                "player {0} discard {1} type is {2} limited".format(
                    player.seat, card_group, group_type))
            return

        proto = game_pb2.CockDiscardResponse()
        proto.code = 1
        player.table.discard_list.append(player.seat)
        # 如果前面判断无误,则加入到全局变量
        player.group_type = group_type
        player.card_group = card_group
        player.joker_group = joker_group
    else:  # 弃牌
        proto = game_pb2.CockDiscardResponse()
        proto.code = 0
        player.table.abandon_list.append(player.seat)
    proto.player = player.uuid
    player.table.replay["procedure"].append(
        {"discard": [player.uuid, player.card_group]})
    player.table.logger.info("player {0} discard {1} type is {2}".format(
        player.seat, player.card_group, player.group_type))

    # 广播所有玩家,已出牌或者弃牌
    player.table.reset_proto(POKER_DISCARD)
    for i in player.table.player_dict.values():
        # if i.uuid == player.uuid:
        #     continue
        i.proto.p = copy(proto)
        i.proto.send()
    from rules.player_rules.manager import PlayerRulesManager
    PlayerRulesManager().condition(player, PLAYER_RULE_WIN)
コード例 #19
0
ファイル: player_action.py プロジェクト: jinguoyang/biji
def skip_wait(player):
    from rules.player_rules.manager import PlayerRulesManager
    PlayerRulesManager().condition(player, PLAYER_RULE_DOUBLE)
コード例 #20
0
ファイル: player_action.py プロジェクト: jinguoyang/biji
def rob_skip(player):
    from rules.player_rules.manager import PlayerRulesManager
    PlayerRulesManager().condition(player, PLAYER_RULE_ROB)
コード例 #21
0
ファイル: player_action.py プロジェクト: jinguoyang/biji
def other_discard(player):
    from rules.player_rules.manager import PlayerRulesManager
    PlayerRulesManager().condition(player, PLAYER_RULE_DISCARD)