def __init__(self, *args, **kwargs): self.context = {} name = kwargs.pop("name", "logger") self.logger = logging.getLogger(name) self.backpack = {} self.backpack = kwargs.pop("backpack", Backpack()) logging.Logger.__init__(self, name, *args, **kwargs)
def __init__(cls): """ Load all data upon creation. """ cls.load() # Initialize other variables stored in the registry cls.backpack = Backpack(cls) cls.loaded = True
def __init__(self, game_map, task=TASKS.MINE): self.user_interface = UserInterface() self.backpack = Backpack() self.mine = Mine(self, game_map) self.smelt = Smelt(self, game_map) self.forge = Forge(self, game_map) # Set the default initial task self.task = task self.action_count = 0
def __init__(self): """ Create a tuple for each tile containing the following properties: 0: tile data, 1: name """ self.backpack = Backpack() try: # Load the saved map from disk self.game_map = np.loadtxt('map.txt', dtype=int) except OSError: # Map does not exist, create a new one self.game_map = np.ones(shape=(82, 240), dtype="int") self.game_map[:, 0:166] = self.TILES.INACCESSIBLE.value self.game_map[:, -10:-1] = self.TILES.INACCESSIBLE.value self.game_map[0, :] = self.TILES.INACCESSIBLE.value self.game_map[-10:-1, :] = self.TILES.INACCESSIBLE.value # Initialize the player position self.player_position = (0, 0) self.templates = [] # Load all accessible tile templates for tile in [ f for f in os.listdir('./accessible_tiles') if f.endswith('.png') ]: tile_template = cv2.imread('./accessible_tiles/' + tile) tile_template = cv2.cvtColor(tile_template, cv2.COLOR_BGR2GRAY) self.templates.append( [tile_template, 'accessible/' + tile.split('.')[0]]) # Load all inaccessible tile templates for tile in [ f for f in os.listdir('./inaccessible_tiles') if f.endswith('.png') ]: tile_template = cv2.imread('./inaccessible_tiles/' + tile) tile_template = cv2.cvtColor(tile_template, cv2.COLOR_BGR2GRAY) self.templates.append( [tile_template, 'inaccessible/' + tile.split('.')[0]]) # Load all NPC tile templates for tile in [f for f in os.listdir('./npcs') if f.endswith('.png')]: tile_template = cv2.imread('./npcs/' + tile) tile_template = cv2.cvtColor(tile_template, cv2.COLOR_BGR2GRAY) self.templates.append( [tile_template, 'npcs/' + tile.split('.')[0]])
def __init__(self, master=None): # initialize GUI window Frame.__init__(self, master) self.b = Backpack() self.lost = False self.lives = IntVar() self.lives.set(5) self.itemCount = StringVar() self.itemCount.set("Backpack (0/" + str(self.b.itemLimit) + ")") self.caption = StringVar() self.currentLocation = ("misc\\title.png", "A strange, desolate, world.") self.caption.set(self.currentLocation[1]) self.grid() self.pack_propagate(0) self.createWidgets()
def __init__(self, name=None, backpack=Backpack(), gold=0, current_health=100, max_health=100, current_coordinate=0, damage=10, armor=10): self.name = name self.backpack = backpack self.gold = gold self.current_health = current_health self.max_health = max_health self.current_coordinate = current_coordinate self.damage = damage self.armor = armor print(f'Creating new player named: {name}')
def main(): # inicializacia hry context = GameContext() context.init_game() context.backpack = Backpack(2) context.backpack.add_item(Whip()) context.world = world commands = [ About(), LookAround(), Inventory(), Quit(), North(), South(), East(), West(), Down(), # Up(), UseItem(), DropItem(), TakeItem(), ExamineItem(), Save() ] commands.append(Commands(commands)) commands.append(Help(commands)) parser = Parser(commands) print("Indiana Jones") context.get_current_room().show() while context.state == 'playing': line = input('> ') try: command = parser.parse(line) command.exec(context) except UnknownCommandException: print('Taký príkaz nepoznám.')
def __init__(self, screen: Surface, map_: str, heroes: int, monsters: int, items: int): """ Создаёт игру :param heroes: колличество героев в игре. Если players_count=0, то создаст читера. """ self.start_time = datetime.now() self.screen = screen # map self.map: Map = self._init_map(map_) # карта self.maps: Group = Group(self.map) # sprites self.characters: Group = Group() # спрайты с героями и монстрами self.heroes: Group = self._init_heroes(heroes) # спрайты с героями self.monsters: Group = self._init_monsters( monsters) # спрайты с монстрами self.items: Group = self._init_items(items) # спрайты с вещами self._start_turn() self.dashboard = Dashboard(self) # приборная панель self.backpack: Backpack = Backpack(self) # рюкзак self.controls: Controls = Controls(self) # help self.monsters_killed = 0
def __init__(self, killed_enemies=0, gamer_type=''): self._killed_enemies = killed_enemies self._backpack = Backpack() self.power = 0 self._gamer_type = gamer_type self._health = random.randint(1, 10)
def get_backpack(self): backpack = Backpack() return backpack
def __init__(self,filename): self.text = self.load_game_test(filename) self.backpack = Backpack() self.starting_text()
def main(): Backpack(from_file=True) BBackpack(from_file=True)
|___| |___|||| |___| |___| |___| | O | O | | | | \ \n\ ||| |___|___| | |__| ) \n\ ___________|||______________________________|______________/ \n\ ||| /-------- \n\ -----------'''---------------------------------------'") else: slow( colored.red( 'You had heard half-hundred gunshots. Everything went dark.'), 1) sys.exit() time.sleep(5) sys.exit() backpack = Backpack() health = 150 current_room = kolegium try: winsound.PlaySound('retro.wav', winsound.SND_ASYNC) except: import os os.system('aplay retro.wav&') #Linux print( colored.red("\n \ \t\t\t _____ _ _ __ __ _ _ \n \ \t\t\t | __ \ | | | | | \/ (_) (_) \n \ \t\t\t | |__) |___| |__ ___| | | \ / |_ ___ ___ _ ___ _ __ ___ \n \ \t\t\t | _ // _ \ '_ \ / _ \ | | |\/| | / __/ __| |/ _ \| '_ \/ __| \n \ \t\t\t | | \ \ __/ |_) | __/ | | | | | \__ \__ \ | (_) | | | \__ \ \n \ \t\t\t |_| \_\___|_.__/ \___|_| |_| |_|_|___/___/_|\___/|_| |_|___/ \n\n\n\n "
from backpack import Backpack from supp.menu import menu # Deklaracja plecaka i jego pojemności backpack = Backpack(15) # Odpalenie menu menu(backpack)
def set_backpack(self) -> int: self._backpack = Backpack().get_backpack()
def __init__(self, game_map, move): self.user_interface = UserInterface() self.backpack = Backpack() self.move = move self.game_map = game_map
def __init__(self, name: str, health: int=10, damage: int=1, location: Room=None): """ Constructor """ super().__init__(name, health, damage) self._location = location self._backpack = Backpack() self._equipped_item = None
bridge.set_character(jill) shed.set_character(jack) drawing_room.set_character(jim) general_store.set_character(gaylord) ballroom.set_item(cheese) dinning_hall.set_item(book) kitchen.set_item(apple_pie) games_room.set_item(breadstick) drawing_room.set_item(duster) # Special Command Items path_pick.set_item(flower) herb_garden_pick.set_item(herb) backpack = Backpack(15.0) # Number determines backpack capacity current_room = kitchen dead = False hugs = 0 fights = 0 favours = 0 print('Welcome to a little adventure') print('Enter the direction you want to move in or help to see what else I can do') while not dead: print("\n") current_room.get_details() inhabitant = current_room.get_character()
def __init__(self): self.wallet = Wallet() self.backpack = Backpack() self.wallet.fill_wallet()
from backpack import Backpack mybackpack = Backpack("Tom", "Green", 10)