def __init__(self, session): self.xmlfile = "tutorialwizard.xml" Wizard.__init__(self, session, showSteps=False, showStepSlider=False, showList=True, showConfig=False) self["rc"] = MovingPixmap() self["arrowdown"] = MovingPixmap() self["arrowup"] = MovingPixmap() self["arrowup2"] = MovingPixmap()
def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True, showMulticontentList = False): Wizard.__init__(self, session, showSteps, showStepSlider, showList, showConfig, showMulticontentList) self.__updateCallbacks = [] self["languagetext"] = Label() self.updateLanguageDescription()
def __init__(self, session, showSteps=True, showStepSlider=True, showList=True, showConfig=True): Wizard.__init__(self, session, showSteps, showStepSlider, showList, showConfig) self["languagetext"] = Label(_("Change Language"))
def __init__(self, session, showSteps=True, showStepSlider=True, showList=True, showConfig=True): Wizard.__init__(self, session, showSteps, showStepSlider, showList, showConfig) self["languagetext"] = Label() self.updateLanguageDescription()
def __init__(self, session, showSteps=True, showStepSlider=True, showList=True, showConfig=True): Wizard.__init__(self, session, showSteps, showStepSlider, showList, showConfig) self['languagetext'] = Label() self.LanguageWizardCallback()
def guess(self, question, possibleAnswers): ''' Determine the correct answer to this question. The 0th Possible Answer should be the true correct one. ''' print "Question: " + question self.totalQuestions += 1 finalAnswer = Wizard(question, possibleAnswers).guess() print "All Results:" for prob in finalAnswer.probabilities: print prob success = "" if possibleAnswers[0] == finalAnswer.getValue(): self.correctAnswers += 1 success = "Right!" else: success = "WRONG!" print 'guess: %s, correct answer: %s, Wizard is %s\n' % (finalAnswer.getValue(), possibleAnswers[0], success)
Creature('Alligator', 5), Creature('Bear', 20), Creature('Toad', 1), Creature('Alligator', 5), Creature('Bear', 20), Creature('Habahabahaba', 200), Creature('Chujemuje', 123), Creature('Toad', 1), Creature('Alligator', 5), Creature('Bear', 20), Creature('Toad', 1), Creature('Alligator', 5), Creature('Bear', 20), Creature('Habahabahaba', 200), Creature('Chujemuje', 123), Wizard('Grześ', 1500), ] def get_enemies(): global enemies return enemies def get_enemy(): enemies = get_enemies() index = random.randrange(0, len(enemies)) return enemies[index] def print_all():
#Load backgrounds town = pygame.image.load("images/town.png").convert_alpha(); forest = pygame.image.load("images/forest.jpg").convert_alpha(); castle = pygame.image.load("images/castle.jpeg").convert_alpha(); dungeon = pygame.image.load("images/dungeon.jpeg").convert_alpha(); backgroundWin = pygame.image.load("images/win.png").convert_alpha(); backgroundLose = pygame.image.load("images/lose.png").convert_alpha(); #Set window title and font pygame.display.set_caption('Dungeon Delver (version 1.2)') font = pygame.font.SysFont(None, 36) #Load characters knight = Knight() wizard = Wizard() character = knight choice = ("no class chosen") #Load enemies and key off-screen enemy = Enemy(2000, 2000) enemy2 = Enemy2(2000, 2000) enemy3 = Enemy3(2000, 2000) key = Key(2000, 2000) #Create groups enemy_group = pygame.sprite.Group() enemy_group.add(enemy) enemy_group.add(enemy2) enemy_group.add(enemy3)
def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True): Wizard.__init__(self, session, showSteps, showStepSlider, showList, showConfig) self['languagetext'] = Label() self.LanguageWizardCallback()
def start_game_loop(): hero = Wizard('Wololo') while True and enemies_list.get_enemies(): enemy = enemies_list.get_enemy() print('The wizard {} has level {}'.format(hero.get_name(), hero.get_level())) print('The wizard {} sees a {}, level {}.'.format( hero.get_name(), enemy.get_name(), enemy.get_level()), end='\n\n') user_command = str.strip( input('Do you [a]ttack, [r]un away or [l]ook around? ')) if user_command.lower() == 'a': hero_wins = hero.attack(enemy) if (hero_wins): hero.gain_level(enemy.get_level()) enemies_list.delete_enemy(enemy) print('The wizard {} has been triuphant over {}'.format( hero.get_name(), enemy.get_name()), end='\n\n') else: print('The wizard {} lost and had to hide to regain energy'. format(hero.get_name()), end='\n\n') hero.reduce_level(enemy.level) hero.hide() elif user_command.lower() == 'r': print('The wizard {} ran away'.format(hero.get_name())) elif user_command.lower() == 'l': enemies_list.print_all() else: break
class GuiManager(object): """ Main class, loads the gui and handles all events. """ def __init__(self): """ Creates the main window. """ # Attributes self.avaliable_modes = [] self.current_show = None self.current_season = None is_first_time = not os.path.exists(CONFIG_FILE) self.config = Config.get() # API try: self.api = getattr(Hosts, self.config.get_key("site")).api except Exception, error: self.api = Hosts.AVALIABLE_APIS[0] self.marks = SList(MARKS_FILE) self.favorites = SList(FAVORITES_FILE) self.accounts = ACCOUNTS self.settings_dialog = SettingsDialog(self) # Gtk builder self.builder = gtk.Builder() self.builder.add_from_file(MAIN_GUI_FILE) self.builder.connect_signals(self) # Getting the used widgets glade_objects = [ "main_window", "statusbar_label", "progress_box", "progress", "progress_label", "name_filter", "name_filter_clear", "name_list", "name_list_model", "file_viewer", "file_viewer_model", "mode_combo", "mode_liststore", "site_combo", "search_button", "search_clear", "search_entry", "search_hbox", "sidebar", "sidebar_vbox", "path_label", "info_window", "info_title", "info_label", "info_image", "file_viewer_menu", "error_label", "error_dialog", "header_hbox", "main_hpaned", "about_dialog", "site_liststore", ] for glade_object in glade_objects: setattr(self, glade_object, self.builder.get_object(glade_object)) # Set up the filter for the show list self.name_list_model_filter = self.name_list_model.filter_new() self.name_list_model_filter.set_visible_func( generic_visible_func, (self.name_filter, NAME_LIST_COLUMN_TEXT)) self.name_list.set_model(self.name_list_model_filter) # Get last mode, needs to be before the filling combo functions last_mode = self.config.get_key("last_mode") # Fill combobox self.fill_sites_combobox() self.fill_mode_combobox() # Set last window position and size last_x, last_y = self.config.get_key("last_window_pos") last_width, last_height = self.config.get_key("last_window_size") self.main_window.move(last_x, last_y) self.main_window.resize(last_width, last_height) # Now we show the window self.main_window.show_all() # Start on last mode try: self.mode_combo.set_active(self.avaliable_modes.index(last_mode)) except: self.set_mode_shows() # Login self.background_task(self.login_accounts, freeze=False) if is_first_time: wizard = Wizard(self.main_window) wizard.show()
from Hero import Hero from Battle import Battle from Goblin import Goblin from Store import Store from Wizard import Wizard from Spider import Spider from Snake import Snake from Medic import Medic from Shadow import Shadow from Zombie import Zombie if __name__ == "__main__": hero = Hero() enemies = [ Goblin(), Wizard(), Medic(), Shadow(), Zombie(), Spider(), Snake() ] battle_engine = Battle() shopping_engine = Store() for enemy in enemies: hero_won = battle_engine.do_battle(hero, enemy) if not hero_won: print("YOU LOSE!") exit(0) shopping_engine.do_shopping(hero)
labyrinth.add_node('E') labyrinth.add_node('F') # Add edges labyrinth.add_edge('A', 'B') labyrinth.add_edge('C', 'B') labyrinth.add_edge('D', 'B') labyrinth.add_edge('D', 'E') labyrinth.add_edge('E', 'C') labyrinth.add_edge('D', 'F') labyrinth.add_edge('E', 'F') # Set the labyrinth exit labyrinth.set_exit_point('F') labyrinth.add_wizard(Wizard('Harry Potter', 'A')) labyrinth.add_wizard(Wizard('Lord Voldemort', 'C')) print labyrinth # Engine res = "---------------------------\n" res += "------ THE LABYRINTH ------\n" res += "---------------------------\n\n" wizards = labyrinth.wizards game_time = max(w.time for w in wizards) for minute in xrange(1, game_time + 1):
def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True): Wizard.__init__(self, session, showSteps, showStepSlider, showList, showConfig) self["languagetext"] = Label(_("Change Language"))
char = Beginner(nickname) bot = Dragon("Dragon") print(f'Your name is: {char.GetUserName()}') print(f'Dragon name is: {bot.GetUserName()}') rank_type = str(char.__class__.__name__) while (char.GetHp() > 0 and bot.GetHp() > 0): turn_a = randint(0, 2) turn_b = randint(0, 4) if (char.GetHp() > 0 and bot.GetHp() > 0): if (wins > 1): rank = (input("Choose a rank\n[1]Knight\n[2]Wizard\n[3]Elf\n")) if rank =="1": char = Knight(nickname) elif rank == "2": char = Wizard(nickname) elif rank == "3": char = Elf(nickname) elif rank == "4": char = Beginner(nickname) else: char = Beginner(nickname) while (char.GetHp() > 0 and bot.GetHp() > 0): turn_a = randint(0, 4) turn_b = randint(0, 4) if (char.GetHp() > 0 and bot.GetHp() > 0): while (turn_a > 0): if (turn_a != 0): try:
g1nick = input("(G1) What`s your nickname?\n>") g2nick = input("(G2) What`s your nickname?\n>") g1class = int(input("(G1) Please choose a class: (1.Elf 2.Knight 3.Wizard\n")) g2class = int(input("(G2) Please choose a class: (1.Elf 2.Knight 3.Wizard\n")) g1 = Beginner(g1nick) g2 = Beginner(g2nick) if g1class == 1: g1 = Elf(g1nick) elif g1class == 2: g1 = Knight(g1nick) elif g1class == 3: g1 = Wizard(g1nick) if g2class == 1: g2 = Elf(g2nick) elif g2class == 2: g2 = Knight(g2nick) elif g2class == 3: g2 = Wizard(g2nick) mind_1 = g1.__class__.__name__ mind_2 = g2.__class__.__name__ print(f'(G1) selected {mind_1}') print(f'(G2) selected {mind_2}') g1_wins = 0 g2_wins = 0
labyrinth.add_edge('Y', 'D', 20) labyrinth.add_edge('E', 'D', 10) labyrinth.add_edge('H', 'D', 5) labyrinth.add_edge('H', 'E', 5) labyrinth.add_edge('H', 'F', 10) labyrinth.add_edge('Y', 'J', 20) labyrinth.add_edge('J', 'I', 30) labyrinth.add_edge('G', 'I', 5) # 3 - Set the labyrinth exit labyrinth.set_exit_point('G') # 4 - Add wizards #labyrinth.add_wizard(Wizard('Harry Potter', 'G')) labyrinth.add_wizard(Wizard('Ron Weasley', 'C')) labyrinth.add_wizard(Wizard('Draco Malfoy', 'E')) # 5 - Haunted the Labyrinth evilPlan = labyrinth.haunt() # Engine printing game = "---------------------------\n" game += "------ THE LABYRINTH ------\n" game += "---------------------------\n\n" wizards = labyrinth.wizards game_time = max(w.time for w in wizards) for minute in xrange(1, game_time + 1):
def make_character(self): return Wizard(self.player_name)
from Wizard import Wizard if __name__ == "__main__": wizard = Wizard(3, 3) wizard.game() print("GAME OVER ") ''' Current turn is 3 Trump is d Player 1 Hand [(1, 's'), (9, 'h'), (7, 's')] Enter your bid: 1 Trump is d Player 2 Hand [(4, 'h'), (14, 'h'), (3, 'h')] Enter your bid: 1 Trump is d Player 3 Hand [(10, 'h'), (7, 'd'), (2, 'd')] Enter your bid: 0 Trump is d Current leading card is none [(1, 's'), (9, 'h'), (7, 's')] Choose a card to play, Player 1 1 Trump is d Current leading card is (9, 'h') [(4, 'h'), (14, 'h'), (3, 'h')]
def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True): Wizard.__init__(self, session, showSteps, showStepSlider, showList, showConfig) self["languagetext"] = Label() self.updateLanguageDescription()