Ejemplo n.º 1
0
 def __parse_add_multi_items(self):
     """Add custom sprites for multi-segmented items like Super Bum, key pieces or knife pieces"""
     if self.state.contains_item('238') and self.state.contains_item(
             '239') and not self.state.contains_item('3000'):
         for item in reversed(self.state.item_list):
             if item.item_id in ("238", "239"):
                 item.info.shown = False
         self.state.add_item(Item("3000", self.state.last_floor))
     elif self.state.contains_item('550') and self.state.contains_item(
             '552'):
         for item in reversed(self.state.item_list):
             if item.item_id == "550":
                 item.info.shown = False
     elif self.state.contains_item('144') and self.state.contains_item(
             '278'
     ) and self.state.contains_item('388') and not self.state.contains_item(
             '3001'
     ) and self.opt.game_version != "Rebirth" and self.opt.game_version != "Antibirth":
         for item in reversed(self.state.item_list):
             if item.item_id in ("144", "278", "388"):
                 item.info.shown = False
         self.state.add_item(Item("3001", self.state.last_floor))
     elif self.state.contains_item('626') and self.state.contains_item(
             '627') and not self.state.contains_item('3002'):
         for item in reversed(self.state.item_list):
             if item.item_id in ("626", "627"):
                 item.info.shown = False
         self.state.add_item(Item("3002", self.state.last_floor))
Ejemplo n.º 2
0
    def __parse_trinket_gulp(self, line):
        """ Parse a (modded) trinket gulp and push it to the state """
        space_split = line.split(" ")
        # When using a mod like racing+ on AB+, a trinket gulp has the form: "Gulping trinket 10"
        # In Repentance, a gulped trinket has the form : "Adding smelted trinket 10"
        if self.opt.game_version == "Repentance" and int(space_split[3]) > 30000:
            numeric_id = str(int(space_split[3]))
        elif self.opt.game_version == "Repentance":
            numeric_id = str(int(space_split[3]) + 2000) # the tracker hackily maps trinkets to items 2000 and up.
        else:
            numeric_id = str(int(space_split[2]) + 2000) # the tracker hackily maps trinkets to items 2000 and up.
        is_Jacob_item = line.endswith("(Jacob)") and self.opt.game_version == "Repentance" and self.state.player != 37 and self.state.player != 39
        is_Esau_item = line.endswith("(Esau)") and self.opt.game_version == "Repentance"

        # Check if we recognize the numeric id
        if Item.contains_info(numeric_id):
            item_id = numeric_id
        else:
            item_id = "NEW"

        self.log.debug("Gulped trinket: %s", item_id)

        added = self.state.add_item(Item(item_id, self.state.last_floor, self.getting_start_items, is_Jacob_item=is_Jacob_item, is_Esau_item=is_Esau_item))
        if not added:
            self.log.debug("Skipped adding item %s to avoid space-bar duplicate", item_id)
        self.state.export_state()
        return True
Ejemplo n.º 3
0
    def __parse_item(self, line_number, line):
        """ Parse an Item and push it to the state """
        if len(self.splitfile) > 1 and self.splitfile[line_number + self.seek -
                                                      1] == line:
            self.log.debug("Skipped duplicate item line from baby presence")
            return False
        space_split = line.split(" ")  # Hacky string manipulation
        item_id = space_split[
            2]  # A string has the form of "Adding collectible 105 (The D6)"

        # Check if the item ID exists
        if not Item.contains_info(item_id):
            item_id = "NEW"

        item_name = " ".join(space_split[3:])[1:-1]
        self.log.debug("Picked up item. id: %s, name: %s", item_id, item_name)
        if ((line_number + self.seek) - self.spawned_coop_baby) < (len(self.state.item_list) + 10) \
                and self.state.contains_item(item_id):
            self.log.debug("Skipped duplicate item line from baby entry")
            return False
        #it's a blind pickup if we're on a blind floor and they don't have the black candle
        blind_pickup = self.state.last_floor.floor_has_curse(
            Curse.Blind) and not self.state.contains_item('260')
        added = self.state.add_item(
            Item(item_id,
                 self.state.last_floor,
                 self.getting_start_items,
                 blind=blind_pickup))
        if not added:
            self.log.debug(
                "Skipped adding item %s to avoid space-bar duplicate", item_id)
        return True
Ejemplo n.º 4
0
 def load_from_export_state(self):
     new_floor_list = []
     new_item_list = []
     data = self.get_export_state()
     try:
         if self.game_version == "Repentance" or self.game_version == "Afterbirth+":
             data = data[self.game_version][str(self.save)]
         else:
             data = data[self.game_version]
         self.seed = data['seed']
         self.player = data['player']
         self.greedmode = data['greedmode']
         for floor in data['floor_list']:
             new_floor = Floor(floor["floor_id"], floor["curse"])
             new_floor_list.append(new_floor)
         self.floor_list = new_floor_list
         for item in data['item_list']:
             new_item = Item(flagstr=item["flags"],
                             item_id=item['item_id'],
                             floor=Floor(floor_id=item['floor_id']))
             new_item_list.append(new_item)
         self.item_list = new_item_list
         self.player_transforms = data['player_transforms']
         if self.player == "19":
             self.player2_transforms = data['player2_transforms']
         self.modified = True
     except:
         return True
Ejemplo n.º 5
0
    def __parse_item_add(self, line_number, line):
        """ Parse an item and push it to the state """
        if len(self.splitfile) > 1 and self.splitfile[line_number + self.seek - 1] == line:
            self.log.debug("Skipped duplicate item line from baby presence")
            return False
        space_split = line.split(" ")
        numeric_id = space_split[2] # When you pick up an item, this has the form: "Adding collectible 105 (The D6)"
        item_name = " ".join(space_split[3:])[1:-1]
        item_id = ""

        # Check if we recognize the numeric id
        if Item.contains_info(numeric_id):
            item_id = numeric_id
        else:
            # it might be a modded custom item. let's see if we recognize the name
            item_id = Item.modded_item_id_prefix + item_name
            if not Item.contains_info(item_id):
                item_id = "NEW"

        self.log.debug("Picked up item. id: %s, name: %s", item_id, item_name)
        if ((line_number + self.seek) - self.spawned_coop_baby) < (len(self.state.item_list) + 10) \
                and self.state.contains_item(item_id):
            self.log.debug("Skipped duplicate item line from baby entry")
            return False

        # It's a blind pickup if we're on a blind floor and we don't have the Black Candle
        blind_pickup = self.state.last_floor.floor_has_curse(Curse.Blind) and not self.state.contains_item('260')
        added = self.state.add_item(Item(item_id, self.state.last_floor, self.getting_start_items, blind=blind_pickup))
        if not added:
            self.log.debug("Skipped adding item %s to avoid space-bar duplicate", item_id)
        return True
Ejemplo n.º 6
0
    def __parse_item_add(self, line_number, line):
        """ Parse an item and push it to the state """
        if len(self.splitfile) > 1 and self.splitfile[line_number + self.seek - 1] == line:
            self.log.debug("Skipped duplicate item line from baby presence")
            return False
        is_Jacob_item = line.endswith("(Jacob)") and self.opt.game_version == "Repentance" and self.state.player == 19
        is_Esau_item = line.endswith("(Esau)") and self.opt.game_version == "Repentance" # The second part of the condition is to avoid showing Esau's Head if you play on a modded char in AB+  
        if self.state.player == 19 and not is_Esau_item and not is_Jacob_item: # This is when J&E transform into another character
            self.state.player = 8 # Put it on Lazarus by default just in case we got another Anemic
        elif self.state.player != 19 and is_Jacob_item:
            self.state.player = 19
        end_name = -1
        space_split = line.split(" ")
        numeric_id = space_split[2] # When you pick up an item, this has the form: "Adding collectible 105 (The D6)" or "Adding collectible 105 (The D6) to Player 0 (Isaac)" in Repentance
        if self.opt.game_version == "Repentance":
            item_name = " ".join(space_split[3:-4])[1:end_name]
        else:
            item_name = " ".join(space_split[3:])[1:end_name]  
        item_id = ""

        if int(numeric_id) < 0:
            numeric_id = "-1"

        # Check if we recognize the numeric id
        if Item.contains_info(numeric_id):
            item_id = numeric_id
        else:
            # it might be a modded custom item. let's see if we recognize the name
            item_id = Item.modded_item_id_prefix + item_name
            if not Item.contains_info(item_id):
                item_id = "NEW"

        self.log.debug("Picked up item. id: %s, name: %s", item_id, item_name)
        if ((line_number + self.seek) - self.spawned_coop_baby) < (len(self.state.item_list) + 10) \
                and self.state.contains_item(item_id):
            self.log.debug("Skipped duplicate item line from baby entry")
            return False

        # It's a blind pickup if we're on a blind floor and we don't have the Black Candle
        blind_pickup = self.state.last_floor.floor_has_curse(Curse.Blind) and not self.state.contains_item('260')
        if not (numeric_id == "214" and ((self.state.contains_item('214') and self.state.contains_item('332')) or (self.state.player == 8 and self.state.contains_item('214')))):
            added = self.state.add_item(Item(item_id, self.state.last_floor, self.getting_start_items, blind=blind_pickup, is_Jacob_item=is_Jacob_item, is_Esau_item=is_Esau_item))
            if not added:
                self.log.debug("Skipped adding item %s to avoid space-bar duplicate", item_id)
        else:
            self.log.debug("Skipped adding Anemic from Lazarus Rags because we already have Anemic")

        if item_id in ("144", "238", "239", "278", "388", "550", "552", "626", "627"):
            self.__parse_add_multi_items()
        self.state.export_state()
        return True
Ejemplo n.º 7
0
 def __parse_add_multi_items(self):
     """Add custom sprites for multi-segmented items like Super Bum, key pieces or knife pieces"""
     # item.info.shown = False is for not showing the item on the tracker
     # item.shown = False is for the export_state function to store the actual shown value instead of the initial value item.info.shown
     if self.state.contains_item('238') and self.state.contains_item(
             '239') and not self.state.contains_item('3000'):
         for item in reversed(self.state.item_list):
             if item.item_id in ("238", "239"):
                 item.info.shown = False
                 item.shown = False
         self.state.add_item(
             Item("3000", "3000", floor=self.state.last_floor))
     elif self.state.contains_item('550') and self.state.contains_item(
             '552'):
         for item in reversed(self.state.item_list):
             if item.item_id == "550":
                 item.info.shown = False
                 item.shown = False
     elif self.state.contains_item('144') and self.state.contains_item(
             '278'
     ) and self.state.contains_item('388') and not self.state.contains_item(
             '3001'
     ) and self.opt.game_version != "Rebirth" and self.opt.game_version != "Antibirth":
         for item in reversed(self.state.item_list):
             if item.item_id in ("144", "278", "388"):
                 item.info.shown = False
                 item.shown = False
         self.state.add_item(
             Item("3001", "3001", floor=self.state.last_floor))
     elif self.state.contains_item('626') and self.state.contains_item(
             '627') and not self.state.contains_item('3002'):
         for item in reversed(self.state.item_list):
             if item.item_id in ("626", "627"):
                 item.info.shown = False
                 item.shown = False
         self.state.add_item(
             Item("3002", "3002", floor=self.state.last_floor))
Ejemplo n.º 8
0
    def __parse_trinket_gulp(self, line):
        """ Parse a (modded) trinket gulp and push it to the state """
        space_split = line.split(" ")
        # When using a mod like racing+, a trinket gulp has the form: "Gulping trinket 10"
        numeric_id = str(int(space_split[2]) + 2000) # the tracker hackily maps trinkets to items 2000 and up.

        # Check if we recognize the numeric id
        if Item.contains_info(numeric_id):
            item_id = numeric_id
        else:
            item_id = "NEW"

        self.log.debug("Gulped trinket: %s", item_id)

        added = self.state.add_item(Item(item_id, self.state.last_floor, self.getting_start_items))
        if not added:
            self.log.debug("Skipped adding item %s to avoid space-bar duplicate", item_id)
        return True
Ejemplo n.º 9
0
    def __parse_item_add(self, line_number, line):
        """ Parse an item and push it to the state """
        if len(self.splitfile) > 1 and self.splitfile[line_number + self.seek -
                                                      1] == line:
            self.log.debug("Skipped duplicate item line from baby presence")
            return False
        is_Jacob_item = line.endswith(
            "(Jacob)"
        ) and self.opt.game_version == "Repentance"  # The second part of the condition is to avoid showing Jacob's Head if you play on a modded char in AB+
        is_Esau_item = line.endswith(
            "(Esau)"
        ) and self.opt.game_version == "Repentance"  # The second part of the condition is to avoid showing Esau's Head if you play on a modded char in AB+
        end_name = -15 if is_Jacob_item or is_Esau_item else -1
        space_split = line.split(" ")
        numeric_id = space_split[
            2]  # When you pick up an item, this has the form: "Adding collectible 105 (The D6)"
        item_name = " ".join(space_split[3:])[1:end_name]
        item_id = ""

        if int(numeric_id) < 0:
            numeric_id = "-1"
        if int(
                numeric_id
        ) == 577:  # Damocles can't be rerolled by D4 so no need to show it twice
            numeric_id = "656"

        # Check if we recognize the numeric id
        if Item.contains_info(numeric_id):
            item_id = numeric_id
        else:
            # it might be a modded custom item. let's see if we recognize the name
            item_id = Item.modded_item_id_prefix + item_name
            if not Item.contains_info(item_id):
                item_id = "NEW"

        self.log.debug("Picked up item. id: %s, name: %s", item_id, item_name)
        if ((line_number + self.seek) - self.spawned_coop_baby) < (len(self.state.item_list) + 10) \
                and self.state.contains_item(item_id):
            self.log.debug("Skipped duplicate item line from baby entry")
            return False

        # It's a blind pickup if we're on a blind floor and we don't have the Black Candle
        blind_pickup = self.state.last_floor.floor_has_curse(
            Curse.Blind) and not self.state.contains_item('260')
        if not (numeric_id == "214" and
                ((self.state.contains_item('214')
                  and self.state.contains_item('332')) or
                 (self.lazarus and self.state.contains_item('214')))):
            added = self.state.add_item(
                Item(item_id,
                     self.state.last_floor,
                     self.getting_start_items,
                     blind=blind_pickup,
                     is_Jacob_item=is_Jacob_item,
                     is_Esau_item=is_Esau_item))
            if not added:
                self.log.debug(
                    "Skipped adding item %s to avoid space-bar duplicate",
                    item_id)
        else:
            self.log.debug(
                "Skipped adding Anemic from Lazarus Rags because we already have Anemic"
            )
        return True