예제 #1
0
def _logbook_node(request):
    has_translator = request.param
    scan_visor = SimpleResourceInfo(1, "Scan", "S", ResourceType.ITEM)
    translator = SimpleResourceInfo(2, "Translator", "T", ResourceType.ITEM)

    node = LogbookNode("Logbook", False, 0, 1000, scan_visor,
                       LoreType.LUMINOTH_LORE,
                       translator if has_translator else None, None)

    return has_translator, scan_visor, translator, node
예제 #2
0
def _create_world_list(asset_id: int, pickup_index: PickupIndex):
    logbook_node = LogbookNode("Logbook A", True, 0, asset_id, None, None,
                               None, None)
    pickup_node = PickupNode("Pickup Node", True, 1, pickup_index, True)

    world_list = WorldList([
        World("World", 5000, [
            Area("Area", False, 10000, 0, [logbook_node, pickup_node], {}),
        ]),
    ])

    return logbook_node, pickup_node, world_list
예제 #3
0
def _create_world_list(asset_id: int, pickup_index: PickupIndex):
    logbook_node = LogbookNode("Logbook A", True, None, 0, asset_id, None,
                               None, None, None)
    pickup_node = PickupNode("Pickup Node", True, None, 1, pickup_index, True)

    world_list = WorldList([
        World("World", "Dark World", 5000, [
            Area("Area", False, 10000, 0, True, [logbook_node, pickup_node],
                 {}),
            Area("Other Area", False, 20000, 0, True, [
                PickupNode(f"Pickup {i}", True, None, 1, PickupIndex(i), True)
                for i in range(pickup_index.index)
            ], {}),
        ]),
    ])

    return logbook_node, pickup_node, world_list
예제 #4
0
    def read_node(self, data: Dict) -> Node:
        name: str = data["name"]
        self.generic_index += 1
        try:
            heal: bool = data["heal"]
            node_type: int = data["node_type"]
            location = None
            if data["coordinates"] is not None:
                location = location_from_json(data["coordinates"])

            if node_type == "generic":
                return GenericNode(name, heal, location, self.generic_index)

            elif node_type == "dock":
                return DockNode(
                    name, heal, location, self.generic_index,
                    data["dock_index"],
                    DockConnection(data["connected_area_asset_id"],
                                   data["connected_dock_index"]),
                    self.dock_weakness_database.get_by_type_and_index(
                        DockType(data["dock_type"]),
                        data["dock_weakness_index"]))

            elif node_type == "pickup":
                return PickupNode(name, heal, location, self.generic_index,
                                  PickupIndex(data["pickup_index"]),
                                  data["major_location"])

            elif node_type == "teleporter":
                instance_id = data["teleporter_instance_id"]

                destination_world_asset_id = data["destination_world_asset_id"]
                destination_area_asset_id = data["destination_area_asset_id"]

                return TeleporterNode(
                    name,
                    heal,
                    location,
                    self.generic_index,
                    instance_id,
                    AreaLocation(destination_world_asset_id,
                                 destination_area_asset_id),
                    data["scan_asset_id"],
                    data["keep_name_when_vanilla"],
                    data["editable"],
                )

            elif node_type == "event":
                return EventNode(
                    name, heal, location, self.generic_index,
                    self.resource_database.get_by_type_and_index(
                        ResourceType.EVENT, data["event_index"]))

            elif node_type == "translator_gate":
                return TranslatorGateNode(name, heal, location,
                                          self.generic_index,
                                          TranslatorGate(data["gate_index"]),
                                          self._get_scan_visor())

            elif node_type == "logbook":
                lore_type = LoreType(data["lore_type"])

                if lore_type == LoreType.LUMINOTH_LORE:
                    required_translator = self.resource_database.get_item(
                        data["extra"])
                else:
                    required_translator = None

                if lore_type in {
                        LoreType.LUMINOTH_WARRIOR, LoreType.SKY_TEMPLE_KEY_HINT
                }:
                    hint_index = data["extra"]
                else:
                    hint_index = None

                return LogbookNode(name, heal, location, self.generic_index,
                                   data["string_asset_id"],
                                   self._get_scan_visor(), lore_type,
                                   required_translator, hint_index)
            else:
                raise Exception(f"Unknown type: {node_type}")

        except Exception as e:
            raise Exception(f"In node {name}, got error: {e}")
예제 #5
0
    def create_new_node(self) -> Node:
        node_type = self.node_type_combo.currentData()
        name = self.name_edit.text()
        heal = self.heals_check.isChecked()
        location = None
        if self.location_group.isChecked():
            location = NodeLocation(self.location_x_spin.value(),
                                    self.location_y_spin.value(),
                                    self.location_z_spin.value())
        index = self.node.index

        if node_type == GenericNode:
            return GenericNode(name, heal, location, index)

        elif node_type == DockNode:
            return DockNode(
                name,
                heal,
                location,
                index,
                self.dock_index_spin.value(),
                DockConnection(
                    self.dock_connection_area_combo.currentData(
                    ).area_asset_id,
                    self.dock_connection_node_combo.currentData()),
                self.dock_weakness_combo.currentData(),
            )

        elif node_type == PickupNode:
            return PickupNode(
                name,
                heal,
                location,
                index,
                PickupIndex(self.pickup_index_spin.value()),
                self.major_location_check.isChecked(),
            )

        elif node_type == TeleporterNode:
            instance_id = self.teleporter_instance_id_edit.text()
            scan_asset_id = self.teleporter_scan_asset_id_edit.text()

            return TeleporterNode(
                name,
                heal,
                location,
                index,
                int(instance_id, 0) if instance_id != "" else None,
                AreaLocation(
                    self.teleporter_destination_world_combo.currentData(
                    ).world_asset_id,
                    self.teleporter_destination_area_combo.currentData().
                    area_asset_id),
                int(scan_asset_id, 0) if scan_asset_id != "" else None,
                self.teleporter_vanilla_name_edit.isChecked(),
                self.teleporter_editable_check.isChecked(),
            )

        elif node_type == EventNode:
            event = self.event_resource_combo.currentData()
            if event is None:
                raise ValueError(
                    "There are no events in the database, unable to create EventNode."
                )
            return EventNode(
                name,
                heal,
                location,
                index,
                event,
            )

        elif node_type == TranslatorGateNode:
            return TranslatorGateNode(
                name, heal, location, index,
                TranslatorGate(self.translator_gate_spin.value()),
                self._get_scan_visor())

        elif node_type == LogbookNode:
            lore_type: LoreType = self.lore_type_combo.currentData()
            if lore_type == LoreType.LUMINOTH_LORE:
                required_translator = self.logbook_extra_combo.currentData()
                if required_translator is None:
                    raise ValueError("Missing required translator.")
            else:
                required_translator = None

            if lore_type == LoreType.LUMINOTH_WARRIOR:
                hint_index = self.logbook_extra_combo.currentData()
            else:
                hint_index = None

            return LogbookNode(
                name, heal, location, index,
                int(self.logbook_string_asset_id_edit.text(), 0),
                self._get_scan_visor(), lore_type, required_translator,
                hint_index)

        elif node_type == PlayerShipNode:
            return PlayerShipNode(name, heal, location, index,
                                  self._unlocked_by_requirement,
                                  self._get_command_visor())

        else:
            raise RuntimeError(f"Unknown node type: {node_type}")
예제 #6
0
    def read_node(self, data: Dict) -> Node:
        name: str = data["name"]
        heal: bool = data["heal"]
        node_type: int = data["node_type"]
        self.generic_index += 1

        if node_type == 0:
            return GenericNode(name, heal, self.generic_index)

        elif node_type == 1:
            return DockNode(
                name, heal, self.generic_index, data["dock_index"],
                DockConnection(data["connected_area_asset_id"],
                               data["connected_dock_index"]),
                self.dock_weakness_database.get_by_type_and_index(
                    DockType(data["dock_type"]), data["dock_weakness_index"]))

        elif node_type == 2:
            return PickupNode(name, heal, self.generic_index,
                              PickupIndex(data["pickup_index"]),
                              data["major_location"])

        elif node_type == 3:
            instance_id = data["teleporter_instance_id"]

            destination_world_asset_id = data["destination_world_asset_id"]
            destination_area_asset_id = data["destination_area_asset_id"]

            return TeleporterNode(
                name,
                heal,
                self.generic_index,
                instance_id,
                AreaLocation(destination_world_asset_id,
                             destination_area_asset_id),
                data["keep_name_when_vanilla"],
                data["editable"],
            )

        elif node_type == 4:
            return EventNode(
                name, heal, self.generic_index,
                self.resource_database.get_by_type_and_index(
                    ResourceType.EVENT, data["event_index"]))

        elif node_type == 5:
            return TranslatorGateNode(
                name, heal, self.generic_index,
                TranslatorGate(data["gate_index"]),
                find_resource_info_with_long_name(self.resource_database.item,
                                                  "Scan Visor"))

        elif node_type == 6:
            lore_type = list(LoreType)[data["lore_type"]]

            if lore_type == LoreType.LUMINOTH_LORE:
                required_translator = self.resource_database.get_item(
                    data["extra"])
            else:
                required_translator = None

            if lore_type in {
                    LoreType.LUMINOTH_WARRIOR, LoreType.SKY_TEMPLE_KEY_HINT
            }:
                hint_index = data["extra"]
            else:
                hint_index = None

            return LogbookNode(
                name, heal, self.generic_index, data["string_asset_id"],
                find_resource_info_with_long_name(self.resource_database.item,
                                                  "Scan Visor"), lore_type,
                required_translator, hint_index)

        else:
            raise Exception("Unknown node type: {}".format(node_type))