當前位置: 首頁>>代碼示例>>Python>>正文


Python BetterMUD.charactertemplate方法代碼示例

本文整理匯總了Python中BetterMUD.charactertemplate方法的典型用法代碼示例。如果您正苦於以下問題:Python BetterMUD.charactertemplate方法的具體用法?Python BetterMUD.charactertemplate怎麽用?Python BetterMUD.charactertemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BetterMUD的用法示例。


在下文中一共展示了BetterMUD.charactertemplate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Run

# 需要導入模塊: import BetterMUD [as 別名]
# 或者: from BetterMUD import charactertemplate [as 別名]
 def Run( self, args ):
     if not args: raise PythonCommand.UsageError
     me = BetterMUD.character( self.me )
     t = BetterMUD.charactertemplate( int( args ) )
     me.DoAction( "announce", 0, 0, 0, 0, "Spawning Character..." )
     self.mud.DoAction( "spawncharacter", t.ID(), me.Room(), 0, 0, "" )
     me.DoAction( "announce", 0, 0, 0, 0, "Success." )
開發者ID:JaguarMantid,項目名稱:bettermud,代碼行數:9,代碼來源:admincommands.py

示例2: init

# 需要導入模塊: import BetterMUD [as 別名]
# 或者: from BetterMUD import charactertemplate [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

示例3: init

# 需要導入模塊: import BetterMUD [as 別名]
# 或者: from BetterMUD import charactertemplate [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


注:本文中的BetterMUD.charactertemplate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。