本文整理汇总了Python中BetterMUD.itemtemplate方法的典型用法代码示例。如果您正苦于以下问题:Python BetterMUD.itemtemplate方法的具体用法?Python BetterMUD.itemtemplate怎么用?Python BetterMUD.itemtemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BetterMUD
的用法示例。
在下文中一共展示了BetterMUD.itemtemplate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Run
# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import itemtemplate [as 别名]
def Run( self, action, arg1, arg2, arg3, arg4, data ):
me = BetterMUD.character( self.me )
if action == "do" and data == "list":
character = BetterMUD.character( arg3 )
character.DoAction( "announce", 0, 0, 0, 0, "<#7F7F7F>--------------------------------------------------------------------------------" )
character.DoAction( "announce", 0, 0, 0, 0, "<#FFFFFF> Item | Cost" )
character.DoAction( "announce", 0, 0, 0, 0, "<#7F7F7F>--------------------------------------------------------------------------------" )
for x in self.iteminventory:
item = BetterMUD.itemtemplate( x )
character.DoAction( "announce", 0, 0, 0, 0, "<#7F7F7F> " + item.Name().ljust( 42 ) + "| " + str( item.GetAttribute( "value" ) ) )
character.DoAction( "announce", 0, 0, 0, 0, "<#7F7F7F>--------------------------------------------------------------------------------" )
return
if action == "do" and data[:3] == "buy":
itemname = data.split( None, 1 )
itemname = itemname[1]
character = BetterMUD.character( arg3 )
id = FindName( BetterMUD.itemtemplate, self.iteminventory, itemname )
if id == 0:
character.DoAction( "announce", 0, 0, 0, 0, "Sorry, you can't buy " + itemname + "here!" )
return
t = BetterMUD.itemtemplate( id )
if not HasEnoughCurrency( character, t.GetAttribute( "value" ) ):
character.DoAction( "announce", 0, 0, 0, 0, "Sorry, you don't have enough money to buy " + t.Name() + "!" )
return
GiveCurrency( character, me, t.GetAttribute( "value" ) )
self.mud.DoAction( "spawnitem", id, character.ID(), 1, 0, "" )
self.mud.AddActionAbsolute( 0, "vision", character.Room(), 0, 0, 0, character.Name() + " buys " + t.Name() + "." )
示例2: Run
# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import itemtemplate [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 )
示例3: Run
# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import itemtemplate [as 别名]
def Run( self, args ):
if not args: raise PythonCommand.UsageError
me = BetterMUD.character( self.me )
t = BetterMUD.itemtemplate( int( args ) )
print t.ID()
me.DoAction( "announce", 0, 0, 0, 0, "Spawning Item..." )
self.mud.DoAction( "spawnitem", t.ID(), me.ID(), 1, 0, "" )
me.DoAction( "announce", 0, 0, 0, 0, "Success." )
示例4: init
# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import itemtemplate [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()
示例5: init
# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import itemtemplate [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()
示例6: Run
# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import itemtemplate [as 别名]
#.........这里部分代码省略.........
# 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:
t = BetterMUD.character( self.target )
t.DoAction( "do", 0, 0, self.me, 0, "brokeattack" )
else:
self.mud.AddActionRelative( 0, "do", 0, self.me, 0, 0, "attack" )
# set the new target and tell him he's been attacked
self.target = arg3
t = BetterMUD.character( arg3 )
t.DoAction( "do", 0, 0, self.me, 0, "attacked" )
self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " begins attacking " + t.Name() + "!!" )
return
# clear the old target if attacking someone else
if action == "do" and data == "breakattack":
self.Break( me )
return
# break if target or you leaves room
if action == "leaveroom":
if arg1 == self.target or arg1 == self.me:
self.Break( me )
return
if action == "do" and data == "attack":
# get the target
target = BetterMUD.character( self.target )
# set another attack round
self.mud.AddActionRelative( self.attacktime, "do", 0, self.me, 0, 0, "attack" )
# get the weapon
if me.GetAttribute( "weapon" ) == 0:
weapon = BetterMUD.itemtemplate( me.GetAttribute( "defaultweapon" ) )
else:
weapon = BetterMUD.item( me.GetAttribute( "weapon" ) )
# calculate the accuracy
accuracy = weapon.GetAttribute( "accuracy" )
accuracy += target.DoAction( "query", me.ID(), target.ID(), 0, 0, "getaccuracydelta" )
accuracy += me.DoAction( "query", me.ID(), target.ID(), 0, 0, "getaccuracydelta" )
# see if you hit him
if accuracy <= random.randint( 0, 99 ):
self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " swings at " + target.Name() + " with " + weapon.Name() + ", but misses!" )
return
# calculate damage and hit
damage = random.randint( weapon.GetAttribute( "mindamage" ), weapon.GetAttribute( "maxdamage" ) )
self.mud.DoAction( "vision", me.Room(), 0, 0, 0, "<#FF0000>" + me.Name() + " hits " + target.Name() + " with " + weapon.Name() + " for " + str( damage ) + " damage!" )
self.mud.DoAction( "modifyattribute", 0, target.ID(), target.GetAttribute( "hitpoints" ) - damage, damage, "hitpoints" )