Nine pages per language (home, description, install, one page per lecture step with its screenshot and what was gained, appendix) plus the sidebar. Doxygen now runs without warnings. The publish workflow is the framework template, unchanged. Task: MIL-005#1 Task: MIL-005#2 Task: MIL-005#3 Task: MIL-005#4 Task: MIL-005#5 Closes #24 Closes #25 Closes #26 Closes #27 Closes #28
1.5 KiB
1.5 KiB
Step 4: buy upgrades
🌐 English · Dansk · Bahasa Melayu
get_store_items reads the 20 store products, choose_upgrade picks the most expensive one the bot can afford, and buy_upgrade clicks it. The screenshot shows the first cursor bought.
Screenshot
Function
def choose_upgrade(items: Sequence[StoreItem]) -> StoreItem | None:
affordable = [item for item in items if item.is_affordable]
if not affordable:
return None
return max(affordable, key=lambda item: (item.price, item.index))
What we gained
- Keep the decision pure.
choose_upgradetakes plainStoreItemvalues and returns one, so it is tested with no game at all (ties, none affordable, empty list). - Confirm the result, do not assume it.
buy_upgradechecks that the owned amount (productOwned<N>) went up. Checking the cookie count first was wrong: the count keeps rising while the bot clicks. - The page lags behind. The live run showed that about 40 percent of the purchase attempts fail because the store flags are read just before the game redraws. The bot logs it and tries again at the next store check.
- The real game finds what fakes cannot. The stale-element retry and the owned-amount check both came from running in Docker.
