Example #1
0
    def genInitLayoutLeft(self, machine_id, init_layout):
        all_symbols = PayTable.getAllSymbols(machine_id)

        ret = [[]for i in range(len(all_symbols) - len(init_layout))]

        for i in range(self.WIDTH):
            column = []
            for row in init_layout:
                column.append(row[i])

            left_column = [s for s in all_symbols if s not in column]
            random.shuffle(left_column)

            for idx, s in enumerate(left_column):
                ret[idx].append(s)

        return ret
Example #2
0
    def genInitLayout(self):
        """
        make sure each column has diff symbols.
        """
        symbols = PayTable.getInitSymbols(self.game_id)
        random.shuffle(symbols)

        symbols += symbols

        slot = [[-1]*self.WIDTH for i in range(self.HEIGHT)]
        for j in range(self.WIDTH):
            for i in range(self.HEIGHT):
                slot[i][j] = symbols.pop(0)

        scatter_pos = random.randint(0, 2)
        slot[scatter_pos][0] = PayTable.SCATTER

        bonus_pos = random.randint(0, 2)
        slot[bonus_pos][3] = PayTable.BONUS

        return slot
Example #3
0
    def doSpin(self, game_id, lv, lines, bet, is_free, fake_flag):
        weight = PayTable.getSymbolWeight(self.game_id, lv, is_free, bet, fake_flag)

        slots = self.genLayout(game_id, weight)

        #final result checking
        bonus_num = 0
        spin_num = 0
        response = {}

        pay_out, ret = self.recheck(game_id, lines, slots)
        if pay_out != 0:
            response['win_lines'] = ret

            combo = self.check5Combo(ret, slots)
            if combo:
                response["5combo"] = combo

        response['symbols'] = slots
        response['win'] = pay_out * bet

        bonus = self.check_bonus(slots, lines)
        if bonus:
            (bonus_num, line, pos) = bonus
            response['win_bonus'] = {'line': line, 'pos': pos}

        scatter = self.check_scatter(slots)
        if scatter:
            (pos, n) = scatter
            spin_num = FreeSpin.getNum(game_id, n)

            response['win_free_spin'] = {'pos': pos, 'num': spin_num}



        return (response, pay_out * bet, bonus_num, spin_num)
Example #4
0
    def recheck(self, game_id, line_num, slots):
        ret = []
        pay_out = 0

        for idx in xrange(line_num):
            n = 0
            wild_n = 0

            x = PayTable.LINES[idx][0]
            y = 0
            k = slots[x][y]

            # if multiple wild exist on the same line
            for (y, x) in enumerate(PayTable.LINES[idx]):
                if slots[x][y] == PayTable.WILD:
                    wild_n += 1
                else:
                    break

            is_triple_wild = False
            # checking for common symbol
            for (y, x) in enumerate(PayTable.LINES[idx]):
                if k == slots[x][y] or (PayTable.isWild(k) or PayTable.isWild(slots[x][y])):
                    n += 1
                    if PayTable.isWild(k):
                        k = slots[x][y]
                    if k == PayTable.TRIPLE_WILD or slots[x][y] == PayTable.TRIPLE_WILD:
                        is_triple_wild = True
                else:
                    break

            single_payout = 0

            win_line = {}
            # except BONUS and SCATTER checking
            pay_table = PayTable.getPayTable(game_id)
            if (k in pay_table) and (n in pay_table[k]):
                single_payout = pay_table[k][n]
                win_line = {'pos' : [(PayTable.LINES[idx][i], i) for i in xrange(n)],
                            'line' : idx}

                if is_triple_wild:
                    single_payout *= 3
                    win_line['triple_wild'] = True

                #Log.debug('detected:(%d, %d, %d)' % (idx, n, k))

            if PayTable.WILD in pay_table and wild_n in pay_table[PayTable.WILD]:
                if pay_table[PayTable.WILD][wild_n] > single_payout:
                    single_payout = pay_table[PayTable.WILD][wild_n]
                    win_line = {'pos': [(PayTable.LINES[idx][i], i) for i in xrange(wild_n)],
                                'line': idx}

                    #Log.debug('detected(override): (%d, %d, %d)' % (idx, wild_n, PayTable.WILD))

            if win_line:
                ret.append(win_line)

            pay_out += single_payout

        return (pay_out, ret)