def explore_start(): state.player = player.Ranger() state.player.x = 40 state.player.y = 6 pytality.term.clear() x = state.width - 80 g.buffer = pytality.buffer.Buffer(x=x, width=state.width - x, height=0) g.text = pytality.buffer.PlainText( "YOU ARE A %s" % state.player.title, x=0, y=state.height/2, center_to=g.buffer.width, fg=pytality.colors.BLUE ) g.stat_bar = pytality.buffer.Box( width=g.buffer.width, height=6, padding_x=2, padding_y=1, draw_left=False, draw_top=False, children = [ pytality.buffer.RichText("<GREEN>Health:</> %s", y=0), pytality.buffer.RichText("<YELLOW>Stamina:</> %s", y=2) ] ) g.room_container = pytality.buffer.Buffer(x=0, width=g.buffer.width, height=state.height - g.stat_bar.height, y=g.stat_bar.height) g.buffer.children += [g.text, g.stat_bar, g.room_container] for i in range(10): message.add("hoo boy!") set_room(room.Room(room.layout))
def on_use(self): if self.consumed: return msg = self.consoles[self.char[0]] message.add("\nA message appears on the video console.") message.add(msg) self.consumed = True
def on_use(self): item = '%s key' % color_map[self.char[0]] if item not in state.inventory: message.add("You need a <WHITE>%s</> to unlock this door" % item) else: message.add("Your <WHITE>%s</> unlocks the door." % item) self.door = True self.passable = True self.clear()
def level_prompt(): while True: event.fire('flip') ret = False key = term.getkey() if key in ('up', 'down', 'left', 'right') and not level.been_cursed: message.newline() message.add("The curse of Melimnor takes hold upon you!") state.player.add_limb() message.newline() level.been_cursed = True if key == 'enter': return elif key == 'f3' and False: #TAKE ME OUT BEFORE RELEASE state.player.mutate() elif key == 'f4' and False: #TAKE ME OUT BEFORE RELEASE state.player.add_limb() elif key == 'up': ret = level.layout.curr_room.try_move(y=-1) elif key == 'down': ret = level.layout.curr_room.try_move(y=+1) elif key == 'left': ret = level.layout.curr_room.try_move(x=-1) elif key == 'right': ret = level.layout.curr_room.try_move(x=+1) log.debug('ret: %r', ret) if not ret: continue elif ret is True: return else: action, args = ret log.debug("action: %r, args: %r", action, args) if action == 'changeroom': level.layout.change_room(*args) add_room_messages() draw_explore() elif action == 'changelevel': log.debug("changing level") level.layout = layouts.random_layout() state.found_key = False add_room_messages() draw_explore() message.add("<LIGHTRED>The stairs vanish behind you!") return
def add_limb(self): log.debug("Adding limb!") message.add("<MAGENTA>The magic of Melimnor grants you a new limb!", flip=True) slot = random.choice(self.limbs) part = self.random_part(slot) self.add_part(slot, part) slot_name = slot.replace("_", " ").title() message.add("<LIGHTMAGENTA>You now have a new %s on your %s!" % (part.name, slot_name), flip=True) self.calc_stats()
def tutorial_onactivate(self): global found_blue if 'red key' in state.inventory: state.enable_shudder = True if 'blue key' in state.inventory and not found_blue: found_blue = True state.enable_shudder = True for cell in self.each_cell(): if cell.special == 'staircase': cell.clear() sanity.shudder(nomsg=True) time.sleep(0.02) log.debug("blam") message.add('The stairs out have disappeared!\nYou are trapped!\n') state.player.lose_san(5)
def start_explore(): sound.play('appear') level.layout = layouts.start_layout() level.layout.setup() state.player.reset_hp() state.player.explore_reset() add_room_messages() message.add(""" <LIGHTGREY>This is the cursed isle of <WHITE>Melimnor</>, spoke of in legend to be rife with hideous, deformed, and unnatural creatures.</> By some horrible luck, you find yourself on it's shores. It is eerily quiet here. """)
def do_action(self): log.debug("doing action") all_attacks = [part.attack for part in self.all_parts() if part.attack] min_delay = min([attack.cur_cooldown for attack in all_attacks]) if min_delay: log.debug("cooldowns: %r", [(attack.name, attack.cur_cooldown) for attack in all_attacks]) message.add("<DARKGREY>%s delays for %i" % (self.name, min_delay)) self.cur_tick_delay = min_delay return available_attacks = {} for attack in all_attacks: if attack.cur_cooldown: continue available_attacks.setdefault(attack.name, []) available_attacks[attack.name].append(attack) #build a list of (duration, combo) so we can use max() to find the slowest one dur, chosen_attack = max([((attacks[0].cooldown + ((len(attacks) - 1)*2)), attacks) for attacks in available_attacks.values()]) return chosen_attack
def room2_onshudder(self): message.add("You're trapped in a prison cell!") message.add("There's no way out!") state.player.lose_stamina(5) message.add("Your panic tires you.")
def mutate(self): #find something new log.debug("Mutating!") message.add("<MAGENTA>The curse of Melimnor twists your body!", flip=True) vetos = 0 last_vetoed = None while True: slot = random.choice(self.slots + self.limbs) part = self.random_part(slot) log.debug("Testing a %r part %r", slot, part.name) if 'Human' in part.name: #can never go back, buddy continue if part.name == last_vetoed: #don't reroll the same part that was just vetoed #(cycles are totally okay) continue if slot in self.limbs: old_part = random.choice(self.parts[slot]) if part.name == old_part.name: #that wouldn't be much of a mutation continue else: old_part = self.parts[slot] if old_part and part.name == old_part.name: #that wouldn't be much of a mutation continue #ask if they want it - if they can if vetos >= self.found_artifacts: #too bad! break message.add("<GREEN>Your <LIGHTGREEN>Melimnarian Artifact</> glows with power!") message.add("<WHITE>Do you accept a <LIGHTMAGENTA>%s</>? (Y/N)" % part.name, flip=True) if self.ask_user(): message.add("<WHITE>You have accepted the <LIGHTMAGENTA>%s</>." % part.name, flip=True) break else: message.add("<WHITE>You force the magical curse to try again.", flip=True) vetos += 1 last_vetoed = part.name #set it log.debug("Chose a %r part %r", slot, part.name) if slot in self.limbs: idx = self.parts[slot].index(old_part) self.parts[slot][idx] = part else: self.parts[slot] = part #tell them about it slot_name = slot.replace("_", " ").title() if old_part: message.add("<LIGHTMAGENTA>Your %s mutates into a %s!" % (slot_name, part.name), flip=True) else: message.add("<LIGHTMAGENTA>A %s sprouts from your %s!" % (part.name, slot_name), flip=True) message.newline(flip=True) self.calc_stats()
def no_stairs(): message.add("stairs?")
def shudder_message(): if explore.g.current_room.manual_shudder: explore.g.current_room.on_shudder(explore.g.current_room) else: message.add("What was that?")
def consume(self): item = self.item_map[self.char[2]] state.inventory.append(item) message.add("You found a <WHITE>%s</>." % item)
def on_use(self): if not state.goblin_alive: return damage_taken = random.randint(1, 8) + ((state.player.strength - 10) / 2) message.add("Your %s deals <GREEN>%i</> damage to the goblin!" % (state.player.weapon, damage_taken)) self.hp -= damage_taken if self.hp <= 0: message.add("<GREEN>The evil goblin falls!") message.add("You take a <WHITE>goblin head</> as a trophy.\n") state.inventory.append('goblin head') message.add("You find a <WHITE>white key</>.") state.inventory.append('white key') state.goblin_alive = False state.goblin_head = True state.found_small_key = True self.clear() return damage_dealt = random.randint(1, 4) + 4 message.add("The evil goblin deals <RED>%i</> damage to you!" % damage_dealt) state.player.lose_hp(damage_dealt, "evil goblin") message.add('')
def consume(self): message.add("stamina pickup!")
def try_move(self, x=0, y=0): px = self.player_x + x py = self.player_y + y if px < 0 or py < 0 or px >= self.width or py >= self.height: message.error("You cannot exit the map.", flip=True) return False tile = self.tiles[py][px] if tile.door: message.add("<YELLOW>You enter the next room.", flip=True) return ("changeroom", (x, y)) elif tile.warp: message.add("<YELLOW>You descend into the darkness.", flip=True) return ("changelevel", (None,)) elif tile.monster: message.add("<LIGHTRED>You attack the monster!", flip=True) state.mode = 'battle' event.fire('battle.start', tile.monster_properties) state.after_battle_tile = tile state.after_battle_pos = (px, py) raise state.StateChanged() elif tile.boss_door and not state.found_key: message.add("<LIGHTRED>You need a boss key to pass through this door.", flip=True) elif tile.passable: if tile.is_pickup and not tile.picked_up: #they found a thing! if tile.pickup_type == "health": message.add("<GREEN>You found a <LIGHTGREEN>Stone Of Health</>!", flip=True) state.player.bonus_hp += 1 state.player.cur_hp += 1 state.player.hp += 1 player.update_player_statblock(state.player) if tile.pickup_type == "key": message.add("<GREEN>You found a <LIGHTGREEN>Boss Key</>!", flip=True) state.found_key = True if tile.pickup_type == "limb": message.add("<GREEN>You found an <LIGHTGREEN>Orb Of Shiva</>!", flip=True) state.player.add_limb() if tile.pickup_type == "macguffin": message.add("<GREEN>You found a <LIGHTGREEN>Melimnerian Artifact</>!", flip=True) message.add("<GREEN>These powerful wards give you some control\nover the magical curse of Melimnor.", flip=True) state.player.quest_accuracy_bonus += 1 state.player.found_artifacts += 1 state.player.calc_stats() player.update_player_statblock(state.player) tile.clear() self.move_player(px, py) return True else: message.error("Something is in the way.", flip=True) return False
def consume(self): item = '%s key' % color_map[self.char[0]] state.inventory.append(item) message.add("You found a <WHITE>%s</>." % item)
def on_use(self): if state.player.san_loss < 5: message.add("Those are the stairs out. Your quest is not complete.") else: self.passable = True sanity.no_stairs()
def consume(self): message.add("health pickup!")