当前位置: 首页>>代码示例>>Python>>正文


Python Formation.initialize_socket方法代码示例

本文整理汇总了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)
开发者ID:hx002,项目名称:sanguo-server,代码行数:72,代码来源:character.py


注:本文中的core.formation.Formation.initialize_socket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。