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})
def ship3(): admiral = get_token_admiral_or_error() #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)
def basic(): """Basic admiral data.""" return svdata(AdmiralHelper.get_admiral_basic_info())
def mapinfo(): return svdata(AdmiralHelper.get_admiral_sorties())
def material(): """Resources such as fuel, ammo, etc...""" admiral = get_token_admiral_or_error() return svdata(AdmiralHelper.get_admiral_resources_api_data(admiral))
def generate_port(api_token): # First, get the admiral. admiral = util.get_token_admiral_or_error(api_token) assert isinstance(admiral, Admiral) # Initial KanColle reply. port2 = {"api_data": {}} # TODO: Log entry port2["api_data"]['api_log'] = [{ "api_state": "0", "api_no": 0, "api_type": "1", "api_message": "ayy lmao" }] # Background music? port2["api_data"]["api_p_bgm_id"] = 100 # This sets the parallel quest count. Don't know what higher values do, default is 5. # I set it to ten because f**k the police port2["api_data"]["api_parallel_quest_count"] = 10 # Combined flag? Event data probably. port2["api_data"]["api_combined_flag"] = 0 # API basic - a replica of api_get_member/basic basic = AdmiralHelper.get_admiral_basic_info() port2['api_data']['api_basic'] = util.merge_two_dicts( basic, { 'api_medals': 0, 'api_large_dock': 0 }) port2['api_data']['api_deck_port'] = [ ] #AdmiralHelper.get_admiral_deck_api_data(admiral) count = 0 # Sort the admiral ships list. Not even sure if this is needed... # Fleets. for fleet in admiral.fleets.all(): count += 1 ships = [ ship.local_ship_num + 1 for ship in fleet.ships.all() if ship is not None ] temp_dict = { # Unknown value, always zero for some reason. 'api_flagship': 0, # The Admiral ID, presumably. 'api_member_id': admiral.id, # The name of the fleet. 'api_name': fleet.name, # Unknown value, always empty. 'api_name_id': "", # The local fleet ID. 'api_id': count, # List of ships. "api_ship": ships + [-1] * (6 - len(ships)), # Mission data? "api_mission": [0, 0, 0, 0] } port2['api_data']['api_deck_port'].append(temp_dict) # Materials. port2['api_data'][ 'api_material'] = AdmiralHelper.get_admiral_resources_api_data(admiral) port2['api_data']['api_ship'] = [] # Ship data, Luckily this is generated for us by a helper class. admiral_ships = sorted(admiral.admiral_ships.all(), key=lambda x: x.local_ship_num) for num, ship in enumerate(admiral_ships): if not ship.active: continue assert isinstance(ship, AdmiralShip) port2['api_data']['api_ship'].append( ShipHelper.get_admiral_ship_api_data(ship.id)) # Generate ndock. port2['api_data']['api_ndock'] = DockHelper.generate_dock_data( admiral)['rdock'] return port2
def queststop(): admiral = get_token_admiral_or_error() quest_id = request.values.get("api_quest_id") AdmiralHelper.deactivate_quest(quest_id, admiral) return svdata({'api_result_msg': 'ok', 'api_result': 1})
def queststop(): admiral = get_token_admiral_or_error() quest_id = request.values.get("api_quest_id") AdmiralHelper.deactivate_quest(quest_id,admiral) return svdata({'api_result_msg': 'ok', 'api_result': 1})
def generate_port(api_token): # First, get the admiral. admiral = util.get_token_admiral_or_error(api_token) assert isinstance(admiral, Admiral) # Initial KanColle reply. port2 = { "api_data": {} } # TODO: Log entry port2["api_data"]['api_log'] = [ { "api_state": "0", "api_no": 0, "api_type": "1", "api_message": "ayy lmao" } ] # Background music? port2["api_data"]["api_p_bgm_id"] = 100 # This sets the parallel quest count. Don't know what higher values do, default is 5. # I set it to ten because f**k the police port2["api_data"]["api_parallel_quest_count"] = 10 # Combined flag? Event data probably. port2["api_data"]["api_combined_flag"] = 0 # API basic - a replica of api_get_member/basic basic = AdmiralHelper.get_admiral_basic_info() port2['api_data']['api_basic'] = util.merge_two_dicts(basic, { 'api_medals': 0, 'api_large_dock': 0 }) port2['api_data']['api_deck_port'] = [] #AdmiralHelper.get_admiral_deck_api_data(admiral) count = 0 # Sort the admiral ships list. Not even sure if this is needed... # Fleets. for fleet in admiral.fleets.all(): count += 1 ships = [ship.local_ship_num+1 for ship in fleet.ships.all() if ship is not None] temp_dict = { # Unknown value, always zero for some reason. 'api_flagship': 0, # The Admiral ID, presumably. 'api_member_id': admiral.id, # The name of the fleet. 'api_name': fleet.name, # Unknown value, always empty. 'api_name_id': "", # The local fleet ID. 'api_id': count, # List of ships. "api_ship": ships + [-1] * (6 - len(ships)), # Mission data? "api_mission": [0, 0, 0, 0] } port2['api_data']['api_deck_port'].append(temp_dict) # Materials. port2['api_data']['api_material'] = AdmiralHelper.get_admiral_resources_api_data(admiral) port2['api_data']['api_ship'] = [] # Ship data, Luckily this is generated for us by a helper class. admiral_ships = sorted(admiral.admiral_ships.all(), key=lambda x: x.local_ship_num) for num, ship in enumerate(admiral_ships): if not ship.active: continue assert isinstance(ship, AdmiralShip) port2['api_data']['api_ship'].append(ShipHelper.get_admiral_ship_api_data(ship.id)) # Generate ndock. port2['api_data']['api_ndock'] = DockHelper.generate_dock_data(admiral)['rdock'] return port2
def basic(): return svdata(AdmiralHelper.get_admiral_basic_info())
def generate_port(api_token): # First, get the admiral. admiral = util.get_token_admiral_or_error(api_token) assert isinstance(admiral, db.Admiral) # Initial KanColle reply. port2 = { "api_result_msg": "成功", "api_result": 1, "api_data": {} } # TODO: Log entry port2["api_data"]['api_log'] = [ { "api_state": "0", "api_no": 0, "api_type": "1", "api_message": "ayy lmao" } ] # Background music? port2["api_data"]["api_p_bgm_id"] = 100 # This sets the parallel quest count. Don't know what higher values do, default is 5. # port2["api_data"]["api_parallel_quest_count"] = 5 # Combined flag? Event data probably. port2["api_data"]["api_combined_flag"] = 0 # API basic - a replica of api_get_member/basic basic = AdmiralHelper.get_admiral_basic_info() port2['api_data']['api_basic'] = util.merge_two_dicts(basic, { 'api_medals': 0, 'api_large_dock': 0 }) port2['api_data']['api_deck_port'] = [] count = 0 admiral_ships = sorted(admiral.admiral_ships.all(), key=lambda x: x.local_ship_num) # Fleets. for fleet in admiral.fleets.all(): count += 1 ships = [ship.local_ship_num+1 for ship in fleet.ships.all() if ship is not None] temp_dict = { # Unknown value, always zero for some reason. 'api_flagship': 0, # The Admiral ID, presumably. 'api_member_id': admiral.id, # The name of the fleet. 'api_name': fleet.name, # Unknown value, always empty. 'api_name_id': "", # The local fleet ID. 'api_id': count, # List of ships. "api_ship": ships + [-1] * (6 - len(ships)), # Mission data? "api_mission": [0, 0, 0, 0] } port2['api_data']['api_deck_port'].append(temp_dict) # Materials. port2['api_data']['api_material'] = [ {"api_id": n + 1, "api_member_id": admiral.id, "api_value": int(val)} for n, val in enumerate(admiral.resources.split(',')) ] # Ships! Yay! (said nobody) port2['api_data']['api_ship'] = [] # Generate the absolute clusterfuck. # count = 0 for num, ship in enumerate(admiral_ships): # count += 1 if not ship.active: continue assert isinstance(ship, db.AdmiralShip) port2['api_data']['api_ship'].append(ShipHelper.generate_api_data(admiral.id, ship.local_ship_num)) # Generate ndock. port2['api_data']['api_ndock'] = DockHelper.generate_dock_data(admiral)['rdock'] return port2