Пример #1
0
def weapon_generation_test():
    Weapon.get_random_weapon()
    Weapon.get_random_weapon(0)
    Weapon.get_random_weapon(-1)
    Weapon.get_random_weapon(10000)
    for weapon_type in Weapon.weapon_types:
        Weapon.get_random_weapon(None, weapon_type)
Пример #2
0
 def __init__(self):
     Weapon.__init__(self)
     self.setName("Long Sword")
     self.setValue(200)
     self.setWeight(12)
     self.setDamage(20)
     self.setSpeed(6)
     self.setWeaponType(WeaponType.StraightSword)
     self.setDamageType(DamageType.Normal)
Пример #3
0
 def __init__(self):
     Weapon.__init__(self)
     self.setName("Rapier")
     self.setValue(240)
     self.setWeight(9)
     self.setDamage(16)
     self.setSpeed(7)
     self.setWeaponType(WeaponType.StraightSword)
     self.setDamageType(DamageType.Normal)
Пример #4
0
 def __init__(self):
     Weapon.__init__(self)
     self.setName("Broad Sword")
     self.setValue(180)
     self.setWeight(11)
     self.setDamage(17)
     self.setSpeed(6)
     self.setWeaponType(WeaponType.StraightSword)
     self.setDamageType(DamageType.Normal)
Пример #5
0
def main():
    blank_item = Item(name="Empty", description="", value=0)
    apple = HealingItem(name="Apple", description="Restores 7 HP", value=10, heals=7)
    old_dagger = Weapon(name="Old Dagger", description="Deals 9 damage", value=14, atk=9)
    pow_glove = Weapon(name="POW Glove", description="Deals 3 damage", value=6, atk=3)
    shield = Armor(name="Shield", description="Adds 7 DEF", value=10, defense=7)
    old_jacket = Armor(name="Old Jacket", description="It's just a jacket", value=3, defense=0)

    inventory = FixedList(size=8, fill=blank_item)
    player = Player(name="David", hp=20, xp=20, lv=1, atk=3, defense=0, weapon=pow_glove, armor=old_jacket, inventory=inventory)
    menu = Menu(player)
    player.inventory.append(apple)
    player.inventory.append(old_jacket)

    menu.open()
Пример #6
0
 def __init__(self,
              name,
              health=15,
              equipped_weapon=Weapon("Claws", "Sharp claws of an animal",
                                     [5, 10])):
     self.name = name
     self.health = health
     self.equipped_weapon = equipped_weapon
Пример #7
0
    def test_decide_drops(self):
        """
        Test the decide drops function by calling it multiple times until
        all the items drop
        """
        l_table = session.query(LootTableSchema).get(self.loot_table_entry)
        self.expected_item1 = Item(name='Linen Cloth',
                                   item_id=self.item_1,
                                   buy_price=1,
                                   sell_price=1)
        self.effect: BeneficialBuff = BeneficialBuff(name="Heart of a Lion",
                                                     buff_stats_and_amounts=[
                                                         ('strength', 15)
                                                     ],
                                                     duration=5)
        self.expected_item2 = Potion(name='Strength Potion',
                                     item_id=4,
                                     buy_price=1,
                                     sell_price=1,
                                     buff=self.effect,
                                     quest_id=0)
        self.expected_item3 = Weapon(name='Worn Axe',
                                     item_id=3,
                                     buy_price=1,
                                     sell_price=1,
                                     min_damage=2,
                                     max_damage=6,
                                     attributes={
                                         'bonus_health': 0,
                                         'bonus_mana': 0,
                                         'armor': 0,
                                         'strength': 0,
                                         'agility': 0
                                     })

        received_items_count = 0
        for _ in range(100):
            drops: [Item] = l_table.decide_drops()
            for drop in drops:
                equal_to_one_of_the_three_items = (
                    drop == self.expected_item1 or drop == self.expected_item2
                    or drop == self.expected_item3)
                self.assertTrue(equal_to_one_of_the_three_items)
                received_items_count += 1

        self.assertGreater(received_items_count, 10)
Пример #8
0
    def __init__(self, **kwargs):
        # Defaults:
        self.id = None
        self.name = 'unnamed character'
        self.strength = 1
        self.dexterity = 1
        self.stamina = 1
        self.brawl = 1
        self.armor_rating = 0
        self.injury_level = 0
        self.weapon = Weapon()
        self.x = 0
        self.y = 0
        self.z = 0
        self.inventory = set()
        for key, value in kwargs.items():
            setattr(self, key, value)

        # Derived stats:
        self.refresh()
Пример #9
0
    def __init__(self,
                 current_room=None,
                 inventory={},
                 equipped_weapon=Weapon('Fists', "Ye ol' left jab, right hook",
                                        [5, 10]),
                 health=20):
        self.name = None
        self.gender = None
        self.race = None
        self.current_room = current_room
        self.inventory = inventory
        self.equipped_weapon = equipped_weapon
        self.health = health
        self.last_action = None
        self.used_item = None

        # Run below methods to set up character
        self.select_name()
        self.select_race()
        self.select_gender()
Пример #10
0
    def __init__(self,
                 name: str,
                 level: int = 1,
                 health: int = 1,
                 mana: int = 1,
                 strength: int = 1,
                 agility: int = 1,
                 loaded_scripts: set = set(),
                 killed_monsters: set = set(),
                 completed_quests: set = set(),
                 saved_inventory: dict = {'gold': 0},
                 saved_equipment: dict = CHARACTER_DEFAULT_EQUIPMENT):
        super().__init__(name, health, mana, level=0)
        self.min_damage = 0
        self.max_damage = 1
        self.equipped_weapon = Weapon(name="Starter Weapon", item_id=0)
        self.experience = 0
        self.xp_req_to_level = 400
        self._bonus_health = 0
        self._bonus_mana = 0
        self._bonus_strength = 0
        self._bonus_armor = 0
        self.attributes: {str: int} = create_character_attributes_template()
        self._level_up(to_print=False)  # level up to 1
        if level > 1:
            self._level_up(to_level=level, to_print=False)

        self.current_zone = CHAR_STARTER_ZONE
        self.current_subzone = CHAR_STARTER_SUBZONE
        # holds the scripts that the character has seen (which should load only once)
        self.loaded_scripts: set() = loaded_scripts
        # holds the GUIDs of the creatures that the character has killed (and that should not be killable a second time)
        self.killed_monsters: set() = killed_monsters
        self.completed_quests: set(
        ) = completed_quests  # ids of the quests that the character has completed
        self.quest_log = {}
        self.inventory = saved_inventory  # dict Key: str, Value: tuple(Item class instance, Item Count)
        self.equipment = saved_equipment  # dict Key: Equipment slot, Value: object of class Equipment

        self._handle_load_saved_equipment(
        )  # add up the attributes for our saved_equipment
Пример #11
0
    def convert_to_item_object(self) -> Item:
        item_id: int = self.entry
        item_name: str = self.name
        item_type: str = self.type
        item_buy_price: int = parse_int(self.buy_price)
        item_sell_price: int = parse_int(self.sell_price)

        if item_type == 'misc':
            item_quest_id = self.quest_id
            return Item(name=item_name, item_id=item_id, buy_price=item_buy_price, sell_price=item_sell_price,
                        quest_id=item_quest_id)
        elif item_type in ['weapon', 'equipment']:
            item_health: int = parse_int(self.health)
            item_mana: int = parse_int(self.mana)
            item_armor: int = parse_int(self.armor)
            item_strength: int = parse_int(self.strength)
            item_agility: int = parse_int(self.agility)
            attributes: {str: int} = create_attributes_dict(bonus_health=item_health, bonus_mana=item_mana,
                                                            armor=item_armor, strength=item_strength,
                                                            agility=item_agility)
            if item_type == 'weapon':
                item_min_dmg: int = parse_int(self.min_dmg)
                item_max_dmg: int = parse_int(self.max_dmg)

                return Weapon(name=item_name, item_id=item_id, attributes=attributes,
                              buy_price=item_buy_price, sell_price=item_sell_price,
                              min_damage=item_min_dmg, max_damage=item_max_dmg)
            else:
                item_slot: str = self.sub_type

                return Equipment(name=item_name, item_id=item_id, slot=item_slot, attributes=attributes,
                                 buy_price=item_buy_price, sell_price=item_sell_price)
        elif item_type == 'potion':
            buff_id: int = self.effect
            item_buff_effect: 'BeneficialBuff' = load_buff(buff_id)

            return Potion(name=item_name, item_id=item_id, buy_price=item_buy_price, sell_price=item_sell_price,
                          buff=item_buff_effect)
        else:
            raise Exception(f'Unsupported item type {item_type}')
Пример #12
0
 def setUp(self):
     self.item_entry = 3
     self.name = 'Worn Axe'
     self.type = 'weapon'
     self.buy_price = 1
     self.attributes = {
         'bonus_health': 0,
         'bonus_mana': 0,
         'armor': 0,
         'strength': 0,
         'agility': 0
     }
     self.sell_price = 1
     self.quest_id = 0
     self.min_damage = 2
     self.max_damage = 6
     self.expected_item = Weapon(name=self.name,
                                 item_id=self.item_entry,
                                 buy_price=self.buy_price,
                                 sell_price=self.sell_price,
                                 min_damage=self.min_damage,
                                 max_damage=self.max_damage,
                                 attributes=self.attributes)
Пример #13
0
def main():
    welcome_print(GAME_VERSION)
    main_character = get_player_character()
    atexit.register(on_exit_handler, main_character)
    ZONES["Northshire Abbey"] = NorthshireAbbey(main_character)
    starter_weapon = Weapon(name="Starter Weapon",
                            item_id=0,
                            min_damage=1,
                            max_damage=3)
    main_character._equip_weapon(starter_weapon)
    print(f'Character {main_character.name} created!')

    zone_object = get_zone_object(main_character.current_zone)  # type: Zone

    alive_npcs, _ = zone_object.get_cs_npcs()
    alive_monsters, _ = zone_object.get_cs_monsters()

    print_live_npcs(zone_object, print_all=True)
    print_live_monsters(zone_object)

    # main game loop
    while True:
        route_main_commands(main_character, zone_object)
Пример #14
0
    #count num of items in slots array
    def __len__(self):
        return len(self.slots)

    def __contains__(self, item):
        return item in self.slots

    def __iter__(self):
        yield from self.slots
        #if item not in slots use this
        #yield also can be used and best instead return


#using item class
inventory = Inventory()
coin = Item('Coin', "A gold coin")
inventory.add(coin)
print(len(inventory))
print(coin.description)

#using weapon class
print("-----using weapon class-----")
sword = Weapon('Sword', 'Sharp and Shine', 500)
inventory.add(sword)

hammer = Weapon('Ham Burger', 'Its big cutter', 403)
inventory.add(hammer)

for i in inventory:
    print(i.description)
Пример #15
0
from Enemy import Enemy
from items import Weapon, HealingPotion, ManaPotion, StaminaPotion
import random

healing_potion = HealingPotion("Health potion", 30)
stamina_potion = HealingPotion("Stamina potion", 15)
mana_potion = HealingPotion("Mana potion", 20)

sword = Weapon("Flaming sword", 11, "slash")
cleaver = Weapon("BattleAxe", 13, "bash")
bow = Weapon("Ebony Bow", 14, "range")
staff = Weapon("Staff of Magus", 17, "staff")

potion = random.choice([healing_potion, stamina_potion, mana_potion])

enemy = Enemy("Slime", 10)
Пример #16
0
    world_map = Route()
    room = world_map.room

    # init a main character and have them start outside
    mainoc = Player(room["outside"], "Generic Playername")
    bag = PlayerBag(20, mainoc)

    # tring to make dry code since i know im going to need this
    # everytime i change a room
    def print_room():
        print("{} is in room {}, {}\n\n".format(mainoc.name, mainoc.room.name,
                                                mainoc.room.description))
        return

    # add a weapon
    great_sword = Weapon(10000.00)
    great_sword.name = "Great Sword"
    great_sword.price = 75000.00
    great_sword.weight = 120.00

    # add the wepon the the player bag
    bag.add(great_sword)

    # Main Loop
    DBG = True
    while True:
        # I want to make sure that i catch any straggler exceptions
        try:
            # print the current room then ask the user to imput a command
            print_room()
Пример #17
0
 def __init__(self, name, hp, inventory):
     self.name = name
     self.hp = hp
     self.inventory = [Weapon.Rock(), Heals.bandage()]
     self.x = 1
     self.y = 2
Пример #18
0
 def setUp(self):
     self.weapon = Weapon('iron blade', 'sword', 35)
Пример #19
0
    def __init__(self, player):
        self.player = player
        # Declare the items
        self.items = {
            'torch':
            Item('Torch', "A small torch used for lighting dark passages."),
            'treasure key':
            Item("Treasure Key",
                 "A glimmering gold key used to unlock the treasure room."),
        }
        # Declare the weapons
        self.weapons = {
            'small dagger':
            Weapon(
                "Small Dagger",
                "Just a basic dagger. Can be used to cause minimal damage. 10-15 dmg dealt.",
                dmg_range=[10, 15])
        }

        # Declare all the rooms
        self.room = {
            'outside':
            Room("Outside Cave Entrance",
                 "North of you, the cave mount beckons"),
            'foyer':
            Room("Foyer",
                 """Dim light filters in from the south. Dusty
        passages run north and east.""",
                 items={"torch": self.items['torch']}),
            'overlook':
            Room("Grand Overlook",
                 """A steep cliff appears before you, falling
        into the darkness. Ahead to the north, a light flickers in
        the distance, but there is no way across the chasm.""",
                 items={"treasure key": self.items['treasure key']}),
            'narrow':
            Room("Narrow Passage",
                 """The narrow passage bends here from west
        to north. A locked door blocks your way at the northern end. The smell of gold permeates the air.""",
                 items_useable={
                     "treasure key": self.items['treasure key'].name
                 }),
            'dark':
            Room(
                "Dark Room",
                """You find yourself surrounded by darkness. You are unable to 
        see any of your surroundings. You can either go back the way you came or figure out 
        how to light your way.""",
                items_useable={"torch": self.items['torch'].name}),
            'treasure':
            Room("Treasure Chamber",
                 """You've found the long-lost treasure
        chamber! Sadly, it has already been completely emptied by earlier explorers. The only exit is to the south.""",
                 items={"small dagger": self.weapons['small dagger']}),
        }

        # Link rooms together

        self.room['outside'].n_to = self.room['foyer']
        self.room['foyer'].s_to = self.room['outside']
        self.room['foyer'].n_to = self.room['overlook']
        self.room['foyer'].e_to = self.room['narrow']
        self.room['overlook'].s_to = self.room['foyer']
        self.room['narrow'].w_to = self.room['foyer']
        self.room['narrow'].n_to = self.room[
            'narrow']  # Default n_to for narrow set to narrow; need key to reset this.
        self.room['dark'].s_to = self.room['narrow']
        self.room['dark'].n_to = self.room[
            'dark']  # Default n_to for dark set to dark; need torch to reset this
        self.room['treasure'].s_to = self.room['narrow']

        # Set player's current location
        self.player.current_room = self.room['outside']
Пример #20
0
from thieves import Thief
from inventory import Inventory
from items import Item
from items import Weapon

charles = Thief(name="Charles", sneaky=False)
print(charles.sneaky)
print(charles.agile)
print(charles.hide(8))
print("\n\n")
print("Printing Class and Instance information using __str__.")
print(charles)

# instantiate an Item object
coin = Item('coin', 'a gold coin')

# instantiate an Inventory object
inventory = Inventory()
inventory.add(coin)

print("You have {} item(s) in your inventory.".format(len(inventory)))
if coin in inventory:
    print("You have a gold coin in your inventory.")

sword = Weapon('sword', '2h sharp sword', 50)
inventory = Inventory()
inventory.add(sword)
for item in inventory:
    print("Item Name: {} - Item Description: {}".format(
        item.name, item.description))
Пример #21
0
}

# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

items = {
    'sword':
    Weapon("sword", "An old sword, very rusty, will not last thru the winter"),
    'bow':
    Weapon("bow", "A worthless bow, looks like something out of a zelda game"),
    'book':
    Treasure("bible", "The most worthless of items a person could find"),
    'hair':
    Treasure("hair", "This item is still more useful than the bible"),
    'lamp':
    LightSource("lamp",
                "a cheap lamp from the dollar store, this wont last long")
}

# Link item to room
room['foyer'].addItem(items['sword'])
room['foyer'].addItem(items['bow'])
room['treasure'].addItem(items['book'])
Пример #22
0
 def load_game(cls, filename: str):
     with (Path(__file__).parent.parent / filename).open() as file:
         data = json.load(file)
     game_map = cls()
     for position, monster_data in data['monsters'].items():
         position = tuple(int(i) for i in position[1:-1].split(', '))
         monster = Monster(1)
         monster.strength = monster_data['strength']
         monster.name = monster_data['name']
         game_map.monsters[position] = monster
     for position, item_data in data['items'].items():
         position = tuple(int(i) for i in position[1:-1].split(', '))
         item = Consumable(1) if item_data['type'] == 'Keks' \
             else Equipment(1)
         item.name = item_data['name']
         item.factor = item_data['factor']
         item.type = item_data['type']
         game_map.items[position] = item
     game_map.starting_positions = [
         tuple(position) for position in data['starting_positions']
     ]
     game_map.levels = data['levels']
     head = data['player_items']['head']
     chest = data['player_items']['chest']
     legs = data['player_items']['legs']
     feet = data['player_items']['feet']
     weapon = data['player_items']['weapon']
     cookies = data['player_items']['cookies']
     game_map.player.head = head if not head else Equipment(1)
     if head:
         game_map.player.head.factor = head['factor']
         game_map.player.head.name = head['name']
         game_map.player.head.type = head['type']
     game_map.player.chest = chest if not chest else Equipment(1)
     if chest:
         game_map.player.chest.factor = chest['factor']
         game_map.player.chest.name = chest['name']
         game_map.player.chest.type = chest['type']
     game_map.player.legs = legs if not legs else Equipment(1)
     if legs:
         game_map.player.legs.factor = legs['factor']
         game_map.player.legs.name = legs['name']
         game_map.player.legs.type = legs['type']
     game_map.player.feet = feet if not feet else Equipment(1)
     if feet:
         game_map.player.feet.factor = feet['factor']
         game_map.player.feet.name = feet['name']
         game_map.player.feet.type = feet['type']
     game_map.player.weapon = weapon if not weapon else Weapon(1)
     if weapon:
         game_map.player.weapon.factor = weapon['factor']
         game_map.player.weapon.name = weapon['name']
         game_map.player.weapon.type = weapon['type']
     game_map.player.cookies = list()
     for cookie_data in cookies:
         cookie = Consumable(1)
         cookie.factor = cookie_data['factor']
         cookie.name = cookie_data['name']
         cookie.type = cookie_data['type']
         game_map.player.cookies.append(cookie)
     game_map.player.position._level = data['level']
     game_map.player.damage = data['damage']
     game_map._last_position = (data['last_position'][0],
                                data['last_position'][1])
     game_map.player.position._x = data['current_position'][0]
     game_map.player.position._y = data['current_position'][1]
     game_map.visited = [
         set(tuple(position) for position in level)
         for level in data['visited']
     ]
     game_map.seen = [
         set(tuple(position) for position in level)
         for level in data['seen']
     ]
     game_map.stories_shown = set(data['stories_shown'])
     return game_map
Пример #23
0
                       Exit(name='Prison cell door', goes_to=None, is_locked=True),
                       Exit(name='Rusty iron gate', goes_to=None, is_locked=True)
                   ],
                   monsters=[
                       Monster(name='Venomous spider', health=5, damage=1)
                   ],
                   items=[Key(name='Prison key', weight=1, unlocks_door=None)]),
 'prison_cell': Room(name='Prison cell',
                     exits=[Exit(name='Prison cell door', goes_to=None, is_locked=False)],
                     monsters=[
                         Monster(name='Frenzied boar', health=6, damage=2),
                         Monster(name='Ferocious wolf', health=4, damage=2),
                     ],
                     items=[
                         Key(name='Rusty iron key', weight=1, unlocks_door=None),
                         Weapon(name='Sharp axe', weight=6, damage=2),
                         Food(name='Leftovers', weight=2, health_points=2),
                     ]),
 'stairway': Room(name='Stairway',
                  exits=[
                      Exit(name='Rusty iron gate', goes_to=None, is_locked=False),
                      Exit(name='Terrace stairs', goes_to=None, is_locked=True)
                  ],
                  monsters=[
                      Monster(name='Bloodfury harpy', health=4, damage=2),
                      Monster(name='Killer croc', health=5, damage=3)
                  ],
                  items=[
                      Key(name='Terrace key', weight=1, unlocks_door=None),
                  ]),
 'terrace': Room(name='Terrace',
Пример #24
0
from items import Weapon

vorpal_blade = Weapon("WEP_VORPAL_BLADE", "Vorpal Blade", "Vorpal Blades",
                      True, 100, 100)
rusty_dagger = Weapon("WEP_RUSTY_DAGGER", "Rusty Dagger", "Rusty Daggers",
                      True, 1, 3)
rusty_spear = Weapon("WEP_RUSTY_SPEAR", "Rusty Spear", "Rusty Spears", True, 4,
                     6)
Пример #25
0
    'lounge-kitchen':
    Room.Exit(room_dict['kitchen'], room_dict['lounge'], False),
    'kitchen-conservatory':
    Room.Exit(room_dict['kitchen'], room_dict['conservatory'], True)
}

item_dict = {
    'key_safe_bedroom':
    Key.Key(container_dict['safe_kitchen'], 'key',
            container_dict['safe_bedroom']),
    'key_kitchen':
    Key.Key(container_dict['shelf'], 'key', exit_dict['hall-kitchen']),
    'key_conservatory':
    Key.Key(container_dict['table'], 'key', exit_dict['kitchen-conservatory']),
    'knife':
    Weapon.Weapon(room_dict['kitchen'], 'knife', 15),
    'knife_2':
    Weapon.Weapon(container_dict['body'], 'knife', 15),
    'bat':
    Weapon.Weapon(room_dict['lounge'], 'baseball bat', 35),
    'note':
    Item.Item(container_dict['body'], 'note')
}

container_dict['shelf'].desc = 'A set of white, wooden shelves.'
container_dict[
    'bed'].desc = 'A bed with a mutilated mattress. All the springs and most of the stuffing has been stripped away.'
container_dict['table'].desc = 'An intact 4-legged dining table.'
container_dict[
    'cupboards'].desc = 'Cupboards surround the room, although most have no doors and have had the hinges removed.'
container_dict[
Пример #26
0
from items import Item, Equipment, Armor, Weapon, Consumable, LoreItem, Book

### STARTER ITEMS
dagger = Weapon(name="Rusted Dagger", shorthand="dagger", slot="weapon", attack=10, strength=1, description="An old, rusty dagger.")
torch = Item(name="Torch", shorthand="torch", description="It's a torch. It looks like it hasn't been used for a while, but there's still oil on it.")
book = Book(name="Test Book", shorthand="book", description="An old, dusty book.", content=["Hello", "Page2", "3", "4", "5"])

outside_items = [dagger, book, torch]


## TIER ONE ITEMS (EASY TO GET)
sword = Weapon(name="Iron Shortsword", shorthand="sword", slot="weapon", attack=2.0, strength=4, description="An iron shortsword.")
axe = Weapon(name="Iron Axe", shorthand="axe", slot="weapon", attack=1.0, strength=7)
circlet = Armor(name="Iron Circlet", shorthand="circlet", slot="helmet", defense=2.0, strength=1)
tunic = Armor(name="Cloth Tunic", shorthand="tunic", slot="chest", defense=1.2, strength=0)
boots = Armor(name="Iron Boots", shorthand="boots", slot="feet", defense=1.2, strength=1)
buckler = Armor(name="Wooden Buckler", shorthand="buckler", slot="shield", defense=6, strength=-2)
gloves = Armor(name="Leather Gloves", shorthand="gloves", slot= "hands", defense=1.5, strength=2)
wristguards = Armor(name="Bronze Wristguards", shorthand="wristguards", slot="wrists", defense=1, strength=1)
biscuits = Consumable(name="Dog Biscuits", shorthand="biscuits", effect="I could give this to a dog at some point. Who knows?")
chalice = LoreItem(name="Chalice", shorthand="chalice", description="An old chalice, likely used for drinking ale or wine.")
skull = LoreItem(name="Skull", shorthand="skull", description="A human skull, with an arrowhead still stuck in the side.")
scale = LoreItem(name="Giant Scale", shorthand="scale", description="An absolutely massive scale. Just touching it sends a wave of warmth through your hand and up your arm, but it doesn't burn. Looks reptilian.")

items_list_tier_one = [sword, axe, circlet, tunic, boots, buckler, gloves, wristguards, biscuits, chalice, skull, scale]
items_list_tier_two = []
items_list_tier_three = []
Пример #27
0
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

# make some rooms lit
room['outside'].is_lit = True
room['foyer'].is_lit = True

# items

item = {
    'sword': Weapon("stick", "Sticky Stick", 10),
    'coins': Treasure("sack", "a small sack (wonder whats in it?)", 5),
    'lamp': LightSource("lamp", "Oil Lamp")
}

# add some items to the rooms

room['overlook'].contents.append(item['sword'])
room['overlook'].contents.append(item['coins'])
room['foyer'].contents.append(item['lamp'])

# # helper functions
# def try_a_direction(player, dir):
#     attribute = dir + '_to'

#     if hasattr(player.current_room, attribute):
Пример #28
0
'''Sample for turn based combat'''

from Player import Player, RPGPlayer
from monster import Monster
from items import Item, Weapon

monster = Monster(name='imp', hp=10, attack_min=3, attack_max=5,
                  armor=0, speed=0)

axe = Weapon(name='axe', min_damage=2,
             max_damage=5, stat='str')

player = RPGPlayer('warrior')

player.weapon = axe

player.combat(monster)

print('combat finished')
Пример #29
0
    def __contains__(self, item):
        return item in self.slots

    def __iter__(self):
        for item in self.slots:
            yield item

        # == yield from self.slots


# Make item
coin = Item('Coin', "A shiny coin")

# Make weapons
staff = Weapon('Staff', 'A magical staff', 35)
sword = Weapon('Staff', 'A sharp sword', 50)

# Make a bag and add the item
inventory = Inventory()
inventory.add(coin)
inventory.add(staff)

# Check amount of item in bag
print(sword in inventory)
print(coin in inventory)
print(len(inventory))

for item in inventory:
    print(item.description)
Пример #30
0
    'apple':
    Food('apple', 'a small to medium-sized conic apple', 'food', 1, 10),
    'bread':
    Food('bread', 'a slice of bread', 'food', 1, 10),
    'ring':
    Treasure('ring', 'a silver ring', 'treasure', 1, 50),
    'lamp':
    LightSource('lamp', 'a lamp', 'light source', 1, 50),
    'necklace':
    Treasure('necklace', 'a silver necklace', 'treasure', 1, 50),
    'bracelet':
    Treasure('bracelet', 'a silver bracelet', 'treasure', 1, 50),
    'largeTreasureChest':
    Treasure('bracelet', 'a large treasure chest', 'treasure', 1, 500),
    'sword':
    Weapon('sword', 'a large ninja katana', 'weapon', 10, 10),
    'knife':
    Weapon('knife', 'a rusty knife', 'weapon', 10, 7),
    'fist':
    Weapon('fist', 'your knuckles hardened by life', 'weapon', 1, 1),

    # 'shield': None,
    # 'helmet': None,
    # 'boots': None
}
"""where add stuff to the rooms"""
# add an apple to the outside room
# room['outside'].take('apple')
room['outside'].take(item_dict['apple'].name)
room['outside'].take(item_dict['apple'].name)
# room['outside'].take(item_dict['apple'].name)