Skip to content

Commit

Permalink
Merge pull request #92 from XVs32/85-record-the-equipment-of-every-ship
Browse files Browse the repository at this point in the history
85 record the equipment of every ship
  • Loading branch information
XVs32 authored Jan 20, 2024
2 parents 6751ebb + 12c115f commit 72150eb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
5 changes: 4 additions & 1 deletion kcauto/api/api_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import combat.combat_core as com
import combat.lbas_core as lbas
import expedition.expedition_core as exp
import ships.equipment_core as equ
import fleet.fleet_core as flt
import fleet_switcher.fleet_switcher_core as fsw
import pvp.pvp_core as pvp
Expand Down Expand Up @@ -239,6 +240,8 @@ def _process_port(self, data):
try:
ship_data = data['api_data']['api_ship']
shp.ships.update_local_ships(ship_data)
equ.equipment.get_loaded_equipment(ship_data)

except KeyError:
Log.log_debug("No ship data found in API response.")

Expand Down Expand Up @@ -273,7 +276,7 @@ def _process_port(self, data):
Log.log_debug("No exp data found in API response.")

try:
gimmick = data['api_event_object']['api_m_flag2']
gimmick = data['api_data']['api_event_object']['api_m_flag2']
Log.log_debug(f"Gimmick data found = {gimmick}.")
if gimmick == 1:
"""A gimmick is solved"""
Expand Down
1 change: 0 additions & 1 deletion kcauto/combat/combat_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ def _click_until_port(self):
def _next_node_handler(self):

while self.combat_api_listener_enable:
Log.log_msg(f"Listening...")
api_result = api.api.update_from_api(
self.COMBAT_APIS | self.RESULT_APIS | self.SHIPDECK_API, need_all=False, timeout=5)
if KCSAPIEnum.SORTIE_NEXT.name in api_result:
Expand Down
2 changes: 2 additions & 0 deletions kcauto/kca_enums/kcsapi_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ class KCSAPIEnum(EnumBase):
PVP_ENEMY_INFO = 'kcsapi/api_req_member/get_practice_enemyinfo'
PVP_RESULTS = 'kcsapi/api_req_practice/battle_result'
EXPEDITION_START = 'kcsapi/api_req_mission/start'
#equipment
FREE_EQUIPMENT = 'kcsapi/api_get_member/ship3'
29 changes: 29 additions & 0 deletions kcauto/ships/equipment_core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from util.json_data import JsonData
from util.logger import Log
from util.wctf import WhoCallsTheFleetData

class EquipmentCore(object):

equipment = {}

def __init__(self):
self.equipment["loaded"] = {}
self.equipment["free"] = {}

def get_loaded_equipment(self, api_data):
"""
method to read the loaded equipment list from api data
api_data (dict) : data from "port/api_data/api_ship" api
"""
self.equipment["loaded"] = {}

for ship in api_data:
Log.log_debug(f"ship {ship['api_id']} equipment")
Log.log_debug(ship["api_slot"])
Log.log_debug(ship["api_slot_ex"])
self.equipment["loaded"][ship['api_id']] = ship["api_slot"]
self.equipment["loaded"][ship['api_id']].append(ship["api_slot_ex"])
Log.log_debug(self.equipment["loaded"])

equipment = EquipmentCore()

0 comments on commit 72150eb

Please sign in to comment.