def __delete_entity(self, dce: DCERPC, entity: Entity, uniq_id: int): domain_name, domain_handle = self.__get_domain_handel(dce) logger.info( f'Deleting {entity.__name__} with id ({uniq_id}) from domain "{domain_name}"' ) try: entity.delete(dce, domain_handle, uniq_id) except Exception as e: raise DeleteEntityException(e) logging.info( f'{entity.__name__} id ({uniq_id}) was deleted successfully')
def showpowerups(self, powerup): lst = [] for p in self.powerups: if p.status == True: lst.append(Entity(1, 1, 1, 1, Fore.WHITE, p.utility_sprite)) for i in range(len(lst)): self.Board[self.height - 3][self.width - i - 3] = lst[i]
def __create_entity(self, dce: DCERPC, entity: Entity, name: str): domain_name, domain_handle = self.__get_domain_handel(dce) logger.info( f'Creating {entity.__name__} named "{name}" at domain "{domain_name}"' ) try: entity = entity.create(dce, domain_handle, name) except Exception as e: raise CreateEntityException(e) logging.info( f'{entity.__class__.__name__} named "{name}" was created successfully with relative ID: {entity.uniq_id}' ) return entity
def __list_all_entities(self, dce: DCERPC, entity: Entity) -> List[Entity]: entities = [] try: # iterating over all domains for domain_name, domain_handle in self.__get_domain_handels( dce).items(): if entity.filter_out_domain(domain_name): # filtering domains according to entity logic break logging.info( f'Looking up {entity.__name__} in domain "{domain_name}"') status = STATUS_MORE_ENTRIES while status == STATUS_MORE_ENTRIES: try: resp = entity.enumerate(dce, domain_handle) except DCERPCException as e: if str(e).find('STATUS_MORE_ENTRIES') < 0: raise resp = e.get_packet() for _entity in resp['Buffer']['Buffer']: _entity = entity.get_entity(dce, domain_handle, _entity) entities.append(_entity) logging.info(f'Received {len(entities)} entries.') enumeration_context = resp['EnumerationContext'] status = resp['ErrorCode'] logger.debug( f"enumeration_context {enumeration_context}, status {status}" ) except Exception as e: raise ListEntitiesException(e) return entities
def push(entity: Entity, direction: Compass.Direction) -> bool: neighbor: Holder = entity.get_parent().get_neighbor(direction) # If the neighbor is empty we can move to it if neighbor.is_empty(): move(entity, direction) return True pushee: Entity = neighbor.get_child() # Checks if there is an arrow facing the wrong way, which blocks our movement if isinstance(pushee, Arrow) and pushee.direction is ~direction: return False # If the pushee is pushable and can successfully be pushed we can move to it if pushee.pushable and push(pushee, direction): move(entity, direction) return True return False
def makeborder(self): self.PrintBoard = [[None for j in range(self.width)] for i in range(self.height)] self.Board = [[None for j in range(self.width)] for i in range(self.height)] a = Entity(1, 1, 1, 1, Fore.WHITE, '┃') b = Entity(1, 1, 1, 1, Fore.WHITE, '┏') c = Entity(1, 1, 1, 1, Fore.WHITE, '┓') d = Entity(1, 1, 1, 1, Fore.WHITE, '━') e = Entity(1, 1, 1, 1, Fore.WHITE, '┗') f = Entity(1, 1, 1, 1, Fore.WHITE, '┛') for i in range(self.height): for j in range(self.width): if j == 0 or j == self.width - 1: self.Board[i][j] = a if i == 0: if j == 0: self.Board[i][j] = b elif j == self.width - 1: self.Board[i][j] = c else: self.Board[i][j] = d if i == self.height - 1: if j == 0: self.Board[i][j] = e elif j == self.width - 1: self.Board[i][j] = f else: self.Board[i][j] = d elif i == self.height - 4: if j == 0: self.Board[i][j] = a elif j == self.width - 1: self.Board[i][j] = a else: self.Board[i][j] = d
def showlevel(self): self.Board[self.height - 3][2] = Entity(1, 1, 1, 1, Fore.WHITE, "L") self.Board[self.height - 3][3] = Entity(1, 1, 1, 1, Fore.WHITE, "E") self.Board[self.height - 3][4] = Entity(1, 1, 1, 1, Fore.WHITE, "V") self.Board[self.height - 3][5] = Entity(1, 1, 1, 1, Fore.WHITE, "E") self.Board[self.height - 3][6] = Entity(1, 1, 1, 1, Fore.WHITE, "L") self.Board[self.height - 3][7] = Entity(1, 1, 1, 1, Fore.WHITE, ":") self.Board[self.height - 3][8] = Entity(1, 1, 1, 1, Fore.WHITE, str(self.level)) self.Board[self.height - 2][2] = Entity(1, 1, 1, 1, Fore.WHITE, "L") self.Board[self.height - 2][3] = Entity(1, 1, 1, 1, Fore.WHITE, "I") self.Board[self.height - 2][4] = Entity(1, 1, 1, 1, Fore.WHITE, "V") self.Board[self.height - 2][5] = Entity(1, 1, 1, 1, Fore.WHITE, "E") self.Board[self.height - 2][6] = Entity(1, 1, 1, 1, Fore.WHITE, "S") self.Board[self.height - 2][7] = Entity(1, 1, 1, 1, Fore.WHITE, ":") self.Board[self.height - 2][8] = Entity(1, 1, 1, 1, Fore.WHITE, str(self.lives)) self.Board[self.height - 2][self.width - 10] = Entity( 1, 1, 1, 1, Fore.WHITE, "S") self.Board[self.height - 2][self.width - 9] = Entity( 1, 1, 1, 1, Fore.WHITE, "C") self.Board[self.height - 2][self.width - 8] = Entity( 1, 1, 1, 1, Fore.WHITE, "O") self.Board[self.height - 2][self.width - 7] = Entity( 1, 1, 1, 1, Fore.WHITE, "R") self.Board[self.height - 2][self.width - 6] = Entity( 1, 1, 1, 1, Fore.WHITE, "E") self.Board[self.height - 2][self.width - 5] = Entity( 1, 1, 1, 1, Fore.WHITE, ":") self.Board[self.height - 2][self.width - 4] = Entity( 1, 1, 1, 1, Fore.WHITE, str(int(self.score / 100))) self.Board[self.height - 2][self.width - 3] = Entity( 1, 1, 1, 1, Fore.WHITE, str(int(self.score / 10))) self.Board[self.height - 2][self.width - 2] = Entity( 1, 1, 1, 1, Fore.WHITE, str(int(self.score % 10)))
def add_entity(self, id, name=None): if id in self.entities: debug("Entity id %d added twice" % id) self.entities[id] = Entity(id, name)
def showhealth(self): for i in range(self.Boss.health): self.Board[self.height - 3][self.width - 2 - i] = Entity( 1, 1, 1, 1, Fore.WHITE, "♥")
def place(entity: Entity, target: Holder): entity.remove_parent() entity.put_into(target)
def move(entity: Entity, direction: Compass.Direction): target = entity.get_parent().get_neighbor(direction) place(entity, target)