Ejemplo n.º 1
0
    def load(self):
        # update the parameters in the parameters classes: Knows, Settings

        # Knows
        for param in self.params['Knows']:
            if isKnows(param) and hasattr(Knows, param):
                setattr(Knows, param, SMBool(self.params['Knows'][param][0],
                                             self.params['Knows'][param][1],
                                             ['{}'.format(param)]))
        # Settings
        ## hard rooms
        for hardRoom in ['X-Ray', 'Gauntlet']:
            if hardRoom in self.params['Settings']:
                Settings.hardRooms[hardRoom] = Settings.hardRoomsPresets[hardRoom][self.params['Settings'][hardRoom]]

        ## bosses
        for boss in ['Kraid', 'Phantoon', 'Draygon', 'Ridley', 'MotherBrain']:
            if boss in self.params['Settings']:
                Settings.bossesDifficulty[boss] = Settings.bossesDifficultyPresets[boss][self.params['Settings'][boss]]

        ## hellruns
        for hellRun in ['Ice', 'MainUpperNorfair', 'LowerNorfair']:
            if hellRun in self.params['Settings']:
                Settings.hellRuns[hellRun] = Settings.hellRunPresets[hellRun][self.params['Settings'][hellRun]]

        # Controller
        for button in self.params['Controller']:
            if isButton(button):
                setattr(Controller, button, self.params['Controller'][button])
Ejemplo n.º 2
0
 def createKnowsFunctions(self):
     # for each knows we have a function knowsKnows (ex: knowsAlcatrazEscape()) which
     # take no parameter
     for knows in Knows.__dict__:
         if isKnows(knows):
             setattr(self, 'knows'+knows, lambda knows=knows: self.knowsKnows(knows,
                                                                              (Knows.__dict__[knows].bool,
                                                                               Knows.__dict__[knows].difficulty)))
Ejemplo n.º 3
0
    def printToScreen(self):
        print("self.params: {}".format(self.params))

        print("loaded knows: ")
        for knows in Knows.__dict__:
            if isKnows(knows):
                print("{}: {}".format(knows, Knows.__dict__[knows]))
        print("loaded settings:")
        for setting in Settings.__dict__:
            if isSettings(setting):
                print("{}: {}".format(setting, Settings.__dict__[setting]))
        print("loaded controller:")
        for button in Controller.__dict__:
            if isButton(button):
                print("{}: {}".format(button, Controller.__dict__[button]))
        print("loaded score: {}".format(self.params['score']))
Ejemplo n.º 4
0
 def prepareFirstPhase(self):
     self.changedKnows = {}
     # forces IceZebSkip if necessary to finish with 10-10-5
     if Knows.IceZebSkip.bool == False or Knows.IceZebSkip.difficulty > self.maxDiff:
         self.changedKnows['IceZebSkip'] = Knows.IceZebSkip
         Knows.IceZebSkip = SMBool(True, 0, [])
     # hack knows to remove those > maxDiff
     for attr, k in Knows.__dict__.items():
         if isKnows(
                 attr) and k.bool == True and k.difficulty > self.maxDiff:
             self.log.debug("prepareFirstPhase. disabling knows " + attr)
             self.changedKnows[attr] = k
             setattr(Knows, attr, SMBool(False, 0))
     # set max diff to god (for hard rooms/hellruns/bosses)
     self.settings.maxDiff = god
     # prepare 1st phase container
     itemCond = isChozoItem
     locCond = lambda loc: 'Chozo' in loc['Class'] or 'Boss' in loc['Class']
     # this will create a new smbm with new knows functions
     cont = self.baseContainer.slice(itemCond, locCond)
     secondPhaseItems = [
         item for item in self.baseContainer.itemPool
         if item not in cont.itemPool
     ]
     contLocs = self.baseContainer.extractLocs(cont.unusedLocations)
     secondPhaseLocs = [
         loc for loc in self.baseContainer.unusedLocations
         if loc not in contLocs
     ]
     self.log.debug("prepareFirstPhase. secondPhaseItems=" +
                    getItemListStr(secondPhaseItems))
     self.log.debug("prepareFirstPhase. secondPhaseLocs=" +
                    getLocListStr(secondPhaseLocs))
     self.secondPhaseContainer = ItemLocContainer(cont.sm, secondPhaseItems,
                                                  secondPhaseLocs)
     return self.fillerFactory.createFirstPhaseFiller(cont)
Ejemplo n.º 5
0
    def computeScore(self):
        # the more techniques you know and the smaller the difficulty of the techniques, the higher the score
        diff2score = {
            easy: 6,
            medium: 5,
            hard: 4,
            harder: 3,
            hardcore: 2,
            mania: 1
        }

        boss2score = {
            "He's annoying": 1,
            'A lot of trouble': 1,
            "I'm scared!": 1,
            "It can get ugly": 1,
            'Default': 2,
            'Quick Kill': 3,
            'Used to it': 3,
            'Is this really the last boss?': 3,
            'No problemo': 4,
            'Piece of cake': 4,
            'Nice cutscene bro': 4
        }

        hellrun2score = {
            'No thanks': 0,
            'Solution': 0,
            'Gimme energy': 2,
            'Default': 4,
            'Bring the heat': 6,
            'I run RBO': 8
        }

        hellrunLN2score = {
            'Default': 0,
            'Solution': 0,
            'Bring the heat': 6,
            'I run RBO': 12
        }

        xray2score = {
            'Aarghh': 0,
            'Solution': 0,
            "I don't like spikes": 1,
            'Default': 2,
            "I don't mind spikes": 3,
            'D-Boost master': 4
        }

        gauntlet2score = {
            'Aarghh': 0,
            "I don't like acid": 1,
            'Default': 2
        }

        score = 0

        # knows
        for know in Knows.__dict__:
            if isKnows(know):
                if know in self.params['Knows']:
                    if self.params['Knows'][know][0] == True:
                        score += diff2score[self.params['Knows'][know][1]]
                else:
                    # if old preset with not all the knows, use default values for the know
                    if Knows.__dict__[know].bool == True:
                        score += diff2score[Knows.__dict__[know].difficulty]

        # hard rooms
        hardRoom = 'X-Ray'
        if hardRoom in self.params['Settings']:
            score += xray2score[self.params['Settings'][hardRoom]]

        hardRoom = 'Gauntlet'
        if hardRoom in self.params['Settings']:
            score += gauntlet2score[self.params['Settings'][hardRoom]]

        # bosses
        for boss in ['Kraid', 'Phantoon', 'Draygon', 'Ridley', 'MotherBrain']:
            if boss in self.params['Settings']:
                score += boss2score[self.params['Settings'][boss]]

        # hellruns
        for hellRun in ['Ice', 'MainUpperNorfair']:
            if hellRun in self.params['Settings']:
                score += hellrun2score[self.params['Settings'][hellRun]]

        hellRun = 'LowerNorfair'
        if hellRun in self.params['Settings']:
            score += hellrunLN2score[self.params['Settings'][hellRun]]

        return score