Skip to content

Typescript refactor - #614

Open
thireven wants to merge 39 commits into
r2-studio:masterfrom
thireven:typescript-refactor
Open

Typescript refactor#614
thireven wants to merge 39 commits into
r2-studio:masterfrom
thireven:typescript-refactor

Conversation

@thireven

@thireven thireven commented Aug 8, 2026

Copy link
Copy Markdown

This is an infrastructure update and should have no bearing on the game itself. I've kept it at v85 since it doesn't add anything new in the end product.

I think we should be ok to take over the old/abandoned Tsum folder here. This update should have the same updates as Beta and should ultimately be what most people use after the update.

thireven and others added 25 commits May 25, 2026 14:44
Reads raw touch events via getevent to detect where the user taps, then
finds the connected same-color component at that position and draws the
chain. Disables auto-play when active so the user picks the cluster.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ws only.

Broke up scripts into multiple files
A few other updates
fix to long-running skills that messes up the script
The tiara-minnie-plus merge restored the pre-refactor monolithic index.ts
alongside the split files. Since tsconfig concatenates index.ts last, its 54
duplicate Tsum.prototype assignments overwrote the split versions at load
time, making the tiara/minnie+ skill, dialog handling and taskWatchdog dead
code. Restore the entry-point index.ts and move the master-side Click Assist
work into clickAssist.ts + pathfinding.ts (findChainAtTouch). pollSkillActivation
is dropped: link()'s blind-tap path supersedes it.

Each skill now lives in its own file under src/skills/ and registers a handler
with skillCore.ts. useSkill keeps the parts common to every skill -- gauge
check, fever hold-off, activation tap(s) -- and delegates the choreography.
Pair Tsum's second button and the burst family's blind-tap eligibility become
registry flags instead of skillType string comparisons scattered across
useSkill, link and maybeAutoTapSkill. Drops the isSkillActive helper, which
duplicated checkSkillReadiness's color table and was equivalent to its
'active' result.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Orientation doc for the source: what each non-skill .ts file holds, how the
concatenated single-global-scope bundle works and why tsconfig file order
matters, the settings-UI-to-script boundary, the dependency layering, and a
lookup table for common tasks. Links it from README.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Replaces the monolithic index.js/index.html with TsumThi's split TypeScript
source (src/*.ts + src/skills/, outFile-bundled to dist/index.js), including
all 15 skill handlers, and the build/deploy tooling that goes with it.

Excluded: the file-backed pause (gPause + tools/pause-hotkey.ahk), which is a
PC-side dev aid rather than a script feature. doc/screenshots is not
duplicated -- the Tiara reference frames stay in com.r2studio.TsumThi.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@thireven

thireven commented Aug 8, 2026

Copy link
Copy Markdown
Author

@mcs @jasoncwho Here's the TS refactor. Made the DEVELOPMENT.MD to explain the structure and where things live as a starting point for other developers.

Sean-Hsueh and others added 3 commits August 8, 2026 12:47
@thireven
thireven force-pushed the typescript-refactor branch from 33386a0 to 07c1b44 Compare August 8, 2026 19:49
@mcs

mcs commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Hey hey,

I'll try compiling it tomorrow, diff the result with the current script files and try understanding the structure. Typescript is of course a way better choice for source code than ES4, but even mid 2026 I am still sceptical regarding AI generated stuff. I'll leave a review here soon 😊

@jasoncwho

Copy link
Copy Markdown
Contributor

@thireven you are changing the behavior of depth first search in this refactor, could u take it out and keep the same logic as it so that we can do an apple to apple comparison? Thanks

thireven and others added 3 commits August 9, 2026 00:42
Closes the last feature gaps against TsumBeta v85:

- "Maximum chain length" setting (default 0 = no limit). Caps the chain
  the board scan returns, trading a few long chains for many short ones,
  which suits Roxas/Maleficent-type Tsums and high-FPS setups. Applied as
  a stopping condition inside the longest-path DFS rather than a trim, so
  a short cap also halves the per-scan search cost. Click Assist is
  exempt -- pointing at a chain should still draw all of it.
- Re-measured the eight lock-badge samples used by "Unlock Level every
  hours" (239,247,255 on the current client).
- Board scans log the chain lengths they found when debug logs are on.

Verified offline at caps 0/3/5/8/12: chains never exceed the cap, stay
contiguous, repeat no tsum, and a cap above what the board offers gives
exactly the uncapped result.

Deliberately not ported: TsumBeta's greedy nearest-neighbour path search
(the graph longest-path here supersedes it), and the
"Handle Long Skill Animations" toggle -- Tsum already confirms game over
positively rather than assuming it, unconditionally.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Tsum is a TypeScript refactor of TsumBeta, so a run of one has to be
comparable with a run of the other. Settings surface is now identical on
every shared key -- same titles, defaults, min/max/step:

- "Maximum Chain Number" takes Beta's spec (3-15, default 3) instead of
  the 0-means-no-limit variant added here.
- "Handle Long Skill Animations" added; the positive game-over
  confirmation is now behind it, as in Beta, rather than always on.
- "Auto Tap Skill" back to Beta's title and its default of on.
- "Tsum app restart frequency" back to 6-hour steps.

Behavioural alignment:

- linkTsums drag timings back to Beta's 10/10/10ms. These had been raised
  to 30/20/20 after the game was seen missing presses; if that returns it
  returns in Beta too, and they have to move together.
- taskTsumAppRestart inlines Beta's restart (10s wait, relaunch only if
  the app is down) instead of calling forceRestartApp(), which is the
  stall-recovery path and differs.

Also fixes calculateNearTsumPaths in TsumBeta, which the merge at 0e31690
left calling into the deleted findTsumComponents -- it pushed to an
undefined `components` and never appended to the path, throwing on first
use. Restored from upstream/master.

DEVELOPMENT.md gains a parity ledger: the comparison method, the
differences that are form-only (leak guards, hoisting, lifted constants,
skill dispatch table), and the ten that are real.

Remaining divergences are structural and still open: path search, native
dialog handling, navigation stall guards, the sender-portrait cap, and the
three Tsum-only settings (all defaulting to Beta's behaviour).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The rest of the Page and Button tables compare value-identical; the
RootDetection entries differ because the navigation loops branch on the
unified name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@thireven
thireven force-pushed the typescript-refactor branch 4 times, most recently from 996627e to 06a5fa7 Compare August 9, 2026 23:38
@thireven

thireven commented Aug 9, 2026

Copy link
Copy Markdown
Author

@thireven you are changing the behavior of depth first search in this refactor, could u take it out and keep the same logic as it so that we can do an apple to apple comparison? Thanks

@jasoncwho This branch should now have feature parity with TsumBeta


// double check
const page = this.findPage(1, 2500);
let page = this.findPage(1, 2500);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use var in ES5

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll get compiled down to var.

@thireven

Copy link
Copy Markdown
Author

I'm still working on some major refactors for this so that it can better utilize Typescript (like finding and clicking-through references).

Some of the goals I hope to achieve with this refactor:

  • Removal of strings being used as references and replaced with constants. For example, something like this.findPage() === 'GamePause' would become this.findPage() === Pages.GamePause.
  • Full typing of all functions and variables. While there are plenty of them that can already be inferred (like booleans and numbers), some of them start out completely nebulous without knowing what they're supposed to be until you dig further.

If there's anything you guys want to implement in the meantime, please do so and don't let this PR hold anything up. I can port whatever gets released into this PR until it's fully ready.

@jasoncwho

jasoncwho commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

the idea is good.
btw, the ts version still doesnt compile the same v85, starting from getDistance, findLongestTsumPath, findTsumComponents,calculatePaths which i believe is the current core tsum mechanics.
not sure if the impact whether there will be better performace, but for large code refactor like this, it is better to keep exactly the same first , and then push those new findLongestTsumPath in next PR.

@jasoncwho

Copy link
Copy Markdown
Contributor

one more difference: var blindTap = skillBareTapActivates(this.skillType);

@jasoncwho

Copy link
Copy Markdown
Contributor

this.gameBubbles = this.skillType === 'block_tiara_minnie_plus_s'
? findGameBubbles(srcImg) : [];

        pls change to 
        
         this.gameBubbles = findGameBubbles(srcImg);
         
         that would fix a lot of bubble issue for other tsum and boost game performance.

@jasoncwho

Copy link
Copy Markdown
Contributor

i have completed the review, good job, thank you for your contribution.

@thireven

Copy link
Copy Markdown
Author

the idea is good. btw, the ts version still doesnt compile the same v85, starting from getDistance, findLongestTsumPath, findTsumComponents,calculatePaths which i believe is the current core tsum mechanics. not sure if the impact whether there will be better performace, but for large code refactor like this, it is better to keep exactly the same first , and then push those new findLongestTsumPath in next PR.

I made a few minor changes based on some of the differences (removed the blindTap addition), but the intent was always feature-parity rather than exact code output match. They should result in the same game behavior.

Thank you for the time put in reviewing this PR so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants