Пример #1
0
    def big_double(handlist, rogue):
        """
        :大对
        :param handlist:
        :param rogue:
        :return:
        """
        temp = list()
        temp.extend(handlist)
        san = MahjongUtils.get_san(temp)
        for i in range(0, 3):
            for s in san:
                temp.remove(s)
        rogueSize = MahjongUtils.containSize(handlist, rogue)
        if 0 == rogueSize and 2 == len(temp) and temp[0] == temp[1]:
            return True
        if rogue not in san:
            for i in range(0, rogueSize):
                temp.remove(rogue)
        if rogue in temp:
            temp.remove(rogue)
        dui = MahjongUtils.get_dui(temp)
        if 1 == rogueSize and ((2 == len(dui) and 4 == len(temp)) or 1 == len(temp)):
            return True
        if 2 == rogueSize and (
                (1 == len(dui) and 3 == len(temp)) or (3 == len(dui) and 6 == len(temp)) or 0 == len(temp)):
            return True
        if 3 == rogueSize and ((4 == len(dui) and 8 == len(temp)) or (
                2 == len(dui) and 5 == len(temp)) or 2 == len(temp)):
            return True
        if 4 == rogueSize and ((5 == len(dui) and 10 == len(temp)) or (3 == len(dui) and 7 == len(temp)) or (
                0 < len(dui) and 4 == len(temp)) or 1 == len(temp)):
            return True

        return False
Пример #2
0
 def double7(handlist, rogue):
     """
     :七对
     :param handlist:
     :param rogue:
     :return:
     """
     temp = list()
     temp.extend(handlist)
     sorted(temp)
     rogueSize = MahjongUtils.containSize(handlist, rogue)
     for i in range(0, rogueSize):
         temp.remove(rogue)
     si = MahjongUtils.get_si(temp)
     if 14 == len(handlist) and 14 - (2 * (len(MahjongUtils.get_dui(temp)) + len(si))) <= 2 * rogueSize:
         siCount = 0
         temp1 = list()
         temp1.extend(temp)
         for i in range(0, 4):
             for s in si:
                 temp1.remove(s)
         siCount += len(si)
         san = MahjongUtils.get_san(temp1)
         for i in range(0, 3):
             for s in san:
                 temp1.remove(s)
         siCount += len(san)
         rogueSize -= len(san)
         dui = MahjongUtils.get_dui(temp1)
         for i in range(0, 2):
             for d in dui:
                 temp1.remove(d)
         rogueSize -= len(temp1)
         siCount += rogueSize / 2
         return siCount
     return -1
Пример #3
0
 def calculate(self, request, context):
     """
     :计算
     :param request:
     :param context:
     :return:
     """
     calculate = CalculateResult()
     san = MahjongUtils.get_san(request.player.handlist)
     calculate.dui.extend(MahjongUtils.get_dui(request.player.handlist))
     calculate.san.extend(san)
     calculate.si.extend(MahjongUtils.get_si(request.player.handlist))
     zimo = MahjongUtils.get_hu(request.player.handlist, request.rogue)
     calculate.zimo.extend(zimo)
     calculate.hu.extend(zimo)
     return calculate
Пример #4
0
 def calculate(self, request, context):
     """
     :计算
     :param request:
     :param context:
     :return:
     """
     calculate = CalculateResult()
     san = MahjongUtils.get_san(request.player.handlist)
     if not request.player.baojiao:
         calculate.dui.extend(MahjongUtils.get_dui(request.player.handlist))
         calculate.san.extend(san)
         calculate.si.extend(MahjongUtils.get_si(request.player.handlist))
     else:
         gang = list()
         for s in san:
             temp = list()
             temp.extend(request.player.handlist)
             temp.remove(s)
             temp.remove(s)
             temp.remove(s)
             if 0 < len(MahjongUtils.get_hu(temp, 0)):
                 gang.append(s)
             temp.append(s)
             temp.append(s)
             temp.append(s)
         calculate.san.extend(gang)
     if 1 == request.allocid:
         zimo = MahjongUtils.get_hu(request.player.handlist, request.rogue)
         calculate.zimo.extend(zimo)
         hu = list()
         for z in zimo:
             handlist = list()
             handlist.extend(request.player.handlist)
             handlist.append(z)
             if 10 != wanzhou_mahjong.getCardType(
                     handlist, request.player.peng, request.player.gang,
                     request.rogue):
                 hu.append(z)
         calculate.hu.extend(hu)
     if 2 == request.allocid or 3 == request.allocid:
         zimo = MahjongUtils.get_hu(request.player.handlist, request.rogue)
         calculate.zimo.extend(zimo)
         calculate.hu.extend(zimo)
     return calculate