本文整理汇总了Python中FantasyDemo类的典型用法代码示例。如果您正苦于以下问题:Python FantasyDemo类的具体用法?Python FantasyDemo怎么用?Python FantasyDemo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FantasyDemo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: msgFriend
def msgFriend(player, string):
"""Sends a message to a friend.
Format: /msgFriend [<friend name>] : <message> (Note the ':')
In game friends (other Avatars)
/msgFriend : Hello - Sends a message to the currently targeted Avatar.
/msgFriend Alice : Hello - Sends a message to the Avatar with playerName 'Alice'.
Instant Message friends
/msgFriend [email protected] : Hello to you
/msgFriend [email protected] : Hello XMPP
/msgFriend [email protected] : Hello MSN"""
words = string.split(':', 1)
if len(words) < 2:
FantasyDemo.addChatMsg(-1, 'Invalid format - /help msgFriend for details', FDGUI.TEXT_COLOUR_SYSTEM)
return
recipient = words[0].strip()
message = words[1].strip()
if not len(message):
FantasyDemo.addChatMsg(-1, 'Invalid format - /help msgFriend for details', FDGUI.TEXT_COLOUR_SYSTEM)
return
friendsList = player.roster.findFriendsLike(recipient)
if not len(friendsList):
player.msgFriend(recipient.encode('utf8'), message)
elif len(friendsList) > 1:
FantasyDemo.addChatMsg(-1, "Found multiple friends that match '%s'.", FDGUI.TEXT_COLOUR_SYSTEM)
for friendItem in friendsList:
FantasyDemo.addChatMsg(-1, friendItem[0], FDGUI.TEXT_COLOUR_SYSTEM)
else:
friend = friendsList[0]
player.base.xmppMsgFriend(friend[0], friend[1], message)
recipient = friend[0] + ' [IM]'
FantasyDemo.addChatMsg(-1, 'You say to ' + recipient + ': ' + message, FDGUI.TEXT_COLOUR_YOU_SAY)
示例2: __init__
def __init__(self):
self.currentSpace = ''
self.currentRegion = None
self.currentDesc = ''
self.listeners = []
FantasyDemo.addChangeEnvironmentsListener(self.onChangeEnvironments)
return
示例3: addFriend
def addFriend(player, string):
"""Adds a friend to player's friends list.
Format: /addFriend [<Game friend name> | <IM friend name[:protocol]>]
In-game friends (other Avatars)
/addFriend - Adds the currently targeted friend.
/addFriend Alice - Adds the Avatar with playerName 'Alice' as a friend.
Instant Message friend (XMPP)
/addFriend [email protected] - Adds the XMPP friend '[email protected]<xmpp.domain.com>' as a friend.
/addFriend [email protected]
Instant Message friend (MSN / other transports)
/addFriend [email protected]:msn"""
if string.find('@') >= 0:
transport = 'xmpp'
if string.startswith('@'):
FantasyDemo.addChatMsg(-1, 'Invalid IM friend name.', FDGUI.TEXT_COLOUR_SYSTEM)
return
imContents = string.rsplit(':', 1)
friendID = imContents[0]
if len(imContents) == 2:
transport = imContents[1].encode('utf8').lower()
if friendID.endswith('@'):
friendID += 'eval.bigworldtech.com'
friendsList = player.roster.findFriendsLike(friendID, transport)
if len(friendsList):
FantasyDemo.addChatMsg(-1, '%s is already a friend.' % friendID, FDGUI.TEXT_COLOUR_SYSTEM)
return
player.base.xmppAddFriend(friendID, transport)
else:
player.addFriend(string.encode('utf8'))
示例4: who
def who(player, string):
"""List all online players near you."""
playerList = 'Players near you:\n'
for i in BigWorld.entities.values():
if i.__class__.__name__ == 'Avatar':
playerList = playerList + i.playerName + '\n'
FantasyDemo.addChatMsg(-1, playerList)
示例5: target
def target(player, string):
"""Send a chat message to the targeted player"""
t = BigWorld.target()
if t:
try:
t.cell.directedChat(player.id, string)
FantasyDemo.addChatMsg(player.id, '[To ' + t.playerName + '] ' + string)
except:
pass
示例6: addNote
def addNote(player, description):
"""Adds a note to the external note data store."""
if description == None or len(description) == 0:
FantasyDemo.addChatMsg(-1, 'Must provide a note description')
else:
print 'Adding a note:', description
if isinstance(description, unicode):
description = description.encode('utf8')
player.base.addNote(description)
return
示例7: onFriendPresenceChange
def onFriendPresenceChange(self, friend, transport, oldPresence, newPresence):
state = None
if oldPresence == 'available' and newPresence == 'unavailable':
state = 'gone offline'
elif oldPresence == 'unavailable' and newPresence == 'available':
state = 'come online'
if state:
msg = '%s has %s' % (friend, state)
FantasyDemo.addChatMsg(-1, msg, FDGUI.TEXT_COLOUR_SYSTEM)
return
示例8: help
def help(player, string):
"""Display help a console command."""
if string:
try:
func = globals()[string]
if callable(func) and func.__doc__:
for s in func.__doc__.split('\n'):
FantasyDemo.addChatMsg(-1, s)
else:
raise 'Not callable'
except:
FantasyDemo.addChatMsg(-1, 'No help for ' + string)
else:
isCallable = lambda x: callable(globals()[x])
ignoreList = ('getV4FromString', 'help')
notIgnored = lambda x: x not in ignoreList
keys = filter(isCallable, globals().keys())
keys = filter(notIgnored, keys)
keys.sort()
FantasyDemo.addChatMsg(-1, '/help {command} for more info.')
stripper = lambda c: c not in '[]\'"'
string = filter(stripper, str(keys))
FantasyDemo.addChatMsg(-1, string)
示例9: delTransportAccount
def delTransportAccount(player, string):
"""Disassociates a legacy transport account from the users XMPP account.
Format: /delTransportAccount <transport>
Example:
/delTransportAccount msn"""
transport = string.encode('utf8').strip()
wasFound = False
for transportDetails in player.xmppTransportDetails:
if not wasFound and transportDetails['transport'] == transport:
wasFound = True
if not wasFound:
FantasyDemo.addChatMsg(-1, 'Transport not known.', FDGUI.TEXT_COLOUR_SYSTEM)
else:
player.base.xmppTransportAccountDeregister(transport)
示例10: addTransportAccount
def addTransportAccount(player, string):
"""Associates a legacy transport account with the users XMPP account.
Format: /addTransportAccount <transport> <username> <password>
Example:
/addTransportAccount msn [email protected] sup3r$ecr37"""
string = string.encode('utf8').strip()
m = re.match('(.+?)\\s+(.+?)\\s+(.+)', string)
if not m:
FantasyDemo.addChatMsg(-1, 'Invalid transport registration details.', FDGUI.TEXT_COLOUR_SYSTEM)
return
transport = m.group(1)
username = m.group(2)
password = m.group(3)
registerMsg = 'Attempting to register %s account %s.' % (transport, username)
FantasyDemo.addChatMsg(-1, registerMsg, FDGUI.TEXT_COLOUR_SYSTEM)
player.base.xmppTransportAccountRegister(transport, username, password)
示例11: delFriend
def delFriend(player, string):
"""Deletes a friend from player's friends list.
Format: /delFriend [<friend name>]
In-game friends (other Avatars)
/delFriend - Removes the currently targeted friend.
/delFriend Alice - Removes the Avatar with playerName 'Alice' as a friend.
Instant Message friends
/delFriend [email protected] - Removes the XMPP friend '[email protected]<xmpp.domain.com>'.
/delFriend [email protected]"""
friendsList = player.roster.findFriendsLike(string)
if not len(friendsList):
player.delFriend(string.encode('utf8'))
elif len(friendsList) > 1:
FantasyDemo.addChatMsg(-1, "Found multiple friends that match '%s'.", FDGUI.TEXT_COLOUR_SYSTEM)
for friendItem in friendsList:
FantasyDemo.addChatMsg(-1, friendItem[0], FDGUI.TEXT_COLOUR_SYSTEM)
else:
friend = friendsList[0]
player.base.xmppDelFriend(friend[0], friend[1])
示例12: onFriendDelete
def onFriendDelete(self, friend, transport):
msg = 'Removed %s from the friends list.' % friend
FantasyDemo.addChatMsg(-1, msg, FDGUI.TEXT_COLOUR_SYSTEM)
示例13: onLoad
def onLoad(self, section):
PyGUIBase.onLoad(self, section)
FantasyDemo.initConsole()
示例14: fini
def fini(self):
FantasyDemo.delChangeEnvironmentsListener(self.onChangeEnvironments)
示例15: onError
def onError(self, message):
FantasyDemo.addChatMsg(-1, message, FDGUI.TEXT_COLOUR_SYSTEM)