本文整理汇总了Python中core.formation.Formation.initialize_socket方法的典型用法代码示例。如果您正苦于以下问题:Python Formation.initialize_socket方法的具体用法?Python Formation.initialize_socket怎么用?Python Formation.initialize_socket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.formation.Formation
的用法示例。
在下文中一共展示了Formation.initialize_socket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: char_initialize
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import initialize_socket [as 别名]
def char_initialize(account_id, server_id, char_id, name):
mc = MongoCharacter(id=char_id)
mc.account_id = account_id
mc.server_id = server_id
mc.name = name
mc.gold = CHARACTER_INIT['gold']
mc.sycee = CHARACTER_INIT['sycee']
mc.save()
from core.item import Item
item = Item(char_id)
# save equipment
for _id, _amount in CHARACTER_INIT['equipment']:
for _x in range(_amount):
item.equip_add(_id, notify=False)
# save gem
if CHARACTER_INIT['gem']:
item.gem_add(CHARACTER_INIT['gem'], send_notify=False)
# save stuff
if CHARACTER_INIT['stuff']:
item.stuff_add(CHARACTER_INIT['stuff'], send_notify=False)
# save hero
if CHARACTER_INIT['hero']:
save_hero(char_id, CHARACTER_INIT['hero'], add_notify=False)
# save souls:
if CHARACTER_INIT['souls']:
s = HeroSoul(char_id)
s.add_soul(CHARACTER_INIT['souls'])
# hero in formation!
in_formaiton_heros = CHARACTER_INIT['hero_in_formation']
final_in_formation_heros = {}
for k, v in in_formaiton_heros.iteritems():
new_ids = []
for _equip_id in v:
if not _equip_id:
new_ids.append(0)
else:
new_ids.append(item.equip_add(_equip_id, notify=False))
final_in_formation_heros[k] = new_ids
hero_ids = save_hero(char_id, final_in_formation_heros.keys(), add_notify=False).id_range
hero_new_id_to_oid_table = dict(zip(hero_ids, final_in_formation_heros.keys()))
hero_oid_socket_id_table = {}
f = Formation(char_id)
for hid in hero_ids:
this_oid = hero_new_id_to_oid_table[hid]
weapon, armor, jewelry = final_in_formation_heros[this_oid]
_sid = f.initialize_socket(hero=hid, weapon=weapon, armor=armor, jewelry=jewelry)
hero_oid_socket_id_table[this_oid] = _sid
socket_ids = FORMATION_INIT_TABLE[:]
for index, oid in enumerate(socket_ids):
if oid:
socket_ids[index] = hero_oid_socket_id_table[oid]
if FORMATION_INIT_OPENED_SOCKETS > len(hero_ids):
for i in range(FORMATION_INIT_OPENED_SOCKETS - len(hero_ids)):
_sid = f.initialize_socket()
for index, sid in enumerate(socket_ids):
if sid == 0:
socket_ids[index] = _sid
break
f.save_formation(socket_ids, send_notify=False)