XVs32 / kcauto_custom

kcauto_custom, the successor to kcauto, a Kantai Collection (Kancolle) bot / automation tool
https://xvs32.github.io/kcauto_custom/
GNU General Public License v3.0
9 stars 2 forks source link

Load the recorded equipment of every ship #87

Closed XVs32 closed 9 months ago

XVs32 commented 10 months ago

What

How

Result

Reference

XVs32 commented 10 months ago

Final decision:

  • Use port api to find the equipment currently loaded on a ship
  • Use api_get_member/ship3/api_slot_data to find equipment currently unuse

_Originally posted by @XVs32 in https://github.com/XVs32/kcauto_custom/issues/85#issuecomment-1902114110_

XVs32 commented 10 months ago

The reload process will be:

  1. Compare the target equipment list to current list :heavy_check_mark:
  2. Unload all equipment on a ship if she doesn't match any equipment on the list :heavy_check_mark:
  3. Load the correct equipment for ships in "2"
XVs32 commented 10 months ago

2.Unload all equipment on a ship if she doesn't match any equipment on the list

Unload everything if any of the following hits:

  1. If a ship doesn't have the equipment on record
  2. If a ship is not on the record (a new ship)
  3. Do NOT unload a ship if she has no equipment already
XVs32 commented 10 months ago

Next step is loading equipment on a ship, the following need to be done:

  1. Get the available equipment api data by loading/unloading random equipment
  2. Sort the data from api to get the available equipment list
  3. switch to "all equipment"(全裝備) in equipment panel
  4. switch page and click on the target equipment
XVs32 commented 10 months ago

Normal equipment load is done.... The issue is reinforcement slot has a different list for equipment, and every ship has different capability to load different equipment.....

I wonder if the port or ship api does show what reinforce equipment a ship can load... Edit: There is, api_mst_equip_exslot:補強スロットに装備可能なカテゴリ shows what カテゴリ a ship can use in reinforce slot, This api only sends on kancolle start up, but this is static data afterall, so it should... be fine

XVs32 commented 10 months ago

The flow of generating available reinforce equipment list should be:

  1. From current ship id, get api_stype(艦種ID) and api_ctype(艦型ID) <= Ship has the data
  2. Search the api_mst_equip_exslot_ship to get the special available equipment list
  3. Search the api_slot_data to find the category of each special available equipment
  4. Use the category as key to sort the normal and special reinforce equipment
  5. There you go the available reinforce equipment list
XVs32 commented 10 months ago

Let't sort this out... The api_id is the production id (non-repetitive) The api_ship_id is the ship id (repetitive)

from this api call, api_id = local_api_id, and api_ship_id = api_id

I don't know why Minyoung made api_id = api_ship_id, maybe some other api use api_id as ship id(repetitive) But whatever, I will stick with the definition above and rewrite Ship class

Ship class should now include all the info provided from api_start2/getData and port

XVs32 commented 10 months ago

Today's progress:

  1. kcauto can now find the general reinforce equipment currently in port
  2. kcauto can find the "name_id" of specific ship's reinforce equipment

todo:

  1. Find the list for equipment "name_id" and "production_id" conversion
  2. Convert the "name_id" to "production_id" from "2" above
XVs32 commented 10 months ago

There are three ways to find the "name_id" and "production_id" conversion list:

I decided to use the data from "Perform a sortie", Data from api_get_member/slot_item contains what I need.

XVs32 commented 10 months ago

Every time kcauto reads api, it also remove all apis currently queued up, Which means if api A and api B arrive at the same time, you cannot read api A first, then come back later for api B, because B gets removed after the first read attempted.

The solution is simple, tell the api update function that you want to read both 'A' and 'B', instead of calling the update function twice.

XVs32 commented 9 months ago

The loading function looks good now, need more test to be sure though.

Since this function does not conflict with other functions, I will merge it to develop first for the coming event.

XVs32 commented 9 months ago

The 改良型艦本式タービン is available for all ship in the reinforce slot, so they use stype: 99 to represent it..... ref

Thanks kancolle staff took me forever to find out

LOL (I will quickly fix my code to suit this)