예제 #1
0
    def roll(self, crit_type, database, weapon_type):

        if database == '--Select database--' or weapon_type == '--Select weapon type--':
            self.textlabel.setText('Invalid input.\nCheck the dropdown menus.')
            return

        db_filename = database + '.sqlite'
        global dbobj
        dbobj = DBHandler(db_filename)

        if self.checkbox.isChecked():
            crit = dbobj.select_random(crit_type, 1, weapon_type)
            if crit == None:
                self.textlabel.setText('No crits in the database!')
                return
        else:
            crit = dbobj.select_random(crit_type, 0, weapon_type)
            if crit == None:
                self.textlabel.setText(
                    'No more unused crits.\nUntick \'used\' box or reset')
                return
            dbobj.set_used(crit[2], crit_type)

        crittext = 'Author: {}\nName: {}\n\n{}'.format(crit[1], crit[2],
                                                       crit[3])
        self.textlabel.setText(crittext)