Files
myrzx_bot/analysis/RANCH_HELPER.md
T

271 lines
18 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Native Qt ranch companion
Implemented in `ranch_assistant`; launch `Start_Ranch_Helper.cmd`.
See `ranch_assistant/README.md` for login, strategies and page screenshots.
The successful V4 combat package was not modified or rebuilt.
## Current workflow
- The compact native page is named 自动孵蛋. The backpack table has per-species
hatch checkboxes, numeric priority, explicit dispatch/feed/keep disposition,
reorder threshold, target stock and eligible coin market. Unchecked species
cannot trigger hatching or buying. Zero-stock configured rules stay visible.
No profitability heuristic chooses the disposition in the UI. The green-slime
preset enables that species alone, priority 1, dispatch, reorder below 1 to 10,
Lilitos market, and retains 4+ stars/A+ grades. Startup remains read-only.
- Login is a simple 登录 page with credentials, official region selection
and saved sessions. Server/token/key/counter controls remain internal only;
logging continues but the debug window opens only on explicit user request.
Native margins/spacing, tab fonts and table rows are compact; manager size is
1100x740 with scrollable settings. Currency/stamina placement was retained.
- The page/log split is vertically draggable, and an explicit show/hide button
preserves logging while hidden. Size and visibility restore per role. Tests
verify that the log can grow beyond the old fixed height and retain records.
- Rule priorities, reorder thresholds/targets and feeding priorities use plain
validated integer line edits, not spin buttons. Full-width 22px scrollbars
receive their own Qt style; application/window/button styles are unchanged.
Manual typing and actual scrollbar sizes were verified at device scale 2.
- Market buying uses `gachaService/gachaGetEggs` with `sc_city<city>`, a bounded
quantity, zero vouchers and balance trace info. Only known coin markets are
eligible. Lilitos costs 100 coins per random egg in the shipped table; it does
not guarantee a green slime. Ten-draw preference sends num=10 using the same
endpoint; actual returned eggs/bonuses are displayed, not promised in advance.
Per-species reorder rules, batch limit, reserved balance and per-role daily
coin budget bound purchases. The budget is persisted before
sending, survives restart, and is not refunded automatically on timeout.
Real `unlockCity` ID arrays such as `["1"]` and legacy boolean maps are both
accepted, including by recurring-task city checks.
- Yield data has independent 1–5-star display filters. Incubation follows checked
species rules; dispatch still follows the protection policy. Feeding
stops at min(user target, potentialLevel * potentialLevelMaxAdd), where the
shipped increment is 10. Unknown breakthrough information stops feeding.
Checked recipients are served by numeric priority, advancing after a target
reaches its cap. Monster rows/details show breakthrough, growth grades,
reference stats, affection and named gift preferences. Reference stats omit
equipment, entanglement and global bonuses and are labeled as such. Context
menus provide lock/unlock and confirmed manual dispatch or feeding; manual
operations pause automatic execution and recheck live state.
Level caps appear in monster and feeding-target views. Quest rows now include
reward coins and premium currency; the role summary also shows current ke.
- Password login uses the normal DYD channel SDK endpoint recovered from the
APK, then the game's SDK-session login. The UI lists the returned Android
servers with existing role names. It does not assume exactly two regions.
The selected server supplies `gameServerAddress`; the center address comes
from the shipped configuration. Remembering the account/password is now on
by default as requested. Passwords are stored with current-user Windows DPAPI
in `credentials.json`, restored on restart and retained after failed login.
Successful role reads now also save the token, protocol key and request counters
in DPAPI-encrypted `sessions/` files. Remember-password controls are independent
of saved sessions. Tokens are not stored in plaintext settings or debug logs.
- `AccountsWindow` hosts independent account tabs, each with its own worker,
engine, trace and credential/session store. The legacy first-account root is
preserved; new accounts use `profiles/<id>/`. Role settings and captures use
`roles/<identity>/`, including account, channel, platform, region and role in
the identity. Switching tabs does not stop another account's monitor.
- Saved sessions restore only after a read verifies the expected role ID.
Automatic execution stays off. Counter high-water marks persist before each
request, including restore requests that time out. Duplicate account-region
connections are guarded within the manager, and workspace locks prevent
opening a profile twice. ADB farming permits one controlling tab per device.
- All data pages support a right-click read-only refresh in their table/blank
area. Local catalog/capture pages refresh local files; role pages read the
role snapshot. Pending manual refreshes queue behind an active request.
The pasture overview now displays counts/capacity, and the summary distinguishes
real versus demo state and shows update time and inventory counts.
- The native debug dialog records each request, HTTP status, elapsed time,
decoded response and errors, including the raw decoded server list before
schema validation. Records are redacted before display or disk storage.
The automatic log is `local_state/ranch_helper/network_debug.jsonl`.
Password login does not open the dialog, and waits for explicit region selection
before `enterGame`. Copy/export actions operate on redacted records.
- The new page-screenshot tab has seven explicit ADB capture buttons. The user
navigates to each page. Capturing pauses assistant monitoring/farming, checks
that the game is foreground, reads the screenshot and saves it. It does not
tap, launch or navigate the phone. No token or login is needed for capture.
- Required samples: stage preparation and victory settlement. Optional samples:
countdown, auto off/on, additional confirmation, defeat. No deliberate defeat
is needed. Original PNGs and `profile.json` are grouped under
`<active-role-directory>/capture_profiles/<serial>/<WxH>/<stage>_<level>/`.
- After the user captures pages, the assistant can inspect those workspace
files and call `capture.write_buttons` with reviewed regions and tap points.
The Qt app loads the resulting `buttons.json`; it does not include a model
that automatically understands arbitrary screenshots. Manual cropping remains
an optional fallback. Profiles can be restored and previewed after restart.
- Generated button configurations check source-image hashes, stage/difficulty,
device identity and exact resolution. Victory recognition and its confirmation
tap can use different positions. Changed samples require regenerated buttons.
- Recurring task planning can accept eligible offers, submit explicitly allowed
resources, advance satisfied steps and claim rewards. Needed eggs/monster
types are reserved against ranch actions. Battles and subsequent story steps
wait for the game; automatic navigation to each quest battle is not implemented.
- The map view shows stage/difficulty unlock and pass records from the account
snapshot, and can choose a normal ADB farming target. There is no claimed
standalone instant-sweep endpoint or headless battle simulator.
- The incubation view includes closed positions and the separate VIP slot.
Real snapshots use monsterId=-1 for an empty slot; <=0 values now count as
empty and negative IDs never enter the managed-monster set. Offline replay of
the retained response now produces three hatch actions for its three non-VIP
empty slots, where the previous planner produced none.
- Growth synchronization now follows MonsterCenter.secondHandler and
checkGrowUpHandler: both clock-driven phase transitions request settlement,
and datas/stackMonsterInfos provide the authoritative mode and growth values.
A per-monster cache prevents stale role reads from reverting that confirmed
state; it is discarded when the main response agrees or the instance changes.
Pending/zero growth is unknown rather than four C grades. Inventory actions
wait for complete mature qualities. Incomplete replies are throttled instead
of causing a request every poll. Explicit growth sync does not dispatch/feed.
- UI phases, pending qualities, auto-execution state and exact protection reasons
now distinguish read-only monitoring from active processing. Runtime execution
toggles are recorded locally. The user's retained response also exposed
roomId=null on incubator monsters: room-capacity counting now handles it.
Replaying the mature response with the saved rules yields two protected
collection actions and two dispatch actions, without the int(None) exception.
- Slot and pasture pages have coin/premium expansion buttons and context menus.
Pricing uses stack_price/room_price and actual openType=1/2 facility counts,
as HistoryVo does, instead of stale history counters. The UI confirms cost and
level before submitting. Fresh reads reject changed quotes, insufficient
balances/levels, already-open positions, and ordinary VIP-slot expansion.
Coin pasture construction unlocks from completed task 1001011, matching the
HistoryVo getter rather than requiring a missing raw openFarmBuild field.
## Artifact evidence
- `NetStack.as`, `NetMonster.as`: incubation, growth settlement, transfer,
dispatch and feeding payloads, including singular/plural dispatch differences.
- `MasterCenter.as`, `MonsterCenter.as`, `StackCenter.as`, `MonsterVo.as`,
`GameMath.as`: snapshot data, maturity, room/VIP limits, growth grades,
sale values and feeding experience formula.
- `MarketPanel.as:68,84`, `GachaPanel.as:302`, `GachaCenter.as:37`, `NetGacha.as`:
market machine IDs, balances, zero-voucher coin costs and purchase payload.
`GameMath.as:544`, `MonsterVo.as:1121` and `potential_info`: breakthrough cap.
`tools/extract_ranch_catalog.py` now retains the nine city-market definitions
and the two level-limit constants.
- `StackVo.isEmpty`, `StackOpenType`, `HistoryVo`, `AddStackPanel`, `AddRoomPanel`,
`NetStack`, `NetRoom`: <=0 empty sentinel, VIP position 3, openType-based prices,
levels, and normal slot/pasture creation payloads. `NetMonster.setLock` and
feeding/dispatch methods supply the manual management requests.
- The catalog also retains monster base stats/gift preferences, referenced gift
names, slot/pasture prices and slot total. MonsterVo's level, potential,
affection and upStar formulas inform labeled reference stats.
- `analysis/sdk_login/*.java`: normal SDK password endpoint
`https://gameapi.diyidan.net/g0.3/users/reallogin`, form fields, query fields,
application headers and returned user-session fields. SDK 407/408 stop login;
SMS challenge UI is not implemented. `MYRStarter.as` supplies app identity.
- `NetUser.as`: SDK-session login and server entry. Its development-only login
is not used as ordinary channel authentication.
- `NetTask.as`, `TaskCenter.as`, `TaskStepVo.as`, `TaskType.as`: recurring task
acceptance, step/reward payloads, one-based server step indices and kill targets.
- `NetStage.as`, `BattleData.as`, `BattlePanel.as`: ordinary stage start,
local simulation and `battleEnd` containing kills, damage, time, formation
and other fields. This is not merely a success flag. Server-side validation
remains unknown. No sweep endpoint was found in the inspected network classes.
- `MYRCryptor.as` and `tools/extract_ranch_catalog.py`: MD5 resource paths,
zlib/AMF3 table decoding. Extracted 749 monsters, 1,178 stages, 78 special-stage
entries and 83 recurring task definitions, plus rooms, server and game settings.
External source: [BWIKI yield comparison](https://wiki.biligame.com/myrzx/%E9%AD%94%E7%89%A9%E6%94%B6%E7%9B%8A%E8%A1%A8),
previously accessed 2026-11-07, visible page date 2020-12-05. Its opportunity-cost
method informs the configurable strategy; numeric values come from the APK.
## Validation and remaining inputs
88 unit/integration tests pass: local encrypted HTTP and inventory actions,
SDK password form/headers -> two Android regions -> selected region entry ->
snapshot, verification/limited-login stops, recurring tasks and protections,
map unlocks per difficulty, screenshot/profile storage and invalidation, fake
device resolution/identity gates, separate recognition/tap coordinates, and
Qt capture buttons performing no phone taps/navigation. Tests also cover Windows
DPAPI persistence, failed-login credential restoration, debug UI updates,
decrypted response retention on schema failure, timeout/HTTP failure records,
and redaction of nested secrets, previews and exception messages.
The new coverage includes the encrypted HTTP buy -> hatch -> growth settlement
-> dispatch -> refreshed coin balance cycle, read-only previews, purchase limits,
unknown/premium/locked markets, raw city ID arrays, restart-persistent purchase
accounting, timeout accounting, star filtering, reservations across split stacks,
breakthrough caps, independent module switches, start while busy, stop during a
read, Qt settings restoration, and visible quest premium-currency rewards.
Growth regression tests cover the two-stage transition, authoritative qualities
over stale reads, automatic dispatch after settlement, S-grade retention with a
specific reason, zero/unknown qualities, no-progress throttling, explicit sync,
UI quality updates and the nullable roomId capacity path.
Login follow-up: the actual retained login response contains two complete server
objects with valid `id` fields, followed by two Fastjson-style `$ref` aliases to
`$.servers[0]` and `$.servers[1]`. Earlier missing-key diagnosis did not account
for these aliases. The normalizer previously rejected the third entry, so the
successful HTTP/JSON response never reached the region selector.
The fix resolves references within the server array, checks chains/bounds/cycles,
deduplicates by server ID, and joins roles using `masterInfos.serverId`.
`masterInfos.id` remains the character ID. Original response data is not mutated
by the normalizer; no URLs are fetched while resolving references. Conflicting
game addresses for one server ID still stop entry. Local failures are labeled
as such in the debug window and are not logged twice at the UI boundary.
Offline replay of the actual local log now yields two server IDs (1, 2), both
matched role names, and both original game addresses. Regression tests cover
normalization, the Qt dropdown and password -> select second server -> snapshot
using a loopback service with the four-entry reference response. The user has
since confirmed successful live entry and role retrieval after the signing fix.
Entry-signature follow-up: the user's next actual log shows successful SDK
authentication and center login, followed by HTTP 200 with `resCode=990`,
`resMsg=Illegal` from `enterGame`. This is a server rejection; the response
does not identify which field failed validation. SDK UID length/value checks
match the center's player UID; the request sequence matches the client queue.
Two concrete client mismatches were found and fixed. `NetUser.makeRandom`
passes `yyMMdd` to `Paster.timestampFormat`, but
`loader_as/scripts/net/pixvi/pfw/utils/Paster.as:86` substitutes `Date.fullYear`
for `yy`, producing an eight-digit date. The helper previously used Python's
two-digit `%y`; it now uses `%Y%m%d`. Also, the original APK's
`assets/tjchannel.json` contains `taptap`, distinct from the game channel `DYD`.
The extractor now retains that resource; SDK center login and entry send its
tracking value rather than copying the game channel. Missing resources use
the original client's `unknow` fallback.
Regression tests pin a date and verify an independent expected MD5 preimage
using synthetic UID/token tails. The loopback login service now rejects wrong
signatures or tracking channels with 990 before allowing role entry. The debug
log includes a local entry-parameter summary without UID/token fragments or
the signature preimage. The user subsequently confirmed successful login and
role retrieval; the retained log contains successful snapshot responses.
Inventory-display follow-up: the successful real snapshot had
`activityHistory.vipInfo=null`. The planner called `.get()` on that null object
before rendering the received data. The null handling is corrected; strategy
errors also leave fetched base data available while disabling actions. Offline
Qt replay of the actual response now shows four incubation slots, four egg
types, four monsters and one pasture. No real inventory action was executed.
Additional regression coverage verifies concurrent isolated account workers,
restart/resume for both accounts, role-specific policy restoration, secret-free
session ciphertext, advanced counters on timeouts, wrong-role rejection,
right-click refresh without writes, normal heartbeat use, and closing/reopening
fresh tabs without starting queued work after close. Heartbeats use the normal
`heartBeatService/keepAlive` at the original `GameCenter`'s 240-second interval;
no client-identity concealment or detection-evasion behavior was implemented.
The offline inventory in `API_INVENTORY.md`, `.csv` and `.json` lists 116 game
paths (115 have send call sites; one is declaration-only), 119 call sites and
13 SDK call variants. `tools/build_api_inventory.py` resolves local path
constants and literal sends and checks coverage against the earlier 111-path
index. Five payment-prefix paths were previously omitted. Sources and callback
fields are linked; the login/entry/snapshot path has now been observed in the
user's real logs. Other endpoint behavior remains statically inferred.
Native Qt was rendered offscreen with installed CJK fonts. The screenshot tab
preview is `ranch_helper_capture_preview.png`; manager/session previews are
`ranch_helper_multi_account_preview.png` and `ranch_helper_session_preview.png`.
The automation preview is `ranch_helper_automation_preview.png`.
These previews use synthetic data. The developer's tests did not send real
credentials to official services, or execute real inventory actions/battles.
The user's own login and snapshots are confirmed; new multi-account live use,
inventory automation and user-triggered page samples still need integration.
At the user's request, there was no further live device inspection/navigation
while they were playing.
The activity's standalone daily-limit field remains unidentified. Farming checks
available tickets plus a labeled local daily attempt limit, including failures
and interruptions. This is not claimed to query the official daily quota.