当前位置: 首页>>代码示例>>Python>>正文


Python BetterMUD.item方法代码示例

本文整理汇总了Python中BetterMUD.item方法的典型用法代码示例。如果您正苦于以下问题:Python BetterMUD.item方法的具体用法?Python BetterMUD.item怎么用?Python BetterMUD.item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BetterMUD的用法示例。


在下文中一共展示了BetterMUD.item方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
 def Run( self, args ):
     me = BetterMUD.character( self.me )
     string =  "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<#00FF00> Your Inventory\r\n"
     string += "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<$reset> "
     if me.Items() == 0:
         string += "NOTHING!!!\r\n"
     else:
         me.BeginItem()
         while me.IsValidItem():
             item = BetterMUD.item( me.CurrentItem() )
             string += item.Name()
             string += "<#00FF00>, <$reset>"
             me.NextItem()
     string += "\r\n<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<#FFFFFF> Weapon:       <$reset>";
     if me.GetAttribute( "weapon" ) == 0:
         item = BetterMUD.itemtemplate( me.GetAttribute( "defaultweapon" ) )
     else:
         item = BetterMUD.item( me.GetAttribute( "weapon" ) )
     string += item.Name() + "\r\n"
     string += "<#FFFFFF> Total Weight: <$reset>" + str( me.GetAttribute( "encumbrance" ) ) + "\r\n"
     string += "<#FFFFFF> Max Weight:   <$reset>" + str( me.GetAttribute( "maxencumbrance" ) ) + "\r\n"
     string += "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     me.DoAction( "announce", 0, 0, 0, 0, string )
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:28,代码来源:usercommands.py

示例2: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        me = BetterMUD.character( self.me )
        if action == "query" and data == "canarm":
            item = BetterMUD.item( arg1 )
            if item.GetAttribute( "arms" ) == 1:
                return 1
            return 0

        if action == "do" and data == "arm":
            item = BetterMUD.item( arg3 )
            self.Disarm( 1 )
            self.Arm( item )

        if action == "do" and data == "disarm":
            self.Disarm( arg3 )

        if action == "dropitem" and arg1 == me.ID():
            self.Lose( me, arg2 )

        if action == "giveitem" and arg1 == me.ID():
            self.Lose( me, arg3 )

        if action == "destroyitem":
            self.Lose( me, arg1 )
            
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:26,代码来源:itemstuff.py

示例3: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
 def Run( self, action, arg1, arg2, arg3, arg4, data ):
     if action == "getitem":
         item = BetterMUD.item( arg2 )
         if item.TemplateID() == 2:
             self.mud.AddActionRelative( 5000, "vision", self.me, 0, 0, 0, "The Baker puts a new pie into the oven!" )
             self.mud.AddActionRelative( 1200000, "spawnitem", 2, self.me, 0, 0, "" )
             self.mud.AddActionRelative( 1200001, "vision", self.me, 0, 0, 0, "A freshly baked Pie pops out of the oven!" )
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:9,代码来源:pieroom.py

示例4: Disarm

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
 def Disarm( self, itemtype ):
     if itemtype == 1:
         me = BetterMUD.character( self.me )
         if me.GetAttribute( "weapon" ) != 0:
             weapon = BetterMUD.item( me.GetAttribute( "weapon" ) )
             me.SetAttribute( "weapon", 0 )
             self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " disarms " + weapon.Name() + "." )
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:9,代码来源:itemstuff.py

示例5: GiveCurrency

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
def GiveCurrency( character, recipient, amount ):
    character.BeginItem()
    mud = BetterMUD.GameWrap()
    while character.IsValidItem():
        item = BetterMUD.item( character.CurrentItem() )
        if item.TemplateID() == 1:   # copper pieces
            mud.DoAction( "attemptgiveitem", character.ID(), recipient.ID(), item.ID(), amount, "" )
            return
        character.NextItem()
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:11,代码来源:currency.py

示例6: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        if action == "getitem":
            item = BetterMUD.item( arg2 )
            print item.TemplateID()
            print "lies"
            if item.TemplateID() == 2:
                print "pies"
                self.mud.AddActionAbsolute( 0, "attemptsay", self.me, 0, 0, 0, "Hey!!!! Thos-a Pies aren't-a FREE!" )
                print "cries"

        return 0
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:13,代码来源:pielogic.py

示例7: HasEnoughCurrency

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
def HasEnoughCurrency( character, amount ):
    total = 0
    character.BeginItem()
    while character.IsValidItem():
        item = BetterMUD.item( character.CurrentItem() )
        if item.TemplateID() == 1:   # copper pieces
            total = total + item.GetQuantity()
        character.NextItem()

    if total >= amount:
        return 1
    return 0
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:14,代码来源:currency.py

示例8: DoRead

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
    def DoRead( self, character, item, name ):
        c = BetterMUD.character( character )
        i = BetterMUD.item( item )
        if c.HasCommand( name ):
            c.DoAction( "error", 0, 0, 0, 0, "You already know this spell!" )
            return

        c.AddCommand( name )
        self.mud.AddActionAbsolute( 0, "vision", c.Room(), 0, 0, 0, c.Name() + " reads " + i.Name() + "!" )
        self.mud.AddActionAbsolute( 1, "destroyitem", i.ID(), 0, 0, 0, "" )
        c.DoAction( "announce", 0, 0, 0, 0, "You now know the spell " + name + "!" )
        c.DoAction( "announce", 0, 0, 0, 0, "The " + i.Name() + " disappears in a bright flash of flame!" )
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:14,代码来源:spellitems.py

示例9: init

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
def init():
    mud = BetterMUD.GameWrap()

    # add weight to every item
    mud.BeginItem()
    while mud.IsValidItem():
        item = BetterMUD.item( mud.CurrentItem() )
        template = BetterMUD.itemtemplate( item.TemplateID() )
        if not item.HasAttribute( "weight" ):
            item.AddAttribute( "weight", template.GetAttribute( "weight" ) )
        mud.NextItem()

    # add encumbrance to every character
    mud.BeginCharacter()
    while mud.IsValidCharacter():
        character = BetterMUD.character( mud.CurrentCharacter() )
        template = BetterMUD.charactertemplate( character.TemplateID() )
        if not character.HasAttribute( "encumbrance" ):
            character.AddAttribute( "encumbrance", template.GetAttribute( "encumbrance" ) )
        if not character.HasAttribute( "maxencumbrance" ):
            character.AddAttribute( "maxencumbrance", template.GetAttribute( "maxencumbrance" ) )

        # now calculate encumbrance of carried items
        character.BeginItem()
        encumbrance = 0
        while character.IsValidItem():
            item = BetterMUD.item( character.CurrentItem() )
            if item.IsQuantity():
                encumbrance = encumbrance + item.GetAttribute( "weight" ) * item.GetQuantity()
            else:
                encumbrance = encumbrance + item.GetAttribute( "weight" )
            character.NextItem()
        character.SetAttribute( "encumbrance", encumbrance )
        if not character.HasLogic( "encumbrance" ):
            character.AddLogic( "encumbrance" )
        mud.NextCharacter()
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:38,代码来源:addencumbrance.py

示例10: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )
        me.SeekItem( args )

        if me.IsValidItem():
            item = me.CurrentItem()
        else:
            room = BetterMUD.room( me.Room() )
            room.SeekItem( args )
            if room.IsValidItem():
                item = room.CurrentItem()
            else:
                me.DoAction( "error", 0, 0, 0, 0, "Cannot find item: " + args )
                return

        i = BetterMUD.item( item )
        me.DoAction( "announce", 0, 0, 0, 0, "Destroying Item: " + i.Name() )
        self.mud.AddActionAbsolute( 0, "destroyitem", item, 0, 0, 0, "" )
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:22,代码来源:admincommands.py

示例11: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )
        r = BetterMUD.room( me.Room() )

        time = self.mud.GetTime()
        if time < self.executiontime:
            me.DoAction( "error", 0, 0, 0, 0, "You need to wait " + str( (self.executiontime - time) / 1000 ) + " more seconds to use this again!" )
            return

        id = FindTarget( r.SeekItem, r.IsValidItem, r.CurrentItem, args )
        item = BetterMUD.item( id )
        name = item.Name()

        # add 120 seconds; 2 minutes
        self.executiontime = time + 120000

        self.mud.AddActionAbsolute( 0, "addlogic", 1, id, 0, 0, "uberweight" )
        self.mud.AddActionAbsolute( 0, "vision", r.ID(), 0, 0, 0, "<#FF0000>" + me.Name() + " just cast UBERWEIGHT on " + name + "!" )
        self.mud.AddActionRelative( 20000, "messagelogic", 1, id, 0, 0, "uberweight remove" )
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:23,代码来源:spells.py

示例12: init

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
def init():
    mud = BetterMUD.GameWrap()

    # add arms to every item
    mud.BeginItem()
    while mud.IsValidItem():
        item = BetterMUD.item( mud.CurrentItem() )
        template = BetterMUD.itemtemplate( item.TemplateID() )
        if not item.HasAttribute( "arms" ):
            item.AddAttribute( "arms", template.GetAttribute( "arms" ) )
        mud.NextItem()

    # add defaultweapon and weapon to every character
    mud.BeginCharacter()
    while mud.IsValidCharacter():
        character = BetterMUD.character( mud.CurrentCharacter() )
        template = BetterMUD.charactertemplate( character.TemplateID() )
        if not character.HasAttribute( "defaultweapon" ):
            character.AddAttribute( "defaultweapon", template.GetAttribute( "defaultweapon" ) )
        if not character.HasAttribute( "weapon" ):
            character.AddAttribute( "weapon", template.GetAttribute( "weapon" ) )
        mud.NextCharacter()
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:24,代码来源:addarmaments.py

示例13: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        me = BetterMUD.character( self.me )


        if action == "modifyattribute" and data == "experience":
            me.DoAction( "announce", 0, 0, 0, 0, "<#00FFFF>You gain " + str( arg4 ) + " experience!" )
            return

        # check for death
        if action == "modifyattribute" and data == "hitpoints":
            if arg3 <= 0:
                me.DoAction( "do", 0, 0, 0, 0, "died" )
            return

        # you killed someone... celebrate!
        if action == "do" and data == "killed":
            self.Break( me )
            return

        if action == "do" and data == "died":
            self.Break( me )
            self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " dies!!!" )

            # calculate how much experience to give to everyone attacking you
            experience = me.GetAttribute( "giveexperience" )
            if len( self.attackedlist ) > 0:
                experience = experience / len( self.attackedlist )

            # go through everyone, tell them you died, and give them their experience

            for x in self.attackedlist[:]:
                c = BetterMUD.character( x )
                c.DoAction( "do", 0, 0, self.me, 0, "killed" )
                self.mud.DoAction( "modifyattribute", 0, x, c.GetAttribute( "experience" ) + experience, experience, "experience" )

            # clear the list
            self.attackedlist = []

            # go through all his items and force them to drop
            me.BeginItem()
            while me.IsValidItem():
                self.mud.DoAction( "dropitem", me.ID(), me.CurrentItem(), 0, 0, "" )
                me.NextItem()

            # now figure out how to kill the character
            if not me.IsPlayer():
                # just destroy non-players
                self.mud.AddActionAbsolute( 0, "destroycharacter", self.me, 0, 0, 0, "" )
            else:
                # give the player some hitpoints back
                me.SetAttribute( "hitpoints", (me.GetAttribute( "maxhitpoints" ) / 10) * 7 )

                # now spawn the player somewhere, checking the current room, current region, current character,
                # and finally giving up and sending the player to room 1.
                r = BetterMUD.room( me.Room() )
                if r.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                r = BetterMUD.region( me.Region() )
                if r.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                if me.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                self.mud.DoAction( "forcetransport", me.ID(), 1, 0, 0, "" )
            return


        # reset hp if maxhp goes down below hp.
        if action == "modifyattribute" and data == "maxhitpoints":
            if me.GetAttribute( "hitpoints" ) > me.GetAttribute( "maxhitpoints" ):
                me.SetAttribute( "hitpoints", me.GetAttribute( "maxhitpoints" ) )
            return

        # people with the combat module can be attacked
        if action == "query" and data == "canattack":
            return 1


        # add character to attacked list if he isn't there
        if action == "do" and data == "attacked":
            try:
                self.attackedlist.index( arg3 )
            except:
                self.attackedlist.append( arg3 )
            return

        # remove character from attacked list
        if action == "do" and data == "brokeattack":
            try:
                self.attackedlist.remove( arg3 )
            except:
                pass
            return


        # initiate an attack
        if action == "do" and data == "initattack":
            if arg3 == self.me: return

            # clear the old target if attacking someone else
            if self.target != 0:
#.........这里部分代码省略.........
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:103,代码来源:combat.py

示例14: Weight

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import item [as 别名]
 def Weight( self, i, q ):
     item = BetterMUD.item( i )
     if item.IsQuantity():
         return q * item.GetAttribute( "weight" )
     else:
         return item.GetAttribute( "weight" )
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:8,代码来源:itemstuff.py


注:本文中的BetterMUD.item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。