def create_build_component(component, statset): """Creates and returns BuildComponent object from inputs Args: component: element of class Build (See champs/classes/items.py) statset: StatSet instance (see champs.models.py) Return: bc: BuildComponent instance (see champs.models.py) Dependencies: ItemStatic BuildComponent timestamp_to_game_time """ # Get Data Dragon version from MatchVersion version = statset.champ.match_version.dd_version # Get ItemStatic for input component item_id = component.item.item_id item = ItemStatic.objects.get(item_id=item_id, version=version) # Rewrite times from millis to YY:ZZ or XX:YY:ZZ time (as appropriate) item_birth_time=timestamp_to_game_time(component.birth_time) item_death_time=timestamp_to_game_time(component.death_time) # Create and return BuildComponent bc = BuildComponent(statset=statset, item=item, item_birth=component.birth_time, item_birth_time=item_birth_time, item_death=component.death_time, item_death_time=item_death_time, item_batch=component.batch) return bc
def get_inventory_at(self, timestamp): game_time = timestamp_to_game_time(timestamp) string = 'INVENTORY AT {time}:\n'.format(time=game_time) for component in self.build_history: if component.exists_at_time(timestamp): string += str(component) + '\n' return string