Exemple #1
0
 def at_object_receive(self, obj, source_location):
     if utils.inherits_from(
             obj, "typeclasses.characters.Character") and self.tags.get(
                 "item", category='chargen'):
         spawn({
             "prototype": "DAGGER",
             "location": self
         }, {
             "prototype": "SIMPLE_ROBE",
             "location": self
         })
     if utils.inherits_from(
             obj, "typeclasses.characters.Character") and self.tags.get(
                 "coins", category='chargen'):
         transfer_funds(obj, 1000)
Exemple #2
0
def _buy_full_leather_armor(caller):
    full_leathers = {
        "key": "a full body suit of woven leather strips",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["armour", "armor"],
        "desc":
        "This suit of leather \"armor\" covers the whole body from ankles to neck but its long-term viability is questionable; it looks like it was made in a rush.",
        "wear_msg":
        "You wrap yourself up into a full body suit of woven leather strips.",
        "wear_msg_room_1":
        "wraps a full body suit of woven leather strips around",  # name
        "wear_msg_room_1": "body.",  # gender (his or her)
        "type": "armor",
        "armor_value": 8,
        "armor_type": "leather",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 11:
        caller.msg("You don't have enough silver - this costs 11 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 11
        caller.msg(
            "The shopkeeper hands you a suit of full leather armor in return for 11 silver sovereigns."
        )
        item = spawn(full_leathers, location=caller)
Exemple #3
0
def _buy_leaf_hoodie(caller):
    leaf_hoodie = {
        "key": "a woven green and grey, leaf-patterned cloak",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["hoodie"],
        "desc":
        "This woven green and grey cloak shows exceptional workmanship in its patterned leaves.",
        "wear_msg":
        "You sweep a woven green and grey, leaf-patterned cloak over your shoulders.",
        "wear_msg_room_1":
        "sweeps a woven green and grey, leaf-patterned cloak over",
        "wear_msg_room_2": "shoulders.",
        "type": "cloak",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 9:
        caller.msg("You don't have enough silver - this costs 9 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 9
        caller.msg(
            "The shopkeeper hands you a leather bandolier in return for 9 silver sovereigns."
        )
        item = spawn(leaf_hoodie, location=caller)
Exemple #4
0
def _buy_axe(caller):
    cold_iron_axe = {
        "key": "a cold iron axe",
        "typeclass": "typeclasses.arms.Weapons",
        "aliases": ["weapon"],
        "short_name": "iron axe",
        "desc":
        "This heavy axe is made from cold iron, making it affordable if somewhat heavy.\nThis weapon has the following attributes:\nOpen Terrain: +5, Cluttered Terrain: 0, Narrow Terrain: -5.\nBalance: Heavy.\nDamage: High.",
        "open_terrain": 5,
        "cluttered_terrain": 0,
        "narrow_terrain": -5,
        "damage_multiplier": 1.15,
        "balance_duration_change": 0.5,
        "weapon_type": "1haxe",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 7:
        caller.msg("You don't have enough silver - this costs 7 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 7
        caller.msg(
            "The shopkeeper hands you a cold iron axe in return for 7 silver sovereigns."
        )
        wpn = spawn(cold_iron_axe, location=caller)
Exemple #5
0
    def at_start(self):
        if not self.db.API_key:
            self.db.API_Key = 'e07c570e1f5f85a42dacce70bc6c63ce'

        if not self.db.fogmessage:
            self.db.fogmessage = ['A mist hangs over everything','The fog turns everything into murky shadows','You worry about your footing in the dense fog']
            self.db.clearmessage = ['The bright sky feels light and carefree','The energy of the earth refreshes you','A clear day','Sunlight warms your face','The trees are bright and green','You hear the laughter of undergrads','You wish you had a frisbee']
            self.db.cloudmessage = ['Clouds sweep across the sky.','A faint breeze is felt','A cloud in the distance reminds you of something','Tree branches creak and sway in the wind','A chill comes over you','You see a mountain in the distance']
            self.db.rainmessage = ['The rain falls heavily on the ground','The dark clouds are pregnant with rain','The ground is slick, be careful','Rain, rain, go away, come again some other day']
            self.db.snowmessage = ['White snow blankets the world','The cold bites at your face']
            self.db.raremessage = ['You feel a pang of nostalgia','A faint smell reminds you of your mother','The air tastes like metal','You feel hopeless and lost','The meaninglessness of existence overcomes you','There\'s some trash on the ground','There doesn\'t seem to be anyone around','You notice the hum of electricity. Has it always been there?','The wounds of your childhood ache']

        # search for veggies in room 
        veggies_in_room = [obj for obj in self.obj.contents_get() if utils.inherits_from(obj, objects.Vegetable)]
        # if not veggies in room
        if not veggies_in_room:
            prototype = random.choice(self.db.available_veggies)
            # use the spawner to create a new Vegetable from the spawner dictionary
            veggie = spawn(objects.VEGETABLE_PROTOTYPES[prototype], prototype_parents=objects.VEGETABLE_PROTOTYPES)[0]
            veggie.location = self.obj
            veggiestring = ("A %s ripens" % veggie)
            self.obj.msg_contents(veggiestring)
            self.obj.msg_contents("DATA,obj_add," + veggie + veggie.dbref)

        # if weather not set for room 
        if not self.db.cweather and self.db.location:
            loc = self.obj.db.location.split(',')
            # if location contains lat, lng
            if len(loc)==2:
                # Get Weather from Forecast.io
                forecast = forecastio.load_forecast(self.db.API_Key, loc[0], loc[1])
                # Extract and store current weather summary
                self.obj.cweather = forecast.currently().summary
Exemple #6
0
def _buy_gladius(caller):
    steel_gladius = {
        "key": "a sturdy steel gladius",
        "typeclass": "typeclasses.arms.Weapons",
        "aliases": ["sword", "weapon"],
        "short_name": "steel gladius",
        "desc":
        "This short sword is good for both stabbing and slashing. It is made from reliable steel and has leather wrapped about the handle above a round pomel.\nThis weapon has the following attributes:\nOpen Terrain: +3, Cluttered Terrain: +2, Narrow Terrain: 0.\nBalance: Neutral.\nDamage: Average.",
        "open_terrain": 3,
        "cluttered_terrain": 2,
        "narrow_terrain": 0,
        "damage_multiplier": 1.0,
        "balance_duration_change": 0.0,
        "weapon_type": "1hsword",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 9:
        caller.msg("You don't have enough silver - this costs 9 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 9
        caller.msg(
            "The shopkeeper hands you a sturdy steel gladius in return for 9 silver sovereigns."
        )
        wpn = spawn(steel_gladius, location=caller)
Exemple #7
0
def _buy_katana(caller):
    curved_katana = {
        "key": "a serrated steel katana",
        "typeclass": "typeclasses.arms.Weapons",
        "aliases": ["sword", "weapon"],
        "short_name": "curved katana",
        "desc":
        "This long, curved but thin sword is made from sturdy steel. It has to be due to its unique shape, otherwise it would break too easily in combat. It looks as if it could deal heavy damage, provided there is enough room to wield it properly.\nThis weapon has the following attributes:\nOpen Terrain: +10, Cluttered Terrain: -5, Narrow Terrain: 0.\nBalance: Very heavy.\nDamage: Very high.",
        "open_terrain": 10,
        "cluttered_terrain": -5,
        "narrow_terrain": 0,
        "damage_multiplier": 1.25,
        "balance_duration_change": 1.0,
        "weapon_type": "2hsword",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 14:
        caller.msg("You don't have enough silver - this costs 14 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 14
        caller.msg(
            "The shopkeeper hands you a serrated steel katana in return for 10 silver sovereigns."
        )
        wpn = spawn(curved_katana, location=caller)
Exemple #8
0
def _buy_broadsword(caller):
    bronze_broadsword = {
        "key": "a ruddy bronze broadsword",
        "typeclass": "typeclasses.arms.Weapons",
        "aliases": ["sword", "weapon"],
        "short_name": "ruddy bronze broadsword",
        "desc":
        "This sharp, thick broadsword is made from fine, if expensive bronze.\nThis weapon has the following attributes:\nOpen Terrain: +3, Cluttered Terrain: +2, Narrow Terrain: 0.\nBalance: Neutral.\nDamage: Average.",
        "open_terrain": 3,
        "cluttered_terrain": 2,
        "narrow_terrain": 0,
        "damage_multiplier": 1.0,
        "balance_duration_change": 0.0,
        "weapon_type": "1hsword",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 10:
        caller.msg("You don't have enough silver - this costs 10 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 10
        caller.msg(
            "The shopkeeper hands you a ruddy bronze broadsword in return for 10 silver sovereigns."
        )
        wpn = spawn(bronze_broadsword, location=caller)
Exemple #9
0
def _buy_spear(caller):
    hunters_spear = {
        "key": "a long hunter's spear",
        "typeclass": "typeclasses.arms.Weapons",
        "aliases": ["weapon"],
        "short_name": "hunter's spear",
        "desc":
        "This light spear has a sharp steel tip, as well as a leather strap for being secured when carrying and a leather cover for the head.\nThis weapon has the following attributes:\nOpen Terrain: 0, Cluttered Terrain: 0, Narrow Terrain: +10.\nBalance: Light.\nDamage: Low.",
        "open_terrain": 0,
        "cluttered_terrain": 0,
        "narrow_terrain": 10,
        "damage_multiplier": 0.85,
        "balance_duration_change": -1,
        "weapon_type": "1hspear",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 6:
        caller.msg("You don't have enough silver - this costs 6 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 6
        caller.msg(
            "The shopkeeper hands you a long hunter's spear in return for 6 silver sovereigns."
        )
        wpn = spawn(hunters_spear, location=caller)
Exemple #10
0
def _buy_dagger(caller):
    cheap_dagger = {
        "key": "a cheap iron dagger",
        "typeclass": "typeclasses.arms.Weapons",
        "aliases": ["weapon"],
        "short_name": "iron dagger",
        "desc":
        "This \"happy\" iron dagger is heavier than it looks but would a useful weapon in close quarters.\nThis weapon has the following attributes:\nOpen Terrain: -5, Cluttered Terrain: +10, Narrow Terrain: 0.\nBalance: Very light.\nDamage: Very low.",
        "open_terrain": -5,
        "cluttered_terrain": 10,
        "narrow_terrain": 0,
        "damage_multiplier": 0.70,
        "balance_duration_change": -1.5,
        "weapon_type": "dagger",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 4:
        caller.msg("You don't have enough silver - this costs 4 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 4
        caller.msg(
            "The shopkeeper hands you a cheap iron dagger in return for 4 silver sovereigns."
        )
        wpn = spawn(cheap_dagger, location=caller)
Exemple #11
0
    def at_start(self):
        """handles the phases of death"""
        super(CharDeathHandler, self).at_start()
        self.obj.msg("you have died")
        self.obj.location.msg_contents('{character} falls to the ground dead.',
                                       mapping={'character': self.obj},
                                       exclude=self.obj)
        self.obj.traits.XP.current -= int(floor(0.15 * self.obj.traits.XP.current))
        corpse_name = 'corpse of %s' % self.obj
        corpse_desc = "A dead body that was once %s in life." % self.obj
        corpse_proto = {'key': corpse_name, "desc": corpse_desc}
        corpse = spawn(corpse_proto)[0]
        corpse.location = self.obj.location
        for i in self.obj.equip:
            self.obj.equip.remove(i)
        for i in self.obj.contents:
            dest_chance = randint(1, 100)
            if dest_chance <= 15:
                i.delete
            else:
                i.move_to(corpse, quiet=True)

        void = self.obj.search('Void', global_search=True)
        self.obj.move_to(void, quiet=True, move_hooks=False)
        #create a corpse of the character that died Corpse of {character}
        #move the equipped,worn and inventory of character that died to corpse
        #check over each item to see what survives remove destroyed items
        delay(20, getattr(self, self.db.death_sequence[self.db.death_step]))
Exemple #12
0
def _buy_human_female_armor(caller):
    female_newbie_armor = {
        "key": "some revealing leather armor that doesn't protect very much",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["armour"],
        "desc":
        "This suit of armor looks like it was made as a joke, or perhaps by someone who didn't intend to use it in a fight. Most of the chest and back are fully exposed and it doesn't cover the legs at all.",
        "wear_msg": "You squeeze into a revealing suit of leather \"armor.\"",
        "wear_msg_room_1":
        "squeezes into a scuffed suit of leather \"armor.\"",  # name
        "type": "armor",
        "armor_value": 8,
        "armor_type": "leather",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 10:
        caller.msg("You don't have enough silver - this costs 10 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 10
        caller.msg(
            "The shopkeeper hands you some revealing leather armor in return for 10 silver sovereigns."
        )
        item = spawn(female_newbie_armor, location=caller)
Exemple #13
0
 def func(self):
     bed = self.caller.search(self.args.strip())
     if not bed:
         self.caller.msg("What did you want to harvest from?")
     elif type(bed) != HydroponicBed:
         self.caller.msg("You can't harvest from that!")
     elif not bed.db.planted:
         self.caller.msg("You cannot reap what you don't sow.")
     elif not bed.db.grown:
         self.caller.msg("It's not ready to harvest yet.")
     else:
         self.caller.msg("You harvest the {produce} from the {bed}".format(
             produce=bed.db.produce.lower(),
             bed=bed))
         self.caller.location.msg_contents("{} harvests the {} from the {}".format(
             self.caller,
             bed.db.produce.lower(),
             bed
         ),
             exclude=self.caller
         )
         bed.db.grown = False
         bed.db.planted = False
         bed.db.desc = bed.db.saved_desc
         produce = spawn(PRODUCE_LIST[bed.db.produce])
         produce[0].location = self.caller
Exemple #14
0
 def assign_room(self):
     """
     Spawn a new home room for this character.
     Set locks:  set "owner" to edit/control lock,
     set owner's home there, (self.home = there)
     set owner's home room there.
         (self.db.objects['home'] = there)
     Move owner there?
     """
     # Spawn a new room with locks:
     home_room_name = self.name + "'s place"
     home_room_desc = settings.HOME_ROOM_DESC
     home_room_locks = 'control:id({0}) or perm(wizard);edit:id({0}) ' \
                       'or perm(helpstaff)'.format(self.id)
     home_room_tags = [('private', 'flags')]
     home_room = {
         'typeclass': 'typeclasses.rooms.Room',
         'key': home_room_name,
         'desc': home_room_desc,
         'locks': home_room_locks,
         'tags': home_room_tags
     }
     from evennia.utils.spawner import spawn  # Import the spawn utility just before using it.
     room = spawn(
         home_room)  # Calling spawn utility to create the home room.
     return room[0]  # Return the first (and only) object created, the room.
Exemple #15
0
def _buy_human_male_armor(caller):
    male_newbie_armor = {
        "key": "some scuffed leather armor with an overly high and tight neck",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["armour"],
        "desc":
        "This suit of armor looks sturdy enough but it was either made for a very strangely proportioned person or some error happened during its fabrication.  This is clear because the neck is strangely small and too tall.",
        "wear_msg": "You squeeze into a scuffed suit of leather armor.",
        "wear_msg_room_1":
        "squeezes into a scuffed suit of leather armor.",  # name
        "type": "armor",
        "armor_value": 8,
        "armor_type": "leather",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 10:
        caller.msg("You don't have enough silver - this costs 10 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 10
        caller.msg(
            "The shopkeeper hands you some scuffed leather armor in return for 10 silver sovereigns."
        )
        item = spawn(male_newbie_armor, location=caller)
    def setUp(self):
        settings.PROTOTYPE_MODULES = ainneve_settings.PROTOTYPE_MODULES
        self.character_typeclass = Character
        self.object_typeclass = NPC
        self.room_typeclass = Room
        self.script_typeclass = CombatHandler
        super(AinneveCombatTest, self).setUp()
        # create weapons for the fight
        self.melee = spawn({'prototype': 'SHORT_SWORD',
                            'location': self.room1},
                           prototype_modules=('world.content.prototypes_weapons',))[0]
        self.reach = spawn({'prototype': 'PIKE_POLEARM',
                            'location': self.room1},
                           prototype_modules=('world.content.prototypes_weapons',))[0]
        self.ranged = spawn({'prototype': 'LONG_BOW',
                             'location': self.room1},
                            prototype_modules=('world.content.prototypes_weapons',))[0]
        self.arrows = spawn({'prototype': 'ARROW_BUNDLE',
                             'location': self.room1},
                            prototype_modules=('world.content.prototypes_weapons',))[0]
        # set up chars
        sample_char(self.char1, 'warrior', 'human', 'cunning')
        self.char1.traits.ATKM.base = self.char1.traits.ATKR.base = self.char1.traits.ATKU.base = 5
        sample_char(self.char2, 'warrior', 'human', 'cunning')
        self.char2.traits.HP.base = self.char2.traits.HP.current = 10
        # one additional NPC
        self.obj3 = create.create_object(self.object_typeclass, key="Obj3", location=self.room1, home=self.room1)

        # set sdescs to key for testing
        self.char1.sdesc.add(self.char1.key)
        self.char2.sdesc.add(self.char2.key)
        self.obj1.sdesc.add(self.obj1.key)
        self.obj2.sdesc.add(self.obj2.key)
        self.obj3.sdesc.add(self.obj3.key)
        # use mock msg methods
        self.char1.msg = Mock()
        self.char2.msg = Mock()
        self.obj1.msg = Mock()
        self.obj2.msg = Mock()
        self.obj3.msg = Mock()
        # add combatants
        self.script.add_character(self.char1)
        self.script.add_character(self.char2)
        self.script.add_character(self.obj1)
        self.script.add_character(self.obj2)
        self.script.add_character(self.obj3)
Exemple #17
0
    def forge_three(self):

        if self.recipe in weapon_list:
            spawn(self.weapon_proto)
        elif self.recipe in armor_list:
            spawn(self.armor_proto)

        caller = self.caller
        caller.msg("|511You succeed in forging a {material} {recipe}|n".format(
            material=self.material,
            recipe=RECIPES.get(self.recipe).get("key")))

        caller.location.msg_contents(
            "|511{actor} succeeds in forging a {material}{recipe}|n",
            mapping=dict(actor=caller,
                         material=self.material,
                         recipe=RECIPES.get(self.recipe).get("key")),
            exclude=caller)
Exemple #18
0
    def at_repeat(self):

        newspaper_in_room = [obj for obj in self.obj.contents_get() if utils.inherits_from(obj, objects.Newspaper)]

        if not newspaper_in_room:
            "newspaper spawned if less than threshold in library"
            prototype = random.choice(self.db.available_newspaper)  # randomly choose a newspaper edition(for now)
            # use the spawner to create a new Newspaper from the spawner dictionary based on type chosen in prototype
            newspaper = spawn(objects.NEWSPAPER_PROTOTYPES[prototype], prototype_parents=objects.NEWSPAPER_PROTOTYPES)[0]
            newspaper.location = self.obj
            newspaperstring = ("The newspaper man drop the latest %s" % newspaper)
            self.obj.msg_contents(newspaperstring)
            self.obj.msg_contents("DATA,obj_add," + newspaper + newspaper.dbref)
Exemple #19
0
    def func(self):

        veg = self.args.strip()
        veg = self.caller.search(veg)
        if not veg:
            self.caller.msg("What do you want to grate?")
        elif type(veg) != Vegetable:
            self.caller.msg("That's not a vegetable!")
        elif veg.db.produce.upper() not in prototypes.EDIBLEVEGS:
            self.caller.msg("You don't know how to prepare that vegetable.")
        else:
            self.caller.msg("You chop up the {}".format(veg.key.lower()))
            self.caller.location.msg_contents("{} chops up the {}".format(
                self.caller,
                veg.key.lower()
            ),
                exclude=self.caller
            )

            food = spawn(prototypes.proto(veg.db.produce))[0]
            seed = spawn(prototypes.proto(veg.db.seed))[0]
            veg.delete()
            seed.location = self.caller
            food.location = self.caller
Exemple #20
0
 def produce_weapon(self, caller):
     """
     This will produce a new weapon from the rack,
     assuming the caller hasn't already gotten one. When
     doing so, the caller will get Tagged with the id
     of this rack, to make sure they cannot keep
     pulling weapons from it indefinitely.
     """
     rack_id = self.db.rack_id
     if caller.tags.get(rack_id, category="tutorial_world"):
         caller.msg(self.db.no_more_weapons_msg)
     else:
         prototype = random.choice(self.db.available_weapons)
         # use the spawner to create a new Weapon from the
         # spawner dictionary, tag the caller
         wpn = spawn(WEAPON_PROTOTYPES[prototype], prototype_parents=WEAPON_PROTOTYPES)[0]
         caller.tags.add(rack_id, category="tutorial_world")
         wpn.location = caller
         caller.msg(self.db.get_weapon_msg % wpn.key + "[REWARD_weapon = 5]")
Exemple #21
0
 def produce_weapon(self, caller):
     """
     This will produce a new weapon from the rack,
     assuming the caller hasn't already gotten one. When
     doing so, the caller will get Tagged with the id
     of this rack, to make sure they cannot keep
     pulling weapons from it indefinitely.
     """
     rack_id = self.db.rack_id
     if caller.tags.get(rack_id, category="tutorial_world"):
         caller.msg(self.db.no_more_weapons_msg)
     else:
         prototype = random.choice(self.db.available_weapons)
         # use the spawner to create a new Weapon from the
         # spawner dictionary, tag the caller
         wpn = spawn(WEAPON_PROTOTYPES[prototype], prototype_parents=WEAPON_PROTOTYPES)[0]
         caller.tags.add(rack_id, category="tutorial_world")
         wpn.location = caller
         caller.msg(self.db.get_weapon_msg % wpn.key)
Exemple #22
0
 def at_defact(self, caller):
     """
     This will produce a new newspaper from the rack,
     assuming the caller hasn't already gotten one. When
     doing so, the caller will get Tagged with the id
     of this rack, to make sure they cannot keep
     pulling newspapers from it indefinitely.
     """
     rack_id = self.db.rack_id
     if caller.tags.get(rack_id, category="tutorial_world"):
         caller.msg(self.db.no_more_newspapers_msg)
     else:
         prototype = random.choice(self.db.available_newspapers)
         # use the spawner to create a new Newspaper from the
         # spawner dictionary
         newspaper = spawn(NEWSPAPER_PROTOTYPES[prototype], prototype_parents=NEWSPAPER_PROTOTYPES)[0]
         # caller.tags.add(rack_id, category="tutorial_world")  # tag the caller so as to track if already got newspaper
         newspaper.location = caller
         caller.msg(self.db.get_newspaper_msg % newspaper.key)
Exemple #23
0
    def at_repeat(self):
        "called every self.interval seconds."

        # Atmosphere
        if (random.randint(1,20) == 1):
            target = random.choice(self.obj.contents)
            target.msg(random.choice(self.db.raremessage))

        # Weather
        weathermessage = 'A clear day'

        # if outdoor and room has cweather set
        if self.obj.db.roomtype_key != 'building' and self.obj.db.cweather:
            "weather updates if outdoors"
            # trigger random message of type found from last weather summary of room
            if 'Haze' in self.obj.db.cweather or 'Fog' in self.obj.db.cweather:
                weathermessage = random.choice(self.db.fogmessage)
            elif 'Clear' in self.obj.db.cweather:
                weathermessage = random.choice(self.db.clearmessage)
            elif 'Cloud' in self.obj.db.cweather or 'Overcast' in self.obj.db.cweather:
                weathermessage = random.choice(self.db.cloudmessage)
            elif 'Rain' in self.obj.db.cweather or 'Thunder' in self.obj.db.cweather or 'thunder' in self.obj.db.cweather or 'Drizzle' in self.obj.db.cweather:
                weathermessage = random.choice(self.db.rainmessage)
            elif 'Snow' in self.obj.db.cweather or 'snow' in self.obj.db.cweather or 'flurry' in self.obj.db.cweather:
                weathermessage = random.choice(self.db.snowmessage)

            # send this message to everyone inside the object this script is attached to (likely a room)
            self.obj.msg_contents(weathermessage)


        # Vegetable Spawning
        veggies_in_room = [obj for obj in self.obj.contents_get() if utils.inherits_from(obj, objects.Vegetable)]

        if self.obj.db.roomtype_key != 'building' and not veggies_in_room:
            "vegetables spawned if less than threshold in farms"
            prototype = random.choice(self.db.available_veggies)
            # use the spawner to create a new Vegetable from the spawner dictionary
            veggie = spawn(objects.VEGETABLE_PROTOTYPES[prototype], prototype_parents=objects.VEGETABLE_PROTOTYPES)[0]
            veggie.location = self.obj
            veggiestring = ("A %s ripens" % veggie)
            self.obj.msg_contents(veggiestring)
            self.obj.msg_contents("DATA,obj_add," + veggie + veggie.dbref)
Exemple #24
0
 def at_repeat(self):
     for obj in self.obj.location.contents:
         if obj.name == "Robot Log":
             self.obj.execute_cmd("get Robot Log")
             self.obj.db.has_robot_log = True 
     if self.obj.db.has_robot_log:
         if self.db.current_log_index < 5:
             message = self.db.after_log_messages[self.db.current_log_index]
             self.obj.execute_cmd("say %s" % message)
             if self.db.current_log_index == 2:
                 spanner = spawn(objects.WEAPON_PROTOTYPES["quantum spanner"], prototype_parents=objects.WEAPON_PROTOTYPES)[0]
                 self.obj.location.msg_contents("DATA,obj_add," + spanner.name + spanner.dbref)
                 spanner.location = self.obj.location
             self.db.current_log_index += 1
         else:
             self.obj.db.HP = 0
             self.stop()
     else:
         message = random.choice(self.db.no_log_messages)
         self.obj.execute_cmd("say %s" % message)
Exemple #25
0
def _buy_grey_trousers(caller):
    grey_trousers = {
        "key": "plain grey woolen trousers",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["pants"],
        "desc": "These grey woolen trousers look sturdy and warm.",
        "wear_msg": "You pull on a pair of plain grey woolen trousers.",
        "wear_msg_room_1": "pulls on a pair of plain grey woolen trousers.",
        "type": "pants",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 5:
        caller.msg("You don't have enough silver - this costs 5 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 5
        caller.msg(
            "The shopkeeper hands you a leather bandolier in return for 5 silver sovereigns."
        )
        item = spawn(grey_trousers, location=caller)
Exemple #26
0
def _buy_laced_boots(caller):
    laced_boots = {
        "key": "laced up leather boots",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["shoes"],
        "desc": "These leather boots have a lot of laces for a firm grip.",
        "wear_msg": "You lace up a pair of leather boots.",
        "wear_msg_room_1": "laces up a pair of leather boots.",
        "type": "shoes",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 6:
        caller.msg("You don't have enough silver - this costs 6 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 6
        caller.msg(
            "The shopkeeper hands you some laced leather boots in return for 6 silver sovereigns."
        )
        item = spawn(laced_boots, location=caller)
Exemple #27
0
def _buy_black_hoodie(caller):
    black_hoodie = {
        "key": "a long hooded black cloak",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["hoodie"],
        "desc": "This long black hoodie cloak looks dramatic, so dramatic.",
        "wear_msg": "You sweep a hooded black cloak over your shoulders.",
        "wear_msg_room_1": "sweeps a hooded black cloak over",  # name
        "wear_msg_room_2": "shoulders.",  # his or her
        "type": "cloak",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 7:
        caller.msg("You don't have enough silver - this costs 7 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 7
        caller.msg(
            "The shopkeeper hands you a long hooded black cloak in return for 7 silver sovereigns."
        )
        item = spawn(black_hoodie, location=caller)
Exemple #28
0
def _buy_white_breeches(caller):
    white_leather_breeches = {
        "key": "white leather riding breeches",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["pants"],
        "desc":
        "These white leather breeches look sturdy, if not sturdy enough to act as armor.",
        "wear_msg": "You pull on a pair of white leather riding breeches.",
        "wear_msg_room_1": "pulls on a pair of white leather riding breeches.",
        "type": "pants",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 8:
        caller.msg("You don't have enough silver - this costs 8 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 8
        caller.msg(
            "The shopkeeper hands you a leather bandolier in return for 8 silver sovereigns."
        )
        item = spawn(white_leather_breeches, location=caller)
Exemple #29
0
def _buy_black_breeches(caller):
    black_silk_breeches = {
        "key": "black silken riding breeches",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["pants"],
        "desc":
        "These black silken breeches look good but might not stand up well to time.",
        "wear_msg": "You pull on a pair of black silken riding breeches.",
        "wear_msg_room_1": "pulls on a pair of black silken riding breeches.",
        "type": "pants",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 9:
        caller.msg("You don't have enough silver - this costs 9 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 9
        caller.msg(
            "The shopkeeper hands you a leather bandolier in return for 9 silver sovereigns."
        )
        item = spawn(black_silk_breeches, location=caller)
Exemple #30
0
def _buy_steel_toed_boots(caller):
    steel_toed_boots = {
        "key": "steel toed leather boots",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["shoes"],
        "desc": "These steel-toed leather boots look very sturdy!",
        "wear_msg": "You squeeze into a pair of steel-toed leather boots.",
        "wear_msg_room_1": "squeezes a pair of steel-toed leather boots onto",
        "wear_msg_room_2": "feet.",
        "type": "shoes",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 8:
        caller.msg("You don't have enough silver - this costs 8 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 8
        caller.msg(
            "The shopkeeper hands you some steel toed leather boots in return for 8 silver sovereigns."
        )
        item = spawn(steel_toed_boots, location=caller)
Exemple #31
0
def _buy_red_silken_scarf(caller):
    red_silken_scarf = {
        "key": "a red silken scarf",
        "typeclass": "typeclasses.clothing.Clothes",
        # "aliases" : ["scarf"],
        "desc": "This red silken scarf looks stylish!",
        "wear_msg": "You wrap a red silken scarf around your neck.",
        "wear_msg_room_1": "wraps a red silken scarf around",
        "wear_msg_room_2": "neck.",
        "type": "scarf",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 8:
        caller.msg("You don't have enough silver - this costs 8 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 8
        caller.msg(
            "The shopkeeper hands you a red silken scarf in return for 8 silver sovereigns."
        )
        item = spawn(red_silken_scarf, location=caller)
Exemple #32
0
def _buy_grey_scarf(caller):
    grey_scarf = {
        "key": "a grey woolen scarf",
        "typeclass": "typeclasses.clothing.Clothes",
        # "aliases" : ["scarf"],
        "desc": "This simple grey woolen scarf looks warm indeed!",
        "wear_msg": "You wrap a grey woolen scarf around your neck.",
        "wear_msg_room_1": "wraps a grey woolen scarf around",
        "wear_msg_room_2": "neck.",
        "type": "scarf",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 3:
        caller.msg("You don't have enough silver - this costs 3 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 3
        caller.msg(
            "The shopkeeper hands you a grey woolen scarf in return for 3 silver sovereigns."
        )
        item = spawn(grey_scarf, location=caller)
Exemple #33
0
def _buy_red_hoodie(caller):
    red_hoodie = {
        "key": "a hooded scarlet cloak",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["hoodie"],
        "desc": "This fine scarlet cloak must have cost quite a bit!",
        "wear_msg": "You sweep a hooded scarlet cloak over your shoulders.",
        "wear_msg_room_1": "sweeps a hooded scarlet cloak over",
        "wear_msg_room_2": "shoulders.",
        "type": "cloak",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 8:
        caller.msg("You don't have enough silver - this costs 8 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 8
        caller.msg(
            "The shopkeeper hands you a leather bandolier in return for 8 silver sovereigns."
        )
        item = spawn(red_hoodie, location=caller)
Exemple #34
0
def _buy_dwarven_girdle(caller):
    sturdy_dwarven_girdle = {
        "key": "a sturdy dwarven weapon girdle",
        "typeclass": "typeclasses.clothing.Clothes",
        # "aliases" : ["armour"],
        "desc":
        "This sturdy girdle acts as a belt, bodily protection and a place to affix sheaths or other kinds of equipment onto the body. It includes some efficient-looking leather suspenders to help support the weight.",
        "wear_msg": "You strap on a sturdy dwarven weapon girdle.",
        "wear_msg_room_1": "straps on a sturdy dwarven weapon girdle.",  # name
        "type": "girdle",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 8:
        caller.msg("You don't have enough silver - this costs 8 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 8
        caller.msg(
            "The shopkeeper hands you a sturdy dwarven girdle in return for 8 silver sovereigns."
        )
        item = spawn(sturdy_dwarven_girdle, location=caller)
Exemple #35
0
def _buy_white_hoodie(caller):
    white_hoodie = {
        "key": "a snowy white cloak",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["hoodie"],
        "desc": "This snowy white hoodie cloak looks pretty, so pretty.",
        "wear_msg": "You sweep a snowy white cloak over your shoulders.",
        "wear_msg_room_1": "sweeps a snowy white cloak over",
        "wear_msg_room_2": "shoulders.",
        "type": "cloak",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 7:
        caller.msg("You don't have enough silver - this costs 7 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 7
        caller.msg(
            "The shopkeeper hands you a snowy white cloak in return for 7 silver sovereigns."
        )
        item = spawn(white_hoodie, location=caller)
Exemple #36
0
def _buy_leather_bandolier(caller):
    bandolier_girdle = {
        "key": "a leather bandolier",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["girdle"],
        "desc":
        "This sturdy bandolier goes over the shoulder instead of around the waste, but otherwise performs the same purpose that a weapon girdle would, to hold sheaths for weapons.",
        "wear_msg": "You strap on a leather tool belt and weapon girdle.",
        "wear_msg_room_1":
        "straps on a leather tool belt and  weapon girdle.",  # name
        "type": "girdle",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 7:
        caller.msg("You don't have enough silver - this costs 7 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 7
        caller.msg(
            "The shopkeeper hands you a leather bandolier in return for 7 silver sovereigns."
        )
        item = spawn(bandolier_girdle, location=caller)
Exemple #37
0
def _buy_riding_hoodie(caller):
    riding_hoodie = {
        "key": "a hooded red riding cloak",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["hoodie"],
        "desc":
        "This hooded red cloak looks like it has seen the road before.",
        "wear_msg": "You sweep a hooded red riding cloak over your shoulders.",
        "wear_msg_room_1": "sweeps a hooded red riding cloak over",
        "wear_msg_room_2": "shoulders.",
        "type": "cloak",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 6:
        caller.msg("You don't have enough silver - this costs 6 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 6
        caller.msg(
            "The shopkeeper hands you a hooded red riding cloak in return for 6 silver sovereigns."
        )
        item = spawn(riding_hoodie, location=caller)
Exemple #38
0
def _buy_wooden_sandals(caller):
    wooden_sandals = {
        "key": "sturdy wooden sandals",
        "typeclass": "typeclasses.clothing.Clothes",
        "aliases": ["shoes"],
        "desc":
        "These sturdy wooden sandals make the wearer look a bit taller",
        "wear_msg": "You don a pair of sturdy wooden sandals.",
        "wear_msg_room_1": "straps a pair of sturdy wooden sandals to",
        "wear_msg_room_2": "feet.",
        "type": "shoes",
        "location": caller,
        "birth_time": time.time(),
        "duration": 2000000.0
    }

    if caller.db.silver_carried < 5:
        caller.msg("You don't have enough silver - this costs 5 silver!")
    else:
        caller.db.silver_carried = caller.db.silver_carried - 5
        caller.msg(
            "The shopkeeper hands you a leather bandolier in return for 5 silver sovereigns."
        )
        item = spawn(wooden_sandals, location=caller)
Exemple #39
0
    def setUp(self):
        settings.PROTOTYPE_MODULES = ainneve_settings.PROTOTYPE_MODULES
        self.character_typeclass = Character
        self.object_typeclass = NPC
        self.room_typeclass = Room
        self.script_typeclass = CombatHandler
        super(AinneveCombatTest, self).setUp()
        # create weapons for the fight
        self.melee = spawn(
            {
                'prototype': 'SHORT_SWORD',
                'location': self.room1
            },
            prototype_modules=('world.content.prototypes_weapons', ))[0]
        self.reach = spawn(
            {
                'prototype': 'PIKE_POLEARM',
                'location': self.room1
            },
            prototype_modules=('world.content.prototypes_weapons', ))[0]
        self.ranged = spawn(
            {
                'prototype': 'LONG_BOW',
                'location': self.room1
            },
            prototype_modules=('world.content.prototypes_weapons', ))[0]
        self.arrows = spawn(
            {
                'prototype': 'ARROW_BUNDLE',
                'location': self.room1
            },
            prototype_modules=('world.content.prototypes_weapons', ))[0]
        # set up chars
        sample_char(self.char1, 'warrior', 'human', 'cunning')
        self.char1.traits.ATKM.base = self.char1.traits.ATKR.base = self.char1.traits.ATKU.base = 5
        sample_char(self.char2, 'warrior', 'human', 'cunning')
        self.char2.traits.HP.base = self.char2.traits.HP.current = 10
        # one additional NPC
        self.obj3 = create.create_object(self.object_typeclass,
                                         key="Obj3",
                                         location=self.room1,
                                         home=self.room1)

        # set sdescs to key for testing
        self.char1.sdesc.add(self.char1.key)
        self.char2.sdesc.add(self.char2.key)
        self.obj1.sdesc.add(self.obj1.key)
        self.obj2.sdesc.add(self.obj2.key)
        self.obj3.sdesc.add(self.obj3.key)
        # use mock msg methods
        self.char1.msg = Mock()
        self.char2.msg = Mock()
        self.obj1.msg = Mock()
        self.obj2.msg = Mock()
        self.obj3.msg = Mock()
        # add combatants
        self.script.add_character(self.char1)
        self.script.add_character(self.char2)
        self.script.add_character(self.obj1)
        self.script.add_character(self.obj2)
        self.script.add_character(self.obj3)
Exemple #40
0
    def func(self):
        "Implements the spawner"

        def _show_prototypes(prototypes):
            "Helper to show a list of available prototypes"
            string = "\nAvailable prototypes:\n %s"
            string %= utils.fill(", ".join(sorted(prototypes.keys())))
            return string

        prototypes = spawn(return_prototypes=True)
        if not self.args:
            string = "Usage: @spawn {key:value, key, value, ... }"
            self.caller.msg(string + _show_prototypes(prototypes))
            return
        try:
            # make use of _convert_from_string from the SetAttribute command
            prototype = _convert_from_string(self, self.args)
        except SyntaxError:
            # this means literal_eval tried to parse a faulty string
            string = "|RCritical Python syntax error in argument. "
            string += "Only primitive Python structures are allowed. "
            string += "\nYou also need to use correct Python syntax. "
            string += "Remember especially to put quotes around all "
            string += "strings inside lists and dicts.|n"
            self.caller.msg(string)
            return

        if isinstance(prototype, basestring):
            # A prototype key
            keystr = prototype
            prototype = prototypes.get(prototype, None)
            if not prototype:
                string = "No prototype named '%s'." % keystr
                self.caller.msg(string + _show_prototypes(prototypes))
                return
        elif not isinstance(prototype, dict):
            self.caller.msg("The prototype must be a prototype key or a Python dictionary.")
            return

        if not "noloc" in self.switches and not "location" in prototype:
            prototype["location"] = self.caller.location

        # set the home of any prototypes to the location they were spawned
        if not "home" in prototype:
            prototype["home"] = prototype["location"]

        # overridden for Ainneve
        traits = prototype.pop('traits') if 'traits' in prototype else None
        skills = prototype.pop('skills') if 'skills' in prototype else None
        sdesc = prototype.pop('sdesc') if 'sdesc' in prototype else None

        for obj in spawn(prototype):
            if sdesc and hasattr(obj, 'sdesc'):
                obj.sdesc.add(sdesc() if callable(sdesc) else sdesc)
            
            if traits and hasattr(obj, 'traits'):
                for trait, value in traits.iteritems():
                    trait = trait.upper()
                    if trait in obj.traits.all:
                        obj.traits[trait].base = value() if callable(value) else value

            if skills and hasattr(obj, 'skills'):
                for skill, value in skills.iteritems():
                    skill = skill.lower()
                    if skill in obj.skills.all:
                        obj.skills[skill].base = value() if callable(value) else value

            self.caller.msg("Spawned %s." % obj.get_display_name(self.caller))
Exemple #41
0
 def expand(self):
     """Expands a bundle into its component items."""
     for i in xrange(self.db.quantity):
         spawn(dict(prototype=self.db.prototype_name,
                    location=self.location))
     self.delete()