Пример #1
0
 def requirements_to_leave(self, patches: GamePatches, current_resources: CurrentResources) -> RequirementSet:
     return RequirementSet([
         RequirementList(0, [
             IndividualRequirement(patches.translator_gates[self.gate], 1, False),
             IndividualRequirement(self.scan_visor, 1, False),
         ])
     ])
Пример #2
0
    def requirements_to_leave(
            self, patches: GamePatches,
            current_resources: CurrentResources) -> RequirementSet:
        items = [IndividualRequirement(self.scan_visor, 1, False)]
        if self.required_translator is not None:
            items.append(
                IndividualRequirement(self.required_translator, 1, False))

        return RequirementSet([RequirementList(0, items)])
Пример #3
0
 def requirements_to_leave(
         self, patches: GamePatches,
         current_resources: CurrentResources) -> RequirementSet:
     return RequirementSet([
         RequirementList(0, [
             IndividualRequirement(self.pickup_node.pickup_index, 1, False),
         ])
     ])
Пример #4
0
 def _new_row():
     empty_item = IndividualRequirement(
         self.resource_database.get_by_type(ResourceType.ITEM)[0],
         1, False)
     ItemRow(group_box, vertical_layout, self.resource_database,
             empty_item, group_box.rows)
     vertical_layout.removeItem(tools_layout)
     vertical_layout.addLayout(tools_layout)
Пример #5
0
def test_replace_missing(replacement):
    trivial = RequirementSet.trivial()

    req_a = SimpleResourceInfo(0, "A", "A", "")
    id_req_a = IndividualRequirement(req_a, 1, False)

    result = trivial.replace(id_req_a, replacement)

    assert result == trivial
Пример #6
0
 def requirements_to_leave(self, patches: GamePatches, current_resources: CurrentResources) -> RequirementSet:
     if current_resources.get("add_self_as_requirement_to_resources") == 1:
         return RequirementSet([
             RequirementList(0, [
                 IndividualRequirement(self.event, 1, False),
             ])
         ])
     else:
         return RequirementSet.trivial()
Пример #7
0
 def requirements_to_leave(self, patches: GamePatches, current_resources: CurrentResources) -> RequirementSet:
     # FIXME: using non-resource as key in CurrentResources
     if current_resources.get("add_self_as_requirement_to_resources") == 1:
         return RequirementSet([
             RequirementList(0, [
                 IndividualRequirement(self.pickup_index, 1, False),
             ])
         ])
     else:
         return RequirementSet.trivial()
Пример #8
0
 def _replace(alternative: RequirementList) -> RequirementList:
     if alternative.get(resource) is not None:
         return RequirementList.without_misc_resources(
             database=database,
             items=[
                 (individual if individual.resource != database.difficulty_resource
                  else IndividualRequirement(database.difficulty_resource, new_difficulty, False))
                 for individual in alternative.values()
             ]
         )
     else:
         return alternative
Пример #9
0
def test_list_dangerous_resources(input_data, output_data):
    # setup
    req_list = RequirementList(0, (IndividualRequirement(
        SimpleResourceInfo(item[0], str(item[0]), str(item[0]), ""), 1,
        item[1]) for item in input_data))
    expected_result = {
        SimpleResourceInfo(item, str(item), str(item), "")
        for item in output_data
    }

    # run
    result = set(req_list.dangerous_resources)

    # assert
    assert result == expected_result
Пример #10
0
def test_minimum_satisfied_difficulty(database: ResourceDatabase, resources,
                                      expected_level):
    res_a, id_req_a = make_req_a()
    res_b, id_req_b = make_req_b()
    res_c, id_req_c = make_req_c()
    the_set = RequirementSet([
        RequirementList(0, [id_req_a]),
        RequirementList(1, [
            id_req_b,
            IndividualRequirement(database.difficulty_resource, 1, False)
        ]),
        RequirementList(2, [
            id_req_c,
            IndividualRequirement(database.difficulty_resource, 2, False)
        ]),
    ])

    res = {
        database.get_by_type_and_index(ResourceType.ITEM, x): 1
        for x in resources
    }
    res[database.difficulty_resource] = 10
    diff = the_set.minimum_satisfied_difficulty(res, 99)
    assert diff == expected_level
Пример #11
0
def _make_req(name: str, index: int):
    req = SimpleResourceInfo(index, name, name, "")
    id_req = IndividualRequirement(req, 1, False)
    return req, id_req
Пример #12
0
def read_individual_requirement(
        data: Dict,
        resource_database: ResourceDatabase) -> IndividualRequirement:
    return IndividualRequirement.with_data(
        resource_database, ResourceType(data["requirement_type"]),
        data["requirement_index"], data["amount"], data["negate"])
Пример #13
0
 def current_individual(self) -> IndividualRequirement:
     return IndividualRequirement(self.resource_name_combo.currentData(),
                                  int(self.amount_edit.text()),
                                  self.negate_combo.currentData())