def animate_fall(target_entity, animation_target_piece): color_fg = target_entity.graphic_char.color_fg target_entity.game_state.value.force_draw() graphic_chars = [ target_entity.graphic_char, GraphicChar(None, color_fg, icon.BIG_CENTER_DOT), GraphicChar(None, color_fg, "*"), GraphicChar(None, color_fg, "+"), GraphicChar(None, color_fg, icon.CENTER_DOT) ] animation_target_piece.char_printer.append_graphic_char_temporary_frames( graphic_chars)
def animate_fall_sync(target_entity): color_fg = target_entity.graphic_char.color_fg target_entity.game_state.value.force_draw() graphic_chars = [ target_entity.graphic_char, GraphicChar(None, color_fg, icon.BIG_CENTER_DOT), GraphicChar(None, color_fg, "*"), GraphicChar(None, color_fg, "+"), GraphicChar(None, color_fg, icon.CENTER_DOT) ] animate_point(target_entity.game_state.value, target_entity.position.value, graphic_chars)
def update(self, time_spent): if self.is_new_round(time_spent): gray_heart = GraphicChar(None, colors.GRAY, icon.HEART) self.target_entity.char_printer.append_graphic_char_temporary_frames( [gray_heart]) self.send_message() self.tick(time_spent)
def new_dagger(game_state): """ A composite component representing a Knife item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Dagger", "A trusty dagger, small and precise but will only inflict small wounds." )) c.set_child(GraphicChar(None, colors.GRAY, icon.DAGGER)) c.set_child(DataPoint(DataTypes.WEIGHT, 5)) c.set_child(DamageType(DamageTypes.CUTTING)) c.set_child(damage_item_stat(1, 3)) c.set_child(accuracy_item_stat(15)) c.set_child(CritChanceBonusEffect(0.2)) c.set_child(crit_multiplier_item_stat(3.5)) c.set_child(ExtraSwingAttackEffect(0.20)) c.set_child(BleedAttackEffect(0.10)) return c
def new_chain_and_ball(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Chain and Spike Ball", "A huge metal ball on a chain, hard to use but can deal massive damage." )) c.set_child(GraphicChar(None, colors.GRAY, icon.BALL_AND_CHAIN)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(damage_item_stat(2, 9)) c.set_child(accuracy_item_stat(5)) c.set_child(CritChanceBonusEffect(0.10)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(KnockBackAttackEffect(0.20)) c.set_child(DefenciveAttackEffect(0.60)) c.set_child(IgnoreArmorAttackEffect(0.10)) return c
def new_morning_star(game_state): """ A composite component representing a Sword item. """ mace = Composite() set_item_components(mace, game_state) set_melee_weapon_component(mace) mace.set_child( Description( "Morning Star", "This old club has an lump of iron with rusty spikes at one end.")) mace.set_child(GraphicChar(None, colors.GRAY, icon.MORNING_STAR)) mace.set_child(DataPoint(DataTypes.WEIGHT, 8)) mace.set_child(accuracy_item_stat(8)) mace.set_child(damage_item_stat(1, 6)) mace.set_child(CritChanceBonusEffect(0.1)) mace.set_child(crit_multiplier_item_stat(2)) mace.set_child(StunAttackEffect(0.2)) mace.set_child(IgnoreArmorAttackEffect(0.2)) mace.set_child(BleedAttackEffect(0.1)) return mace
def new_trident(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Trident", "A long stick with a with three sharp points at one end." "It's a useful weapon when you want to keep danger at bay.")) c.set_child(GraphicChar(None, colors.ORANGE_D, icon.TRIDENT)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(accuracy_item_stat(10)) c.set_child(damage_item_stat(1, 5)) c.set_child(CritChanceBonusEffect(0.15)) c.set_child(crit_multiplier_item_stat(2.5)) c.set_child(DefenciveAttackEffect(0.75)) c.set_child(BleedAttackEffect(0.20)) return c
def new_kris(game_state): """ A composite component representing a Knife item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Kris", "A dagger with a wavy blade, its sharp end can cause major damage." )) c.set_child(GraphicChar(None, colors.GRAY_D, icon.KRIS)) c.set_child(DataPoint(DataTypes.WEIGHT, 5)) c.set_child(DamageType(DamageTypes.CUTTING)) c.set_child(damage_item_stat(1, 3)) c.set_child(accuracy_item_stat(15)) c.set_child(CritChanceBonusEffect(0.20)) c.set_child(crit_multiplier_item_stat(3.5)) c.set_child(ExtraSwingAttackEffect(0.2)) c.set_child(BleedAttackEffect(0.2)) return c
def __init__(self, sling_weapon): super(PlayerSlingStoneAction, self).__init__(GraphicChar(None, colors.GRAY, icon.STONE)) self.component_type = "sling_stone_action" self.name = "Throw Stone" self.display_order = 95 self.sling_weapon = sling_weapon
def new_cyclops(game_state): cyclops = Composite() set_monster_components(cyclops, game_state) set_humanoid_components(cyclops) cyclops.set_child(EntityMessages("The eye of the cyclops watches at you.", "The cyclops is dead.")) cyclops.set_child(Description("Cyclops", "A Giant with a single disgusting eye, it's looking for prey.")) cyclops.set_child(GraphicChar(None, colors.LIGHT_ORANGE, icon.CYCLOPS)) cyclops.set_child(Health(45)) cyclops.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn)) cyclops.set_child(DataPoint(DataTypes.THROW_SPEED, gametime.double_turn)) cyclops.set_child(DataPoint(DataTypes.STRENGTH, 21)) cyclops.set_child(DataPoint(DataTypes.EVASION, 7)) cyclops.set_child(DataPoint(DataTypes.ACCURACY, 9)) cyclops.set_child(DataPoint(DataTypes.ARMOR, 6)) cyclops.set_child(DataPoint(DataTypes.AWARENESS, 3)) cyclops.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.one_and_half_turn)) cyclops.set_child(DataPoint(DataTypes.THROW_SPEED, gametime.double_turn)) cyclops.set_child(DataPoint(DataTypes.MELEE_DAMAGE_MULTIPLIER, 0.5)) cyclops.set_child(ThrowRockAttacker()) cyclops.set_child(MonsterThrowRockAction(900)) cyclops.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 5)) return cyclops
def __init__(self, ranged_weapon): super(PlayerShootWeaponAction, self).__init__() self.name = "Shoot" self.display_order = 85 self.ranged_weapon = ranged_weapon self._missile_graphic = GraphicChar(None, colors.WHITE, icon.BIG_CENTER_DOT)
def new_plant(): plant = Composite() set_dungeon_feature_components(plant) plant.set_child(GraphicChar(None, colors.GREEN_D, icon.PLANT)) plant.set_child(Flag("is_opaque")) plant.set_child(Flag(Flags.FLAMMABLE)) plant.set_child(UpdateDungeonMaskWhenRemoved()) return plant
def __init__(self): super(PoolOfBlood, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.DUNGEON_TRASH)) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(Description("A pool of blood.", "A pool of blood.")) self.set_child(GraphicChar(None, colors.RED, random.choice(icon.BLOOD_ICONS))) self.set_child(CharPrinter()) self.set_child(Mover())
def set_scroll_components(item): item.set_child(ItemType(ItemType.SCROLL)) item.set_child(PlayerAutoPickUp()) item.set_child(DataPoint(DataTypes.WEIGHT, 1)) item.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.SCROLL)) set_thrown_item_hit_floor_action(item, [ MoveTriggeredEffect(), LocalMessageEffect(messenger.ITEM_HITS_THE_GROUND_LIGHT) ])
def __init__(self): super(GlassWall, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.TERRAIN)) self.set_child(Mover()) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(GraphicChar(colors.FLOOR_BG, colors.WHITE, icon.GLASS_WALL)) self.set_child(CharPrinter()) self.set_child(Flag("is_solid"))
def _act(self): """ Just returns energy spent, shows it's stunned. """ if self.notice_player_check(): self.parent.monster_actor_state.value = MonsterActorState.HUNTING else: self.parent.char_printer.append_graphic_char_temporary_frames([GraphicChar(None, colors.GRAY, "z")]) return gametime.single_turn
def new_flame_orb(game_state): orb = Composite() set_item_components(orb, game_state) set_ranged_weapon_components(orb) orb.set_child(RangeWeaponType(RangeWeaponType.MAGIC)) orb.set_child( Description( "Flame Orb", "An orb with a living flame inside, it allows the wielder to channel fire from it." )) orb.set_child(GraphicChar(None, colors.RED, icon.ORB)) orb.set_child(DataPoint(DataTypes.WEAPON_RANGE, 5)) orb.set_child(DataPoint(DataTypes.WEIGHT, 2)) orb.set_child(accuracy_item_stat(5)) orb.set_child(Damage(2, 4)) orb.set_child( MagicMissileEffect(GraphicChar(None, colors.RED, icon.BIG_CENTER_DOT))) return orb
def new_healing_device(game_state): device = Composite() set_item_components(device, game_state) set_device_components(device) device.set_child( Description("Device of Healing", "This ancient device will heal everything within view.")) set_device_item_action(device, [HealAllSeenTriggeredEffect()]) device.set_child(GraphicChar(None, colors.PINK, icon.MACHINE)) return device
def set_dungeon_feature_components(dungeon_feature): dungeon_feature.set_child( DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.DUNGEON_FEATURE)) dungeon_feature.set_child(Position()) dungeon_feature.set_child(DungeonLevel()) dungeon_feature.set_child(GraphicChar(None, colors.RED, icon.FOUNTAIN_FULL)) dungeon_feature.set_child(CharPrinter()) dungeon_feature.set_child(Mover()) dungeon_feature.set_child(IsDungeonFeature())
def __init__(self): super(Water, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.TERRAIN)) self.set_child(Mover()) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(GraphicChar(colors.BLUE_D, colors.BLUE, icon.WATER)) self.set_child(CharPrinter())
def new_glass_device(game_state): device = Composite() set_item_components(device, game_state) set_device_components(device) device.set_child( Description( "Dev. of Glassmaking", "This ancient device will turn all nearby stone into glass.")) set_device_item_action(device, [WallToGlassTriggeredEffect()]) device.set_child(GraphicChar(None, colors.CYAN, icon.MACHINE)) return device
def new_ring_of_invisibility(game_state): ring = Composite() set_item_components(ring, game_state) set_ring_components(ring) ring.set_child(GraphicChar(None, colors.CYAN, icon.RING)) ring.set_child(SetInvisibilityFlagEquippedEffect()) ring.set_child( Description( "Ring of Invisibility", "The metal is warm to your skin, " "this ring will make you invisible")) return ring
def new_ring_of_evasion(game_state): ring = Composite() set_item_components(ring, game_state) set_ring_components(ring) ring.set_child(GraphicChar(None, colors.GREEN, icon.RING)) ring.set_child(StatBonusEquipEffect("evasion", 3)) ring.set_child( Description( "Ring of Evasion", "The ring is light on your finger, " "Its magic powers makes it easier for you to dodge attacks.")) return ring
def new_ring_of_stealth(game_state): ring = Composite() set_item_components(ring, game_state) set_ring_components(ring) ring.set_child(GraphicChar(None, colors.BLUE, icon.RING)) ring.set_child(StatBonusEquipEffect("stealth", 3)) ring.set_child( Description( "Ring of Stealth", "The ring is smooth to your skin, " "Its magic powers makes it easier for you to sneak past enemies.")) return ring
def new_ring_of_strength(game_state): ring = Composite() set_item_components(ring, game_state) set_ring_components(ring) ring.set_child(GraphicChar(None, colors.ORANGE, icon.RING)) ring.set_child(StatBonusEquipEffect("strength", 3)) ring.set_child( Description( "Ring of Strength", "The ring feels unnaturally heavy, " "Its magic powers makes you stronger.")) return ring
def value(self, new_value): if (self._value != MonsterActorState.HUNTING and MonsterActorState.HUNTING == new_value): found_gfx = GraphicChar(None, colors.BLUE, "!") (self.parent.char_printer. append_graphic_char_temporary_frames([found_gfx])) msg.send_visual_message(self.parent.entity_messages.notice, self.parent.position.value) if self.parent.has("sleeping"): self.parent.effect_queue.add(RemoveChildEffect(self.parent, "sleeping", time_to_live=1)) self._value = new_value
def __init__(self): super(Floor, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.TERRAIN)) self.set_child(Mover()) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(GraphicChar(colors.FLOOR_BG, colors.FLOOR_FG, icon.CENTER_DOT)) self.set_child(CharPrinter()) self.set_child(Flag(Floor.FLOOR_FLAG))
def new_zap_device(game_state): device = Composite() set_item_components(device, game_state) set_device_components(device) device.set_child( Description( "Device of Zapping", "This ancient device will zap a random creature within view.")) set_device_item_action(device, [ZapRandomSeenEntityTriggeredEffect()]) device.set_child(GraphicChar(None, colors.GRAY, icon.MACHINE)) return device
def new_stairs_up(): """ Stairs up allows the player to ascend to the next level. """ stairs = Composite() set_dungeon_feature_components(stairs) stairs.set_child( Description("Stairs Up", ("A way back, when the ", "nightmare becomes too real."))) stairs.set_child(GraphicChar(None, colors.WHITE, icon.STAIRS_UP)) stairs.set_child(Flag("is_stairs_up")) return stairs
def __init__(self): super(Unknown, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.TERRAIN)) self.set_child(Mover()) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(CharPrinter()) self.set_child(GraphicChar(colors.BLACK, colors.BLACK, ' ')) self.set_child(Flag("is_unknown")) self.set_child(Flag("is_solid"))