def town_mode_interpreter(keyEvent, previousModeIn=None): if previousModeIn is None: previousModeIn = town_mode global previousMode if keyEvent.key == K_ESCAPE: confirm_quit(previousMode) elif keyEvent.key == K_i: confirm_title_screen(previousMode) elif keyEvent.key == K_s: save(previousMode) elif keyEvent.key == K_l: load(previousMode) elif keyEvent.key == K_q: save_game('quick', previousMode) elif keyEvent.key == K_t: talk(previousMode) elif keyEvent.key == K_g: select_destination(previousMode) elif keyEvent.key == K_p: previousMode = previousModeIn universal.set_commands(['(#)Character', '<==Back']) universal.say_title('Characters:') #universal.say(''.join(['Name:', universal.tab("Name:"), 'Health:', universal.tab("Health:"), 'Mana:\n'])) universal.say('\t'.join(['Name:', 'Health:', 'Mana:\n\t']), columnNum=3) universal.say(universal.state.party.display_party(), columnNum=3) universal.set_command_interpreter(select_character_interpreter)
def start_scene_1_episode_3(loading=False): universal.say("Next Time on Pandemonium Cycle: The Potion Wars") music.play_music(music.THEME) universal.say(["Roland and Elise are getting married, and", pwutilities.name(), "is asked to escort Elise to the Lowen Monastery for the wedding. But things get a little bit complicated when an old enemy of Roland's", "ambushes them!"]) universal.set_commands("Press Enter to save") universal.set_command_interpreter(pwutilities.end_content_interpreter)
def rest_mode(bedroomIn=None, sayDescription=True): if bedroomIn is None: bedroomIn = universal.state.bedroom town_mode(sayDescription) if bedroomIn: universal.set_commands(['(P)arty', '(G)o', '(S)ave', '(Q)uick Save', '(T)alk', '(L)oad', '(Esc)Quit', '(R)oom Actions'] if bedroomIn.boarding else ['(P)arty', '(G)o', '(S)ave', '(Q)uick Save', '(T)alk', '(L)oad', '(Esc)Quit']) universal.set_command_interpreter(bedroom_interpreter)
def title_screen(episode=None): global firstEpisode, loadingGame textSurface = None titleImage = None try: titleImage = pygame.image.load(TITLE_IMAGES[0]).convert() titleImage = pygame.transform.scale(titleImage, (pygame.display.Info().current_w, pygame.display.Info().current_h)) except IOError: textSurface = textrect.render_textrect(get_title(), #+ (":" if get_subtitle() != "" else ""), universal.font, universal.worldView, LIGHT_GREY, DARK_GREY, 1) except IndexError: textSurface = textrect.render_textrect(get_title(), #+ (":" if get_subtitle() != "" else ""), universal.font, universal.worldView, LIGHT_GREY, DARK_GREY, 1) titleImages = [] if os.path.exists(os.path.join(os.getcwd(), 'save')) and '.init.sav' in os.listdir(os.path.join(os.getcwd(), 'save')): #townmode.clear_rooms() townmode.previousMode = None townmode.load_game('.init.sav', preserveLoadName=False) else: townmode.save_game('.init.sav', preserveSaveName=False) assert(episode is not None or firstEpisode is not None) if episode is not None: firstEpisode = episode screen = universal.get_screen() worldView = universal.get_world_view() background = universal.get_background() screen.fill(universal.DARK_GREY) font = pygame.font.SysFont(universal.FONT_LIST, 50) wvMidLeft = worldView.midleft if loadingGame: for i in range(1, len(TITLE_IMAGES)): try: titleImages.append(pygame.image.load(TITLE_IMAGES[i])) titleImages[-1] = pygame.transform.scale(titleImages[-1], (pygame.display.Info().current_w, pygame.display.Info().current_h)) except IOError: continue opening_crawl() loadingGame = False music.play_music(music.THEME) universal.set_commands(['(S)tart', '(L)oad', '(A)cknowledgments', '(Esc)Quit']) universal.set_command_interpreter(title_screen_interpreter) if not skip: pygame.time.delay(125) for i in range(0, len(titleImages)): screen.blit(titleImages[i], worldView.topleft) pygame.time.delay(25) pygame.display.flip() if titleImage is not None: screen.blit(titleImage, worldView.topleft) else: screen.blit(textSurface, worldView.centerleft) pygame.display.flip() while 1: universal.textToDisplay = '' universal.titleText = '' for event in pygame.event.get(): if event.type == KEYUP: return [universal.get_command_view()]
def request_difficulty(): universal.say_title('Character Creation') universal.get_screen().blit(universal.get_background(), universal.get_world_view().topleft) universal.say('Before we get started, we need to pick a difficulty level:\n\n') universal.say('HAND: Enemies choose their actions purely at random.\n\n') universal.say('STRAP: Enemies choose their actions based on their own statistics, and the skills of their allies. They choose their target at random.\n\n') universal.say('CANE: Enemies choose their actions based on their statistics, the skills of their allies and previous rounds. They choose their target based on the effects of previous rounds.') universal.set_commands(['(H)and', '(S)trap', '(C)ane', '(Esc)Quit', '<==Back']) universal.set_command_interpreter(request_difficulty_interpreter)
def request_nickname(): global partialName universal.say('Provide a nickname for your character:\n') universal.set_commands(['Esc']) if universal.state.player.is_male(): partialName = 'Juli' elif universal.state.player.is_female(): partialName = 'Julia' universal.say(partialName) universal.say('_') universal.set_command_interpreter(request_nickname_interpreter)
def talk(previousModeIn): party = person.get_party() talkableCharacters = [c for cName, c in universal.state.location.characters.iteritems() if c and not party.inParty(c)] if talkableCharacters: print(talkableCharacters) universal.say('Who would you like to speak to?\n') universal.say('\n'.join([j + name for j, name in zip( [str(i) + '. ' for i in range(1, len(talkableCharacters)+1)], [c.printedName for c in talkableCharacters])])) universal.set_commands(['(#) Select person', '<==Back']) global previousMode previousMode = previousModeIn universal.set_command_interpreter(talk_interpreter)
def request_name(): """ Asks the player for the PC's name. """ global partialName, gender universal.say(requestNameString) universal.set_commands(['Esc']) if gender == person.MALE: partialName = 'Julian' else: partialName = 'Juliana' universal.say(partialName) universal.say('_') universal.set_command_interpreter(request_name_interpreter)
def final_confirmation(): universal.state.player.learn_spell(person.allSpells[0][0][0]) universal.state.player.learn_spell(person.allSpells[0][1][0]) universal.state.player.learn_spell(person.allSpells[0][2][0]) universal.state.player.learn_spell(person.allSpells[0][3][0]) universal.state.player.equip(itemspotionwars.oldShirt) universal.state.player.equip(itemspotionwars.comfyShorts) spells = [person.allSpells[0][0][0], person.allSpells[0][1][0], person.allSpells[0][2][0], person.allSpells[0][3][0]] for i in range(len(spells)): universal.state.player.quickSpells[i] = spells[i] universal.say(universal.state.player.appearance(True), justification=0) universal.say(' '.join(["\n\nEnemies will try to spank you in battle: ", "Yes" if universal.state.enemiesCanSpank else "No"]), justification=0) universal.set_commands(['(Enter) Begin Game', '<==Back', '(Esc) To Title Screen']) universal.set_command_interpreter(final_confirmation_interpreter)
def select_equipment(): universal.say_title("Select Equipment to Enchant:") global equipmentList global partialNum equipmentList = [] partialNum = '' for person in universal.state.party: equipmentList.extend([(person, equipment) for equipment in person.equipmentList if not items.is_empty_item(equipment) and not items.is_pajamas(equipment)]) personEquipmentStrings = [''.join([person.printedName, ": ", equipment.name]) for person, equipment in equipmentList] universal.say('\n'.join(universal.numbered_list(personEquipmentStrings))) universal.set_commands(["(#) Select Equipment: " + str(partialNum) + '_', "<==Back"]) universal.set_command_interpreter(select_equipment_interpreter)
def town_mode(sayDescription=True): """ Goes into town mode (i.e. displays the commands for town-mode, and says the description of the current location, if sayDescription is True. Otherwise, it doesn't say the description. """ room = universal.state.location global previousMode previousMode = town_mode if sayDescription: universal.say_title(room.name) if sayDescription: universal.say_replace(room.get_description()) universal.set_commands(['(P)arty', '(G)o', '(S)ave', '(Q)uick Save', '(T)alk', '(L)oad', '(Esc)Quit', 't(I)tle Screen']) universal.set_command_interpreter(town_mode_interpreter) music.play_music(room.bgMusic)
def select_destination(previousModeIn): global adjacentList global previousMode if previousModeIn is None: previousMode = town_mode else: previousMode = previousModeIn currentRoom = universal.state.location adjacent = currentRoom.adjacent if currentRoom.adjacent is not None: universal.say('\n'.join([str(i) + '. ' + adj.name for i, adj in zip([j for j in range(1, len(adjacent) + 1)], adjacent)])) universal.set_commands(['(#) Select destination', '<==Back']) else: universal.set_commands(['<==Back']) previousMode = previousModeIn universal.set_command_interpreter(select_destination_interpreter)
def load(returnMode=None): global returnTo, loadName, saveFiles if returnMode is not None: returnTo = returnMode else: returnTo = town_mode saveFiles = sorted([fileName for fileName in os.listdir('save') if fileName[0] != '.']) try: saveFiles.insert(0, saveFiles.pop(saveFiles.index('quick.sav'))) except ValueError: pass universal.clear_world_view() universal.say_title('Load') universal.say('\n'.join(universal.numbered_list([sf for sf in saveFiles if sf[0] != '.']))) if len(saveFiles) < 10: universal.set_commands(['(#) Select a file to load:', '<==Back']) else: universal.set_commands(['(#) Select a file to load:_', '<==Back']) universal.set_command_interpreter(load_interpreter)
def select_gem(shopkeeperIn=None, doneShoppingLitany=None): global partialNum if sum(person.coins for person in universal.state.party) < 30 and ( universal.state.enchantmentFreebies == 0): universal.say("You don't have enough money to enchant anything!") universal.acknowledge(done_shopping, ()) return universal.say_title("Select Enhancement Gem") global gemList, litany, shopkeeper shopkeeper = shopkeeperIn litany = doneShoppingLitany gemList = [] for person in universal.state.party: gemList.extend([(person, item) for item in person.get_inventory() if hasattr(item, "enchantmentType")]) gemStrings = [''.join([person.name, ": ", item.name]) for person, item in gemList] universal.say(universal.numbered_list(gemStrings)) universal.set_commands(["(#) Select Gem: " + str(partialNum) + '_', "<==Back"]) universal.set_command_interpreter(select_gem_interpreter) partialNum = ''
def save(previousModeIn): global saveFiles, previousMode previousMode = previousModeIn try: saveFiles = sorted([file for file in os.listdir('save') if file[0] != '.']) except OSError: os.mkdir('save') saveFiles = sorted([file for file in os.listdir('save') if file[0] != '.']) universal.clear_world_view() universal.say_title('Save') try: saveFiles.insert(0, saveFiles.pop(saveFiles.index('quick.sav'))) except ValueError: pass universal.say('\n'.join(universal.numbered_list(saveFiles))) if len(saveFiles) < 10: universal.set_commands(['Provide a save name:_', '(#) Select a save file.', '<==Back']) else: universal.set_commands([' '.join(['Provide a save name:_']), '(#) Select a save file:_', '<==Back']) universal.set_command_interpreter(save_interpreter)
def final_confirmation_interpreter(key_event): #universal.state.player = person.get_PC() if key_event.key == K_RETURN: universal.state.player.currentEpisode = firstEpisode.name episode.allEpisodes[universal.state.player.currentEpisode].currentSceneIndex = 0 #episode.set_post_title_card(townmode.save_game, ['.init', townmode.town_mode, False]) episode.allEpisodes[universal.state.player.currentEpisode].start_episode(False) townmode.saveName = '' elif key_event.key == K_BACKSPACE: can_enemies_spank() elif key_event.key == K_ESCAPE: global spellPoints global statPoints spellPoints = 3 statPoints = 3 #universal.state.player.clear_spells() #universal.state.player.reset_stats() title_screen(firstEpisode) universal.set_command_interpreter(title_screen_interpreter) universal.set_commands(['(S)tart', '(L)oad', '(Esc)Quit'])
def bedroom_actions(): universal.set_commands(['(R)est', '(B)raid Hair', '<==Back']) #'(S)tore Item', '<==Back']) universal.set_command_interpreter(bedroom_actions_interpreter)
def end_content_mode(): universal.say(universal.format_line(['''That's the end of the content, I hope you've enjoyed playing this far. If you have any comments, criticisms, questions, bug reports, or anything else, either comment on my blog''', '''spankingrpgs.blogspot.com, or send me an e-mail at [email protected] (please post bug reports on the blog however, so that others can see them). Criticisms are welcome, however please keep them constructive. Saying "This game''', '''sucks!" tells me nothing except that you didn't like it. Saying "Your combat system felt unbalanced. The magic was way too powerful." tells me much much more.''']), justification=0) universal.set_commands(['(Esc) To exit']) universal.set_command_interpreter(quit_interpreter)
def request_description(): universal.say(requestDescriptionString) universal.say(universal.state.player.description) universal.say('_') universal.set_command_interpreter(request_description_interpreter)
def request_gender(): universal.say('Please select a gender.') universal.set_commands(['(M)ale', '', '(F)emale', '<==Back', '(Esc)Quit']) universal.set_command_interpreter(request_gender_interpreter)
def confirm_quit(previousModeIn): global previousMode previousMode = previousModeIn universal.set_commands(['Would you like to save before quitting? Y/N', '<==Back']) universal.set_command_interpreter(confirm_quit_interpreter)
def confirm_title_screen(previousModeIn): global previousMode previousMode = previousModeIn universal.set_commands(['Would you like to save before returning to the title screen? Y/N', '<==Back']) universal.set_command_interpreter(confirm_title_screen_interpreter)
def confirm_save(saveName): global possibleSave possibleSave = saveName universal.set_commands(' '.join(['Save to', saveName, 'this correct? Y/N'])) universal.set_command_interpreter(confirm_save_interpreter)
def confirm_load(): global loadName universal.set_commands([' '.join(['(Enter) Load ', loadName]), '<==Back']) universal.set_command_interpreter(confirm_load_interpreter)
def start_scene_2_episode_2(loading=False): universal.say("You've reached the end of the current content. Hope you've enjoyed playing it. If you have any comments or criticisms, please either post on my website spankingrpgs.com, or send me an e-mail at [email protected]. Once the next scene is posted, you'll be able to enjoy by loading a save from just before this scene. Thanks!", justification=0) universal.set_commands('Press Enter to go back to the title screen') universal.set_command_interpreter(pwutilities.to_title_screen_interpreter)