本文整理汇总了Python中BetterMUD类的典型用法代码示例。如果您正苦于以下问题:Python BetterMUD类的具体用法?Python BetterMUD怎么用?Python BetterMUD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BetterMUD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Run
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 )
示例2: Run
def Run( self, action, arg1, arg2, arg3, arg4, data ):
me = BetterMUD.character( self.me )
if action == "say" and data.find( "pies" ) != -1 and arg1 != me.ID():
c = BetterMUD.character( arg1 )
self.mud.AddActionAbsolute( 0, "attemptsay", me.ID(), 0, 0, 0, c.Name() + ": YES!!! PIES!!!!!" )
return 0
示例3: Run
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 )
示例4: Run
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." )
示例5: Run
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() + "." )
示例6: Disarm
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() + "." )
示例7: DoRead
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!" )
示例8: Execute
def Execute( self, args ):
try:
self.Run( args )
except UsageError:
me = BetterMUD.character( self.me )
me.DoAction( "error", 0, 0, 0, 0, "Usage: " + self.Usage() )
except TargetError, e:
me = BetterMUD.character( self.me )
me.DoAction( "error", 0, 0, 0, 0, "Cannot find: " + e.value )
示例9: Run
def Run( self, args ):
if not args: raise PythonCommand.UsageError
me = BetterMUD.character( self.me )
r = BetterMUD.room( me.Room() )
# find the name:
id = FindTarget( r.SeekCharacter, r.IsValidCharacter, r.CurrentCharacter, args )
c = BetterMUD.character( id )
name = c.Name()
self.mud.AddActionAbsolute( 0, "addlogic", 0, id, 0, 0, "superglue" )
self.mud.AddActionAbsolute( 0, "vision", r.ID(), 0, 0, 0, "<#FF0000>OMG!!! " + me.Name() + " just SUPERGLUED " + name + " to the floor!!!!!" )
self.mud.AddActionRelative( 20000, "messagelogic", 0, id, 0, 0, "superglue remove" )
示例10: Run
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!" )
示例11: Run
def Run( self, args ):
me = BetterMUD.character( self.me )
r = BetterMUD.room( me.Room() )
# find the name:
if not args:
name = "himself"
else:
r.SeekCharacter( args )
if not r.IsValidCharacter():
me.DoAction( "error", 0, 0, 0, 0, "Cannot find character: " + args )
return
id = r.CurrentCharacter()
c = BetterMUD.character( id )
name = c.Name()
self.mud.AddActionAbsolute( 0, "vision", r.ID(), 0, 0, 0, "<#00FF00>OMG!!! " + me.Name() + " just threw a huge <#FFFF00>CUSTARD PIE<#00FF00> at " + name + "!!!!" )
示例12: Break
def Break( self, me ):
if self.target == 0:
return
t = BetterMUD.character( self.target )
me.KillHook( "do", "attack" )
self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " stops attacking " + t.Name() + "!!" )
t.DoAction( "do", 0, 0, self.me, 0, "brokeattack" )
self.target = 0
示例13: Run
def Run( self, action, arg1, arg2, arg3, arg4, data ):
if action == "canenterregion":
character = BetterMUD.character( arg1 )
if character.TemplateID() == 2:
character.SeekItem( "Dwarven Mine Pass" )
if character.IsValidItem():
return 0
character.DoAction( "error", 0, 0, 0, 0, "As an elf, you are morally obligated to not enter these mines!" )
return 1
示例14: Run
def Run( self, action, arg1, arg2, arg3, arg4, data ):
me = BetterMUD.character( self.me )
if action == "canleaveroom":
me.DoAction( "error", 0, 0, 0, 0, "You're superglued to the ground. Sit tight, you ain't goin nowhere." )
return 1
if action == "messagelogic":
if data == "superglue remove":
self.mud.AddActionAbsolute( 0, "dellogic", 0, self.me, 0, 0, "superglue" )
self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, "The superglue on " + me.Name() + " wears off!" )
示例15: GiveCurrency
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()