Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(54)  |  Call(43)  |  Derive(0)  |  Import(11)

src/l/a/Lampost-Mud-HEAD/lampost/mud/action.py   Lampost-Mud(Download)
from collections import defaultdict
from lampost.context.resource import m_requires, register
from lampost.gameops.action import make_action, ActionError, convert_verbs
from lampost.util.lmutil import StateError
 
    action = _mud_actions.get(args, None)
    if not action:
        raise ActionError("No matching command found")
    return getattr(action, "help_text", "No help available.")
 
def unfriend(source, args, **_):
    if not args or len(args) > 1:
        raise ActionError("Who do you want to unfriend?")
    unfriend_id = user_manager.name_to_id(args[0])
    friend_name = user_manager.id_to_name(unfriend_id)
        message_service.add_message('system', "{} unfriended you!".format(source.name), unfriend_id)
    else:
        raise ActionError("{} is not your friend".format(args[0]))
 
 
@mud_action('message')
def message(source, args, command, **_):
    if not args:
        raise ActionError("Message who?")

src/l/a/Lampost-Mud-HEAD/lampost/lpflavor/player.py   Lampost-Mud(Download)
from lampost.context.resource import m_requires
from lampost.datastore.dbo import DBOField
from lampost.env.room import Room
from lampost.gameops.action import ActionError
from lampost.gameops.display import SYSTEM_DISPLAY, COMBAT_DISPLAY
    def check_logout(self):
        if self.last_opponent:
            raise ActionError("You can't log out right now.", COMBAT_DISPLAY)
 
    def status_change(self):

src/l/a/Lampost-Mud-HEAD/lampost/mud/immortal.py   Lampost-Mud(Download)
from lampost.env.room import Room
from lampost.model.area import Area
from lampost.gameops.action import ActionError
from lampost.context.resource import m_requires, get_resource
from lampost.mud.action import imm_action
def add_flag(source, target, obj, **_):
    try:
        flag_id = target[0]
    except IndexError:
        raise ActionError("Flag id required.")
        flag_value = str_to_primitive(flag_value)
    except ValueError:
        raise ActionError("Cannot parse {}".flag_value)
    obj.flags[flag_id] = flag_value
    source.display_line("Flag {} set to {} on {}.".format(flag_id, flag_value, obj.name))
def add_flag(source, target, obj, **_):
    try:
        flag_id = target[0]
    except IndexError:
        raise ActionError("Flag id required.")
    try:
        old_value = obj.flags.pop(flag_id)
    except KeyError:
        raise ActionError("Flag {} not set.".format(flag_id))

src/l/a/Lampost-Mud-HEAD/lampost/lpflavor/skill.py   Lampost-Mud(Download)
from random import randint
from lampost.context.resource import m_requires
from lampost.datastore.dbo import DBOField, DBOTField
from lampost.datastore.auto import TemplateField
from lampost.gameops.action import ActionError, convert_verbs
def add_skill(skill_id, target, skill_level):
    skill_template = load_object(SkillTemplate, skill_id)
    if not skill_template:
        warn("Skill {} not found.".format(skill_id))
        raise ActionError("Skill not found")
    def prepare_action(self, source, target, **kwargs):
        if self.available > 0:
            raise ActionError("You cannot {} yet.".format(self.verb))
        self.validate(source, target, **kwargs)
        if self.prep_map and self.prep_time:
def add_skill_action(target, obj, **_):
    try:
        skill_id = target[0]
    except IndexError:
        raise ActionError("Skill id required")

src/l/a/Lampost-Mud-HEAD/lampost/lpflavor/combat.py   Lampost-Mud(Download)
from __future__ import division
from lampost.context.resource import m_requires
from lampost.datastore.dbo import DBOTField
from lampost.datastore.auto import RootAuto, TemplateField
from lampost.gameops.action import ActionError
    if ability.weapon_type == 'unarmed':
        if weapon_type:
            raise ActionError("You can't do that with a weapon.")
        return
    if not weapon_type:
        raise ActionError("That requires a weapon.")
    if ability.weapon_type != 'any' and ability.weapon_type != weapon_type:
        raise ActionError("You need a different weapon for that.")
def validate_delivery(ability, delivery):
    if delivery not in ability.delivery:
        raise ActionError("This doesn't work against that.")
 
 

src/l/a/Lampost-Mud-HEAD/lampost/lpflavor/feature/store.py   Lampost-Mud(Download)
from lampost.datastore.dbo import DBOField
from lampost.env.feature import Feature
from lampost.gameops.action import item_action, ActionError
from lampost.mud.inventory import InvenContainer
 
    def sell(self, source, target, quantity=None, **_):
        if quantity or target.quantity:
            raise ActionError("You can't sell that kind of item.")
        if self.currency:
            if not target.value:
                raise ActionError("That's not worth anything.")
    def buy(self, source, target, **_):
        if target not in self.inven:
            raise ActionError("That is not in the store.")
        if self.currency and target.value:
            money = self._take_money(source, self._price(target))
    def _take_money(self, source, price):
        for inven in source.inven:
            if inven.template == self.currency:
                if inven.quantity < price:
                    raise ActionError("You only have {}.".format(inven.name))

src/l/a/Lampost-Mud-HEAD/lampost/lpflavor/entity.py   Lampost-Mud(Download)
from lampost.context.resource import m_requires
from lampost.gameops.action import action_handler, ActionError
from lampost.lpflavor.fight import Fight
from lampost.lpflavor.attributes import need_refresh, POOL_LIST
from lampost.lpflavor.combat import calc_consider
            self.fight.update_skills()
        except KeyError:
            raise ActionError('{} does not have that skill'.format(self.name))
 
    def check_costs(self, costs):
        for pool, cost in costs.viewitems():
            if getattr(self, pool, 0) < cost:
                raise ActionError("Your condition prevents you from doing that.")
    def start_action(self, action, act_args):
        if hasattr(action, 'prepare_action'):
            if self.dead:
                raise ActionError("Ah, would that you could.  Was it so long ago that you had such freedom of movement?")
            action.prepare_action(**act_args)
    def equip_article(self, article):
        if article.equip_slot == 'none':
            raise ActionError('This is not something you can equip.')
        if article.art_type == 'weapon' and self.weapon:
            self.remove_article(self.weapon)

src/l/a/Lampost-Mud-HEAD/lampost/comm/chat.py   Lampost-Mud(Download)
from lampost.gameops.display import *
from lampost.gameops.action import ActionError
from lampost.context.resource import m_requires
from lampost.mud.action import mud_action
 
def tell(source, args, command, **_):
    if not args:
        raise ActionError("Tell who?")
    tell_message(source, args[0], command.partition(args[0])[2][1:])
 
def reply(source, verb, command, **_):
    if not source.last_tell:
        raise ActionError("You have not received a tell recently.")
    ix = command.find(verb[0]) + len(verb[0]) + 1
    tell_message(source, source.last_tell, command[ix:])
def say(source, command, **_):
    space_ix = command.find(" ")
    if space_ix == -1:
        raise ActionError("Say what?")
    statement = command[space_ix + 1:]

src/l/a/Lampost-Mud-HEAD/lampost/comm/message.py   Lampost-Mud(Download)
from lampost.context.resource import m_requires, provides
from lampost.gameops.action import ActionError
from lampost.util.lmutil import timestamp
 
m_requires('log', 'datastore', 'dispatcher', 'session_manager', 'user_manager', __name__)
    def add_message(self, msg_type, content, player_id, source_id=None):
        if self.is_blocked(player_id, source_id):
            raise ActionError("You are blocked from sending messages to that player.")
        msg_id = db_counter("message_id")
        message = {'msg_type': msg_type, 'msg_id': msg_id, 'content': content, 'source': user_manager.id_to_name(source_id)}

src/l/a/Lampost-Mud-HEAD/lampost/model/article.py   Lampost-Mud(Download)
from lampost.datastore.auto import TemplateField
from lampost.gameops.script import Scriptable
from lampost.model.item import BaseItem, target_keys
from lampost.gameops.action import ActionError
from lampost.datastore.dbo import RootDBO, DBOField, DBOTField
    def drop(self, source, quantity=None, **_):
        source.check_drop(self, quantity)
        if self.current_slot:
            raise ActionError("You must unequip the item before dropping it.")
        drop = self.take_from(source, quantity)

  1 | 2  Next