class Bat(Animal): name = "Bat" hit_dice = dice.D1(1) attack_bonus = AttackBonusTable.get_by_hit_dice(0) attack_sets = [AttackSet(ConfusionBySwarm(None))] base_armor_class = 14 morale = 7 movement = movement.MovementSet(walk=units.FeetPerGameTurn(30), fly=units.FeetPerGameTurn(40)) no_appearing = AppearingSet(dice_dungeon=dice.D100(1), dice_wild=dice.D100(2), dice_lair=dice.D100(2)) save_as = None xp = 10
def execute(self, character, target_selection=None): for game_object in character.location.level.game_objects: if game_object is character: continue if game_object.vision and game_object.vision.can_see_object(character): self.game.echo.player(character, "You may not hide in plain sight.") return False hide_target = character.query.special_ability(HideAbility) value = dice.D100(1).roll_total() if value > hide_target: if character.effects.has_effect(effects.Hidden): character.effects.remove_effect(effects.Hidden) context = contexts.Action(character, None) self.game.echo.see( actor=character, message=StringBuilder(Actor, Verb("attempt",Actor), "to hide."), context=context ) return False else: self.game.echo.player(character, "You attempt to hide.") if not character.effects.has_effect(effects.Hidden): character.effects.add_effect(effects.Hidden(None)) return True
def execute(self, character, target_selection=None): holder = target_selection.get("Holder") item = target_selection.get("Item") pick_pocket_target = character.query.special_ability(PickPocketAbility) value = dice.D100(1).roll_total() context = contexts.TwoTargetAction(character, holder, item) if value > pick_pocket_target: if value == 100 or value >= pick_pocket_target * 2: message = StringBuilder(TargetOne, Verb("catch", TargetOne), Actor, "trying to steal") self.game.echo.see(character, message, context) else: self.game.echo.player(character, "You fail your pick pocket attempt!") return False else: if holder.inventory.remove(item): if character.inventory.add(item): message = StringBuilder(Actor, Verb("steal", Actor), TargetTwo, "from", TargetOne) self.game.echo.player(character, message) else: holder.inventory.add(item) message = StringBuilder(Actor, "are too full to steal", TargetTwo, "from", TargetOne, "!") self.game.echo.player(character, message) return True
def execute(self, character, target_selection=None): remove_trap_target = character.query.special_ability( RemoveTrapsAbility) item = target_selection[0] value = dice.D100(1).roll_total() context = contexts.Action(character, item) if not target_selection[0].trap or value > remove_trap_target: self.game.echo.player(character, "You think there is no trap.") return False else: message = StringBuilder(Actor, Verb("found", Actor), "a", Target) self.game.player(character, message, context) value = dice.D100(1).roll_total() message = StringBuilder(Actor, Verb("attempt", Actor), "to disarm", Target, "'s trap...") self.game.see(character, message, context) if value > remove_trap_target: item.trap.add_failed_attempt(character, character.experience.level) return False else: item.unregister_component_name(components.Trap.NAME) return True
def execute(self, character, target_selection=None): open_lock_target = character.query.special_ability(OpenLockAbility) item = target_selection[0] value = dice.D100(1).roll_total() if value > open_lock_target: context = contexts.Action(character, item) message = StringBuilder(Actor, Verb("fail", Actor), "at picking", Target, "'s lock!") self.game.echo.see(actor=character, message=message, context=context) item.lock.add_failed_attempt(character, character.experience.level) return False item.lock.unlock() context = contexts.Action(character, item) message = StringBuilder(Actor, Verb("succeed", Actor), "at picking", Target, "'s lock!") self.game.echo.see(actor=character, message=message, context=context) return True
class TreasureTable(object): rows = [ TreasureRow(TreasureType.A, TreasureElement(50, coins.Copper, dice.D6(5)), TreasureElement(60, coins.Silver, dice.D6(5)), TreasureElement(40, coins.Electrum, dice.D4(5)), TreasureElement(70, coins.Gold, dice.D6(10)), TreasureElement(50, coins.Platinum, dice.D10(1)), TreasureElement(50, (Gem, ), dice.D6(6)), TreasureElement(50, (Jewelry, ), dice.D6(6)), TreasureElement(30, (RandomMagicItem, ), 3)), TreasureRow(TreasureType.B, TreasureElement(75, coins.Copper, dice.D10(5)), TreasureElement(50, coins.Silver, dice.D6(5)), TreasureElement(50, coins.Electrum, dice.D4(5)), TreasureElement(50, coins.Gold, dice.D6(3)), TreasureElement(25, Gem, dice.D6(1)), TreasureElement(25, Jewelry, dice.D6(1)), TreasureElement(10, ( Armor, Weapon, ), 1)), TreasureRow(TreasureType.C, TreasureElement(60, coins.Copper, dice.D6(6)), TreasureElement(60, coins.Silver, dice.D4(5)), TreasureElement(30, coins.Electrum, dice.D6(2)), TreasureElement(25, Gem, dice.D4(1)), TreasureElement(25, Jewelry, dice.D4(1)), TreasureElement(15, ( Armor, Weapon, ), dice.D2(1))), TreasureRow(TreasureType.D, TreasureElement(30, coins.Copper, dice.D6(4)), TreasureElement(45, coins.Silver, dice.D6(6)), TreasureElement(90, coins.Gold, dice.D8(5)), TreasureElement(30, Gem, dice.D8(1)), TreasureElement(30, Jewelry, dice.D8(1)), TreasureElement(20, RandomMagicItem, dice.D2(1), Potion)), TreasureRow( TreasureType.E, TreasureElement(30, coins.Copper, dice.D8(2)), TreasureElement(60, coins.Silver, dice.D6(10)), TreasureElement(50, coins.Electrum, dice.D8(3)), TreasureElement(50, coins.Gold, dice.D10(4)), TreasureElement(10, Gem, dice.D10(1)), TreasureElement(10, Jewelry, dice.D10(1)), TreasureElement(30, RandomMagicItem, dice.D4(1), MagicScroll)), TreasureRow( TreasureType.F, TreasureElement(40, coins.Silver, dice.D8(3)), TreasureElement(50, coins.Electrum, dice.D8(4)), TreasureElement(85, coins.Gold, dice.D10(6)), TreasureElement(70, coins.Platinum, dice.D8(2)), TreasureElement(20, Gem, dice.D12(2)), TreasureElement(10, Jewelry, dice.D12(1)), TreasureElement(35, RandomMagicItem, dice.D4(1), Potion, MagicScroll)), TreasureRow( TreasureType.G, TreasureElement(90, coins.Gold, dice.D6(4, multiplier=10)), TreasureElement(75, coins.Platinum, dice.D8(5)), TreasureElement(25, Gem, dice.D6(3)), TreasureElement(25, Jewelry, dice.D10(1)), TreasureElement(50, RandomMagicItem, dice.D4(1), MagicScroll)), TreasureRow( TreasureType.H, TreasureElement(75, coins.Copper, dice.D10(8)), TreasureElement(75, coins.Silver, dice.D10(6, multiplier=10)), TreasureElement(75, coins.Electrum, dice.D10(3, multiplier=10)), TreasureElement(75, coins.Gold, dice.D8(5, multiplier=10)), TreasureElement(75, coins.Platinum, dice.D8(9)), TreasureElement(50, Gem, dice.D100(1)), TreasureElement(50, Jewelry, dice.D4(10)), TreasureElement(20, RandomMagicItem, dice.D4(1), Potion, MagicScroll)), TreasureRow(TreasureType.I, TreasureElement(80, coins.Platinum, dice.D10(3)), TreasureElement(50, Gem, dice.D6(2)), TreasureElement(50, Jewelry, dice.D6(2)), TreasureElement(15, RandomMagicItem, 1)), TreasureRow( TreasureType.J, TreasureElement(45, coins.Copper, dice.D8(3)), TreasureElement(45, coins.Silver, dice.D8(1)), ), TreasureRow( TreasureType.K, TreasureElement(90, coins.Silver, dice.D10(2)), TreasureElement(35, coins.Electrum, dice.D8(1)), ), TreasureRow( TreasureType.L, TreasureElement(50, Gem, dice.D4(1)), ), TreasureRow( TreasureType.M, TreasureElement(90, coins.Gold, dice.D10(4)), TreasureElement(90, coins.Platinum, dice.D8(2, multiplier=10)), TreasureElement(55, Gem, dice.D4(5)), TreasureElement(45, Jewelry, dice.D6(2)), ), TreasureRow( TreasureType.N, TreasureElement(40, Potion, dice.D4(2)), ), TreasureRow( TreasureType.O, TreasureElement(50, MagicScroll, dice.D4(1)), ), TreasureRow( TreasureType.P, TreasureElement(100, coins.Copper, dice.D8(3)), ), TreasureRow( TreasureType.Q, TreasureElement(100, coins.Silver, dice.D6(3)), ), TreasureRow( TreasureType.R, TreasureElement(100, coins.Electrum, dice.D6(2)), ), TreasureRow( TreasureType.S, TreasureElement(100, coins.Gold, dice.D4(2)), ), TreasureRow( TreasureType.T, TreasureElement(100, coins.Platinum, dice.D6(1)), ), TreasureRow( TreasureType.U, TreasureElement(50, coins.Copper, dice.D20(1)), TreasureElement(50, coins.Silver, dice.D20(1)), TreasureElement(25, coins.Gold, dice.D20(1)), TreasureElement(5, Gem, dice.D4(1)), TreasureElement(5, Jewelry, dice.D4(1)), TreasureElement(2, RandomMagicItem, 1), ), TreasureRow( TreasureType.V, TreasureElement(25, coins.Silver, dice.D20(1)), TreasureElement(25, coins.Electrum, dice.D20(1)), TreasureElement(50, coins.Gold, dice.D20(1)), TreasureElement(25, coins.Platinum, dice.D20(1)), TreasureElement(10, Gem, dice.D4(1)), TreasureElement(10, Jewelry, dice.D4(1)), TreasureElement(5, RandomMagicItem, 1), ), ] inner_table = {row.treasure_type: row for row in rows} @classmethod def get_row(cls, treasure_type): """ :type treasure_type: TreasureType :rtype: TreasureRow """ return cls.inner_table.get(treasure_type)
def execute(cls, character, target_selection=None): hide_target = character.query.special_ability(MoveSilentlyAbility) value = dice.D100(1).roll_total() if value > hide_target: return False return True