def update_inventory(self, Apple_amt, Bread_amt, Water_amt): self.inventory = [ items.Apple(Apple_amt), items.Bread(Bread_amt), items.Water(Water_amt), items.Sword() ]
def __init__(self, x, y): """Initial supplies at the tile""" # index for switching descriptive messagages self.i = 0 self.name = "Supplies" self.inventory = [items.Blaster(), items.OxygenTank(), items.SpaceSuit(), items.FirstAid(), items.CrustyBread(), items.Water(), items.Shelter()] super().__init__(x, y)
def reset_stats(self): self.inventory = [ items.Apple(5), items.Bread(2), items.Water(3), items.Sword() ] self.hp = 100 self.stamina = 50 self.glory = 0 self.glory_statement = "=======================\nYou failed. History will forget you"
def __init__(self, x, y): self.i = 0 self.name = "Eau,Nourriture;Oxygene" self.inventory = [ items.Blaster(), items.OxygenTank(), items.SpaceSuit(), items.FirstAid(), items.CrustyBread(), items.Water(), items.Shelter() ] super().__init__(x, y)
def __init__(self): self.inventory = [ items.RayGun(), items.Water(), items.Food(), items.Bandage(), items.HealingPotion() ] #items you start with self.x = 4 #start player at x =4 and y = 4 self.y = 4 self.hp = 100 #max hp self.gold = 5 #gold you start with self.spacesuit = 0 #need to pick up the spacesuit and flashlight, start with none self.flashlight = 0 self.victory = False #victory only true on victory tile
def __init__(self, root): self.game = Game() # Create two frames owned by the window root # In order to use multiple layout managers, the frames # cannot share a parent frame. Here both frames are owned # by a top level instance root. super().__init__(master=root) # set up the Gameframe self.gameFrame = tk.Frame(root, width=1025, height=550, bg='WHITE', borderwidth=3) self.gameFrame.grid_propagate(0) # Prevents resizing self.gameFrame.columnconfigure(0, weight=0) self.gameFrame.columnconfigure(1, weight=4) self.gameFrame.columnconfigure(2, weight=0) self.gameFrame.pack_propagate(0) # Prevents resizing self.inventoryVar = tk.StringVar(value=[ 'Your Inventory' ]) # adding variable to hold inventory in gameframe # set up the Navigationframe self.navFrame = tk.Frame(root, width=1025, height=550, bg='GREY', borderwidth=3) self.navFrame.grid_propagate(0) # Prevents resizing # This packs both frames into the root window ... self.gameFrame.pack() self.navFrame.pack() # add buttons to the menubar menubar = tk.Menu() menubar.add_command(label='About', command=self.showAbout) menubar.add_command(label='Account', command=self.showAccount) menubar.add_command(label='Inventory', command=self.showItems) menubar.add_command(label='Hints', command=self.displayHint) menubar.add_command(label='Quit', command=root.destroy) # Account = tk.Menu() # menubar.(label="ChangeText", menu=Account) root.config(menu=menubar) # Now we add images (for NavFrame). These are stored in the images/ folder self.ghsImg = ImageTk.PhotoImage(Image.open('images/greenhouse.png')) self.rsegdnImg = ImageTk.PhotoImage( Image.open('images/rose_garden.png')) self.gdnImg = ImageTk.PhotoImage(Image.open('images/garden.png')) self.fldImg = ImageTk.PhotoImage(Image.open('images/field.png')) self.stallImg = ImageTk.PhotoImage(Image.open('images/farm_stall.png')) self.wkshpImg = ImageTk.PhotoImage(Image.open('images/workshop.png')) self.grgImg = ImageTk.PhotoImage(Image.open('images/garage.png')) self.entImg = ImageTk.PhotoImage(Image.open('images/entrance.png')) self.barnImg = ImageTk.PhotoImage(Image.open('images/barn.png')) self.cknImg = ImageTk.PhotoImage(Image.open('images/chicken_coop.png')) # add a dictionary of buttons to use for available navigation options self.buttons = { 'greenhouse': tk.Button(self.navFrame, image=self.ghsImg, command=lambda: self.location_changed("greenhouse")), 'rose_garden': tk.Button(self.navFrame, image=self.rsegdnImg, command=lambda: self.location_changed("rose_garden")), 'garden': tk.Button(self.navFrame, image=self.gdnImg, command=lambda: self.location_changed("garden")), 'field': tk.Button(self.navFrame, image=self.fldImg, command=lambda: self.location_changed("field")), 'farm_stall': tk.Button(self.navFrame, image=self.stallImg, command=lambda: self.location_changed("farm_stall")), 'workshop': tk.Button(self.navFrame, image=self.wkshpImg, command=lambda: self.location_changed("workshop")), 'garage': tk.Button(self.navFrame, image=self.grgImg, command=lambda: self.location_changed("garage")), 'entrance': tk.Button(self.navFrame, image=self.entImg, command=lambda: self.location_changed("entrance")), 'barn': tk.Button(self.navFrame, image=self.barnImg, command=lambda: self.location_changed("barn")), 'chicken_coop': tk.Button(self.navFrame, image=self.cknImg, command=lambda: self.location_changed("chicken_coop")), } self.buttons['greenhouse'].grid(row=0, column=0) self.buttons['rose_garden'].grid(row=0, column=1) self.buttons['garden'].grid(row=0, column=2) self.buttons['field'].grid(row=0, column=3) self.buttons['farm_stall'].grid(row=0, column=4) self.buttons['workshop'].grid(row=1, column=0) self.buttons['garage'].grid(row=1, column=1) self.buttons['entrance'].grid(row=1, column=2) self.buttons['barn'].grid(row=1, column=3) self.buttons['chicken_coop'].grid(row=1, column=4) # Dictionary of the items to ensure only one instance of the item, copied everywhere. self.items = { "seeds": items.Seeds(), "water": items.Water(), "feed": items.Feed(), "manure": items.Manure(), "wheelbarrow": items.Wheelbarrow(), "eggs": items.Eggs(), "vegetables": items.Vegetables(), "herbs": items.Herbs(), "roses": items.Roses(), "honey": items.Honey(), } # dictionary of images to fetch correct images in a loop for each location. self.collect_images = { "seeds": ImageTk.PhotoImage(Image.open('images/seedpu.png')), "water": ImageTk.PhotoImage(Image.open('images/waterpu.png')), "feed": ImageTk.PhotoImage(Image.open('images/feedpu.png')), "manure": ImageTk.PhotoImage(Image.open('images/manurepu.png')), "wheelbarrow": ImageTk.PhotoImage(Image.open('images/wheelbarrowpu.png')), "eggs": ImageTk.PhotoImage(Image.open('images/eggpu.png')), "vegetables": ImageTk.PhotoImage(Image.open('images/vegpu.png')), "herbs": ImageTk.PhotoImage(Image.open('images/herbpu.png')), "roses": ImageTk.PhotoImage(Image.open('images/rosepu.png')), "honey": ImageTk.PhotoImage(Image.open('images/honeypu.png')), } self.drop_images = { "seeds": ImageTk.PhotoImage(Image.open('images/seedneg.png')), "water": ImageTk.PhotoImage(Image.open('images/waterneg.png')), "feed": ImageTk.PhotoImage(Image.open('images/feedneg.png')), "manure": ImageTk.PhotoImage(Image.open('images/manureneg.png')), "wheelbarrow": ImageTk.PhotoImage(Image.open('images/barrowneg.png')), "eggs": ImageTk.PhotoImage(Image.open('images/eggdrop.png')), "vegetables": ImageTk.PhotoImage(Image.open('images/vegneg.png')), "herbs": ImageTk.PhotoImage(Image.open('images/herbneg.png')), "roses": ImageTk.PhotoImage(Image.open('images/roseneg.png')), "honey": ImageTk.PhotoImage(Image.open('images/honeyneg.png')), } self.display_current_location() self.disable_buttons()