def portal_fairy_behavior(): # That function is our portal fairy controller. # It works a bit like the whale controller: look around for a player, offer a dialog and ultimately open the portal. global g global current_menu global fairy_gold fairy = g.current_board().get_movables(type='fairy') portal = g.current_board().get_immovables(type='portal') if g.player in g.neighbors(1,fairy[0]): if portal[0].model == g.current_board().ui_board_void_cell: # If the player is around the fairy, then we set the menu to the portal fairy dialog current_menu = 'portal_fairy_dialog' # And pause the other NPC to refresh the screen g.pause() # Before refreshing we update the dialog update_fairy_dialog() refresh_screen() # If the player has gold in his inventory we give the possibility to give it to the fairy. money_bags = g.player.inventory.search('Money') # Now we want to get the answer immediately, we don't want that function to return. # Note: This is going to be a problem when we multithread this code. But it's going to be a good exercise. key = Utils.get_key() if key == '1': print(Sprites.FAIRY+' That is too bad, good bye.') current_menu = 'default' refresh_screen() elif key == '2': fairy_gold += money_bags[0].value g.player.inventory.delete_item(money_bags[0].name) elif key == '3': fairy_gold += money_bags[0].value fairy_gold += money_bags[1].value g.player.inventory.delete_item(money_bags[0].name) g.player.inventory.delete_item(money_bags[1].name) elif key == '4': for b in money_bags: fairy_gold += b.value g.player.inventory.delete_item(b.name) update_fairy_dialog() refresh_screen() if fairy_gold >= 300: refresh_screen() print(Sprites.FAIRY+' Great! Thank you!! Now let\'s do some magic.') print(Utils.BLACK_SQUARE+Sprites.CYCLONE+' By my powers, cometh forth dimensional portal'+Sprites.CYCLONE) portal[0].model = Sprites.CYCLONE portal[0].set_overlappable(False) time.sleep(2) current_menu = 'default' refresh_screen() elif fairy_gold < 300 and (key == '1' or key == '2' or key == '3' or key == '4'): print(Sprites.FAIRY+' Thank you, that is a good start but I still don\'t have enough gold to open a portal.') # When we are finished we un-pause the game g.start() else: print(Sprites.FAIRY+' I have already opened the only portal I could in this world!')
def model_picker(): global game while True: game.clear_screen() print("What kind of model do you want (you can edit that later)?\n1 - Colored squares and rectangles\n2 - Sprites\n3 - Set your own string of character(s)") choice = str( Utils.get_key() ) if choice == '1': picked = game.get_menu_entry('graphics_utils',color_picker()) if picked != None: return picked['data'] if choice == '2': picked = game.get_menu_entry('graphics_sprites',sprite_picker()) if picked != None: return picked['data'] if choice == '3': return str( input('Enter your string now: ') )
def model_picker(): global game while True: game.clear_screen() print("What kind of model do you want (you can edit that later)?\n" "1 - Colored squares and rectangles\n" "2 - Sprites\n" "3 - Set your own string of character(s)") choice = str(Utils.get_key()) if choice == "1": picked = game.get_menu_entry("graphics_utils", color_picker()) if picked is not None: return picked["data"] if choice == "2": picked = game.get_menu_entry("graphics_sprites", sprite_picker()) if picked is not None: return picked["data"] if choice == "3": return str(input("Enter your string now: "))
def create_wizard(): global game key = '' while True: game.clear_screen() print(Utils.green_bright("\t\tObject creation wizard")) print('What do you want to create: a NPC or a structure?') print('1 - NPC (Non Playable Character)') print('2 - Structure (Wall, Door, Treasure, Portal, Trees, etc.)') key = Utils.get_key() if key == '1' or key == '2': break if key == '1': game.clear_screen() print( Utils.green_bright("\t\tObject creation wizard: ") + Utils.cyan_bright("NPC")) new_object = NPC() print("First give a name to your NPC. Default value: " + new_object.name) r = str(input('(Enter name)> ')) if len(r) > 0: new_object.name = r print( "Then give it a type. A type is important as it allows grouping.\nType is a string. Default value: " + new_object.type) r = str(input('(Enter type)> ')) if len(r) > 0: new_object.type = r print("Now we need a model. Default value: " + new_object.model) input('Hit "Enter" when you are ready to choose a model.') new_object.model = model_picker() game.clear_screen() print( Utils.green_bright("\t\tObject creation wizard: ") + Utils.cyan_bright("NPC") + f' - {new_object.model}') print( 'We now needs to go through some basic statistics. You can decide to go with default by simply hitting the "Enter" key.' ) r = input_digit( f'Number of cell crossed in one turn. Default: {new_object.step}(type: int) > ' ) if len(r) > 0: new_object.step = int(r) else: # If it's 0 it means it's going to be a static NPC so to prevent python to pass some random pre-initialized default, we explicitly set the Actuator to a static one new_object.actuator = SimpleActuators.RandomActuator(moveset=[]) r = input_digit( f'Max HP (Health Points). Default: {new_object.max_hp}(type: int) > ' ) if len(r) > 0: new_object.max_hp = int(r) new_object.hp = new_object.max_hp r = input_digit( f'Max MP (Mana Points). Default: {new_object.max_mp}(type: int) > ' ) if len(r) > 0: new_object.max_mp = int(r) new_object.mp = new_object.max_mp r = input_digit( f'Remaining lives (it is advised to set that to 1 for a standard NPC). Default: {new_object.remaining_lives}(type: int) > ' ) if len(r) > 0: new_object.remaining_lives = int(r) r = input_digit( f'AP (Attack Power). Default: {new_object.attack_power}(type: int) > ' ) if len(r) > 0: new_object.attack_power = int(r) r = input_digit( f'DP (Defense Power). Default: {new_object.defense_power}(type: int) > ' ) if len(r) > 0: new_object.defense_power = int(r) r = input_digit( f'Strength. Default: {new_object.strength}(type: int) > ') if len(r) > 0: new_object.strength = int(r) r = input_digit( f'Intelligence. Default: {new_object.intelligence}(type: int) > ') if len(r) > 0: new_object.intelligence = int(r) r = input_digit( f'Agility. Default: {new_object.agility}(type: int) > ') if len(r) > 0: new_object.agility = int(r) game.clear_screen() print( "We now need to give some life to that NPC. What kind of movement should it have:" ) print("1 - Randomly chosen from a preset of directions") print("2 - Following a predetermined path") r = Utils.get_key() if r == '1': new_object.actuator = SimpleActuators.RandomActuator(moveset=[]) print( 'Random it is! Now choose from which preset of movements should we give it:' ) print('1 - UP,DOWN,LEFT, RIGHT') print('2 - UP,DOWN') print('3 - LEFT, RIGHT') print('4 - UP,DOWN,LEFT, RIGHT + all DIAGONALES') print( '5 - DIAGONALES (DIAG UP LEFT, DIAG UP RIGHT, etc.) but NO straight UP, DOWN, LEFT and RIGHT' ) print('6 - No movement') r = Utils.get_key() if r == '1': new_object.actuator.moveset = [ Constants.UP, Constants.DOWN, Constants.LEFT, Constants.RIGHT ] elif r == '2': new_object.actuator.moveset = [Constants.UP, Constants.DOWN] elif r == '3': new_object.actuator.moveset = [Constants.RIGHT, Constants.LEFT] elif r == '4': new_object.actuator.moveset = [ Constants.UP, Constants.DOWN, Constants.LEFT, Constants.RIGHT, Constants.DLDOWN, Constants.DLUP, Constants.DRDOWN, Constants.DRUP ] elif r == '5': new_object.actuator.moveset = [ Constants.DLDOWN, Constants.DLUP, Constants.DRDOWN, Constants.DRUP ] elif r == '6': new_object.actuator.moveset = [] else: Utils.warn( f'"{r}" is not a valid choice. Movement set is now empty.') new_object.actuator.moveset = [] elif r == '2': new_object.actuator = SimpleActuators.PathActuator(path=[]) print("Great, so what path this NPC should take:") print('1 - UP/DOWN patrol') print('2 - DOWN/UP patrol') print('3 - LEFT/RIGHT patrol') print('4 - RIGHT/LEFT patrol') print('5 - Circle patrol: LEFT, DOWN, RIGHT, UP') print('6 - Circle patrol: LEFT, UP, RIGHT, DOWN') print('7 - Circle patrol: RIGHT, DOWN, LEFT, UP') print('8 - Circle patrol: RIGHT, UP, LEFT, DOWN') print('9 - Write your own path') r = Utils.get_key() if r == '1': print( "How many steps should the NPC go in one direction before turning back ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] elif r == '2': print( "How many steps should the NPC go in one direction before turning back ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == '3': print( "How many steps should the NPC go in one direction before turning back ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] elif r == '3': print( "How many steps should the NPC go in one direction before turning back ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] elif r == '4': print( "How many steps should the NPC go in one direction before turning back ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == '5': print( "How many steps should the NPC go in EACH direction before changing ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == '6': print( "How many steps should the NPC go in EACH direction before changing ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] elif r == '7': print( "How many steps should the NPC go in EACH direction before changing ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == '8': print( "How many steps should the NPC go in EACH direction before changing ?" ) r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] elif r == '9': print( "Write your own path using only words from this list: UP, DOWN, LEFT, RIGHT, DLDOWN, DLUP, DRDOWN, DRUP." ) print('Each direction has to be separated by a coma.') r = str(input('Write your path: ')).upper() new_object.actuator.path = r.split(',') else: Utils.warn(f'"{r}" is not a valid choice. Path is now empty.') new_object.actuator.path = [] return new_object elif key == '2': while True: game.clear_screen() print( Utils.green_bright("\t\tObject creation wizard: ") + Utils.magenta_bright("Structure")) print("What kind of structure do you want to create:") print( '1 - A wall like structure (an object that cannot be picked-up and is not overlappable). Ex: walls, trees, non moving elephant (try to go through an elephant or to pick it up in your backpack...)' ) print('2 - A door (player and/or NPC can go through)') print( '3 - A treasure (can be picked up, take space in the inventory, give points to the player)' ) print( '4 - A generic object (you can set the properties to make it pickable or overlappable)' ) print( '5 - A generic actionable object (to make portals, heart to replenish life, etc.)' ) key = Utils.get_key() new_object = None if key == '1': new_object = Structures.Wall() new_object.name = str(uuid.uuid1()) new_object.model = model_picker() break elif key == '2': new_object = Structures.Door() new_object.name = str(uuid.uuid1()) new_object.model = model_picker() break elif key == '3': new_object = Structures.Treasure() print("First give a name to your Treasure. Default value: " + new_object.name) r = str(input('(Enter name)> ')) if len(r) > 0: new_object.name = r print( "Then give it a type. A type is important as it allows grouping (in this case probably in the inventory).\nType is a string. Default value: " + new_object.type) r = str(input('(Enter type)> ')) if len(r) > 0: new_object.type = r print("Now we need a model. Default value: " + new_object.model) input('Hit "Enter" when you are ready to choose a model.') new_object.model = model_picker() break elif key == '4' or key == '5': if key == '4': new_object = Structures.GenericStructure() else: new_object = Structures.GenericActionableStructure() new_object.set_overlappable(False) new_object.set_pickable(False) print("First give a name to your structure. Default value: " + new_object.name) r = str(input('(Enter name)> ')) if len(r) > 0: new_object.name = r print( "Then give it a type. \nType is a string. Default value: " + new_object.type) r = str(input('(Enter type)> ')) if len(r) > 0: new_object.type = r print("Now we need a model. Default value: " + new_object.model) input('Hit "Enter" when you are ready to choose a model.') new_object.model = model_picker() print( 'Is this object pickable? (can it be picked up by the player)?' ) print('0 - No') print('1 - Yes') r = Utils.get_key() if r == '1': new_object.set_pickable(True) print( 'Is this object overlappable? (can it be walked over by player?' ) print('0 - No') print('1 - Yes') r = Utils.get_key() if r == '1': new_object.set_overlappable(True) break return new_object #Placeholder return BoardItemVoid()
if edit_mode: print(Utils.green_bright("EDIT"), end='') else: print(Utils.red_bright('DELETE'), end='') print( f' | Board: {game.current_board().name} - {game.current_board().size} | Cursor @ {game.player.pos}' ) game.display_board() if len(object_history) > 10: del (object_history[0]) if current_menu == 'main': print('Item history:') cnt = 0 for o in object_history: print(f"{cnt}: {o.model}", end=' ') cnt += 1 print('') print(f'Current item: {current_object.model}') if not (current_menu == 'main' and menu_mode == 'hidden'): game.display_menu(current_menu, Constants.ORIENTATION_VERTICAL, 15) for m in dbg_messages: Utils.debug(m) for m in info_messages: Utils.info(m) for m in warn_messages: Utils.warn(m) if current_menu == 'boards_list': key = input('Enter your choice (and hit ENTER): ') else: key = Utils.get_key()
print(Utils.green('OK')) except FileNotFoundError as e: print(Utils.red('KO')) if len(hmaps) > 0: map_num = 0 game.add_menu_entry('boards_list',None,"Choose a map to edit") for m in hmaps: print(f"{map_num} - edit hac-maps/{m}") game.add_menu_entry('boards_list',str(map_num),f"edit hac-maps/{m}",f"hac-maps/{m}") map_num += 1 else: print("No pre-existing map found.") print("n - create a new map") print("q - Quit the editor") choice = str( Utils.get_key() ) if choice == "q": print("Good Bye!") exit() elif choice == "n": create_board_wizard() break elif choice.isdigit() and int(choice) < len(hmaps): game.load_board('hac-maps/'+hmaps[int(choice)],1) break game.change_level(1) if len(game.object_library)>0: object_history += game.object_library
def title_screen(g): global logo, current_state, term_res menu_index = 0 key = None while current_state == "title": g.clear_screen() for logo_line in logo: print(logo_line, end="\r") print("\r") print( Utils.blue(f"{' '*int(term_res/2-10)}Welcome {g.player.name}!\r")) for i in range(0, len(title_screen_menu)): if i == menu_index: print( Utils.green_bright( f"{' '*int(term_res/2-10)}{menu_indicator_left}" f"{title_screen_menu[i]}{menu_indicator_right}\r")) else: print(f" {' '*int(term_res/2-10)}{title_screen_menu[i]}\r") key = Utils.get_key() if key == Utils.key.DOWN: menu_index += 1 if menu_index >= len(title_screen_menu): menu_index = 0 elif key == Utils.key.UP: menu_index -= 1 if menu_index < 0: menu_index = len(title_screen_menu) - 1 elif key == Utils.key.ENTER: if menu_index == 0: g.clear_screen() print(term.bold_underline_green("How to play")) print( "\nThe arrow " + term.bold_underline("(\u2190/\u2191/\u2193/\u2192)") + " keys move the panda.\n\n" + "The " + term.bold_underline("p") + " key, pause the game.\n\n" "The " + term.bold_underline("space") + " key is for jump. You can move while jumping.\n\n" + term.bold_underline("w(z)/a(q)/s/d") + " keys are for shooting seeds that sprouts trees.\n" " Sprouted trees can be used as platforms but:\n" " - You can only have 2 trees at the same time.\n" " - Shooting a seed cost you 3 secondes of time!\n" "\nRunning forward earn you some time (depending on difficulty).\n" "\nYour goal is to reach the end of a level as quickly as " "possible without falling into radioactive wastes.\n" "If you do fall into the radioactive wastes, the game will revive " "you up the nearest safe platform. You can move during that time.\n" "It is up to you to try your luck and trick the game or respawn " "safely. You have 3 lives to complete your run.\n" "\nAt the end of a level look for the portal to the next level. " "It looks like a cyclone: " + Graphics.Sprites.CYCLONE + "\n" "\nTo increase your score, just move forward! The higher the level" " the higher the score. Difficulty also inscrease as you earn less" " time.\n" "\nOh... there's also treasures that gives you time and/or points " "and traps that takes times or score (or your life...)\n" "\n\nGOOD LUCK PANDA!!\n\n" + Graphics.Sprites.WARNING + " This game relies on emojis for its " "user interface. If you don't see a panda face between the " "parenthesis (" + Graphics.Sprites.PANDA + "), it means that your terminal fonts do NOT support " "emojis. This game won't display correctly. Try other fonts.\n\n" ) input("Press ENTER when done reading.") elif menu_index == 1: current_state = "game" # We need to start over so back to level 1 g.current_level = 0 # Let's make sure the player is correctly placed by the engine g.player.pos = [None, None] # And lives, score and timer are reset g.timer = 60 g.score = 0 g.player.remaining_lives = 3 # Then reset the player model in case he died g.player.model = (bg_color + Graphics.Sprites.PANDA + Graphics.Style.RESET_ALL) g.clear_screen() change_level([g]) elif menu_index == 2: g.clear_screen() print( Utils.blue(f"{' '*int(term_res/2-10)}" + term.bold_underline("Hall of fame") + "\r")) ranking = 1 for el in sorted(g.config("settings")["hiscores"], reverse=True, key=lambda x: x[1]): extra = "" if ranking == 1: extra = Graphics.Sprites.FIRST_PLACE_MEDAL elif ranking == 2: extra = Graphics.Sprites.SECOND_PLACE_MEDAL elif ranking == 3: extra = Graphics.Sprites.THIRD_PLACE_MEDAL print(f"{' '*int(term_res/2-10)}{el[0]} : {el[1]} {extra}") ranking += 1 input("\n\nHit the ENTER key to return to the main menu.\n") elif menu_index == 3: # Switch resolution if term_res == 80: term_res = 140 else: term_res = 80 load_logo() g.partial_display_viewport = [10, int(term_res / 4)] elif menu_index == 4: g.player.name = input( "\n\nPlease enter your name (it will be used for high scores)> " ) g.config("settings")["player_name"] = g.player.name elif menu_index == (len(title_screen_menu) - 1): # Quit current_state = "eop"
def create_wizard(): global game key = "" while True: game.clear_screen() print(Utils.green_bright("\t\tObject creation wizard")) print("What do you want to create: a NPC or a structure?") print("1 - NPC (Non Playable Character)") print("2 - Structure (Wall, Door, Treasure, Portal, Trees, etc.)") key = Utils.get_key() if key == "1" or key == "2": break if key == "1": game.clear_screen() print( Utils.green_bright("\t\tObject creation wizard: ") + Utils.cyan_bright("NPC")) new_object = NPC() print("First give a name to your NPC. Default value: " + new_object.name) r = str(input("(Enter name)> ")) if len(r) > 0: new_object.name = r print( "Then give it a type. A type is important as it allows grouping.\n" "Type is a string. Default value: " + new_object.type) r = str(input("(Enter type)> ")) if len(r) > 0: new_object.type = r print("Now we need a model. Default value: " + new_object.model) input('Hit "Enter" when you are ready to choose a model.') new_object.model = model_picker() game.clear_screen() print( Utils.green_bright("\t\tObject creation wizard: ") + Utils.cyan_bright("NPC") + f" - {new_object.model}") print("We now needs to go through some basic statistics. " "You can decide to go with default by simply hitting " 'the "Enter" key.') r = input_digit(f"Number of cell crossed in one turn. " f"Default: {new_object.step}(type: int) > ") if len(r) > 0: new_object.step = int(r) else: # If it's 0 it means it's going to be a static NPC so to prevent # python to pass some random pre-initialized default, we explicitly # set the Actuator to a static one new_object.actuator = SimpleActuators.RandomActuator(moveset=[]) r = input_digit(f"Max HP (Health Points). " f"Default: {new_object.max_hp}(type: int) > ") if len(r) > 0: new_object.max_hp = int(r) new_object.hp = new_object.max_hp r = input_digit(f"Max MP (Mana Points). " f"Default: {new_object.max_mp}(type: int) > ") if len(r) > 0: new_object.max_mp = int(r) new_object.mp = new_object.max_mp r = input_digit( f"Remaining lives (it is advised to set that to 1 for a " f"standard NPC). " f"Default: {new_object.remaining_lives}(type: int) > ") if len(r) > 0: new_object.remaining_lives = int(r) r = input_digit(f"AP (Attack Power). " f"Default: {new_object.attack_power}(type: int) > ") if len(r) > 0: new_object.attack_power = int(r) r = input_digit(f"DP (Defense Power). " f"Default: {new_object.defense_power}(type: int) > ") if len(r) > 0: new_object.defense_power = int(r) r = input_digit( f"Strength. Default: {new_object.strength}(type: int) > ") if len(r) > 0: new_object.strength = int(r) r = input_digit( f"Intelligence. Default: {new_object.intelligence}(type: int) > ") if len(r) > 0: new_object.intelligence = int(r) r = input_digit( f"Agility. Default: {new_object.agility}(type: int) > ") if len(r) > 0: new_object.agility = int(r) game.clear_screen() print("We now need to give some life to that NPC. " "What kind of movement should it have:") print("1 - Randomly chosen from a preset of directions") print("2 - Following a predetermined path") print("3 - Following a predetermined path back and forth") print( "4 - Automatically finding it's way from one point to another (no" " pre-determined path, you will set the points on the map).") r = Utils.get_key() if r == "1": new_object.actuator = SimpleActuators.RandomActuator(moveset=[]) print("Random it is! Now choose from which preset " "of movements should we give it:") print("1 - UP,DOWN,LEFT, RIGHT") print("2 - UP,DOWN") print("3 - LEFT, RIGHT") print("4 - UP,DOWN,LEFT, RIGHT + all DIAGONALES") print("5 - DIAGONALES (DIAG UP LEFT, DIAG UP RIGHT, etc.) " "but NO straight UP, DOWN, LEFT and RIGHT") print("6 - No movement") r = Utils.get_key() if r == "1": new_object.actuator.moveset = [ Constants.UP, Constants.DOWN, Constants.LEFT, Constants.RIGHT, ] elif r == "2": new_object.actuator.moveset = [Constants.UP, Constants.DOWN] elif r == "3": new_object.actuator.moveset = [Constants.RIGHT, Constants.LEFT] elif r == "4": new_object.actuator.moveset = [ Constants.UP, Constants.DOWN, Constants.LEFT, Constants.RIGHT, Constants.DLDOWN, Constants.DLUP, Constants.DRDOWN, Constants.DRUP, ] elif r == "5": new_object.actuator.moveset = [ Constants.DLDOWN, Constants.DLUP, Constants.DRDOWN, Constants.DRUP, ] elif r == "6": new_object.actuator.moveset = [] else: Utils.warn( f'"{r}" is not a valid choice. Movement set is now empty.') new_object.actuator.moveset = [] elif r == "2" or r == "3": if r == "2": new_object.actuator = SimpleActuators.PathActuator(path=[]) elif r == "3": new_object.actuator = SimpleActuators.PatrolActuator(path=[]) print("Great, so what path this NPC should take:") print("1 - UP/DOWN patrol") print("2 - DOWN/UP patrol") print("3 - LEFT/RIGHT patrol") print("4 - RIGHT/LEFT patrol") print("5 - Circle patrol: LEFT, DOWN, RIGHT, UP") print("6 - Circle patrol: LEFT, UP, RIGHT, DOWN") print("7 - Circle patrol: RIGHT, DOWN, LEFT, UP") print("8 - Circle patrol: RIGHT, UP, LEFT, DOWN") print("9 - Write your own path") r = Utils.get_key() if r == "1": print("How many steps should the NPC go in one direction " "before turning back ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += ([ Constants.UP for i in range(0, r, 1) ], ) new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] elif r == "2": print("How many steps should the NPC go in one " "direction before turning back ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == "3": print("How many steps should the NPC go in one " "direction before turning back ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] elif r == "3": print("How many steps should the NPC go in one direction " "before turning back ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] elif r == "4": print("How many steps should the NPC go in one " "direction before turning back ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == "5": print("How many steps should the NPC go in EACH " "direction before changing ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == "6": print("How many steps should the NPC go in EACH " "direction before changing ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] elif r == "7": print("How many steps should the NPC go in EACH " "direction before changing ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] elif r == "8": print("How many steps should the NPC go in EACH direction " "before changing ?") r = int(input_digit("(please enter an integer)> ")) new_object.actuator.path += [ Constants.RIGHT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.UP for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.LEFT for i in range(0, r, 1) ] new_object.actuator.path += [ Constants.DOWN for i in range(0, r, 1) ] elif r == "9": print("Write your own path using only words from this list: " "UP, DOWN, LEFT, RIGHT, DLDOWN, DLUP, DRDOWN, DRUP.") print("Each direction has to be separated by a coma.") r = str(input("Write your path: ")).upper() new_object.actuator.path = r.split(",") else: Utils.warn(f'"{r}" is not a valid choice. Path is now empty.') new_object.actuator.path = [] elif r == "4": new_object.actuator = AdvancedActuators.PathFinder( parent=new_object, circle_waypoints=True) print( "Do you want the NPC to go through your way points once and stop or" " to cycle through all of them infinitely ?") print("1 - Cycle once") print("2 - Cycle infinitely (default value)") r = Utils.get_key() if r == "1": new_object.actuator.circle_waypoints = False return new_object elif key == "2": while True: game.clear_screen() print( Utils.green_bright("\t\tObject creation wizard: ") + Utils.magenta_bright("Structure")) print("What kind of structure do you want to create:") print( "1 - A wall like structure (an object that cannot be picked-up " "and is not overlappable). Ex: walls, trees, non moving " "elephant (try to go through an elephant or to pick it up " "in your backpack...)") print("2 - A door (player and/or NPC can go through)") print("3 - A treasure (can be picked up, take space in the " "inventory, give points to the player)") print("4 - A generic object (you can set the properties to " "make it pickable or overlappable)") print("5 - A generic actionable object (to make portals, heart " "to replenish life, etc.)") key = Utils.get_key() new_object = None if key == "1": new_object = Structures.Wall() new_object.name = str(uuid.uuid1()) new_object.model = model_picker() break elif key == "2": new_object = Structures.Door() new_object.name = str(uuid.uuid1()) new_object.model = model_picker() break elif key == "3": new_object = Structures.Treasure() print("First give a name to your Treasure. Default value: " + new_object.name) r = str(input("(Enter name)> ")) if len(r) > 0: new_object.name = r print("Then give it a type. A type is important as it allows " "grouping (in this case probably in the inventory).\n" "Type is a string. Default value: " + new_object.type) r = str(input("(Enter type)> ")) if len(r) > 0: new_object.type = r print("Now we need a model. Default value: " + new_object.model) input('Hit "Enter" when you are ready to choose a model.') new_object.model = model_picker() break elif key == "4" or key == "5": if key == "4": new_object = Structures.GenericStructure() else: new_object = Structures.GenericActionableStructure() new_object.set_overlappable(False) new_object.set_pickable(False) print("First give a name to your structure. Default value: " + new_object.name) r = str(input("(Enter name)> ")) if len(r) > 0: new_object.name = r print( "Then give it a type. \nType is a string. Default value: " + new_object.type) r = str(input("(Enter type)> ")) if len(r) > 0: new_object.type = r print("Now we need a model. Default value: " + new_object.model) input('Hit "Enter" when you are ready to choose a model.') new_object.model = model_picker() print("Is this object pickable? (can it be picked up " "by the player)?") print("0 - No") print("1 - Yes") r = Utils.get_key() if r == "1": new_object.set_pickable(True) print("Is this object overlappable? (can it be walked " "over by player?") print("0 - No") print("1 - Yes") r = Utils.get_key() if r == "1": new_object.set_overlappable(True) break return new_object # Placeholder return BoardItemVoid()