Beispiel #1
0
    def MoPai(self, nPos, bCheckEventAndBuHua):
        assert self.m_nNextCardIndex < self.m_nMaxCardNum
        if self.m_nNextCardIndex >= self.m_nMaxCardNum - 12:
            self.OneJuEnd()
            return

        nCard = self.GetNextCard()
        self.m_dictPosCarList[nPos].append(nCard)
        self.StartQiPaiTick(nPos)
        self.SynOtherTouchEvent(EMjEvent.ev_mo_pai,
                                self.m_roomObj.GetMemberIDByPos(nPos), 0,
                                str(nCard))
        self.SynOrder()

        ffext.LOGINFO(
            "FFSCENE_PYTHON", "GasMj.MoPai {0}, {1}, {2} {3}".format(
                nPos, self.m_roomObj.GetMemberIDByPos(nPos),
                check_hu.GetCardNameChinese(nCard),
                len(self.m_dictPosCarList[nPos])))

        if bCheckEventAndBuHua is True:
            gas_mj_event_mgr.TouchEvent(self, EMjEvent.ev_mo_pai,
                                        [nPos, nCard])
            while True:
                bHaveHuaPai, nCard = self.CheckBuHua(nPos, nCard)
                if bHaveHuaPai is False:
                    break
                self.SynOrder()

        self.SerialEventList2Client()
Beispiel #2
0
    def CheckBuHua(self, nPos, nCard=None):
        if nCard is not None:
            listTmp = [nCard]
        else:
            listTmp = self.m_dictPosCarList[nPos][:]

        bNewCardIsHuaPai = False
        nDstCard = None
        for nCard in listTmp:
            nCardType = check_hu.GetCardType(nCard)
            if nCardType != ECardType.eHuaPai:
                continue

            nNextCard = self.GetNextCard()
            self.m_dictPosCarList[nPos].remove(nCard)
            self.m_dictPosCarListEx[nPos].append(nCard)
            self.m_dictPosCarList[nPos].append(nNextCard)
            gas_mj_event_mgr.TouchEvent(self, EMjEvent.ev_bu_hua,
                                        [nPos, nCard, nNextCard])
            ffext.LOGINFO(
                "FFSCENE_PYTHON", "GasMj.BuHua {0}, {1}, {2}".format(
                    nPos, check_hu.GetCardNameChinese(nCard),
                    check_hu.GetCardNameChinese(nNextCard)))

            if check_hu.GetCardType(nNextCard) == ECardType.eHuaPai:
                bNewCardIsHuaPai = True
                nDstCard = nNextCard

        if bNewCardIsHuaPai is False:
            # 八仙过海
            if check_hu.CheckBaXianGuoHai(
                    self.m_dictPosCarListEx[nPos]) is True:
                gas_mj_event_mgr.TouchEvent(EMjEvent.ev_hu_ba_xian_guo_hai,
                                            [nPos])

        return bNewCardIsHuaPai, nDstCard
Beispiel #3
0
    def KaiJin(self):
        nNum = self.GetJinPaiNum()
        self.m_listJinPai = []
        for _ in xrange(0, nNum):
            nCard = None
            while True:
                nCard = self.GetNextCard()
                if check_hu.GetCardType(
                        nCard
                ) != ECardType.eHuaPai and nCard not in self.m_listJinPai:
                    break

            assert nCard is not None
            self.m_listJinPai.append(nCard)

        gas_mj_event_mgr.TouchEvent(self, EMjEvent.ev_kai_jin,
                                    self.m_listJinPai[:])

        ffext.LOGINFO("FFSCENE_PYTHON",
                      "GasMj.KaiJin {0}".format(json.dumps(self.m_listJinPai)))
Beispiel #4
0
    def AutoQiPai(self, nPos):
        self.StopQiPaiTick(nPos)
        nCardPos = random.randint(0, len(self.m_dictPosCarList[nPos]) - 1)
        nCardID = self.m_dictPosCarList[nPos][nCardPos]

        self.m_dictPosCarList[nPos].pop(nCardPos)
        self.m_dictPosHistory[nPos].append(
            (self.m_nNextCardIndex - 1, nCardID))
        ffext.LOGINFO(
            "FFSCENE_PYTHON", "GasMj.AutoQiPai {0}, {1}, {2}. {3} {4}".format(
                nPos, self.m_roomObj.GetMemberIDByPos(nPos),
                check_hu.GetCardNameChinese(nCardID), json.dumps([]),
                len(self.m_dictPosCarList[nPos])))
        bCanNextTurn = gas_mj_event_mgr.TouchEvent(self, EMjEvent.ev_be_qi_pai,
                                                   [nPos, nCardID, -1])
        self.SerialEventList2Client()

        if bCanNextTurn is True:
            self.NextTurn()
        else:
            self.StartEventTick()
Beispiel #5
0
    def OptQiPai(self, nPos, nCardID, nCardPos):
        listCard = self.m_dictPosCarList[nPos]
        assert nCardID in listCard

        # use 4 client.
        nCardPos -= 1

        self.StopQiPaiTick(nPos)
        listCard.remove(nCardID)
        # listCard.pop(nCardPos)
        self.m_dictPosHistory[nPos].append(
            (self.m_nNextCardIndex - 1, nCardID))

        ffext.LOGINFO(
            "FFSCENE_PYTHON", "GasMj.OptQiPai {0}, {1}".format(
                nPos, check_hu.GetCardNameChinese(nCardID)))
        bCanNextTurn = gas_mj_event_mgr.TouchEvent(self, EMjEvent.ev_be_qi_pai,
                                                   [nPos, nCardID, nCardPos])
        self.SerialEventList2Client()

        if bCanNextTurn is True:
            self.NextTurn()
        else:
            self.StartEventTick()