• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.svdata函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.svdata函数的典型用法代码示例。如果您正苦于以下问题:Python svdata函数的具体用法?Python svdata怎么用?Python svdata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了svdata函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: getship

def getship():
    dock = int(request.values.get("api_kdock_id"))
    try:
        data = _DockHelper.get_and_remove_ship(dockid=dock)
    except (IndexError, AttributeError):
        return svdata({}, code=201, message='申し訳ありませんがブラウザを再起動し再ログインしてください。')
    return svdata(data)
开发者ID:solofandy,项目名称:kcsrv,代码行数:7,代码来源:actions.py


示例2: change_position

def change_position():
    # TODO UNFUCK THIS CODE UP
    admiral = get_token_admiral_or_error()
    # Get request parameters
    fleet_id = int(request.values.get("api_id")) - 1
    ship_id = int(request.values.get("api_ship_id")) - 1
    ship_pos = int(request.values.get("api_ship_idx"))
    fleet = admiral.fleets.all()[fleet_id]
    fships = fleet.ships.all()

    print(ship_id, ship_pos)
    if ship_id == -2:
        # Delete ship.
        oldship = fships[ship_pos]
        oldship.local_fleet_num = None
        fships.remove(oldship)
        # Get the rest of the ships, and bump it down.
        for n, ship in enumerate(fships):
            if n > ship_id:
                ship.local_fleet_num -= 1
                fships[n] = ship
        fleet.ships = fships
    elif len(fships) == ship_pos:
        # Append to the ships list
        if admiral.admiral_ships.filter_by(local_ship_num=ship_id).first() in fships:
            pass
        else:
            # Get the first ship, update the local fleet num, and append it to the fleet.
            nship = admiral.admiral_ships.filter_by(local_ship_num=ship_id).first()
            nship.local_fleet_num = ship_pos
            fships.append(nship)
            fleet.ships = fships
    else:
        # Get the original ship.
        original_ship = fships[ship_pos]
        # Get the new ship.
        new_ship = fleet.ships.filter_by(local_ship_num=ship_id).first()
        if new_ship is None:
            # BLEH
            original_ship.local_fleet_num = None
            original_ship.fleet_id = None
            db.session.add(original_ship)
            new_ship = admiral.admiral_ships.filter_by(local_ship_num=ship_id).first()
            new_ship.local_fleet_num = ship_pos
            fleet.ships.append(new_ship)
            db.session.add(fleet)
            db.session.commit()
            return svdata({})
        # Do the bullshit swap.
        original_ship.local_fleet_num, new_ship.local_fleet_num = new_ship.local_fleet_num, original_ship.local_fleet_num
        # Eww, merge ships back into the admiral_ships table
        db.session.add(original_ship)
        db.session.add(new_ship)

    # Update the fleet.
    db.session.add(fleet)
    db.session.commit()
    return svdata({})
开发者ID:solofandy,项目名称:kcsrv,代码行数:58,代码来源:actions.py


示例3: firstship

def firstship():
    admiral = get_token_admiral_or_error()
    if admiral.setup:
        return svdata({'api_result_msg': "Nice try.", 'api_result': 200})
    shipid = request.values.get("api_ship_id")
    new_admiral = AdmiralHelper.setup(shipid, admiral)
    db.db.session.add(new_admiral)
    db.db.session.commit()
    return svdata({'api_result_msg': 'shitty api is shitty', 'api_result': 1})
开发者ID:minamion,项目名称:kcsrv,代码行数:9,代码来源:actions.py


示例4: firstship

def firstship():
    admiral = get_token_admiral_or_error()
    if admiral.setup:
        return svdata({'api_result_msg': "Nice try.", 'api_result': 200})
    shipid = request.values.get("api_ship_id")
    ShipHelper.assign_ship(admiral, shipid)

    admiral.setup = True

    db.session.add(admiral)
    db.session.commit()
    return svdata({'api_result_msg': 'shitty api is shitty', 'api_result': 1})
开发者ID:f-matos,项目名称:kcsrv,代码行数:12,代码来源:actions.py


示例5: slotset

def slotset():
    admiral = get_token_admiral_or_error()
    admiral_ship_id = request.values.get("api_id")
    admiral_item_id = request.values.get("api_item_id")
    slot = request.values.get("api_slot_idx")
    _ShipHelper.change_ship_item(admiral_ship_id, admiral_item_id, slot)
    return svdata({'api_result_msg': 'ok', 'api_result': 1})
开发者ID:solofandy,项目名称:kcsrv,代码行数:7,代码来源:actions.py


示例6: furniture

def furniture():
    """Available furniture."""
    # TODO: Implement this properly
    return svdata([{
                       'api_member_id': g.admiral.id, 'api_id': item.id, 'api_furniture_type': item.type,
                       'api_furniture_no': item.no, 'api_furniture_id': item.id
                   } for item in []])
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:7,代码来源:member.py


示例7: lock

def lock():
    admiral = get_token_admiral_or_error()
    admiralship = admiral.admiral_ships.filter_by(local_ship_num=int(request.values.get("api_ship_id"))).first()
    admiralship.heartlocked = True
    db.db.session.add(admiralship)
    db.db.session.commit()
    return svdata({})
开发者ID:SoftwareGuy,项目名称:kcsrv,代码行数:7,代码来源:actions.py


示例8: build

def build():
    fuel = int(request.values.get("api_item1"))
    ammo = int(request.values.get("api_item2"))
    steel = int(request.values.get("api_item3"))
    baux = int(request.values.get("api_item4"))
    dock = int(request.values.get("api_kdock_id")) - 1
    DockHelper.craft_ship(fuel, ammo, steel, baux, dock)
    return svdata({})
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:8,代码来源:actions.py


示例9: build

def build():
    admiral = get_token_admiral_or_error()
    fuel = int(request.values.get("api_item1"))
    ammo = int(request.values.get("api_item2"))
    steel = int(request.values.get("api_item3"))
    baux = int(request.values.get("api_item4"))
    dock = int(request.values.get("api_kdock_id")) # -1 # For some reason, it doesn't need minusing one. ¯\_(ツ)_/¯
    _DockHelper.craft_ship(fuel, ammo, steel, baux, admiral, dock)
    return svdata({})
开发者ID:solofandy,项目名称:kcsrv,代码行数:9,代码来源:actions.py


示例10: record

def record():
    data = {
        "api_member_id": g.admiral.id,
        "api_nickname": g.admiral.name,
        "api_nickname_id": str(g.admiral.id),
        "api_cmt": "",
        "api_cmt_id": "",
        "api_photo_url": "",
        "api_rank": g.admiral.rank,
        "api_level": g.admiral.level,
        "api_experience": [
            g.admiral.experience,
            # Exp to next level
            sum(HQ_LEVEL[:g.admiral.level + 1])
        ],
        # api_war -> sorties
        "api_war": {
            "api_win": str(g.admiral.sortie_successes),
            "api_lose": str(g.admiral.sortie_total - g.admiral.sortie_successes),
            "api_rate": str(round((g.admiral.sortie_successes / g.admiral.sortie_total)
                                  if g.admiral.sortie_total else 0, 2))
        },
        # api_mission -> expeditions
        "api_mission": {
            "api_count": str(g.admiral.expedition_total),
            "api_success": str(g.admiral.expedition_successes),
            "api_rate": str(round(((g.admiral.expedition_total / g.admiral.expedition_successes) * 100)
                                  if g.admiral.expedition_successes else 0, 2))
            # Full percentage. Not rounded percentage. Stupid kc
        },
        "api_practice": {
            "api_win": str(g.admiral.pvp_successes),
            "api_lose": str(g.admiral.pvp_total - g.admiral.pvp_successes),
            "api_rate": str(round((g.admiral.pvp_total / g.admiral.pvp_successes)
                                  if g.admiral.pvp_successes else 0, 2))
        },
        "api_friend": 0,  # No idea
        "api_deck": len(g.admiral.fleets),
        "api_kdoc": len(g.admiral.docks_craft),
        "api_ndoc": len(g.admiral.docks_repair),
        "api_ship": [  # Current amount, max
            len(g.admiral.kanmusu),
            999999
        ],
        "api_slotitem": [
            len(g.admiral.equipment.all()),
            9999999
        ],
        "api_furniture": 8,  # Not sure
        "api_complate": [
            "0.0",
            "0.0"
        ],  # Not sure
        "api_large_dock": 1,
        "api_material_max": 1000000  # Maximum materials
    }
    return svdata(data)
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:57,代码来源:member.py


示例11: lock

def lock():
    """Heartlock/unheartlock a ship."""
    admiral = get_token_admiral_or_error()
    admiralship = admiral.admiral_ships.filter_by(local_ship_num=int(request.values.get("api_ship_id")) - 1).first()

    locked = not admiralship.heartlocked

    admiralship.heartlocked = locked
    db.session.add(admiralship)
    db.session.commit()
    return svdata({"api_locked": int(locked)})
开发者ID:solofandy,项目名称:kcsrv,代码行数:11,代码来源:actions.py


示例12: ship3

def ship3():
    admiral = g.admiral
    # No idea.
    # spi_sort_order = request.values.get('spi_sort_order')
    # spi_sort_order = request.values.get('api_sort_key')
    admiral_ship_id = request.values.get('api_shipid')
    data = {
        "api_ship_data": [_ShipHelper.get_admiral_ship_api_data(
            admiral_ship_id)], "api_deck_data": AdmiralHelper.get_admiral_deck_api_data(
            admiral), "api_slot_data": _ItemHelper.get_slottype_list(admiral=admiral)
    }
    return svdata(data)
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:12,代码来源:actions.py


示例13: mission

def mission():
    # Gets list of expeditions.
    # This is a simple query that lists all expeditions.
    # If the admiral has completed them, it will respond with the appropriate state.
    # Note that expedition details are stored in api_start2.
    expd = Expedition.query.all()
    states = {}
    for e in expd:
        if e in g.admiral.expeditions:
            states[e.id] = 2
        else:
            states[e.id] = 0
    return svdata([OrderedDict(api_mission_id=id, api_state=state) for (id, state) in states.items()])
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:13,代码来源:member.py


示例14: cancel

def cancel():
    """Cancels a mission"""
    fleet_id = int(request.values.get("api_deck_id")) - 1

    try:
        fleet = g.admiral.fleets[fleet_id]
    except IndexError:
        logger.warn("Fleet does not exist -> {}".format(fleet_id))
        abort(404)
        return

    fleet.expedition_cancelled = True
    db.session.add(fleet)
    db.session.commit()
    return svdata(MemberHelper.expedition(fleet, cancelled=True))
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:15,代码来源:expedition.py


示例15: lock

def lock():
    """Heartlock/unheartlock a ship."""
    try:
        kanmusu = g.admiral.kanmusu[int(request.values.get("api_ship_id")) - 1]
    except IndexError:
        abort(404)
        return
    except ValueError:
        abort(400)
        return
    kanmusu.locked = not kanmusu.locked

    db.session.add(kanmusu)
    db.session.commit()
    return svdata({"api_locked": int(kanmusu.locked)})
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:15,代码来源:actions.py


示例16: start_mission

def start_mission():
    # This is mostly an internal method.
    # This sets up the fleet for an expedition, sending them out.

    # First, get the required data from the request.
    fleet_id = int(request.values.get("api_deck_id")) - 1
    expedition_id = int(request.values.get("api_mission_id"))
    # There's an extra value, api_mission.
    # No idea what it does.

    # Also, api_serial_cid
    # This is presumably an anti-bot method by DMM.
    # We don't have these, because we don't have the game source code (and never will)
    # So we ignore this

    # Get the expedition requested by the ID.
    expedition = Expedition.query.filter(Expedition.id == expedition_id).first_or_404()

    # Get the fleet requested by the ID.
    try:
        fleet = g.admiral.fleets[fleet_id]
    except IndexError:
        abort(404)
        return

    # Set the fleet up.
    if fleet.expedition is not None:
        # Nice try.
        abort(400)
        return

    # Set the expedition && time.
    fleet.expedition = expedition
    fleet.expedition_completed = time.time() + expedition.time_taken

    db.session.add(fleet)
    db.session.commit()

    # Internal state updated, now to reflect this state on the rest of the app.
    return svdata(
        {"api_complatetime": util.
            millisecond_timestamp(datetime.datetime.now() + datetime.timedelta(seconds=expedition.time_taken)),
         "api_complatetime_str": datetime.datetime.fromtimestamp(fleet.expedition_completed / 1000)
            .strftime('%Y-%m-%d %H:%M:%S')
         })
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:45,代码来源:expedition.py


示例17: resupply

def resupply():
    # Get the ships. Misleading name of the year candidate.
    ships = request.values.get("api_id_items")
    ships = ships.split(',')
    ships = [int(_) for _ in ships]
    # Get kind.
    kind = int(request.values.get("api_kind"))
    api_ship = []
    # New dict for api_ships
    for ship_id in ships:
        ship = Kanmusu.query.filter(Admiral.id == g.admiral.id, Kanmusu.number == ship_id).first_or_404()
        # Assertion for autocompletion in pycharm
        assert isinstance(ship, Kanmusu)
        # Calculate requirements.
        # Simply replenish up to the maximum stats amount.
        if kind == 1:
            g.admiral.resources.sub(ship.stats.fuel - ship.current_fuel, 0, 0, 0)
            ship.current_fuel = ship.stats.fuel
        elif kind == 2:
            g.admiral.resources.sub(0, ship.stats.ammo - ship.current_ammo, 0, 0)
            ship.current_ammo = ship.stats.ammo
        elif kind == 3:
            g.admiral.resources.sub(ship.stats.fuel - ship.current_fuel, 0, 0, 0)
            ship.current_fuel = ship.stats.fuel
            g.admiral.resources.sub(0, ship.stats.ammo - ship.current_ammo, 0, 0)
            ship.current_ammo = ship.stats.ammo
        api_ship.append({
            "api_id": ship.number,
            "api_fuel": ship.current_fuel,
            "api_bull": ship.current_ammo,
            "api_onslot": [0, 0, 0, 0, 0]  # ???
        })
        db.session.add(ship)
    db.session.add(g.admiral)
    db.session.commit()
    return svdata({"api_ship": api_ship, "api_material": g.admiral.resources.to_list()})
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:36,代码来源:actions.py


示例18: ship2

def ship2():
    """Fuck ship2."""
    """Agreed."""
    return svdata({})
开发者ID:solofandy,项目名称:kcsrv,代码行数:4,代码来源:member.py


示例19: unsetslot

def unsetslot():
    return svdata(MemberHelper.unsetslot())
开发者ID:solofandy,项目名称:kcsrv,代码行数:2,代码来源:member.py


示例20: ndock

def ndock():
    return svdata(MemberHelper.rdock())
开发者ID:solofandy,项目名称:kcsrv,代码行数:2,代码来源:member.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.system函数代码示例发布时间:2022-05-26
下一篇:
Python util.substr函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap