├── .gitattributes ├── .github ├── actions │ └── build │ │ └── action.yml └── workflows │ ├── deploy-website.yml │ └── pull-request.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── app ├── app.ts ├── download.ts ├── index.html ├── index.ts └── utils.ts ├── build.ts ├── bun.lockb ├── content └── app.css ├── favicon.ico ├── models ├── BaseSkillTreeRenderer.ts ├── Constants.ts ├── PIXISkillTreeRenderer.ts ├── SkillNode.ts ├── SkillTreeData.ts ├── SkillTreeEvents.ts ├── SkillTreeUtilities.ts ├── events │ └── UIEvents.ts ├── skill-tree │ ├── SkillTreePreprocessors.ts │ ├── options-preprocessors │ │ └── SkillTreeOptionsV1Preprocessor.ts │ └── preprocessors │ │ ├── SkillTreeOptionsPreprocessor.ts │ │ ├── SkillTreePreprocessor.ts │ │ ├── SkillTreeV10Preprocessor.ts │ │ ├── SkillTreeV11Preprocessor.ts │ │ ├── SkillTreeV12Preprocessor.ts │ │ ├── SkillTreeV13Preprocessor.ts │ │ ├── SkillTreeV14Preprocessor.ts │ │ ├── SkillTreeV1Preprocessor.ts │ │ ├── SkillTreeV2Preprocessor.ts │ │ ├── SkillTreeV3Preprocessor.ts │ │ ├── SkillTreeV4Preprocessor.ts │ │ ├── SkillTreeV5Preprocessor.ts │ │ ├── SkillTreeV6Preprocessor.ts │ │ ├── SkillTreeV7Preprocessor.ts │ │ ├── SkillTreeV8Preprocessor.ts │ │ └── SkillTreeV9Preprocessor.ts ├── spatial-hash │ └── SpatialHash.ts ├── types │ ├── IAscendancyClasses.d.ts │ ├── ICharacter.d.ts │ ├── IClassImage.d.ts │ ├── IConstants.d.ts │ ├── IExpansionJewel.d.ts │ ├── IGroup.d.ts │ ├── IMasteryEffect.d.ts │ ├── IPoint.d.ts │ ├── IPoints.d.ts │ ├── ISkillNode.d.ts │ ├── ISkillTreeCodec.d.ts │ ├── ISkillTreeData.d.ts │ ├── ISkillTreeOptions.d.ts │ ├── ISkillTreeRenderer.d.ts │ ├── ISpriteSheet.d.ts │ ├── IVersions.d.ts │ ├── skill-tree-json │ │ ├── ISkillTreeBase.d.ts │ │ ├── ISkillTreePreprocessor.d.ts │ │ ├── v01 │ │ │ ├── ICharacterV1.d.ts │ │ │ ├── IConstantsV1.d.ts │ │ │ ├── IGroupV1.d.ts │ │ │ ├── IRootNodeV1.d.ts │ │ │ ├── ISkillNodeV1.d.ts │ │ │ ├── ISkillTreeV1.d.ts │ │ │ ├── ISpriteSheetV1.d.ts │ │ │ └── ISpriteV1.d.ts │ │ ├── v02 │ │ │ ├── ISkillTreeV2.d.ts │ │ │ └── ISpriteSheetV2.d.ts │ │ ├── v03 │ │ │ ├── ISkillNodeV3.d.ts │ │ │ └── ISkillTreeV3.d.ts │ │ ├── v04 │ │ │ ├── IClassImageV4.d.ts │ │ │ └── ISkillTreeV4.d.ts │ │ ├── v05 │ │ │ ├── IRootNodeV5.d.ts │ │ │ ├── ISkillNodeV5.d.ts │ │ │ └── ISkillTreeV5.d.ts │ │ ├── v06 │ │ │ ├── ISkillNodeV6.d.ts │ │ │ └── ISkillTreeV6.d.ts │ │ ├── v07 │ │ │ ├── IAscendancyClassV7.d.ts │ │ │ ├── IAscendancyClassesV7.d.ts │ │ │ ├── IExpansionJewelV7.d.ts │ │ │ ├── IGroupV7.d.ts │ │ │ ├── ISkillNodeV7.d.ts │ │ │ ├── ISkillTreeRectV7.d.ts │ │ │ └── ISkillTreeV7.d.ts │ │ ├── v08 │ │ │ └── ISkillTreeV8.d.ts │ │ ├── v09 │ │ │ ├── ISkillNodeV9.d.ts │ │ │ └── ISkillTreeV9.d.ts │ │ ├── v10 │ │ │ ├── IGroupV10.d.ts │ │ │ ├── IPointsV10.d.ts │ │ │ ├── ISkillTreeV10.d.ts │ │ │ └── IUIArtOptionsV10.d.ts │ │ ├── v11 │ │ │ ├── ISkillTreeV11.d.ts │ │ │ ├── ISpriteSheetKeyV11.d.ts │ │ │ └── ISpriteSheetV11.d.ts │ │ ├── v12 │ │ │ ├── IGroupBackgroundV12.d.ts │ │ │ ├── IGroupV12.d.ts │ │ │ └── ISkillTreeV12.d.ts │ │ ├── v13 │ │ │ ├── ISkillNodeV13.d.ts │ │ │ ├── ISkillTreeV13.d.ts │ │ │ └── ISpriteSheetKeyV13.d.ts │ │ ├── v14 │ │ │ └── ISpriteSheetKeyV14.d.ts │ │ └── v15 │ │ │ ├── ISkillTreeV15.d.ts │ │ │ └── ISpriteSheetKeyV15.d.ts │ └── skill-tree-options-json │ │ ├── ISkillTreeOptionsBase.d.ts │ │ ├── ISkillTreeOptionsPreprocessor.d.ts │ │ ├── v01 │ │ ├── IAscendancyClassV1.d.ts │ │ ├── IAscendancyClassesV1.d.ts │ │ └── ISkillTreeOptionsV1.d.ts │ │ └── v02 │ │ ├── ICircleOptionV2.d.ts │ │ └── ISkillTreeOptionsV2.d.ts ├── url-processing │ ├── ISkillTreeUrlData.ts │ ├── SkillTreeCodec.ts │ └── decoders │ │ ├── ISkillTreeUrlDecoder.ts │ │ ├── SkillTreeUrlV3Decoder.ts │ │ ├── SkillTreeUrlV4Decoder.ts │ │ ├── SkillTreeUrlV5Decoder.ts │ │ └── SkillTreeUrlV6Decoder.ts └── versions │ └── verions.ts ├── package.json └── tsconfig.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/actions/build/action.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | runs: 3 | using: 'composite' 4 | steps: 5 | - uses: oven-sh/setup-bun@v1 6 | with: 7 | bun-version: 1.0.6 8 | 9 | - name: Build 10 | shell: bash 11 | run: | 12 | bun install 13 | bun run build 14 | -------------------------------------------------------------------------------- /.github/workflows/deploy-website.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Website 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | with: 13 | submodules: true 14 | 15 | - name: Build 16 | uses: ./.github/actions/build 17 | 18 | - name: Add Scripts 19 | uses: jacobtomlinson/gha-find-replace@v2 20 | with: 21 | find: "" 22 | replace: ${{ secrets.SCRIPTS }} 23 | regex: false 24 | include: dist/index.html 25 | 26 | - name: Publish 27 | uses: easingthemes/ssh-deploy@main 28 | env: 29 | REMOTE_HOST: ${{ secrets.SSH_HOST }} 30 | REMOTE_USER: ${{ secrets.SSH_USER }} 31 | SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }} 32 | SOURCE: "dist/" 33 | TARGET: ${{ secrets.SSH_DIR }} 34 | -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: Build - Pull Request 2 | 3 | on: 4 | pull_request: 5 | branches: [ master ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | with: 13 | submodules: true 14 | 15 | - name: Build 16 | uses: ./.github/actions/build -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc 262 | *.js 263 | !/scripts/*.js 264 | *.map 265 | !/scripts/*.map 266 | *.d.ts 267 | !/models/types/**/*.d.ts 268 | /index.html 269 | dist/* 270 | !dist/data -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dist/data/skill-trees"] 2 | path = dist/data/skill-trees 3 | url = https://github.com/poe-tool-dev/passive-skill-tree-json 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 EmmittJ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/app.ts: -------------------------------------------------------------------------------- 1 | import '../content/app.css'; 2 | 3 | import { SkillTreeData } from "../models/SkillTreeData"; 4 | import { SkillTreeEvents } from "../models/SkillTreeEvents"; 5 | import { ISkillTreeRenderer } from '../models/types/ISkillTreeRenderer'; 6 | import { PIXISkillTreeRenderer } from '../models/PIXISkillTreeRenderer'; 7 | import { SkillTreeUtilities } from '../models/SkillTreeUtilities'; 8 | import { SkillNodeStates } from '../models/SkillNode'; 9 | import { utils } from './utils'; 10 | import { SkillTreePreprocessors } from '../models/skill-tree/SkillTreePreprocessors'; 11 | import { SemVer } from 'semver'; 12 | import { versions } from '../models/versions/verions'; 13 | import { UIEvents } from 'models/events/UIEvents'; 14 | 15 | export class App { 16 | private skillTreeData!: SkillTreeData; 17 | private skillTreeDataCompare: SkillTreeData | undefined; 18 | private skillTreeUtilities!: SkillTreeUtilities; 19 | private renderer!: ISkillTreeRenderer; 20 | private uievents!: UIEvents 21 | 22 | public launch = async (version: string, versionCompare: string, versionJson: IVersions) => { 23 | for (const i of [version, versionCompare]) { 24 | if (i === '') { 25 | continue; 26 | } 27 | 28 | let options: ISkillTreeOptions | undefined = undefined; 29 | const semver = new SemVer(i); 30 | if (semver.compare(versions.v2_2_0) >= 0 && semver.compare(versions.v3_9_0) <= 0) { 31 | options = await fetch(`${utils.SKILL_TREES_URI}/${i}/Opts.json`).then(response => response.status === 200 ? response.json() : undefined); 32 | } 33 | var json = await fetch(`${utils.SKILL_TREES_URI}/${i}/SkillTree.json`).then(response => response.json()) as ISkillTreeBase; 34 | const data = new SkillTreeData(SkillTreePreprocessors.Decode(json, options), semver); 35 | 36 | if (i === version) { 37 | this.skillTreeData = data; 38 | } 39 | 40 | if (i === versionCompare) { 41 | this.skillTreeDataCompare = data; 42 | } 43 | } 44 | this.uievents = new UIEvents(this.skillTreeData, this.skillTreeDataCompare); 45 | this.skillTreeUtilities = new SkillTreeUtilities(this.skillTreeData, this.skillTreeDataCompare); 46 | 47 | const versionSelect = document.getElementById("skillTreeControl_Version") as HTMLSelectElement; 48 | const compareSelect = document.getElementById("skillTreeControl_VersionCompare") as HTMLSelectElement; 49 | for (const ver of versionJson.versions) { 50 | const v = document.createElement("option"); 51 | v.text = v.value = ver; 52 | if (ver === version) { 53 | v.setAttribute('selected', 'selected'); 54 | } 55 | versionSelect.appendChild(v); 56 | 57 | const c = document.createElement("option"); 58 | c.text = c.value = ver; 59 | if (ver === versionCompare) { 60 | c.setAttribute('selected', 'selected'); 61 | } 62 | compareSelect.appendChild(c); 63 | } 64 | 65 | const controls = document.getElementsByClassName("skillTreeVersions") as HTMLCollectionOf; 66 | for (const i in controls) { 67 | if (controls[i].style !== undefined) { 68 | controls[i].style.removeProperty('display'); 69 | } 70 | } 71 | 72 | const go = document.getElementById("skillTreeControl_VersionGo") as HTMLButtonElement; 73 | go.addEventListener("click", () => { 74 | const version = versionSelect.value !== '0' ? versionSelect.value : ''; 75 | const compare = compareSelect.value !== '0' ? compareSelect.value : ''; 76 | App.ChangeSkillTreeVersion(version, compare, ""); 77 | }); 78 | 79 | 80 | const reset = document.getElementById("skillTreeControl_Reset") as HTMLButtonElement; 81 | reset.addEventListener("click", () => { 82 | const start = this.skillTreeData.getStartClass(); 83 | const asc = this.skillTreeData.getAscendancyClass(); 84 | const wildwoodAsc = this.skillTreeData.getWildwoodAscendancyClass(); 85 | 86 | this.skillTreeData.clearState(SkillNodeStates.Active); 87 | 88 | SkillTreeEvents.controls.fire("class-change", start); 89 | SkillTreeEvents.controls.fire("ascendancy-class-change", asc); 90 | SkillTreeEvents.controls.fire("wildwood-ascendancy-class-change", wildwoodAsc); 91 | }); 92 | 93 | const showhide = document.getElementById("skillTreeStats_ShowHide") as HTMLButtonElement; 94 | showhide.addEventListener("click", () => { 95 | const content = document.getElementById("skillTreeStats_Content") as HTMLDivElement; 96 | const stats = document.getElementById("skillTreeStats") as HTMLDivElement; 97 | if (content.toggleAttribute('hidden')) { 98 | stats.style.setProperty('height', 'fit-content'); 99 | showhide.innerText = "Show"; 100 | } else { 101 | stats.style.setProperty('height', `80%`); 102 | showhide.innerText = "Hide"; 103 | } 104 | }); 105 | 106 | const container = document.getElementById("skillTreeContainer"); 107 | if (container !== null) { 108 | this.renderer = new PIXISkillTreeRenderer(container, this.skillTreeData, this.skillTreeDataCompare); 109 | this.renderer.Initialize() 110 | .then(() => { 111 | this.SetupEventsAndControls(); 112 | this.renderer.RenderBase(); 113 | this.skillTreeUtilities.decodeURL(); 114 | this.renderer.RenderCharacterStartsActive(); 115 | this.renderer.RenderActive(); 116 | 117 | const screenshot = document.getElementById("skillTreeControl_Screenshot") as HTMLSelectElement; 118 | screenshot.style.removeProperty('display'); 119 | screenshot.addEventListener("click", async () => { 120 | const mimeType: 'image/jpeg' = 'image/jpeg'; 121 | utils.Download(await this.renderer.CreateScreenshot(mimeType), `${version.replace(/\./g, '')}_skilltree.jpg`, mimeType); 122 | }); 123 | }) 124 | .catch((reason) => console.error(reason)); 125 | } 126 | } 127 | 128 | private SetupEventsAndControls = () => { 129 | SkillTreeEvents.skill_tree.on("highlighted-nodes-update", this.renderer.RenderHighlight); 130 | SkillTreeEvents.skill_tree.on("class-change", this.renderer.RenderCharacterStartsActive); 131 | SkillTreeEvents.skill_tree.on("class-change", this.updateClassControl); 132 | SkillTreeEvents.skill_tree.on("ascendancy-class-change", this.updateAscClassControl); 133 | SkillTreeEvents.skill_tree.on("wildwood-ascendancy-class-change", this.updateWildwoodAscClassControl); 134 | 135 | SkillTreeEvents.skill_tree.on("hovered-nodes-start", this.renderer.StartRenderHover); 136 | SkillTreeEvents.skill_tree.on("hovered-nodes-end", this.renderer.StopRenderHover); 137 | SkillTreeEvents.skill_tree.on("active-nodes-update", this.renderer.RenderActive); 138 | SkillTreeEvents.skill_tree.on("active-nodes-update", this.updateStats); 139 | 140 | SkillTreeEvents.skill_tree.on("normal-node-count", (count: number) => { const e = document.getElementById("skillTreeNormalNodeCount"); if (e !== null) e.innerHTML = count.toString(); }); 141 | SkillTreeEvents.skill_tree.on("normal-node-count-maximum", (count: number) => { const e = document.getElementById("skillTreeNormalNodeCountMaximum"); if (e !== null) e.innerHTML = count.toString(); }); 142 | SkillTreeEvents.skill_tree.on("ascendancy-node-count", (count: number) => { const e = document.getElementById("skillTreeAscendancyNodeCount"); if (e !== null) e.innerHTML = count.toString(); }); 143 | SkillTreeEvents.skill_tree.on("ascendancy-node-count-maximum", (count: number) => { const e = document.getElementById("skillTreeAscendancyNodeCountMaximum"); if (e !== null) e.innerHTML = count.toString(); }); 144 | SkillTreeEvents.skill_tree.on("wildwood-ascendancy-node-count", (count: number) => { const e = document.getElementById("skillTreeWildwoodAscendancyNodeCount"); if (e !== null) e.innerHTML = count.toString(); }); 145 | SkillTreeEvents.skill_tree.on("wildwood-ascendancy-node-count-maximum", (count: number) => { const e = document.getElementById("skillTreeWildwoodAscendancyNodeCountMaximum"); if (e !== null) e.innerHTML = count.toString(); }); 146 | 147 | this.populateStartClasses(document.getElementById("skillTreeControl_Class") as HTMLSelectElement); 148 | this.bindSearchBox(document.getElementById("skillTreeControl_Search") as HTMLInputElement); 149 | const controls = document.getElementsByClassName("skillTreeControls") as HTMLCollectionOf; 150 | for (const i in controls) { 151 | if (controls[i].style !== undefined) { 152 | controls[i].style.removeProperty('display'); 153 | } 154 | } 155 | 156 | const points = document.getElementsByClassName("skillTreePoints") as HTMLCollectionOf; 157 | for (const i in points) { 158 | if (points[i].style !== undefined) { 159 | points[i].style.removeProperty('display'); 160 | } 161 | } 162 | } 163 | 164 | private masteries: string[] | undefined = undefined; 165 | private masteryTest: { [name: string]: string } | undefined = undefined; 166 | private defaultStats: { [stat: string]: boolean } | undefined = undefined; 167 | private buildStatLookups = (defaultGroup: string): [masteries: string[], masteryTest: { [name: string]: string }, defaultStats: { [stat: string]: boolean }] => { 168 | if (this.masteries === undefined || this.masteryTest === undefined) { 169 | const masteries: string[] = ["The Maven"]; 170 | const masteryTest: { [name: string]: string } = { "The Maven": " Maven" } 171 | for (const id in this.skillTreeData.nodes) { 172 | const node = this.skillTreeData.nodes[id]; 173 | const mastery = this.skillTreeData.getMasteryForGroup(node.nodeGroup); 174 | if (mastery !== null && mastery.name !== defaultGroup) { 175 | masteries.push(mastery.name); 176 | masteryTest[mastery.name] = mastery.name.replace("The", "").replace("Mastery", "") 177 | } 178 | } 179 | this.masteries = masteries; 180 | this.masteryTest = masteryTest; 181 | } 182 | 183 | if (this.defaultStats === undefined) { 184 | const defaultStats: { [stat: string]: boolean } = {}; 185 | for (const id in this.skillTreeData.nodes) { 186 | const node = this.skillTreeData.nodes[id]; 187 | for (const stat of node.stats) { 188 | if (defaultStats[stat] !== undefined) { 189 | continue 190 | } 191 | 192 | const mastery = this.skillTreeData.getMasteryForGroup(node.nodeGroup); 193 | if (mastery === null) { 194 | let found = false; 195 | for (const name of this.masteries) { 196 | if (stat.indexOf(this.masteryTest[name]) >= 0) { 197 | found = true 198 | break; 199 | } 200 | } 201 | 202 | if (!found) { 203 | defaultStats[stat] = true; 204 | } 205 | } 206 | } 207 | } 208 | this.defaultStats = defaultStats; 209 | } 210 | return [this.masteries, this.masteryTest, this.defaultStats]; 211 | } 212 | 213 | private updateStats = () => { 214 | const defaultGroup = this.skillTreeData.isAtlasTree() ? "Maps" : "Default"; 215 | const [masteries, masteryTest, defaultStats] = this.buildStatLookups(defaultGroup); 216 | 217 | const groups: { [group: string]: string[] } = {}; 218 | const statGroup: { [stat: string]: string } = {}; 219 | const stats: { [stat: string]: number } = {}; 220 | const nodes = this.skillTreeData.getSkilledNodes(); 221 | for (const id in nodes) { 222 | const node = nodes[id]; 223 | for (const stat of node.stats) { 224 | if (stats[stat] === undefined) { 225 | stats[stat] = 1; 226 | } else { 227 | stats[stat] = stats[stat] + 1; 228 | } 229 | 230 | if (statGroup[stat] !== undefined) { 231 | const group = statGroup[stat]; 232 | if (groups[group].indexOf(stat) === -1) { 233 | groups[group].push(stat); 234 | } 235 | continue; 236 | } 237 | 238 | if (defaultStats[stat]) { 239 | if (groups[defaultGroup] === undefined) { 240 | groups[defaultGroup] = []; 241 | } 242 | 243 | if (groups[defaultGroup].indexOf(stat) === -1) { 244 | statGroup[stat] = defaultGroup; 245 | groups[defaultGroup].push(stat); 246 | } 247 | continue; 248 | } 249 | 250 | const mastery = this.skillTreeData.getMasteryForGroup(node.nodeGroup); 251 | if (mastery !== null) { 252 | if (groups[mastery.name] === undefined) { 253 | groups[mastery.name] = []; 254 | } 255 | 256 | if (groups[mastery.name].indexOf(stat) === -1) { 257 | statGroup[stat] = mastery.name; 258 | groups[mastery.name].push(stat); 259 | } 260 | } else { 261 | let group = defaultGroup; 262 | for (const name of masteries) { 263 | if (stat.indexOf(masteryTest[name]) >= 0) { 264 | group = name; 265 | break; 266 | } 267 | } 268 | 269 | if (groups[group] === undefined) { 270 | groups[group] = []; 271 | } 272 | 273 | if (groups[group].indexOf(stat) === -1) { 274 | statGroup[stat] = group; 275 | groups[group].push(stat); 276 | } 277 | } 278 | } 279 | } 280 | 281 | const content = document.getElementById("skillTreeStats_Content") as HTMLDivElement; 282 | while (content.firstChild) { 283 | content.removeChild(content.firstChild); 284 | } 285 | 286 | for (const name of Object.keys(groups).sort((a, b) => a === defaultGroup ? -1 : (b === defaultGroup ? 1 : (a < b) ? -1 : 1))) { 287 | const groupStats: { [stat: string]: number } = {}; 288 | for (const stat of groups[name]) { 289 | groupStats[stat] = stats[stat]; 290 | } 291 | const div = this.createStatGroup(name, groupStats); 292 | content.appendChild(div); 293 | } 294 | } 295 | 296 | private createStatGroup = (name: string, stats: { [stat: string]: number }): HTMLDivElement => { 297 | const group = document.createElement("div"); 298 | group.className = "group"; 299 | 300 | const title = document.createElement("span"); 301 | title.className = "title"; 302 | title.innerText = name; 303 | title.addEventListener("click", () => { 304 | const elements = document.querySelectorAll(`[data-group-name="${name}"]`); 305 | elements.forEach((element) => { 306 | element.toggleAttribute("hidden"); 307 | }) 308 | }); 309 | 310 | group.appendChild(title); 311 | 312 | for (const stat of Object.keys(stats).sort()) { 313 | const num = stats[stat]; 314 | group.appendChild(this.createStat(name, `${num}x ${stat}`)); 315 | } 316 | 317 | return group; 318 | } 319 | 320 | private createStat = (group: string, stat: string): HTMLDivElement => { 321 | const div = document.createElement("div"); 322 | div.className = "stat"; 323 | div.innerText = stat; 324 | div.setAttribute("data-group-name", group); 325 | return div; 326 | } 327 | 328 | private populateStartClasses = (classControl: HTMLSelectElement) => { 329 | while (classControl.firstChild) { 330 | classControl.removeChild(classControl.firstChild); 331 | } 332 | 333 | const options = new Array(); 334 | for (const id in this.skillTreeData.classStartNodes) { 335 | const classId = this.skillTreeData.nodes[id].classStartIndex; 336 | if (classId === undefined) { 337 | continue; 338 | } 339 | const e = document.createElement("option"); 340 | e.text = this.skillTreeData.root.out.length === 1 ? "Atlas" : this.skillTreeData.constants.classIdToName[classId]; 341 | e.value = classId.toString(); 342 | 343 | if (classId === this.skillTreeData.getStartClass()) { 344 | e.setAttribute("selected", "selected"); 345 | } 346 | options.push(e); 347 | } 348 | 349 | options.sort((a, b) => { 350 | const first = a.value; 351 | const second = b.value; 352 | if (first !== null && second !== null) { 353 | return +first - +second; 354 | } 355 | return 0; 356 | }); 357 | 358 | for (const e of options) { 359 | classControl.append(e); 360 | } 361 | 362 | const ascControl = document.getElementById("skillTreeControl_Ascendancy") as HTMLSelectElement; 363 | if (ascControl !== null) { 364 | this.populateAscendancyClasses(ascControl); 365 | } 366 | 367 | const wildwoodAscControl = document.getElementById("skillTreeControl_WildwoodAscendancy") as HTMLSelectElement; 368 | if (wildwoodAscControl !== null) { 369 | this.populateWildwoodAscendancyClasses(wildwoodAscControl); 370 | } 371 | 372 | classControl.onchange = () => { 373 | const val = classControl.value; 374 | SkillTreeEvents.controls.fire("class-change", +val); 375 | if (ascControl !== null) { 376 | this.populateAscendancyClasses(ascControl, +val, 0); 377 | } 378 | if (wildwoodAscControl !== null) { 379 | this.populateWildwoodAscendancyClasses(wildwoodAscControl, 0) 380 | } 381 | }; 382 | } 383 | 384 | private updateClassControl = () => { 385 | const start = this.skillTreeData.getStartClass(); 386 | (document.getElementById("skillTreeControl_Class") as HTMLSelectElement).value = String(start); 387 | } 388 | 389 | private updateAscClassControl = () => { 390 | if (this.skillTreeData.classes.length === 0) { 391 | return; 392 | } 393 | 394 | const start = this.skillTreeData.getAscendancyClass(); 395 | const ascClasses = this.skillTreeData.classes[this.skillTreeData.getStartClass()].ascendancies; 396 | if (ascClasses === undefined) { 397 | return; 398 | } 399 | 400 | const ascControl = (document.getElementById("skillTreeControl_Ascendancy") as HTMLSelectElement); 401 | this.createAscendancyClassOptions(ascControl, ascClasses, start); 402 | } 403 | 404 | private populateAscendancyClasses = (ascControl: HTMLSelectElement, start: number | undefined = undefined, startasc: number | undefined = undefined) => { 405 | while (ascControl.firstChild) { 406 | ascControl.removeChild(ascControl.firstChild); 407 | } 408 | 409 | if (this.skillTreeData.classes.length === 0) { 410 | ascControl.style.display = "none"; 411 | const e = document.getElementById("skillTreeAscendancy") as HTMLDivElement; 412 | if (e !== null) e.style.display = "none"; 413 | return; 414 | } 415 | 416 | const startClass = start !== undefined ? start : this.skillTreeData.getStartClass(); 417 | const ascClasses = this.skillTreeData.classes[startClass].ascendancies; 418 | if (ascClasses === undefined) { 419 | return; 420 | } 421 | 422 | const ascStart = startasc !== undefined ? startasc : this.skillTreeData.getAscendancyClass(); 423 | this.createAscendancyClassOptions(ascControl, ascClasses, ascStart); 424 | 425 | ascControl.onchange = () => { 426 | SkillTreeEvents.controls.fire("ascendancy-class-change", +ascControl.value); 427 | }; 428 | } 429 | 430 | private updateWildwoodAscClassControl = () => { 431 | if (this.skillTreeData.alternate_ascendancies.length === 0) { 432 | return; 433 | } 434 | 435 | const start = this.skillTreeData.getWildwoodAscendancyClass(); 436 | const ascClasses = this.skillTreeData.alternate_ascendancies; 437 | if (ascClasses === undefined) { 438 | return; 439 | } 440 | 441 | const ascControl = (document.getElementById("skillTreeControl_WildwoodAscendancy") as HTMLSelectElement); 442 | this.createAscendancyClassOptions(ascControl, ascClasses, start); 443 | } 444 | 445 | private populateWildwoodAscendancyClasses = (ascControl: HTMLSelectElement, startasc: number | undefined = undefined) => { 446 | while (ascControl.firstChild) { 447 | ascControl.removeChild(ascControl.firstChild); 448 | } 449 | 450 | if (this.skillTreeData.alternate_ascendancies.length === 0) { 451 | ascControl.style.display = "none"; 452 | const e = document.getElementById("skillTreeWildwoodAscendancy") as HTMLDivElement; 453 | if (e !== null) e.style.display = "none"; 454 | return; 455 | } 456 | 457 | const ascClasses = this.skillTreeData.alternate_ascendancies; 458 | if (ascClasses === undefined) { 459 | return; 460 | } 461 | 462 | const ascStart = startasc !== undefined ? startasc : this.skillTreeData.getAscendancyClass(); 463 | this.createAscendancyClassOptions(ascControl, ascClasses, ascStart); 464 | 465 | ascControl.onchange = () => { 466 | SkillTreeEvents.controls.fire("wildwood-ascendancy-class-change", +ascControl.value); 467 | }; 468 | } 469 | 470 | private createAscendancyClassOptions = (control: HTMLSelectElement, classes: IAscendancyClassV7[], start: number) => { 471 | while (control.firstChild) { 472 | control.removeChild(control.firstChild); 473 | } 474 | 475 | const none = document.createElement("option"); 476 | none.text = "None"; 477 | none.value = "0"; 478 | if (start === 0) { 479 | none.setAttribute("selected", "selected"); 480 | } 481 | control.append(none); 482 | 483 | if (classes.length === 0) { 484 | return 485 | } 486 | 487 | for (const id in classes) { 488 | const asc = classes[id]; 489 | const value = +id + 1; 490 | 491 | const e = document.createElement("option"); 492 | e.text = asc.id; 493 | e.value = `${value}`; 494 | 495 | if (value === start) { 496 | e.setAttribute("selected", "selected"); 497 | } 498 | control.append(e); 499 | } 500 | } 501 | 502 | private searchTimout: Timer | null = null; 503 | private bindSearchBox = (searchControl: HTMLInputElement) => { 504 | searchControl.onkeyup = () => { 505 | if (this.searchTimout !== null) { 506 | clearTimeout(this.searchTimout); 507 | } 508 | this.searchTimout = setTimeout(() => { 509 | SkillTreeEvents.controls.fire("search-change", searchControl.value); 510 | this.searchTimout = null; 511 | }, 250); 512 | }; 513 | } 514 | 515 | public static decodeURLParams = (search = ''): { [id: string]: string } => { 516 | const hashes = search.slice(search.indexOf("?") + 1).split("&"); 517 | return hashes.reduce((params, hash) => { 518 | const split = hash.indexOf("="); 519 | 520 | if (split < 0) { 521 | return Object.assign(params, { 522 | [hash]: null 523 | }); 524 | } 525 | 526 | const key = hash.slice(0, split); 527 | const val = hash.slice(split + 1); 528 | 529 | return Object.assign(params, { [key]: decodeURIComponent(val) }); 530 | }, {}); 531 | }; 532 | 533 | public static ChangeSkillTreeVersion = (version: string, compare: string, hash: string) => { 534 | let search = '?'; 535 | if (version !== '') { 536 | search += `v=${version}`; 537 | } 538 | 539 | if (!search.endsWith('?') && compare !== '') search += '&'; 540 | 541 | if (compare !== '') { 542 | search += `c=${compare}`; 543 | } 544 | 545 | if (window.location.hash !== hash) { 546 | window.location.hash = hash; 547 | } 548 | 549 | if (window.location.search !== search) { 550 | window.location.search = search; 551 | } 552 | } 553 | } 554 | -------------------------------------------------------------------------------- /app/download.ts: -------------------------------------------------------------------------------- 1 | //download.js v4.21, by dandavis; 2008-2018. [MIT] see http://danml.com/download.html for tests/usage 2 | // v1 landed a FF+Chrome compatible way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime 3 | // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs 4 | // v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling. 5 | // v4 adds AMD/UMD, commonJS, and plain browser support 6 | // v4.1 adds url download capability via solo URL argument (same domain/CORS only) 7 | // v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors 8 | // https://github.com/rndme/download 9 | 10 | // @ts-nocheck 11 | export function download(data, strFileName, strMimeType) { 12 | 13 | var self = window, // this script is only for browsers anyway... 14 | defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads 15 | mimeType = strMimeType || defaultMime, 16 | payload = data, 17 | url = !strFileName && !strMimeType && payload, 18 | anchor = document.createElement("a"), 19 | toString = function (a) { return String(a); }, 20 | myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString), 21 | fileName = strFileName || "download", 22 | blob, 23 | reader; 24 | myBlob = myBlob.call ? myBlob.bind(self) : Blob; 25 | 26 | if (url && url.length < 2048) { // if no filename and no mime, assume a url was passed as the only argument 27 | fileName = url.split("/").pop().split("?")[0]; 28 | anchor.href = url; // assign href prop to temp anchor 29 | if (anchor.href.indexOf(url) !== -1) { // if the browser determines that it's a potentially valid url path: 30 | var ajax = new XMLHttpRequest(); 31 | ajax.open("GET", url, true); 32 | ajax.responseType = 'blob'; 33 | ajax.onload = function (e) { 34 | download(e.target.response, fileName, defaultMime); 35 | }; 36 | setTimeout(function () { ajax.send(); }, 0); // allows setting custom ajax headers using the return: 37 | return ajax; 38 | } // end if valid url? 39 | } // end if url? 40 | 41 | 42 | //go ahead and download dataURLs right away 43 | if (/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)) { 44 | 45 | if (payload.length > (1024 * 1024 * 1.999) && myBlob !== toString) { 46 | payload = dataUrlToBlob(payload); 47 | mimeType = payload.type || defaultMime; 48 | } else { 49 | return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs: 50 | navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : 51 | saver(payload); // everyone else can save dataURLs un-processed 52 | } 53 | 54 | } else {//not data url, is it a string with special needs? 55 | if (/([\x80-\xff])/.test(payload)) { 56 | var i = 0, tempUiArr = new Uint8Array(payload.length), mx = tempUiArr.length; 57 | for (i; i < mx; ++i) tempUiArr[i] = payload.charCodeAt(i); 58 | payload = new myBlob([tempUiArr], { type: mimeType }); 59 | } 60 | } 61 | blob = payload instanceof myBlob ? 62 | payload : 63 | new myBlob([payload], { type: mimeType }); 64 | 65 | 66 | function dataUrlToBlob(strUrl) { 67 | var parts = strUrl.split(/[:;,]/), 68 | type = parts[1], 69 | indexDecoder = strUrl.indexOf("charset") > 0 ? 3 : 2, 70 | decoder = parts[indexDecoder] == "base64" ? atob : decodeURIComponent, 71 | binData = decoder(parts.pop()), 72 | mx = binData.length, 73 | i = 0, 74 | uiArr = new Uint8Array(mx); 75 | 76 | for (i; i < mx; ++i) uiArr[i] = binData.charCodeAt(i); 77 | 78 | return new myBlob([uiArr], { type: type }); 79 | } 80 | 81 | function saver(url, winMode) { 82 | 83 | if ('download' in anchor) { //html5 A[download] 84 | anchor.href = url; 85 | anchor.setAttribute("download", fileName); 86 | anchor.className = "download-js-link"; 87 | anchor.innerHTML = "downloading..."; 88 | anchor.style.display = "none"; 89 | anchor.addEventListener('click', function (e) { 90 | e.stopPropagation(); 91 | this.removeEventListener('click', arguments.callee); 92 | }); 93 | document.body.appendChild(anchor); 94 | setTimeout(function () { 95 | anchor.click(); 96 | document.body.removeChild(anchor); 97 | if (winMode === true) { setTimeout(function () { self.URL.revokeObjectURL(anchor.href); }, 250); } 98 | }, 66); 99 | return true; 100 | } 101 | 102 | // handle non-a[download] safari as best we can: 103 | if (/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) { 104 | if (/^data:/.test(url)) url = "data:" + url.replace(/^data:([\w\/\-\+]+)/, defaultMime); 105 | if (!window.open(url)) { // popup blocked, offer direct download: 106 | if (confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")) { location.href = url; } 107 | } 108 | return true; 109 | } 110 | 111 | //do iframe dataURL download (old ch+FF): 112 | var f = document.createElement("iframe"); 113 | document.body.appendChild(f); 114 | 115 | if (!winMode && /^data:/.test(url)) { // force a mime that will download: 116 | url = "data:" + url.replace(/^data:([\w\/\-\+]+)/, defaultMime); 117 | } 118 | f.src = url; 119 | setTimeout(function () { document.body.removeChild(f); }, 333); 120 | 121 | }//end saver 122 | 123 | if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL) 124 | return navigator.msSaveBlob(blob, fileName); 125 | } 126 | 127 | if (self.URL) { // simple fast and modern way using Blob and URL: 128 | saver(self.URL.createObjectURL(blob), true); 129 | } else { 130 | // handle non-Blob()+non-URL browsers: 131 | if (typeof blob === "string" || blob.constructor === toString) { 132 | try { 133 | return saver("data:" + mimeType + ";base64," + self.btoa(blob)); 134 | } catch (y) { 135 | return saver("data:" + mimeType + "," + encodeURIComponent(blob)); 136 | } 137 | } 138 | 139 | // Blob but not URL support: 140 | reader = new FileReader(); 141 | reader.onload = function (e) { 142 | saver(this.result); 143 | }; 144 | reader.readAsDataURL(blob); 145 | } 146 | return true; 147 | }; /* end download() */ 148 | 149 | -------------------------------------------------------------------------------- /app/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | PoE Skill Tree 8 | 9 | 10 | 11 | 12 |
13 | 22 | 34 |
35 | 36 | 37 |
38 | 49 | 50 |
51 | 55 |
56 |
57 |
58 | 59 | 60 | -------------------------------------------------------------------------------- /app/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | import { SemVer } from "semver"; 5 | import { App } from "./app"; 6 | import { versions } from '../models/versions/verions'; 7 | 8 | window.onload = async () => { 9 | const query = App.decodeURLParams(window.location.search); 10 | 11 | const versionsJson: IVersions = { 12 | versions: [] 13 | } 14 | const semversions = Object.fromEntries(Object.entries(versions)) 15 | for (const key in semversions) { 16 | const value = semversions[key]; 17 | if (!(value instanceof SemVer)) { 18 | continue 19 | } 20 | versionsJson.versions.push(value.version) 21 | } 22 | 23 | if (versionsJson.versions.indexOf(query['v']) === -1) { 24 | query['v'] = versionsJson.versions[versionsJson.versions.length - 1]; 25 | } 26 | 27 | if (!query['c']) { 28 | query['c'] = ''; 29 | } 30 | 31 | App.ChangeSkillTreeVersion(query['v'], query['c'], window.location.hash); 32 | new App().launch(query['v'], query['c'], versionsJson); 33 | }; -------------------------------------------------------------------------------- /app/utils.ts: -------------------------------------------------------------------------------- 1 | import { download } from "./download"; 2 | 3 | export class utils { 4 | public static poecdn = "http://web.poecdn.com/"; 5 | public static DATA_URI = "data"; 6 | public static SKILL_TREES_URI = `${utils.DATA_URI}/skill-trees`; 7 | 8 | public static getKeyByValue(dict: { [key: string]: any }, value: any): string | undefined { 9 | return Object.keys(dict).find((key: string) => { return dict[key] === value; }); 10 | } 11 | 12 | public static NotUndefined(x: T | undefined): x is T { 13 | return x !== undefined; 14 | } 15 | 16 | public static NotNullOrWhiteSpace(x: string | null | undefined): x is string | null | undefined { 17 | return x !== undefined && x !== null && x.trim() !== ""; 18 | } 19 | 20 | public static Download(data: string | Uint8Array | Blob, filename?: string, mimeType?: string): XMLHttpRequest | boolean { 21 | return download(data, filename, mimeType); 22 | } 23 | } -------------------------------------------------------------------------------- /build.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import klaw from 'klaw' 3 | import { unlink } from 'node:fs/promises' 4 | import { BuildOutput, BunFile } from 'bun' 5 | 6 | const find_scripts = (results: BuildOutput, end_marker: string): string => { 7 | let scripts = "" 8 | for (const result of results.outputs) { 9 | const filename = path.basename(result.path) 10 | if (filename.endsWith('.css')) { 11 | scripts += '\r\n' 12 | scripts += `\t` 13 | } else if (filename.endsWith('.js')) { 14 | scripts += '\r\n' 15 | scripts += `\t` 16 | } 17 | } 18 | scripts += '\r\n' 19 | scripts += end_marker 20 | return scripts 21 | } 22 | 23 | const copy = async (src: string, dst: string, callback: undefined | ((file: BunFile) => Promise) = undefined) => { 24 | const file = Bun.file(src) 25 | const data = callback === undefined ? file : await callback(file) 26 | Bun.write(dst, data) 27 | } 28 | 29 | (async () => { 30 | const output = './dist' 31 | 32 | klaw(output, { depthLimit: 0 }) 33 | .on('data', async data => { 34 | if (data.stats.isDirectory()) { 35 | return 36 | } 37 | await unlink(data.path) 38 | }) 39 | 40 | const results = await Bun.build({ 41 | entrypoints: ['./app/index.ts'], 42 | naming: "[dir]/[name]-[hash].[ext]", 43 | outdir: output, 44 | minify: true, 45 | splitting: true, 46 | target: 'browser' 47 | }) 48 | 49 | if (!results.success) { 50 | console.error('❌ bun build failed:'); 51 | console.error(results.logs.join('\n')); 52 | return process.exit(1); 53 | } 54 | 55 | console.log('🤖 bun build completed'); 56 | 57 | try { 58 | const marker = '' 59 | const scripts = find_scripts(results, `\t${marker}`) 60 | 61 | await copy('./favicon.ico', `${output}/favicon.ico`) 62 | await copy('./app/index.html', `${output}/index.html`, async (file) => { 63 | const text = await file.text() 64 | return text.replace(marker, scripts) 65 | }) 66 | console.log('📁 static files copied'); 67 | } catch (error) { 68 | console.error('❌ static files copy failed', error); 69 | return process.exit(1); 70 | } 71 | 72 | console.log('✅ build succeeded'); 73 | })(); -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmmittJ/SkillTree_TypeScript/e48c5c39874ac2b6fac1b58283562f656ab85c42/bun.lockb -------------------------------------------------------------------------------- /content/app.css: -------------------------------------------------------------------------------- 1 | body { 2 | overflow: hidden; 3 | width: 100%; 4 | height: 100%; 5 | margin: 0; 6 | padding: 0; 7 | background-color: black; 8 | } 9 | 10 | .skillTreeControls { 11 | position: fixed; 12 | bottom: 0; 13 | left: 0; 14 | height: 1.5em; 15 | width: 100%; 16 | display: flex; 17 | flex-flow: row nowrap; 18 | justify-content: center; 19 | align-items: center; 20 | } 21 | 22 | .skillTreeVersions { 23 | position: fixed; 24 | bottom: 0; 25 | left: 0; 26 | height: 1.5em; 27 | display: flex; 28 | flex-flow: row nowrap; 29 | justify-content: center; 30 | align-items: center; 31 | } 32 | 33 | .skillTreeStats { 34 | position: fixed; 35 | bottom: 2em; 36 | left: 0; 37 | height: fit-content; 38 | width: 22.4em; 39 | background: #333; 40 | border: 1px solid #999; 41 | color: #FFF; 42 | margin: 0.25em; 43 | padding: 0.25em; 44 | display: inline-block; 45 | overflow: auto; 46 | } 47 | 48 | .skillTreeStats .group { 49 | padding-top: 0.5em; 50 | } 51 | 52 | .skillTreeStats .group .title { 53 | font-size: x-large; 54 | cursor: pointer; 55 | display: inline-block; 56 | width: 100%; 57 | } 58 | 59 | .skillTreeStats .group .stat { 60 | padding: 0.2em; 61 | font-size: medium; 62 | } 63 | 64 | #skillTreeStats_ShowHide { 65 | background: #333; 66 | border: 1px solid #999; 67 | color: #FFF; 68 | margin: 0 0 0 10.5em; 69 | width: 6em; 70 | display: inline-block; 71 | } 72 | 73 | #skillTreeContainer label { 74 | width: 4em; 75 | height: 1.5em; 76 | display: inline-block; 77 | } 78 | 79 | #skillTreeContainer select { 80 | width: 8em; 81 | height: 1.5em; 82 | } 83 | 84 | #skillTreeContainer input { 85 | width: 7.7em; 86 | height: 1.2em; 87 | } 88 | 89 | #skillTreeContainer button { 90 | height: 1.5em; 91 | cursor: pointer; 92 | } 93 | 94 | #skillTreeContainer input, #skillTreeContainer select, #skillTreeContainer button { 95 | background: #333; 96 | border: 1px solid #999; 97 | color: #FFF; 98 | margin: 0 0 0.25em 0.25em; 99 | display: inline-block; 100 | text-decoration-line: none; 101 | } 102 | 103 | .skillTreePoints { 104 | position: fixed; 105 | top: 0; 106 | left: 0; 107 | height: 1.5em; 108 | width: 100%; 109 | display: flex; 110 | flex-flow: row nowrap; 111 | justify-content: center; 112 | align-items: center; 113 | } 114 | 115 | .skillTreeNodes { 116 | background-image: url('/data/skill-trees/PSPointsFrame.png'); 117 | background-size: 120px 25px; 118 | margin-right: 0.5em; 119 | width: 120px; 120 | height: 25px; 121 | display: flex; 122 | flex-flow: row; 123 | justify-content: center; 124 | align-items: center; 125 | font-size: larger; 126 | color: #FFFFFF; 127 | text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; 128 | } 129 | 130 | .ad-container { 131 | position: fixed; 132 | bottom: 0.25em; 133 | right: 0; 134 | height: 50px; 135 | display: flex; 136 | flex-flow: row nowrap; 137 | justify-content: center; 138 | align-items: end; 139 | } 140 | 141 | #standard-banner { 142 | background: #333; 143 | border: 1px solid #999; 144 | color: #FFF; 145 | margin: 0.25em; 146 | padding: 0.25em; 147 | display: inline-block; 148 | width: 320px; 149 | height: fit-content; 150 | } 151 | 152 | span[data-ccpa-link="1"] span { 153 | height: 1.5em; 154 | line-height: 1.5em; 155 | cursor: pointer; 156 | background: #333; 157 | border: 1px solid #999; 158 | color: #FFF; 159 | margin: 0.125em 0.25em; 160 | padding: 0.25em; 161 | display: inline-block; 162 | text-decoration-line: none; 163 | font-size: 0.75em; 164 | } 165 | 166 | #ncmp-consent-link > button { 167 | height: 1.5em; 168 | line-height: 0.75em; 169 | cursor: pointer; 170 | background: #333; 171 | border: 1px solid #999; 172 | color: #FFF; 173 | margin: 0.125em 0.25em; 174 | padding: 0.25em; 175 | display: inline-block; 176 | text-decoration-line: none; 177 | font-size: 0.75em; 178 | } -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmmittJ/SkillTree_TypeScript/e48c5c39874ac2b6fac1b58283562f656ab85c42/favicon.ico -------------------------------------------------------------------------------- /models/Constants.ts: -------------------------------------------------------------------------------- 1 | export class Constants implements IConstants { 2 | classes: { [id: string]: number; }; 3 | characterAttributes: { [id: string]: number; }; 4 | PSSCentreInnerRadius: number; 5 | skillsPerOrbit: number[]; 6 | orbitRadii: number[]; 7 | 8 | classesToName: { [id: string]: string }; 9 | classIdToName: { [id: number]: string }; 10 | 11 | constructor(constants: IConstants) { 12 | this.classes = constants.classes; 13 | this.characterAttributes = constants.characterAttributes; 14 | this.PSSCentreInnerRadius = constants.PSSCentreInnerRadius; 15 | this.skillsPerOrbit = constants.skillsPerOrbit; 16 | this.orbitRadii = constants.orbitRadii; 17 | 18 | this.classesToName = { 19 | "StrClass": "Marauder", 20 | "DexClass": "Ranger", 21 | "IntClass": "Witch", 22 | "StrDexClass": "Duelist", 23 | "StrIntClass": "Templar", 24 | "DexIntClass": "Shadow", 25 | "StrDexIntClass": "Scion" 26 | }; 27 | 28 | this.classIdToName = { 29 | 0: "Scion", 30 | 1: "Marauder", 31 | 2: "Ranger", 32 | 3: "Witch", 33 | 4: "Duelist", 34 | 5: "Templar", 35 | 6: "Shadow" 36 | }; 37 | } 38 | } -------------------------------------------------------------------------------- /models/SkillNode.ts: -------------------------------------------------------------------------------- 1 | import { SemVer } from "semver"; 2 | import { utils } from "../app/utils"; 3 | 4 | export declare type DrawType = "Allocated" | "Active" | "CanAllocate" | "Unallocated" | "Normal" | "Highlight"; 5 | 6 | export enum SkillNodeStates { 7 | None = 0, 8 | Active = 1 << 0, 9 | Hovered = 1 << 1, 10 | Pathing = 1 << 2, 11 | Highlighted = 1 << 3, 12 | Compared = 1 << 4, 13 | Moved = 1 << 5, 14 | } 15 | 16 | export enum ConnectionStyle { 17 | Line, 18 | Arc 19 | } 20 | 21 | export class SkillNode implements ISkillNode { 22 | id: string; 23 | activeEffectImage: string; 24 | activeIcon: string; 25 | ascendancyName: string; 26 | classStartIndex: number | undefined; 27 | expansionJewel: IExpansionJewel | undefined; 28 | flavourText: string[]; 29 | grantedDexterity: number; 30 | grantedIntelligence: number; 31 | grantedPassivePoints: number; 32 | grantedStrength: number; 33 | group: number | undefined; 34 | icon: string; 35 | in: string[]; 36 | inactiveIcon: string; 37 | isAscendancyStart: boolean; 38 | isBlighted: boolean; 39 | isJewelSocket: boolean; 40 | isKeystone: boolean; 41 | isMastery: boolean; 42 | isMultipleChoice: boolean; 43 | isMultipleChoiceOption: boolean; 44 | isNotable: boolean; 45 | isProxy: boolean; 46 | isWormhole: boolean; 47 | masteryEffects: IMasteryEffect[]; 48 | name: string; 49 | orbit: number; 50 | orbitIndex: number; 51 | out: string[]; 52 | recipe: string[]; 53 | reminderText: string[]; 54 | skill: number; 55 | stats: string[]; 56 | 57 | state: SkillNodeStates; 58 | 59 | nodeGroup: IGroup | undefined; 60 | orbitAngles: { [orbit: number]: Array }; 61 | orbitRadii: Array; 62 | scale: number; 63 | arc: number; 64 | x: number; 65 | y: number; 66 | isRegular2: boolean; 67 | isRegular1: boolean; 68 | targetSize: { width: number, height: number }; 69 | hoverText: string | null = null; 70 | patch: SemVer; 71 | 72 | constructor(id: string, node: ISkillNode, group: IGroup | undefined, orbitRadii: Array, orbitAngles: { [orbit: number]: Array }, scale: number, patch: SemVer) { 73 | this.id = id; 74 | this.activeEffectImage = node.activeEffectImage || ""; 75 | this.activeIcon = node.activeIcon || ""; 76 | this.ascendancyName = node.ascendancyName || ""; 77 | this.classStartIndex = node.classStartIndex; 78 | this.expansionJewel = node.expansionJewel; 79 | this.flavourText = node.flavourText || []; 80 | this.grantedDexterity = node.grantedDexterity || 0; 81 | this.grantedIntelligence = node.grantedIntelligence || 0; 82 | this.grantedPassivePoints = node.grantedPassivePoints || 0; 83 | this.grantedStrength = node.grantedStrength || 0; 84 | this.group = node.group; 85 | this.icon = node.icon; 86 | this.in = node.in; 87 | this.inactiveIcon = node.inactiveIcon || ""; 88 | this.isAscendancyStart = node.isAscendancyStart || false; 89 | this.isBlighted = node.isBlighted; 90 | this.isJewelSocket = node.isJewelSocket; 91 | this.isKeystone = node.isKeystone || false; 92 | this.isMastery = node.isMastery || false; 93 | this.isMultipleChoice = node.isMultipleChoice || false; 94 | this.isMultipleChoiceOption = node.isMultipleChoiceOption || false; 95 | this.isNotable = node.isNotable || false; 96 | this.isProxy = node.isProxy || false; 97 | this.isWormhole = node.isWormhole || false; 98 | this.masteryEffects = node.masteryEffects || []; 99 | this.name = node.name; 100 | this.orbit = node.orbit; 101 | this.orbitIndex = node.orbitIndex; 102 | this.out = node.out; 103 | this.recipe = node.recipe || []; 104 | this.reminderText = node.reminderText || []; 105 | this.skill = node.skill; 106 | this.stats = node.stats; 107 | 108 | this.state = SkillNodeStates.None; 109 | 110 | this.nodeGroup = group; 111 | this.orbitAngles = orbitAngles; 112 | this.orbitRadii = orbitRadii; 113 | this.scale = scale; 114 | this.arc = this.getArc(this.orbitIndex); 115 | this.x = this.getX(this.arc); 116 | this.y = this.getY(this.arc); 117 | this.isRegular2 = !this.isKeystone && !this.isNotable && !this.isJewelSocket && !this.isMastery && !this.isWormhole; 118 | this.isRegular1 = this.isRegular2 && (this.grantedStrength > 0 || this.grantedDexterity > 0 || this.grantedIntelligence > 0) && this.stats.filter(utils.NotNullOrWhiteSpace).length === 1; 119 | this.targetSize = this.getTargetSize(); 120 | this.patch = patch; 121 | 122 | if (this.grantedPassivePoints > 0) { 123 | this.stats.push(`Grants ${this.grantedPassivePoints} Passive Skill Point${this.grantedPassivePoints > 1 ? 's' : ''}`); 124 | } 125 | } 126 | 127 | private getArc = (oidx: number): number => this.orbitAngles[this.orbit] !== undefined && this.orbitAngles[this.orbit].length > oidx ? this.orbitAngles[this.orbit][oidx] : 0; 128 | private getX = (arc: number): number => this.orbitRadii.length > this.orbit && this.nodeGroup !== undefined ? (this.nodeGroup.x * this.scale) - (this.orbitRadii[this.orbit] * this.scale) * Math.sin(-arc) : 0; 129 | private getY = (arc: number): number => this.orbitRadii.length > this.orbit && this.nodeGroup !== undefined ? (this.nodeGroup.y * this.scale) - (this.orbitRadii[this.orbit] * this.scale) * Math.cos(-arc) : 0; 130 | private getTargetSize = (): { width: number, height: number } => { 131 | if (this.isRegular1 || this.isRegular2) { 132 | return { width: Math.floor(70 * this.scale), height: Math.floor(70 * this.scale) }; 133 | } 134 | 135 | if (this.isNotable || this.isJewelSocket || this.isMastery) { 136 | return { width: Math.floor(100 * this.scale), height: Math.floor(100 * this.scale) }; 137 | } 138 | 139 | if (this.isKeystone || this.isWormhole) { 140 | return { width: Math.floor(138 * this.scale), height: Math.floor(140 * this.scale) }; 141 | } 142 | 143 | return { width: 0, height: 0 }; 144 | } 145 | 146 | public is = (test: SkillNodeStates) => { 147 | return (this.state & test) === test; 148 | } 149 | 150 | public _add = (state: SkillNodeStates) => { 151 | this.state |= state; 152 | } 153 | 154 | public _remove = (state: SkillNodeStates) => { 155 | this.state &= ~state; 156 | } 157 | 158 | public GetId = (): string => { 159 | return `${this.id}`; 160 | } 161 | 162 | public GetIcon = () => { 163 | if (this.isMastery) { 164 | if (this.is(SkillNodeStates.Active) && this.activeIcon) { 165 | return this.activeIcon; 166 | } 167 | 168 | if (this.inactiveIcon) { 169 | return this.inactiveIcon; 170 | } 171 | } else if (this.isWormhole) { 172 | return "Wormhole"; 173 | } 174 | 175 | return this.icon; 176 | } 177 | 178 | public GetDrawType = (others: SkillNode[]): DrawType => { 179 | if (this.is(SkillNodeStates.Active) || this.is(SkillNodeStates.Hovered)) { 180 | if (this.expansionJewel !== undefined || this.isProxy || this.nodeGroup?.isProxy) { 181 | return "Active"; 182 | } 183 | if (this.isWormhole && this.is(SkillNodeStates.Hovered)) { 184 | return "Highlight" 185 | } 186 | return "Allocated"; 187 | } else if (others.filter(x => x && x.is(SkillNodeStates.Active)).length > 0) { 188 | return "CanAllocate"; 189 | } else if (this.ascendancyName !== "" || this.expansionJewel !== undefined || this.isProxy || this.nodeGroup?.isProxy) { 190 | return "Normal"; 191 | } 192 | 193 | return "Unallocated"; 194 | } 195 | 196 | public GetFrameAssetKey = (others: SkillNode[]): string | null => { 197 | const drawType = this.GetDrawType(others); 198 | 199 | if (this.isAscendancyStart) { 200 | return "AscendancyMiddle"; 201 | } else if (this.isJewelSocket) { 202 | if (this.expansionJewel !== undefined || this.isProxy || this.nodeGroup?.isProxy) { 203 | return `JewelSocketAlt${drawType}`; 204 | } 205 | if (this.name === "Charm Socket") { 206 | return `CharmFrame${drawType}`; 207 | } 208 | return `JewelFrame${drawType}`; 209 | } else if (this.isKeystone) { 210 | return `KeystoneFrame${drawType}`; 211 | } else if (this.isNotable && this.ascendancyName === "") { 212 | if (this.isBlighted) { 213 | return `BlightedNotableFrame${drawType}` 214 | } 215 | return `NotableFrame${drawType}`; 216 | } else if (this.isNotable && this.ascendancyName !== "") { 217 | return `AscendancyFrameLarge${drawType}`; 218 | } else if (this.isMastery) { 219 | return null; 220 | } else if (this.ascendancyName !== "") { 221 | return `AscendancyFrameSmall${drawType}`; 222 | } else if (this.isWormhole) { 223 | return `WormholeFrame${drawType}` 224 | } 225 | 226 | switch (drawType) { 227 | case "Normal": 228 | case "Unallocated": 229 | return "PSSkillFrame"; 230 | case "CanAllocate": 231 | return "PSSkillFrameHighlighted"; 232 | case "Active": 233 | case "Allocated": 234 | return "PSSkillFrameActive"; 235 | default: 236 | return null; 237 | } 238 | } 239 | 240 | public GetSpriteSheetKey = (): SpriteSheetKey => { 241 | const drawType = this.is(SkillNodeStates.Active) ? "Active" : "Inactive"; 242 | if (this.isKeystone) { 243 | return `keystone${drawType}`; 244 | } else if (this.isNotable) { 245 | return `notable${drawType}`; 246 | } else if (this.isMastery) { 247 | if (this.activeEffectImage !== "") { 248 | if (this.is(SkillNodeStates.Active)) { 249 | return "masteryActiveSelected"; 250 | } else if (this.is(SkillNodeStates.Hovered) || this.is(SkillNodeStates.Pathing)) { 251 | return "masteryConnected"; 252 | } else { 253 | return "masteryInactive"; 254 | } 255 | } else if (this.is(SkillNodeStates.Active) || this.is(SkillNodeStates.Hovered)) { 256 | return "masteryConnected"; 257 | } else { 258 | return "mastery"; 259 | } 260 | } else if (this.isWormhole) { 261 | return `wormhole${drawType}` 262 | } 263 | 264 | return `normal${drawType}`; 265 | } 266 | 267 | public GetConnectionType = (other: SkillNode): "Active" | "Intermediate" | "Normal" => { 268 | return this.is(SkillNodeStates.Active) && other.is(SkillNodeStates.Active) ? "Active" : (this.is(SkillNodeStates.Active) || other.is(SkillNodeStates.Active) || (this.is(SkillNodeStates.Pathing) && other.is(SkillNodeStates.Pathing)) ? "Intermediate" : "Normal"); 269 | } 270 | } -------------------------------------------------------------------------------- /models/SkillTreeData.ts: -------------------------------------------------------------------------------- 1 | import { SkillNode, SkillNodeStates } from "./SkillNode"; 2 | import { Constants } from "./Constants"; 3 | import { SemVer } from "semver"; 4 | import { versions } from "./versions/verions"; 5 | import { ISkillTreeData } from "./types/ISkillTreeData"; 6 | import { SpatialHash } from "./spatial-hash/SpatialHash"; 7 | 8 | export class SkillTreeData implements ISkillTreeData { 9 | tree: "Default" | "Royale" | "Atlas"; 10 | patch: SemVer; 11 | version: number; 12 | masteryEffects: { [id: number]: number } 13 | classes: IAscendancyClasses[]; 14 | alternate_ascendancies: IAscendancyClassV7[]; 15 | groups: { [id: string]: IGroup }; 16 | root: ISkillNode; 17 | nodes: { [id: string]: SkillNode }; 18 | min_x: number; 19 | min_y: number; 20 | max_x: number; 21 | max_y: number; 22 | imageZoomLevels: Array; 23 | sprites: { [id: string]: { [zoomLevel: string]: ISpriteSheet } }; 24 | constants: Constants; 25 | points: IPoints; 26 | jewelSlots: Array; 27 | extraImages: { [id: string]: IClassImage; }; 28 | 29 | width: number; 30 | height: number; 31 | maxZoomLevel: number; 32 | scale: number; 33 | classStartNodes: { [id: string]: SkillNode }; 34 | ascendancyNodes: { [id: string]: SkillNode }; 35 | nodesInState: { [state in SkillNodeStates]: Array } = { 36 | [SkillNodeStates.None]: new Array(), 37 | [SkillNodeStates.Active]: new Array(), 38 | [SkillNodeStates.Hovered]: new Array(), 39 | [SkillNodeStates.Pathing]: new Array(), 40 | [SkillNodeStates.Highlighted]: new Array(), 41 | [SkillNodeStates.Compared]: new Array(), 42 | [SkillNodeStates.Moved]: new Array(), 43 | } 44 | grid: SpatialHash 45 | 46 | constructor(skillTree: ISkillTreeData, patch: SemVer) { 47 | this.tree = skillTree.tree || "Default"; 48 | this.patch = patch; 49 | this.version = 4; skillTree.version = this.version; 50 | this.masteryEffects = []; 51 | this.jewelSlots = skillTree.jewelSlots; 52 | this.extraImages = skillTree.extraImages; 53 | this.groups = skillTree.groups as { [id: string]: IGroup };; 54 | this.root = skillTree.nodes["root"]; 55 | this.extraImages = skillTree.extraImages; 56 | this.min_x = skillTree.min_x; 57 | this.max_x = skillTree.max_x; 58 | this.min_y = skillTree.min_y; 59 | this.max_y = skillTree.max_y; 60 | this.imageZoomLevels = skillTree.imageZoomLevels; 61 | this.constants = new Constants(skillTree.constants); 62 | this.points = skillTree.points || { totalPoints: 121, ascendancyPoints: 8 }; 63 | this.width = Math.abs(this.min_x) + Math.abs(this.max_x); 64 | this.height = Math.abs(this.min_y) + Math.abs(this.max_y); 65 | this.maxZoomLevel = skillTree.imageZoomLevels.length - 1 66 | this.scale = skillTree.imageZoomLevels[this.maxZoomLevel]; 67 | this.sprites = skillTree.sprites; 68 | this.classes = skillTree.classes || []; 69 | this.alternate_ascendancies = skillTree.alternate_ascendancies || []; 70 | 71 | this.root.id = 'root'; 72 | delete skillTree.nodes["root"]; 73 | 74 | // #region Fix ascendancy groups 75 | const offsetDistance = 1450; 76 | if (this.classes.length > 0) { 77 | const groupsCompleted: { [id: string]: boolean | undefined } = {}; 78 | for (const id in skillTree.nodes) { 79 | const node = skillTree.nodes[id]; 80 | const nodeGroupId = `${node.group || 0}`; 81 | if (node.isAscendancyStart && groupsCompleted[nodeGroupId] === undefined) { 82 | let startNode: ISkillNode | undefined = undefined; 83 | for (const o of node.out) { 84 | if (skillTree.nodes[o].classStartIndex !== undefined) { 85 | startNode = skillTree.nodes[o]; 86 | } 87 | } 88 | 89 | for (const o of node.in) { 90 | if (skillTree.nodes[o].classStartIndex !== undefined) { 91 | startNode = skillTree.nodes[o]; 92 | } 93 | } 94 | 95 | if (startNode === undefined) { 96 | continue; 97 | } 98 | 99 | let offset = 0; 100 | if (startNode.classStartIndex !== undefined) { 101 | const classes = this.classes[startNode.classStartIndex].ascendancies; 102 | for (const i in classes) { 103 | if (node.ascendancyName && classes[i].id.toLowerCase().includes(node.ascendancyName.toLowerCase())) { 104 | offset = +i - 1; 105 | break; 106 | } 107 | } 108 | } 109 | 110 | const centerThreshold = 100; 111 | let baseX = 0; 112 | let baseY = 0; 113 | const startGroup = this.groups[startNode.group || 0]; 114 | 115 | if ((startGroup.x > -centerThreshold && startGroup.x < centerThreshold) && (startGroup.y > -centerThreshold && startGroup.y < centerThreshold)) { 116 | // Scion 117 | baseX = this.min_x * .65; 118 | baseY = this.max_y * .95; 119 | if (this.patch.compare(versions.v3_16_0) >= 0) { 120 | baseX = this.min_x * .85; 121 | baseY = this.max_y * .85; 122 | } 123 | } else if (startGroup.x > -centerThreshold && startGroup.x < centerThreshold) { 124 | // Witch, Duelist 125 | baseX = startGroup.x + (Math.sign(startGroup.x) * offset * offsetDistance); 126 | baseY = Math.sign(startGroup.y) > 0 ? this.max_y * 1.05 : this.min_y; 127 | } else { 128 | // Templar, Marauder, Ranger, Shadow 129 | baseX = startGroup.x < 0 ? this.min_x * .80 : this.max_x; 130 | baseY = startGroup.y + (Math.sign(startGroup.y) * (offset + 1) * offsetDistance); 131 | if (this.patch.compare(versions.v3_16_0) >= 0) { 132 | baseX = startGroup.x < 0 ? this.min_x * 1.05 : this.max_x; 133 | } 134 | } 135 | 136 | groupsCompleted[nodeGroupId] = true; 137 | for (const oid in skillTree.nodes) { 138 | const other = skillTree.nodes[oid]; 139 | const otherGroupId = `${other.group || 0}`; 140 | if (groupsCompleted[otherGroupId] === undefined && other.ascendancyName === node.ascendancyName) { 141 | const diffX = this.groups[nodeGroupId].x - this.groups[otherGroupId].x; 142 | const diffY = this.groups[nodeGroupId].y - this.groups[otherGroupId].y; 143 | this.groups[otherGroupId].x = baseX - diffX; 144 | this.groups[otherGroupId].y = baseY - diffY; 145 | groupsCompleted[otherGroupId] = true; 146 | } 147 | } 148 | 149 | this.groups[nodeGroupId].x = baseX; 150 | this.groups[nodeGroupId].y = baseY; 151 | } 152 | } 153 | } 154 | 155 | if (this.alternate_ascendancies.length > 0) { 156 | const groupsCompleted: { [id: string]: boolean | undefined } = {}; 157 | for (const id in skillTree.nodes) { 158 | const node = skillTree.nodes[id]; 159 | const nodeGroupId = `${node.group || 0}`; 160 | if (!node.isAscendancyStart || groupsCompleted[nodeGroupId] !== undefined) { 161 | continue; 162 | } 163 | 164 | let index = -1; 165 | for (const i in this.alternate_ascendancies) { 166 | const ascendancy = this.alternate_ascendancies[i]; 167 | if (ascendancy.id === node.ascendancyName) { 168 | index = +i; 169 | break; 170 | } 171 | } 172 | 173 | if (index === -1) { 174 | continue; 175 | } 176 | 177 | const offset = index - 1; 178 | const baseX = (this.max_x * .80) + (offset * -offsetDistance * .75); 179 | const baseY = (this.max_y * .90) + (offset * offsetDistance * .75); 180 | groupsCompleted[nodeGroupId] = true; 181 | for (const oid in skillTree.nodes) { 182 | const other = skillTree.nodes[oid]; 183 | const otherGroupId = `${other.group || 0}`; 184 | if (groupsCompleted[otherGroupId] === undefined && other.ascendancyName === node.ascendancyName) { 185 | const diffX = this.groups[nodeGroupId].x - this.groups[otherGroupId].x; 186 | const diffY = this.groups[nodeGroupId].y - this.groups[otherGroupId].y; 187 | this.groups[otherGroupId].x = baseX - diffX; 188 | this.groups[otherGroupId].y = baseY - diffY; 189 | groupsCompleted[otherGroupId] = true; 190 | } 191 | } 192 | 193 | this.groups[nodeGroupId].x = baseX; 194 | this.groups[nodeGroupId].y = baseY; 195 | } 196 | } 197 | // #endregion 198 | this.grid = new SpatialHash([[this.min_x, this.min_y], [this.max_x, this.max_y]], [100, 100]); 199 | this.nodes = {}; 200 | this.classStartNodes = {}; 201 | this.ascendancyNodes = {}; 202 | const orbitAngles = this.getOrbitAngles(skillTree.constants.skillsPerOrbit) 203 | for (const id in skillTree.nodes) { 204 | const groupId = skillTree.nodes[id].group || 0; 205 | const node = new SkillNode(id, skillTree.nodes[id], this.groups[groupId], skillTree.constants.orbitRadii, orbitAngles, this.scale, this.patch); 206 | if (this.root.out.indexOf(id) >= 0) { 207 | if (node.classStartIndex === undefined && node.ascendancyName === "") { 208 | node.classStartIndex = this.root.out.indexOf(id); 209 | } 210 | if (node.ascendancyName !== "") { 211 | node.isAscendancyStart = true; 212 | } 213 | } 214 | 215 | this.nodes[id] = node; 216 | 217 | if (node.classStartIndex === this.getDefaultStartNode()) { 218 | this.addState(node, SkillNodeStates.Active); 219 | } 220 | 221 | if (node.ascendancyName !== "") { 222 | this.ascendancyNodes[id] = node; 223 | } 224 | 225 | if (node.classStartIndex !== undefined) { 226 | this.classStartNodes[id] = node; 227 | } 228 | 229 | if (this.shouldAddToGrid(node)) { 230 | this.grid.add(node.id, { x: node.x, y: node.y }, node.targetSize) 231 | } 232 | } 233 | } 234 | 235 | public isAtlasTree = (): boolean => { 236 | return this.tree.startsWith("Atlas") 237 | } 238 | 239 | public getDefaultStartNode = (): number => { 240 | if (this.isAtlasTree()) { 241 | return 0; 242 | } 243 | return 3; 244 | } 245 | 246 | private shouldAddToGrid = (node: SkillNode): boolean => { 247 | return node.group !== undefined && node.classStartIndex === undefined; 248 | } 249 | 250 | private getOrbitAngles = (skillsPerOrbit: Array): { [orbit: number]: Array } => { 251 | const degrees: { [orbit: number]: Array } = {}; 252 | 253 | for (const orbit in skillsPerOrbit) { 254 | const skills = skillsPerOrbit[orbit]; 255 | degrees[orbit] = []; 256 | 257 | if (skills === 16) { 258 | degrees[orbit] = [0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330] 259 | } else if (skills === 40) { 260 | degrees[orbit] = [0, 10, 20, 30, 40, 45, 50, 60, 70, 80, 90, 100, 110, 120, 130, 135, 140, 150, 160, 170, 180, 190, 200, 210, 220, 225, 230, 240, 250, 260, 270, 280, 290, 300, 310, 315, 320, 330, 340, 350] 261 | } else { 262 | for (let i = 0; i < skills; i++) { 263 | degrees[orbit].push(360 * i / skills); 264 | } 265 | } 266 | } 267 | 268 | const radians: { [orbit: number]: Array } = {}; 269 | const conversion = Math.PI / 180; 270 | for (const orbit in degrees) { 271 | const angles = degrees[orbit]; 272 | radians[orbit] = []; 273 | for (const angle of angles) { 274 | radians[orbit].push(angle * conversion); 275 | } 276 | } 277 | 278 | return radians; 279 | } 280 | 281 | public getStartClass = (): number => { 282 | for (const id in this.classStartNodes) { 283 | if (this.nodes[id].is(SkillNodeStates.Active)) { 284 | return this.nodes[id].classStartIndex || 0; 285 | } 286 | } 287 | 288 | for (const id in this.classStartNodes) { 289 | this.addState(this.nodes[id], SkillNodeStates.Active); 290 | return this.nodes[id].classStartIndex || 0; 291 | } 292 | 293 | return 0; 294 | } 295 | 296 | public getAscendancyClass = (): number => { 297 | if (this.classes === undefined || this.classes.length === 0) { 298 | return 0; 299 | } 300 | 301 | for (const id in this.ascendancyNodes) { 302 | if (this.nodes[id].isAscendancyStart && this.nodes[id].is(SkillNodeStates.Active)) { 303 | for (const classid in this.classes) { 304 | const ascendancies = this.classes[classid].ascendancies; 305 | if (ascendancies === undefined) { 306 | continue; 307 | } 308 | 309 | for (const ascid in ascendancies) { 310 | const asc = ascendancies[ascid]; 311 | if (asc.id === this.nodes[id].ascendancyName) { 312 | return (+ascid) + 1; 313 | } 314 | } 315 | } 316 | } 317 | } 318 | 319 | return 0; 320 | } 321 | 322 | public getWildwoodAscendancyClass = (): number => { 323 | if (this.alternate_ascendancies === undefined || this.alternate_ascendancies.length === 0) { 324 | return 0; 325 | } 326 | 327 | for (const id in this.ascendancyNodes) { 328 | if (this.nodes[id].isAscendancyStart && this.nodes[id].is(SkillNodeStates.Active)) { 329 | for (const ascid in this.alternate_ascendancies) { 330 | const asc = this.alternate_ascendancies[ascid]; 331 | if (asc.id === this.nodes[id].ascendancyName) { 332 | return (+ascid) + 1; 333 | } 334 | } 335 | } 336 | } 337 | 338 | return 0; 339 | } 340 | 341 | public isWildwoodAscendancyClass = (node: SkillNode): boolean => { 342 | if (node.ascendancyName === "") { 343 | return false; 344 | } 345 | 346 | for (const ascendancy of this.alternate_ascendancies) { 347 | if (node.ascendancyName === ascendancy.id) { 348 | return true; 349 | } 350 | } 351 | 352 | return false; 353 | } 354 | 355 | public getMasteryForGroup = (group: IGroup | undefined): SkillNode | null => { 356 | if (group === undefined || group.nodes === undefined) { 357 | return null; 358 | } 359 | 360 | for (const id of group.nodes) { 361 | const out = this.nodes[id]; 362 | if (!out.isMastery) { 363 | continue; 364 | } 365 | 366 | return out; 367 | } 368 | 369 | return null; 370 | } 371 | 372 | public getSkilledNodes = (): { [id: string]: SkillNode } => this.getNodes(SkillNodeStates.Active); 373 | 374 | public getHoveredNodes = (): { [id: string]: SkillNode } => { 375 | const hovered: { [id: string]: SkillNode } = {}; 376 | 377 | for (const id in this.getNodes(SkillNodeStates.Hovered)) { 378 | hovered[id] = this.nodes[id]; 379 | } 380 | 381 | for (const id in this.getNodes(SkillNodeStates.Pathing)) { 382 | hovered[id] = this.nodes[id]; 383 | } 384 | 385 | return hovered; 386 | } 387 | 388 | public getNodes = (state: SkillNodeStates): { [id: string]: SkillNode } => { 389 | const n: { [id: string]: SkillNode } = {}; 390 | 391 | for (const id of this.nodesInState[state]) { 392 | if (this.nodes[id].is(state)) { 393 | n[id] = this.nodes[id]; 394 | } 395 | } 396 | 397 | return n; 398 | } 399 | 400 | public getNodeAtPoint = (point: IPoint): SkillNode | null => { 401 | const ids = this.grid.find(point, { width: 0, height: 0 }); 402 | if (ids.length === 0) { 403 | return null; 404 | } 405 | 406 | let minNode: SkillNode | null = null; 407 | let minDistance: number | null = null; 408 | for (const id of ids) { 409 | const node = this.nodes[id]; 410 | const distance = this.inRange(node, point); 411 | if (distance === null) { 412 | continue; 413 | } 414 | if (minDistance === null || distance < minDistance) { 415 | minNode = node; 416 | minDistance = distance; 417 | } 418 | } 419 | return minNode; 420 | } 421 | 422 | private inRange = (node: SkillNode, point: IPoint): number | null => { 423 | const size = node.targetSize; 424 | const range = size.width * size.height * this.scale; 425 | const distance = this.getDistance(node, point); 426 | return distance < range ? distance : null; 427 | } 428 | 429 | private getDistance = (node: SkillNode, point: IPoint): number => { 430 | const diff = { x: node.x - point.x, y: node.y - point.y } 431 | return diff.x * diff.x + diff.y * diff.y; 432 | } 433 | 434 | public addState = (node: SkillNode, state: SkillNodeStates) => this.addStateById(node.GetId(), state); 435 | public addStateById = (id: string, state: SkillNodeStates) => { 436 | if (this.nodes[id] === undefined) { 437 | return; 438 | } 439 | 440 | if (this.nodes[id].is(state)) { 441 | return; 442 | } 443 | 444 | this.nodes[id]._add(state); 445 | this.nodesInState[state].push(id); 446 | } 447 | 448 | public removeState = (node: SkillNode, state: SkillNodeStates) => this.removeStateById(node.GetId(), state); 449 | public removeStateById = (id: string, state: SkillNodeStates) => { 450 | if (this.nodes[id] === undefined) { 451 | return; 452 | } 453 | 454 | if (!this.nodes[id].is(state)) { 455 | return; 456 | } 457 | 458 | this.nodes[id]._remove(state); 459 | this.nodesInState[state].splice(this.nodesInState[state].indexOf(id), 1); 460 | } 461 | 462 | public clearState = (state: SkillNodeStates) => { 463 | for (const id in this.getNodes(state)) { 464 | this.nodes[id]._remove(state); 465 | 466 | if (state === SkillNodeStates.Hovered) { 467 | this.nodes[id].hoverText = null; 468 | } 469 | } 470 | 471 | this.nodesInState[state] = new Array(); 472 | } 473 | 474 | public hasSprite = (sheet: SpriteSheetKey, icon: string): boolean => { 475 | return this.sprites[sheet] && 476 | ((this.sprites[sheet][this.scale.toString()] && this.sprites[sheet][this.scale.toString()].coords[icon] !== undefined) 477 | || (this.sprites[sheet]["1"] && this.sprites[sheet]["1"].coords[icon] !== undefined)) 478 | } 479 | } -------------------------------------------------------------------------------- /models/SkillTreeEvents.ts: -------------------------------------------------------------------------------- 1 | class SkillTreeEventContainer { 2 | private events: { [event: string]: Array } = {} 3 | 4 | public on = (event: T, fn: Function) => { 5 | if (this.events[event] === undefined) { 6 | this.events[event] = new Array(); 7 | } 8 | 9 | this.events[event].push(fn); 10 | } 11 | 12 | public off = (event: T, fn: Function) => { 13 | if (this.events[event] === undefined || this.events[event].indexOf(fn) === -1) { 14 | return; 15 | } 16 | 17 | this.events[event].splice(this.events[event].indexOf(fn), 1); 18 | } 19 | 20 | public fire(event: T, context?: any) { 21 | if (this.events[event] === undefined) { 22 | return; 23 | } 24 | for (const fn of this.events[event]) { 25 | setTimeout(() => fn(context), 0); 26 | } 27 | } 28 | } 29 | 30 | export class SkillTreeEvents { 31 | public static controls = new SkillTreeEventContainer< 32 | | "ascendancy-class-change" 33 | | "wildwood-ascendancy-class-change" 34 | | "class-change" 35 | | "search-change" 36 | >(); 37 | 38 | public static skill_tree = new SkillTreeEventContainer< 39 | | "active-nodes-update" 40 | | "ascendancy-class-change" 41 | | "wildwood-ascendancy-class-change" 42 | | "ascendancy-node-count-maximum" 43 | | "wildwood-ascendancy-node-count-maximum" 44 | | "ascendancy-node-count" 45 | | "wildwood-ascendancy-node-count" 46 | | "class-change" 47 | | "encode-url" 48 | | "highlighted-nodes-update" 49 | | "hovered-nodes-end" 50 | | "hovered-nodes-start" 51 | | "normal-node-count-maximum" 52 | | "normal-node-count" 53 | >(); 54 | 55 | public static node = new SkillTreeEventContainer< 56 | | "click" 57 | | "in" 58 | | "out" 59 | >(); 60 | 61 | public static viewport = new SkillTreeEventContainer< 62 | | "cancel" 63 | | "down" 64 | | "move" 65 | | "up" 66 | >(); 67 | } -------------------------------------------------------------------------------- /models/SkillTreeUtilities.ts: -------------------------------------------------------------------------------- 1 | import { SkillTreeData } from "./SkillTreeData"; 2 | import { SkillNode, SkillNodeStates } from "./SkillNode"; 3 | import { SkillTreeEvents } from "./SkillTreeEvents"; 4 | import { SkillTreeCodec } from "./url-processing/SkillTreeCodec"; 5 | 6 | export class SkillTreeUtilities { 7 | skillTreeData: SkillTreeData; 8 | skillTreeDataCompare: SkillTreeData | undefined; 9 | skillTreeCodec: SkillTreeCodec; 10 | 11 | constructor(context: SkillTreeData, contextComapre: SkillTreeData | undefined) { 12 | this.skillTreeData = context; 13 | this.skillTreeDataCompare = contextComapre; 14 | this.skillTreeCodec = new SkillTreeCodec(); 15 | 16 | SkillTreeEvents.node.on("click", this.click); 17 | SkillTreeEvents.node.on("in", this.mouseover); 18 | SkillTreeEvents.node.on("out", this.mouseout); 19 | 20 | SkillTreeEvents.controls.on("class-change", this.changeStartClass); 21 | SkillTreeEvents.controls.on("ascendancy-class-change", this.changeAscendancyClass); 22 | SkillTreeEvents.controls.on("wildwood-ascendancy-class-change", this.changeWildwoodAscendancyClass); 23 | SkillTreeEvents.controls.on("search-change", this.searchChange); 24 | 25 | SkillTreeEvents.skill_tree.on("encode-url", this.encodeURL); 26 | } 27 | 28 | private lastHash = ""; 29 | public decodeURL = () => { 30 | if (window.location.hash === "") { 31 | this.changeStartClass(this.skillTreeData.getDefaultStartNode(), false); 32 | } 33 | if (this.lastHash === window.location.hash) { 34 | return; 35 | } 36 | this.lastHash = window.location.hash; 37 | 38 | try { 39 | const data = window.location.hash.replace("#", ""); 40 | if (data === null) { 41 | window.location.hash = ""; 42 | return; 43 | } 44 | 45 | const def = this.skillTreeCodec.decodeURL(data, this.skillTreeData); 46 | this.skillTreeData.version = def.Version; 47 | this.changeStartClass(def.Class, false); 48 | this.changeAscendancyClass(def.Ascendancy, false); 49 | this.changeWildwoodAscendancyClass(def.WildwoodAscendancy, false); 50 | 51 | for (const node of def.Nodes) { 52 | this.skillTreeData.addStateById(`${node.skill}`, SkillNodeStates.Active) 53 | } 54 | 55 | for (const node of def.ExtendedNodes) { 56 | this.skillTreeData.addStateById(`${node.skill}`, SkillNodeStates.Active) 57 | } 58 | 59 | for (const [node, effect] of def.MasteryEffects) { 60 | this.skillTreeData.addStateById(`${node.skill}`, SkillNodeStates.Active) 61 | this.skillTreeData.masteryEffects[node.skill] = effect; 62 | } 63 | 64 | for (const id in this.skillTreeData.classStartNodes) { 65 | if (this.skillTreeData.nodes[id].is(SkillNodeStates.Active)) { 66 | const refund = this.getRefundNodes(this.skillTreeData.nodes[id]); 67 | for (const i of refund) { 68 | this.skillTreeData.removeState(i, SkillNodeStates.Active); 69 | } 70 | } 71 | } 72 | 73 | this.encodeURL(); 74 | } 75 | catch (ex) { 76 | window.location.hash = ""; 77 | console.log(ex); 78 | } 79 | } 80 | 81 | private encodeURL = () => { 82 | SkillTreeEvents.skill_tree.fire("active-nodes-update"); 83 | this.broadcastSkillCounts(); 84 | window.location.hash = `#${this.skillTreeCodec.encodeURL(this.skillTreeData)}`; 85 | } 86 | 87 | private broadcastSkillCounts = () => { 88 | //need to add bandits here 89 | let maximumNormalPoints = this.skillTreeData.points.totalPoints; 90 | const maximumAscendancyPoints = this.skillTreeData.points.ascendancyPoints; 91 | let normalNodes = 0; 92 | let ascNodes = 0; 93 | let wildwoodAscNodes = 0; 94 | 95 | const nodes = this.skillTreeData.getNodes(SkillNodeStates.Active); 96 | for (const id in nodes) { 97 | const node = nodes[id]; 98 | if (node.classStartIndex === undefined && !node.isAscendancyStart && !node.isMultipleChoice) { 99 | if (node.ascendancyName === "") { 100 | normalNodes++; 101 | } else { 102 | if (this.skillTreeData.isWildwoodAscendancyClass(node)) { 103 | wildwoodAscNodes++; 104 | } else { 105 | ascNodes++; 106 | } 107 | } 108 | maximumNormalPoints += node.grantedPassivePoints; 109 | } 110 | } 111 | 112 | SkillTreeEvents.skill_tree.fire("normal-node-count", normalNodes); 113 | SkillTreeEvents.skill_tree.fire("normal-node-count-maximum", maximumNormalPoints); 114 | SkillTreeEvents.skill_tree.fire("ascendancy-node-count", ascNodes); 115 | SkillTreeEvents.skill_tree.fire("ascendancy-node-count-maximum", maximumAscendancyPoints); 116 | SkillTreeEvents.skill_tree.fire("wildwood-ascendancy-node-count", wildwoodAscNodes); 117 | SkillTreeEvents.skill_tree.fire("wildwood-ascendancy-node-count-maximum", maximumAscendancyPoints); 118 | } 119 | 120 | public changeStartClass = (start: number, encode = true) => { 121 | for (const id in this.skillTreeData.classStartNodes) { 122 | const node = this.skillTreeData.nodes[id]; 123 | if (node.classStartIndex === undefined) { 124 | continue; 125 | } 126 | 127 | if (node.classStartIndex !== start) { 128 | this.skillTreeData.removeState(node, SkillNodeStates.Active); 129 | continue; 130 | } 131 | 132 | this.skillTreeData.addState(node, SkillNodeStates.Active); 133 | SkillTreeEvents.skill_tree.fire("class-change", node); 134 | for (const i of this.getRefundNodes(node)) { 135 | this.skillTreeData.removeState(i, SkillNodeStates.Active); 136 | } 137 | } 138 | this.changeAscendancyClass(0, false, true); 139 | this.changeWildwoodAscendancyClass(0, false, true); 140 | 141 | if (encode) { 142 | this.encodeURL(); 143 | } 144 | } 145 | 146 | public changeAscendancyClass = (start: number, encode = true, newStart = false) => { 147 | if (newStart) SkillTreeEvents.skill_tree.fire("ascendancy-class-change"); 148 | if (this.skillTreeData.classes.length === 0) { 149 | return; 150 | } 151 | 152 | const ascClasses = this.skillTreeData.classes[this.skillTreeData.getStartClass()].ascendancies; 153 | if (ascClasses === undefined) { 154 | return; 155 | } 156 | this.changeAscendancyClassInternal(false, start, ascClasses, encode); 157 | } 158 | 159 | public changeWildwoodAscendancyClass = (start: number, encode = true, newStart = false) => { 160 | if (newStart) SkillTreeEvents.skill_tree.fire("wildwood-ascendancy-class-change"); 161 | if (this.skillTreeData.alternate_ascendancies.length === 0) { 162 | return; 163 | } 164 | 165 | const ascClasses = this.skillTreeData.alternate_ascendancies; 166 | if (ascClasses === undefined) { 167 | return; 168 | } 169 | 170 | this.changeAscendancyClassInternal(true, start, ascClasses, encode); 171 | } 172 | 173 | private changeAscendancyClassInternal = (isWildwood: boolean, start: number, ascClasses: IAscendancyClassV7[], encode: boolean) => { 174 | const ascClass = ascClasses[start - 1]; 175 | const name = ascClass !== undefined ? ascClass.id : undefined; 176 | 177 | for (const id in this.skillTreeData.ascendancyNodes) { 178 | const node = this.skillTreeData.nodes[id]; 179 | if (this.skillTreeData.isWildwoodAscendancyClass(node) !== isWildwood) { 180 | continue; 181 | } 182 | 183 | if (node.ascendancyName !== name) { 184 | this.skillTreeData.removeState(node, SkillNodeStates.Active); 185 | continue; 186 | } 187 | 188 | if (node.isAscendancyStart) { 189 | this.skillTreeData.addState(node, SkillNodeStates.Active); 190 | } 191 | } 192 | 193 | if (encode) { 194 | this.encodeURL(); 195 | } 196 | } 197 | 198 | public searchChange = (str: string | undefined = undefined) => { 199 | this.skillTreeData.clearState(SkillNodeStates.Highlighted); 200 | 201 | if (str !== undefined && str.length !== 0) { 202 | const regex = new RegExp(str, "gi"); 203 | for (const id in this.skillTreeData.nodes) { 204 | const node = this.skillTreeData.nodes[id]; 205 | if (node.isAscendancyStart || node.classStartIndex !== undefined) { 206 | continue; 207 | } 208 | if (node.name.match(regex) !== null || node.stats.find(stat => stat.match(regex) !== null) !== undefined) { 209 | this.skillTreeData.addState(node, SkillNodeStates.Highlighted); 210 | } 211 | } 212 | } 213 | 214 | SkillTreeEvents.skill_tree.fire("highlighted-nodes-update"); 215 | } 216 | 217 | private click = (node: SkillNode) => { 218 | if (node.is(SkillNodeStates.Compared)) { 219 | return; 220 | } 221 | 222 | if (node.classStartIndex !== undefined || node.isAscendancyStart) { 223 | return; 224 | } 225 | 226 | const refund = this.getRefundNodes(node); 227 | const shortest = this.getShortestPath(node); 228 | 229 | if (shortest.length > 0 || node.is(SkillNodeStates.Active)) { 230 | for (const i of refund) { 231 | if (i.classStartIndex !== undefined) { 232 | continue; 233 | } 234 | this.skillTreeData.removeState(i, SkillNodeStates.Active); 235 | } 236 | } 237 | 238 | for (const i of shortest) { 239 | if (!i.is(SkillNodeStates.Active) && refund.indexOf(i) < 0) { 240 | this.skillTreeData.addState(i, SkillNodeStates.Active); 241 | } 242 | } 243 | 244 | this.skillTreeData.clearState(SkillNodeStates.Hovered); 245 | this.skillTreeData.clearState(SkillNodeStates.Pathing); 246 | this.skillTreeDataCompare?.clearState(SkillNodeStates.Hovered); 247 | this.encodeURL(); 248 | } 249 | 250 | private mouseover = (node: SkillNode) => { 251 | this.skillTreeData.clearState(SkillNodeStates.Hovered); 252 | this.skillTreeData.clearState(SkillNodeStates.Pathing); 253 | this.skillTreeDataCompare?.clearState(SkillNodeStates.Hovered); 254 | 255 | if (node.classStartIndex === undefined) { 256 | if (node.is(SkillNodeStates.Compared)) { 257 | this.skillTreeDataCompare?.addState(node, SkillNodeStates.Hovered); 258 | } else { 259 | this.skillTreeData.addState(node, SkillNodeStates.Hovered); 260 | 261 | if (this.skillTreeData.isAtlasTree() && node.isMastery) { 262 | for (const id in this.skillTreeData.nodes) { 263 | const other = this.skillTreeData.nodes[id]; 264 | if (!other.isMastery) { 265 | continue; 266 | } 267 | 268 | if (other.name !== node.name) { 269 | continue; 270 | } 271 | 272 | this.skillTreeData.addState(other, SkillNodeStates.Hovered); 273 | } 274 | } 275 | } 276 | } 277 | const shortest = this.getShortestPath(node); 278 | for (const i of shortest) { 279 | if (!i.is(SkillNodeStates.Pathing) && !i.is(SkillNodeStates.Active)) { 280 | this.skillTreeData.addState(i, SkillNodeStates.Pathing); 281 | } 282 | } 283 | node.hoverText = shortest.length.toString(); 284 | 285 | if (shortest.length > 0 || node.is(SkillNodeStates.Active)) { 286 | const refund = this.getRefundNodes(node); 287 | for (const i of refund) { 288 | this.skillTreeData.addState(i, SkillNodeStates.Pathing); 289 | } 290 | if (refund.length > 0) { 291 | node.hoverText = refund.length.toString(); 292 | } 293 | } 294 | 295 | SkillTreeEvents.skill_tree.fire("hovered-nodes-start", node); 296 | } 297 | 298 | private mouseout = (node: SkillNode) => { 299 | this.skillTreeData.clearState(SkillNodeStates.Hovered); 300 | this.skillTreeData.clearState(SkillNodeStates.Pathing); 301 | this.skillTreeDataCompare?.clearState(SkillNodeStates.Hovered); 302 | SkillTreeEvents.skill_tree.fire("hovered-nodes-end", node); 303 | } 304 | 305 | private getShortestPath = (target: SkillNode): Array => { 306 | if (target.isBlighted) { 307 | return new Array(target); 308 | } 309 | 310 | const skilled = this.skillTreeData.getSkilledNodes(); 311 | if (skilled[target.GetId()]) { 312 | return new Array(); 313 | } 314 | 315 | const frontier: Array = []; 316 | const distance: { [id: string]: number } = {}; 317 | const adjacent = this.getAdjacentNodes(skilled); 318 | for (const id in adjacent) { 319 | if (id === target.GetId()) { 320 | const path = new Array(); 321 | path.push(target); 322 | return path; 323 | } 324 | const node = this.skillTreeData.nodes[id]; 325 | if (node.isAscendancyStart && !node.is(SkillNodeStates.Active)) { 326 | continue; 327 | } 328 | frontier.push(adjacent[id]); 329 | distance[id] = 1; 330 | } 331 | 332 | const explored = skilled; 333 | const prev: { [id: string]: SkillNode } = {}; 334 | while (frontier.length > 0) { 335 | const current = frontier.shift(); 336 | if (current === undefined) { 337 | continue; 338 | } 339 | 340 | explored[current.GetId()] = current; 341 | const dist = distance[current.GetId()]; 342 | for (const id of current.out) { 343 | const out = this.skillTreeData.nodes[id]; 344 | if ((current.ascendancyName === "" && out.ascendancyName !== "" && !out.is(SkillNodeStates.Active)) 345 | || (current.ascendancyName !== "" && out.ascendancyName === "" && !current.is(SkillNodeStates.Active))) { 346 | continue; 347 | } 348 | if (explored[id] || distance[id]) { 349 | continue; 350 | } 351 | if (out.isAscendancyStart && !out.is(SkillNodeStates.Active)) { 352 | continue; 353 | } 354 | if (out.classStartIndex !== undefined && !out.is(SkillNodeStates.Active)) { 355 | continue; 356 | } 357 | 358 | distance[id] = dist + 1; 359 | prev[id] = current; 360 | frontier.push(out); 361 | if (out.GetId() === target.GetId()) { 362 | frontier.length = 0; 363 | } 364 | } 365 | } 366 | 367 | if (distance[target.GetId()] === undefined) { 368 | return new Array(); 369 | } 370 | 371 | let current: SkillNode | undefined = target; 372 | const path = new Array(); 373 | while (current !== undefined) { 374 | path.push(current); 375 | current = prev[current.GetId()]; 376 | } 377 | return path.reverse(); 378 | } 379 | 380 | private getRefundNodes = (source: SkillNode): Array => { 381 | let characterStartNode: SkillNode | undefined = undefined; 382 | for (const id in this.skillTreeData.classStartNodes) { 383 | const node = this.skillTreeData.nodes[id]; 384 | if (node.is(SkillNodeStates.Active) && node.classStartIndex !== undefined) { 385 | characterStartNode = node; 386 | } 387 | } 388 | if (characterStartNode === undefined) { 389 | return new Array(); 390 | } 391 | 392 | let frontier = new Array(); 393 | const reachable: { [id: string]: SkillNode } = {}; 394 | for (const id of characterStartNode.out) { 395 | const out = this.skillTreeData.nodes[id]; 396 | if (!this.isSameAscendancyClass(source, out)) { 397 | continue; 398 | } 399 | if (out.is(SkillNodeStates.Active) && out.GetId() !== source.GetId()) { 400 | frontier.push(out); 401 | reachable[id] = out; 402 | } 403 | } 404 | 405 | // support for wildwood ascendancies 406 | for (const id of this.skillTreeData.root.out) { 407 | const node = this.skillTreeData.nodes[id]; 408 | if (node.isAscendancyStart && node.is(SkillNodeStates.Active)) { 409 | frontier.push(node); 410 | reachable[id] = node; 411 | } 412 | } 413 | 414 | while (frontier.length > 0) { 415 | const nextFrontier = new Array(); 416 | for (const node of frontier) { 417 | for (const id of node.out) { 418 | const out = this.skillTreeData.nodes[id]; 419 | if (out.isMultipleChoiceOption && source.isMultipleChoiceOption) { 420 | const outchoice = out.in.find(id => this.skillTreeData.nodes[id].isMultipleChoice); 421 | if (outchoice !== undefined && outchoice === source.in.find(id => this.skillTreeData.nodes[id].isMultipleChoice)) { 422 | continue; 423 | } 424 | } 425 | if (!this.isSameAscendancyClass(source, out)) { 426 | continue; 427 | } 428 | if (out.GetId() === source.GetId() || reachable[id] || !out.is(SkillNodeStates.Active)) { 429 | continue; 430 | } 431 | 432 | nextFrontier.push(out); 433 | reachable[id] = out; 434 | } 435 | } 436 | 437 | frontier = nextFrontier; 438 | } 439 | 440 | const unreachable = new Array(); 441 | const skilledNodes = this.skillTreeData.getSkilledNodes(); 442 | for (const id in skilledNodes) { 443 | if (reachable[id] === undefined && this.skillTreeData.nodes[id].classStartIndex === undefined) { 444 | unreachable.push(this.skillTreeData.nodes[id]); 445 | } 446 | } 447 | return unreachable; 448 | 449 | 450 | } 451 | 452 | private isSameAscendancyClass = (left: SkillNode, right: SkillNode): boolean => { 453 | if (left.ascendancyName === "" || right.ascendancyName === "") { 454 | return true; 455 | } 456 | 457 | if (this.skillTreeData.isWildwoodAscendancyClass(left) !== this.skillTreeData.isWildwoodAscendancyClass(right)) { 458 | return true; 459 | } 460 | 461 | return left.ascendancyName === right.ascendancyName; 462 | } 463 | 464 | private getAdjacentNodes = (start: { [id: string]: SkillNode }): { [id: string]: SkillNode } => { 465 | const adjacentNodes: { [id: string]: SkillNode } = {}; 466 | for (const parent in start) { 467 | for (const id of start[parent].out) { 468 | const out = this.skillTreeData.nodes[id]; 469 | if (out.classStartIndex !== undefined && !out.is(SkillNodeStates.Active)) { 470 | continue; 471 | } 472 | adjacentNodes[id] = out; 473 | } 474 | } 475 | return adjacentNodes; 476 | } 477 | } -------------------------------------------------------------------------------- /models/events/UIEvents.ts: -------------------------------------------------------------------------------- 1 | import { SkillNode } from "models/SkillNode"; 2 | import { SkillTreeData } from "models/SkillTreeData"; 3 | import { SkillTreeEvents } from "models/SkillTreeEvents"; 4 | 5 | export class UIEvents { 6 | private DRAG_THRESHOLD_SQUARED = 4 * 4; 7 | private start: IPoint = { x: 0, y: 0 }; 8 | private dragged: boolean = false; 9 | private hovered: SkillNode[] = []; 10 | 11 | skillTreeData: SkillTreeData; 12 | skillTreeDataCompare: SkillTreeData | undefined; 13 | 14 | constructor(context: SkillTreeData, contextComapre: SkillTreeData | undefined) { 15 | this.skillTreeData = context; 16 | this.skillTreeDataCompare = contextComapre; 17 | 18 | SkillTreeEvents.viewport.on("up", this.up); 19 | SkillTreeEvents.viewport.on("move", this.move); 20 | SkillTreeEvents.viewport.on("down", this.down); 21 | SkillTreeEvents.viewport.on("cancel", () => setTimeout(() => this.cancelDrag(), 250)); 22 | } 23 | 24 | private skillTrees = (): SkillTreeData[] => { 25 | const result = [this.skillTreeData] 26 | if (this.skillTreeDataCompare !== undefined) { 27 | result.push(this.skillTreeDataCompare); 28 | } 29 | return result; 30 | } 31 | 32 | private up = (point: IPoint) => { 33 | if (!this.dragged) { 34 | UIEvents.clickSkillTree(point, this.skillTreeData); 35 | } 36 | this.cancelDrag(); 37 | } 38 | 39 | private static clickSkillTree = (point: IPoint, skillTree: SkillTreeData) => { 40 | const node = skillTree.getNodeAtPoint(point); 41 | if (node === null) { 42 | return; 43 | } 44 | SkillTreeEvents.node.fire("click", node); 45 | } 46 | 47 | private cancelDrag = () => { 48 | this.start = { x: 0, y: 0 }; 49 | this.dragged = false; 50 | } 51 | 52 | private down = (point: IPoint) => { 53 | this.start = { x: point.x, y: point.y }; 54 | } 55 | 56 | private move = (point: IPoint) => { 57 | if (!this.dragged && this.start.x !== 0 && this.start.y !== 0) { 58 | const diff = { x: this.start.x - point.x, y: this.start.y - point.y }; 59 | this.dragged = this.dragged || (diff.x * diff.x + diff.y * diff.y) > this.DRAG_THRESHOLD_SQUARED; 60 | } 61 | 62 | const current = new Array(); 63 | for (const skillTree of this.skillTrees()) { 64 | const node = skillTree.getNodeAtPoint(point); 65 | if (node !== null) { 66 | current.push(node); 67 | break; 68 | } 69 | } 70 | 71 | const diff = this.hovered.filter(x => !current.includes(x)); 72 | for (const node of diff) { 73 | SkillTreeEvents.node.fire("out", node); 74 | } 75 | 76 | this.hovered = current; 77 | for (const node of this.hovered) { 78 | SkillTreeEvents.node.fire("in", node); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /models/skill-tree/SkillTreePreprocessors.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeData } from "../types/ISkillTreeData"; 2 | import { SkillTreeOptionsV1Preprocessor } from "./options-preprocessors/SkillTreeOptionsV1Preprocessor"; 3 | import { SkillTreeOptionsPreprocessor } from "./preprocessors/SkillTreeOptionsPreprocessor"; 4 | import { SkillTreePreprocessor } from "./preprocessors/SkillTreePreprocessor"; 5 | import { SkillTreeV1Preprocessor } from "./preprocessors/SkillTreeV1Preprocessor"; 6 | import { SkillTreeV2Preprocessor } from "./preprocessors/SkillTreeV2Preprocessor"; 7 | import { SkillTreeV3Preprocessor } from "./preprocessors/SkillTreeV3Preprocessor"; 8 | import { SkillTreeV4Preprocessor } from "./preprocessors/SkillTreeV4Preprocessor"; 9 | import { SkillTreeV5Preprocessor } from "./preprocessors/SkillTreeV5Preprocessor"; 10 | import { SkillTreeV6Preprocessor } from "./preprocessors/SkillTreeV6Preprocessor"; 11 | import { SkillTreeV7Preprocessor } from "./preprocessors/SkillTreeV7Preprocessor"; 12 | import { SkillTreeV8Preprocessor } from "./preprocessors/SkillTreeV8Preprocessor"; 13 | import { SkillTreeV9Preprocessor } from "./preprocessors/SkillTreeV9Preprocessor"; 14 | import { SkillTreeV10Preprocessor } from "./preprocessors/SkillTreeV10Preprocessor"; 15 | import { SkillTreeV11Preprocessor } from "./preprocessors/SkillTreeV11Preprocessor"; 16 | import { SkillTreeV12Preprocessor } from "./preprocessors/SkillTreeV12Preprocessor"; 17 | import { SkillTreeV13Preprocessor } from "./preprocessors/SkillTreeV13Preprocessor"; 18 | import { SkillTreeV14Preprocessor } from "./preprocessors/SkillTreeV14Preprocessor"; 19 | 20 | export class SkillTreePreprocessors { 21 | private static _preprocessors: Array = [ 22 | new SkillTreeV1Preprocessor(), 23 | new SkillTreeV2Preprocessor(), 24 | new SkillTreeV3Preprocessor(), 25 | new SkillTreeV4Preprocessor(), 26 | new SkillTreeV5Preprocessor(), 27 | new SkillTreeV6Preprocessor(), 28 | new SkillTreeV7Preprocessor(), 29 | new SkillTreeV8Preprocessor(), 30 | new SkillTreeV9Preprocessor(), 31 | new SkillTreeV10Preprocessor(), 32 | new SkillTreeV11Preprocessor(), 33 | new SkillTreeV12Preprocessor(), 34 | new SkillTreeV13Preprocessor(), 35 | new SkillTreeV14Preprocessor(), 36 | new SkillTreeOptionsPreprocessor(), 37 | new SkillTreePreprocessor() 38 | ]; 39 | 40 | private static _optionsPreprocessors: Array = [ 41 | new SkillTreeOptionsV1Preprocessor() 42 | ]; 43 | 44 | public static Decode(data: ISkillTreeBase, options: ISkillTreeOptionsBase | undefined): ISkillTreeData { 45 | if (options !== undefined) { 46 | for (const preprocessor of this._optionsPreprocessors) { 47 | if (preprocessor.CanProcess(options)) { 48 | options = preprocessor.Process(options); 49 | } 50 | } 51 | } 52 | 53 | for (const preprocessor of this._preprocessors) { 54 | if (preprocessor.CanProcess(data, options)) { 55 | data = preprocessor.Process(data, options); 56 | } 57 | } 58 | 59 | return data as ISkillTreeData; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /models/skill-tree/options-preprocessors/SkillTreeOptionsV1Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 2.2.0 to 3.7.0 */ 2 | export class SkillTreeOptionsV1Preprocessor implements ISkillTreeOptionsPreprocessor { 3 | CanProcess(data: ISkillTreeOptionsV1): boolean { 4 | return (data as ISkillTreeOptionsV2).circles === undefined; 5 | } 6 | 7 | Process(data: ISkillTreeOptionsV1): ISkillTreeOptionsV2 { 8 | let v2 = data as ISkillTreeOptionsV2; 9 | 10 | v2.realm = 'pc'; 11 | v2.circles = { "Small": [{ "level": 0.1246, "width": 199 }, { "level": 0.2109, "width": 337 }, { "level": 0.2972, "width": 476 }, { "level": 0.3835, "width": 614 }], "Medium": [{ "level": 0.1246, "width": 299 }, { "level": 0.2109, "width": 506 }, { "level": 0.2972, "width": 713 }, { "level": 0.3835, "width": 920 }], "Large": [{ "level": 0.1246, "width": 374 }, { "level": 0.2109, "width": 633 }, { "level": 0.2972, "width": 892 }, { "level": 0.3835, "width": 1151 }] }; 12 | 13 | return v2; 14 | } 15 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeOptionsPreprocessor.ts: -------------------------------------------------------------------------------- 1 | export class SkillTreeOptionsPreprocessor implements ISkillTreePreprocessor { 2 | CanProcess(_: ISkillTreeV10, options: ISkillTreeOptionsV2 | undefined): boolean { 3 | return options !== undefined; 4 | } 5 | 6 | Process(data: ISkillTreeV10, options: ISkillTreeOptionsV2 | undefined): ISkillTreeV10 { 7 | if (options === undefined) 8 | return data; 9 | 10 | if (data.classes === undefined) 11 | data.classes = []; 12 | 13 | for (const id in options.ascClasses) { 14 | const character = options.ascClasses[id]; 15 | const current = data.classes[+id] || {}; 16 | current.name = current.name || character.name; 17 | current.ascendancies = []; 18 | 19 | for (const ascId in character.classes) { 20 | const asc = character.classes[ascId]; 21 | current.ascendancies[+ascId - 1] = { 22 | flavourText: asc.flavourText, 23 | flavourTextColour: asc.flavourTextColour, 24 | flavourTextRect: this.UpgradeFlavourTextRect(asc.flavourTextRect), 25 | id: asc.displayName, 26 | name: asc.name 27 | } 28 | } 29 | data.classes[+id] = current; 30 | } 31 | 32 | return data; 33 | } 34 | 35 | private UpgradeFlavourTextRect(flavourTextRect: string): ISkillTreeRectV7 { 36 | const rect = flavourTextRect.split(","); 37 | return { 38 | x: +rect[0], 39 | y: +rect[1], 40 | width: +rect[2], 41 | height: +rect[3] 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreePreprocessor.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeData } from "../../types/ISkillTreeData"; 2 | 3 | /** Clean up after all versions are done */ 4 | export class SkillTreePreprocessor implements ISkillTreePreprocessor { 5 | CanProcess(_: ISkillTreeData): boolean { 6 | return true; 7 | } 8 | 9 | Process(data: ISkillTreeData): ISkillTreeData { 10 | data.nodes["root"].in = data.nodes["root"].in || []; 11 | data.nodes["root"].out = data.nodes["root"].out || []; 12 | 13 | const nodes: { [id: string]: ISkillNodeV13 } = {}; 14 | for (const id in data.nodes) { 15 | nodes[id.toString()] = this.FixNode(id, data.nodes[id]); 16 | } 17 | 18 | for (const id in nodes) { 19 | if (id === "root") continue; 20 | 21 | for (const outId of nodes[id].out) { 22 | if (outId === "root") continue; 23 | 24 | if (nodes[id].in.indexOf(outId) < 0) { 25 | nodes[id].in.push(outId); 26 | } 27 | if (!nodes[outId].isMastery && nodes[outId].out.indexOf(id) < 0) { 28 | nodes[outId].out.push(id); 29 | } 30 | } 31 | 32 | for (const inId of nodes[id].in) { 33 | if (inId === "root") continue; 34 | 35 | if (!nodes[id].isMastery && nodes[id].out.indexOf(inId) < 0) { 36 | nodes[id].out.push(inId); 37 | } 38 | if (nodes[inId].in.indexOf(id) < 0) { 39 | nodes[inId].in.push(id); 40 | } 41 | } 42 | } 43 | 44 | data.nodes = nodes; 45 | 46 | for (var id in data.sprites) { 47 | for (var zoom in data.sprites[id]) { 48 | data.sprites[id][zoom].filename = data.sprites[id][zoom].filename.replace("https://web.poecdn.com/image/passive-skill/", ""); 49 | } 50 | } 51 | 52 | for (const id in data.groups) { 53 | const group = data.groups[id]; 54 | data.groups[id].nodes = (group.nodes || []).map(n => n.toString()); 55 | data.groups[id].orbits = group.orbits || []; 56 | } 57 | 58 | return data; 59 | } 60 | 61 | private FixNode(id: string, node: ISkillNodeV13): ISkillNodeV13 { 62 | node.in = (node.in || []).map(x => x.toString()) || []; 63 | node.out = (node.out || []).map(x => x.toString()) || []; 64 | node.in = node.in.filter(x => x !== id); 65 | node.out = node.out.filter(x => x !== id); 66 | return node; 67 | } 68 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV10Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.19.0 */ 2 | export class SkillTreeV10Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV10): boolean { 4 | return data.assets !== undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV10): ISkillTreeV11 { 8 | const v11 = JSON.parse(JSON.stringify(data)) as ISkillTreeV11; 9 | 10 | const sprites: { [id: string]: { [zoomLevel: string]: ISpriteSheetV11 } } = {}; 11 | const upgradedSpriteSheets = this.UpgradeSpriteSheets(data); 12 | for (const id in upgradedSpriteSheets) { 13 | sprites[id] = {}; 14 | const zooms = upgradedSpriteSheets[id]; 15 | for (const zoom in zooms) { 16 | sprites[id][zoom] = upgradedSpriteSheets[id][zoom]; 17 | } 18 | } 19 | 20 | const upgradedAssets = this.UpgradeAssets(data); 21 | for (const id in upgradedAssets) { 22 | sprites[id] = {}; 23 | const zooms = upgradedAssets[id]; 24 | for (const zoom in zooms) { 25 | sprites[id][zoom] = upgradedAssets[id][zoom]; 26 | } 27 | } 28 | v11.sprites = sprites; 29 | 30 | delete (v11 as any).assets; 31 | delete (v11 as any).skillSprites; 32 | 33 | return v11; 34 | } 35 | 36 | private UpgradeSpriteSheets(data: ISkillTreeV10): { [id: string]: { [zoomLevel: string]: ISpriteSheetV11 } } { 37 | const filesizes: { [filenameAndZoomLevel: string]: { w: number, h: number } } = {}; 38 | for (const id in data.skillSprites) { 39 | const spriteSheets = data.skillSprites[id]; 40 | for (const i in data.imageZoomLevels) { 41 | const zoom = data.imageZoomLevels[i].toString(); 42 | const spriteSheet = spriteSheets[i]; 43 | if (spriteSheet === undefined) 44 | continue; 45 | const current = filesizes[`${spriteSheet.filename}-${zoom}`] || { w: 0, h: 0 }; 46 | filesizes[`${spriteSheet.filename}-${zoom}`] = this.CalculateWidthAndHeight(current, spriteSheet); 47 | } 48 | } 49 | 50 | const sprites: { [id: string]: { [zoomLevel: string]: ISpriteSheetV11 } } = {}; 51 | for (const id in data.skillSprites) { 52 | sprites[id] = {}; 53 | const spriteSheets = data.skillSprites[id]; 54 | for (const i in data.imageZoomLevels) { 55 | const zoom = data.imageZoomLevels[i].toString(); 56 | const spriteSheet = spriteSheets[i]; 57 | if (spriteSheet === undefined) 58 | continue; 59 | sprites[id][zoom] = this.UpgradeSpriteSheet(spriteSheet, filesizes[`${spriteSheet.filename}-${zoom}`]); 60 | } 61 | } 62 | return sprites; 63 | } 64 | 65 | private UpgradeSpriteSheet(spriteSheet: ISpriteSheetV2, dimensions: { w: number, h: number }): ISpriteSheetV11 { 66 | const v11 = spriteSheet as ISpriteSheetV11; 67 | v11.w = dimensions.w; 68 | v11.h = dimensions.h; 69 | return v11; 70 | } 71 | 72 | private CalculateWidthAndHeight(initial: { w: number, h: number }, spriteSheet: ISpriteSheetV2): { w: number, h: number } { 73 | let width = initial.w; 74 | let height = initial.h; 75 | 76 | for (const id in spriteSheet.coords) { 77 | const coord = spriteSheet.coords[id]; 78 | width = Math.max(width, coord.x + coord.w); 79 | height = Math.max(height, coord.y + coord.h); 80 | } 81 | 82 | return { w: width, h: height }; 83 | } 84 | 85 | private UpgradeAssets(data: ISkillTreeV10): { [id: string]: { [zoomLevel: string]: ISpriteSheetV11 } } { 86 | 87 | const sprites: { [id: string]: { [zoomLevel: string]: ISpriteSheetV11 } } = {}; 88 | for (const id in data.assets) { 89 | const key = this.MapAssetToGroup(id); 90 | if (key === null) continue; 91 | if (sprites[key] === undefined) sprites[key] = {}; 92 | for (const zoom in data.assets[id]) { 93 | if (sprites[key][zoom] === undefined) { 94 | sprites[key][zoom] = { 95 | filename: `LOAD_COORDS`, 96 | h: -1, 97 | w: -1, 98 | coords: {} 99 | } 100 | } 101 | sprites[key][zoom].coords[id] = { x: 0, y: 0, h: -1, w: -1 }; 102 | } 103 | } 104 | return sprites; 105 | } 106 | 107 | private MapAssetToGroup(asset: string): SpriteSheetKey | null { 108 | asset = asset.startsWith('PassiveSkillScreen') ? asset.replace('PassiveSkillScreen', '') : asset; 109 | 110 | if (asset === 'Background2' || asset === 'Background1') { 111 | return 'background'; 112 | } 113 | 114 | if (asset === 'PassiveMasteryConnectedButton') { 115 | return 'masteryActiveSelected'; 116 | } 117 | 118 | if (asset.startsWith('Classes')) { 119 | return 'ascendancyBackground'; 120 | } 121 | 122 | if (asset.startsWith('Ascendancy')) { 123 | return 'ascendancy'; 124 | } 125 | 126 | if (asset.startsWith('Background') || asset.startsWith('center') || asset === 'PSStartNodeBackgroundInactive') { 127 | return 'startNode'; 128 | } 129 | 130 | if (asset.startsWith('PSGroupBackground') || asset.startsWith('GroupBackground')) { 131 | return 'groupBackground'; 132 | } 133 | 134 | if (asset.indexOf('Frame') >= 0 || asset.startsWith('JewelSocketClusterAlt') || asset.startsWith('JewelSocketAlt')) { 135 | return 'frame'; 136 | } 137 | 138 | if (asset.startsWith('JewelSocket')) { 139 | return 'jewel'; 140 | } 141 | 142 | if (asset.startsWith('LineConnector') || asset.startsWith('Orbit') || asset.startsWith('PSLineDeco')) { 143 | return 'line'; 144 | } 145 | 146 | if (asset.indexOf('JewelCircle') >= 0) { 147 | return 'jewelRadius'; 148 | } 149 | 150 | if (asset === 'AtlasPassiveSkillScreenStart') { 151 | return 'startNode'; 152 | } 153 | 154 | if (asset === 'AtlasPassiveBackground') { 155 | return 'atlasBackground'; 156 | } 157 | 158 | if (asset === 'PSStartNodeBackgroundActive') { 159 | return null; 160 | } 161 | 162 | if (asset.startsWith('imgPSFade')) { 163 | return null; 164 | } 165 | 166 | if (asset.endsWith('Oil')) { 167 | return null; 168 | } 169 | 170 | throw new Error(`Unhandled Asset: ${asset}`); 171 | } 172 | 173 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV11Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.20.0 */ 2 | export class SkillTreeV11Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV11): boolean { 4 | for (const id in data.groups) { 5 | const group = data.groups[id] as any; 6 | if (group.background) { 7 | return false; 8 | } 9 | } 10 | return true; 11 | } 12 | 13 | Process(data: ISkillTreeV11): ISkillTreeV12 { 14 | const v12 = JSON.parse(JSON.stringify(data)) as ISkillTreeV12; 15 | 16 | const upgradedGroups = this.UpgradeGroups(data); 17 | v12.groups = upgradedGroups; 18 | 19 | delete (v12 as any).uiArtOptions 20 | return v12; 21 | } 22 | 23 | private UpgradeGroups(data: ISkillTreeV11): { [id: string]: IGroupV12 } { 24 | var groups: { [id: string]: IGroupV12 } = {}; 25 | for (const id in data.groups) { 26 | const group = data.groups[id]; 27 | const nodes = group.nodes || []; 28 | if (nodes.length === 0 || nodes.find(id => data.nodes[id].ascendancyName !== undefined) !== undefined) { 29 | groups[id] = this.CopyGroup(group); 30 | continue; 31 | } 32 | 33 | let orbits = group.orbits || []; 34 | orbits = orbits.filter(x => x <= 3); 35 | const max = group.backgroundOverride !== undefined && group.backgroundOverride !== 0 ? group.backgroundOverride : Math.max(...orbits); 36 | if (max <= 0 || max > 3) { 37 | groups[id] = this.CopyGroup(group); 38 | continue; 39 | } 40 | 41 | groups[id] = this.UpgradeGroup(group, max, (data.uiArtOptions == undefined) ? true : data.uiArtOptions.largeGroupUsesHalfImage); 42 | } 43 | return groups 44 | } 45 | 46 | private CopyGroup(group: IGroupV10): IGroupV12 { 47 | return { 48 | x: group.x, 49 | y: group.y, 50 | isProxy: group.isProxy, 51 | orbits: group.orbits, 52 | nodes: group.nodes, 53 | background: undefined 54 | } 55 | } 56 | 57 | private UpgradeGroup(group: IGroupV10, max: number, largeGroupUsesHalfImage: boolean | undefined): IGroupV12 { 58 | var v12 = this.CopyGroup(group); 59 | v12.background = { 60 | image: this.MapBackground(max), 61 | isHalfImage: (max === 3 && largeGroupUsesHalfImage) ? true : undefined, 62 | offsetX: undefined, 63 | offsetY: undefined 64 | } 65 | return v12; 66 | } 67 | 68 | private MapBackground(max: number): BackgroundKey { 69 | switch (max) { 70 | case 1: 71 | return "PSGroupBackground1"; 72 | case 2: 73 | return "PSGroupBackground2"; 74 | case 3: 75 | return "PSGroupBackground3"; 76 | default: 77 | throw new Error(`Unhandled BackgroundKey: ${max}`); 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV12Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.21.0 to 3.22.0 */ 2 | export class SkillTreeV12Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV12): boolean { 4 | return data.tree === "Atlas" && data.sprites["wormholeInactive"] === undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV12): ISkillTreeV13 { 8 | const v13 = JSON.parse(JSON.stringify(data)) as ISkillTreeV13; 9 | // nothing to do since "isWormhole is already undefined 10 | return v13; 11 | } 12 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV13Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.22.0 to 3.23.0 */ 2 | export class SkillTreeV13Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV13): boolean { 4 | return data.sprites["tattooActiveEffect"] === undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV13): ISkillTreeV14 { 8 | const v13 = JSON.parse(JSON.stringify(data)) as ISkillTreeV14; 9 | return v13; 10 | } 11 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV14Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.23.0 to current */ 2 | export class SkillTreeV14Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV14): boolean { 4 | return data.sprites["azmeri"] === undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV14): ISkillTreeV15 { 8 | const v13 = JSON.parse(JSON.stringify(data)) as ISkillTreeV15; 9 | return v13; 10 | } 11 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV1Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 0.9.6 to 0.9.11 */ 2 | export class SkillTreeV1Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV1): boolean { 4 | return data.root !== undefined 5 | && data.root.g !== undefined 6 | && Array.isArray(data.nodes) 7 | && Object.keys(data.skillSprites).length === 2 8 | && data.skillSprites["active"] !== undefined 9 | && data.skillSprites["inactive"] !== undefined 10 | } 11 | 12 | Process(data: ISkillTreeV1): ISkillTreeV2 { 13 | var v2 = JSON.parse(JSON.stringify(data)) as ISkillTreeV2; 14 | 15 | for (const i in data.skillSprites) { 16 | const sprites = data.skillSprites[i]; 17 | if (!(i === "active" || i === "inactive")) 18 | continue; 19 | 20 | const key = i.charAt(0).toUpperCase() + i.slice(1); 21 | const sheets: { [id: string]: ISpriteSheetV2[] } = {}; 22 | sheets[`notable${key}`] = []; 23 | sheets[`keystone${key}`] = []; 24 | sheets[`normal${key}`] = []; 25 | 26 | for (const sheet of sprites) { 27 | const notableCoords = sheet.notableCoords === undefined ? sheet.coords : sheet.notableCoords; 28 | const keystoneCoords = sheet.notableCoords === undefined ? sheet.coords : sheet.notableCoords; 29 | const normalCoords = sheet.coords; 30 | 31 | sheets[`notable${key}`].push({ filename: sheet.filename, coords: notableCoords }); 32 | sheets[`keystone${key}`].push({ filename: sheet.filename, coords: keystoneCoords }); 33 | sheets[`normal${key}`].push({ filename: sheet.filename, coords: normalCoords }); 34 | } 35 | 36 | for (const j in sheets) { 37 | v2.skillSprites[j] = sheets[j]; 38 | } 39 | } 40 | 41 | return v2; 42 | } 43 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV2Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 0.9.12 to 2.1.0 */ 2 | export class SkillTreeV2Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV2): boolean { 4 | const init = data.root !== undefined 5 | && data.root.g !== undefined 6 | && Array.isArray(data.nodes) 7 | && Object.keys(data.skillSprites).length >= 6 8 | if (!init) { 9 | return false; 10 | } 11 | 12 | for (var id in data.nodes) { 13 | const v3 = (data.nodes[id] as ISkillNodeV3); 14 | if (v3.ascendancyName !== undefined && v3.ascendancyName !== '') { 15 | return false; 16 | } 17 | } 18 | 19 | return true; 20 | } 21 | 22 | Process(data: ISkillTreeV2): ISkillTreeV3 { 23 | var v3 = JSON.parse(JSON.stringify(data)) as ISkillTreeV3; 24 | 25 | var nodes: ISkillNodeV3[] = []; 26 | for (const node of data.nodes) { 27 | nodes.push(this.UpgradeNode(node)) 28 | } 29 | v3.nodes = nodes; 30 | 31 | return v3; 32 | } 33 | 34 | private UpgradeNode(node: ISkillNodeV1): ISkillNodeV3 { 35 | var v3 = node as ISkillNodeV3; 36 | v3.isJewelSocket = false; 37 | v3.isMultipleChoice = false; 38 | v3.isMultipleChoiceOption = false; 39 | v3.passivePointsGranted = 0; 40 | v3.ascendancyName = ""; 41 | v3.isAscendancyStart = false; 42 | v3.flavourText = []; 43 | v3.reminderText = []; 44 | return v3; 45 | } 46 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV3Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 2.2.0 to 2.4.0 */ 2 | export class SkillTreeV3Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV3): boolean { 4 | return (data as ISkillTreeV4).extraImages === undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV3): ISkillTreeV4 { 8 | var v4 = JSON.parse(JSON.stringify(data)) as ISkillTreeV4; 9 | 10 | v4.extraImages = {}; 11 | 12 | return v4; 13 | } 14 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV4Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 2.5.0 to 3.1.0 */ 2 | export class SkillTreeV4Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV4): boolean { 4 | return Array.isArray(data.nodes); 5 | } 6 | 7 | Process(data: ISkillTreeV4): ISkillTreeV5 { 8 | var v5 = JSON.parse(JSON.stringify(data)) as ISkillTreeV5; 9 | 10 | const nodes: { [id: string]: ISkillNodeV5 } = {}; 11 | for (const node of data.nodes) { 12 | nodes[node.id.toString()] = this.UpgradeNode(node); 13 | } 14 | v5.nodes = nodes; 15 | 16 | return v5; 17 | } 18 | 19 | private UpgradeNode(node: ISkillNodeV3): ISkillNodeV5 { 20 | var v5 = node as ISkillNodeV5; 21 | if (v5.out === undefined) 22 | v5.out = []; 23 | if (v5.in === undefined) 24 | v5.in = []; 25 | return v5; 26 | } 27 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV5Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.2.0 to 3.7.0 */ 2 | export class SkillTreeV5Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV5): boolean { 4 | for (var id in data.nodes) { 5 | if ((data.nodes[id] as ISkillNodeV6).isBlighted === true) { 6 | return false; 7 | } 8 | } 9 | 10 | return true; 11 | } 12 | 13 | Process(data: ISkillTreeV5): ISkillTreeV6 { 14 | var v6 = JSON.parse(JSON.stringify(data)) as ISkillTreeV6; 15 | 16 | const nodes: { [id: string]: ISkillNodeV6 } = {}; 17 | for (const id in data.nodes) { 18 | nodes[id.toString()] = this.UpgradeNode(data.nodes[id]); 19 | } 20 | v6.nodes = nodes; 21 | 22 | return v6; 23 | } 24 | 25 | private UpgradeNode(node: ISkillNodeV5): ISkillNodeV6 { 26 | var v6 = node as ISkillNodeV6; 27 | v6.isBlighted = false; 28 | return v6; 29 | } 30 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV6Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.8.0 to 3.9.0 */ 2 | export class SkillTreeV6Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV6): boolean { 4 | return data.root !== undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV6): ISkillTreeV7 { 8 | var v7: ISkillTreeV7 = { 9 | assets: data.assets || {}, 10 | classes: [], 11 | constants: data.constants || {}, 12 | extraImages: data.extraImages || {}, 13 | groups: {}, 14 | imageZoomLevels: data.imageZoomLevels || [], 15 | jewelSlots: [], 16 | max_x: data.max_x, 17 | max_y: data.max_y, 18 | min_x: data.min_x, 19 | min_y: data.min_y, 20 | nodes: {}, 21 | skillSprites: data.skillSprites || {} 22 | }; 23 | 24 | for (const id in data.characterData) { 25 | const character = data.characterData[id]; 26 | const name = this.ClassIdToName(+id); 27 | if (name === null) continue; 28 | v7.classes[+id] = { 29 | ascendancies: [], 30 | base_dex: character.base_dex, 31 | base_int: character.base_int, 32 | base_str: character.base_str, 33 | name: name 34 | }; 35 | } 36 | 37 | const nodes: { [id: string]: ISkillNodeV7 } = {}; 38 | for (const id in data.nodes) { 39 | nodes[id.toString()] = this.UpgradeNode(data.nodes[id]); 40 | } 41 | nodes["root"] = this.UpgradeNode(data.root as ISkillNodeV6); 42 | v7.nodes = nodes; 43 | 44 | const groups: { [id: string]: IGroupV7 } = {}; 45 | for (const id in data.groups) { 46 | groups[id.toString()] = this.UpgradeGroup(data.groups[id]); 47 | } 48 | v7.groups = groups; 49 | 50 | return v7; 51 | } 52 | 53 | private UpgradeNode(node: ISkillNodeV6): ISkillNodeV7 { 54 | return { 55 | ascendancyName: node.ascendancyName || "", 56 | classStartIndex: (node.spc && node.spc.length > 0) ? node.spc[0] : undefined, 57 | expansionJewel: undefined, 58 | flavourText: node.flavourText || [], 59 | grantedDexterity: node.da || 0, 60 | grantedIntelligence: node.ia || 0, 61 | grantedPassivePoints: node.passivePointsGranted || 0, 62 | grantedStrength: node.sa || 0, 63 | group: node.g, 64 | icon: node.icon, 65 | in: (node.in || []).map(x => x.toString()) || [], 66 | isAscendancyStart: node.isAscendancyStart || false, 67 | isBlighted: node.isBlighted || false, 68 | isJewelSocket: node.isJewelSocket || false, 69 | isKeystone: node.ks || false, 70 | isMastery: node.m || false, 71 | isMultipleChoice: node.isMultipleChoice || false, 72 | isMultipleChoiceOption: node.isMultipleChoiceOption || false, 73 | isNotable: node.not || false, 74 | isProxy: false, 75 | name: node.dn || "", 76 | orbit: node.o || 0, 77 | orbitIndex: node.oidx || 0, 78 | out: (node.out || []).map(x => x.toString()) || [], 79 | recipe: [], 80 | reminderText: node.reminderText || [], 81 | skill: +node.id || -1, 82 | stats: node.sd || [] 83 | }; 84 | } 85 | 86 | private UpgradeGroup(group: IGroupV1): IGroupV7 { 87 | var orbits: number[] = []; 88 | if (Array.isArray(group.oo)) { 89 | group.oo = { "0": group.oo[0] }; 90 | } 91 | for (const id in group.oo) { 92 | orbits.push(+id); 93 | } 94 | 95 | return { 96 | isProxy: false, 97 | nodes: (group.n || []).map(n => n.toString()), 98 | orbits: orbits, 99 | x: group.x, 100 | y: group.y 101 | } 102 | } 103 | 104 | private ClassIdToName(id: number): string | null { 105 | switch (id) { 106 | case 0: return "Scion"; 107 | case 1: return "Marauder"; 108 | case 2: return "Ranger"; 109 | case 3: return "Witch"; 110 | case 4: return "Duelist"; 111 | case 5: return "Templar"; 112 | case 6: return "Shadow"; 113 | default: return null; 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV7Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.10.0 to 3.14.0 */ 2 | export class SkillTreeV7Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV7): boolean { 4 | return (data as ISkillTreeV8).tree === undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV7): ISkillTreeV8 { 8 | var v8 = data as ISkillTreeV8; 9 | v8.tree = "Default"; 10 | return v8; 11 | } 12 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV8Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.15.0 */ 2 | export class SkillTreeV8Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV8): boolean { 4 | for (var id in data.nodes) { 5 | if ((data.nodes[id] as ISkillNodeV9).activeEffectImage !== undefined) { 6 | return false; 7 | } 8 | } 9 | 10 | return true; 11 | } 12 | 13 | Process(data: ISkillTreeV8): ISkillTreeV9 { 14 | var v9 = data as ISkillTreeV9; 15 | 16 | const nodes: { [id: string]: ISkillNodeV9 } = {}; 17 | for (const id in data.nodes) { 18 | nodes[id.toString()] = this.UpgradeNode(data.nodes[id]); 19 | } 20 | v9.nodes = nodes; 21 | 22 | return v9; 23 | } 24 | 25 | private UpgradeNode(node: ISkillNodeV7): ISkillNodeV9 { 26 | var v9 = node as ISkillNodeV9 27 | v9.activeEffectImage = undefined; 28 | v9.activeIcon = undefined; 29 | v9.inactiveIcon = undefined; 30 | v9.masteryEffects = undefined; 31 | return v9 32 | } 33 | } -------------------------------------------------------------------------------- /models/skill-tree/preprocessors/SkillTreeV9Preprocessor.ts: -------------------------------------------------------------------------------- 1 | /** 3.16.0 to 3.18.0 */ 2 | export class SkillTreeV9Preprocessor implements ISkillTreePreprocessor { 3 | CanProcess(data: ISkillTreeV9): boolean { 4 | return (data as ISkillTreeV10).points === undefined; 5 | } 6 | 7 | Process(data: ISkillTreeV9): ISkillTreeV10 { 8 | var v10 = data as ISkillTreeV10; 9 | 10 | v10.points = { totalPoints: 121, ascendancyPoints: 8 }; 11 | 12 | return v10; 13 | } 14 | } -------------------------------------------------------------------------------- /models/spatial-hash/SpatialHash.ts: -------------------------------------------------------------------------------- 1 | export class SpatialHash { 2 | private _cells: (Node | null)[][]; 3 | private _bounds: number[][]; 4 | private _dimensions: number[]; 5 | private _queryIds: number; 6 | 7 | constructor(bounds: number[][], dimensions: number[]) { 8 | const [x, y] = dimensions; 9 | this._cells = [...Array(x)].map(_ => [...Array(y)].map(_ => (null))); 10 | this._dimensions = dimensions; 11 | this._bounds = bounds; 12 | this._queryIds = 0; 13 | } 14 | 15 | private getCellIndex = (position: IPoint): number[] => { 16 | const x = this.sat((position.x - this._bounds[0][0]) / (this._bounds[1][0] - this._bounds[0][0])); 17 | const y = this.sat((position.y - this._bounds[0][1]) / (this._bounds[1][1] - this._bounds[0][1])); 18 | 19 | const xIndex = Math.floor(x * (this._dimensions[0] - 1)); 20 | const yIndex = Math.floor(y * (this._dimensions[1] - 1)); 21 | 22 | return [xIndex, yIndex]; 23 | } 24 | 25 | public add = (id: string, position: IPoint, dimensions: { width: number, height: number }) => { 26 | const client: Client = { 27 | id: id, 28 | position: position, 29 | dimensions: dimensions, 30 | _cells: { 31 | min: null, 32 | max: null, 33 | nodes: null, 34 | }, 35 | _queryId: -1, 36 | }; 37 | 38 | const x = client.position.x; 39 | const y = client.position.y; 40 | const w = client.dimensions.width; 41 | const h = client.dimensions.height; 42 | 43 | const i1 = this.getCellIndex({ x: x - w / 2, y: y - h / 2 }); 44 | const i2 = this.getCellIndex({ x: x + w / 2, y: y + h / 2 }); 45 | 46 | const nodes = new Array>(); 47 | 48 | for (let x = i1[0], xn = i2[0]; x <= xn; ++x) { 49 | nodes.push([]); 50 | 51 | for (let y = i1[1], yn = i2[1]; y <= yn; ++y) { 52 | const xi = x - i1[0]; 53 | 54 | const head: Node = { 55 | next: null, 56 | prev: null, 57 | client: client, 58 | }; 59 | 60 | nodes[xi].push(head); 61 | 62 | head.next = this._cells[x][y]; 63 | if (this._cells[x][y] !== null) { 64 | this._cells[x][y]!.prev = head; 65 | } 66 | 67 | this._cells[x][y] = head; 68 | } 69 | } 70 | 71 | client._cells.min = i1; 72 | client._cells.max = i2; 73 | client._cells.nodes = nodes; 74 | } 75 | 76 | public find = (position: IPoint, dimensions: { width: number, height: number }): string[] => { 77 | const x = position.x; 78 | const y = position.y; 79 | const w = dimensions.width; 80 | const h = dimensions.height; 81 | 82 | const i1 = this.getCellIndex({ x: x - w / 2, y: y - h / 2 }); 83 | const i2 = this.getCellIndex({ x: x + w / 2, y: y + h / 2 }); 84 | 85 | const clients = new Array(); 86 | const queryId = this._queryIds++; 87 | 88 | for (let x = i1[0], xn = i2[0]; x <= xn; ++x) { 89 | for (let y = i1[1], yn = i2[1]; y <= yn; ++y) { 90 | let head = this._cells[x][y]; 91 | 92 | while (head) { 93 | const v = head.client; 94 | head = head.next; 95 | 96 | if (v._queryId != queryId) { 97 | v._queryId = queryId; 98 | clients.push(v.id); 99 | } 100 | } 101 | } 102 | } 103 | return clients; 104 | } 105 | 106 | private sat = (x: number): number => { 107 | return Math.min(Math.max(x, 0.0), 1.0); 108 | } 109 | } 110 | 111 | type Client = { 112 | id: string; 113 | position: IPoint; 114 | dimensions: { 115 | width: number; 116 | height: number; 117 | }; 118 | _cells: { 119 | min: number[] | null; 120 | max: number[] | null; 121 | nodes: Node[][] | null; 122 | }; 123 | _queryId: number; 124 | } 125 | 126 | type Node = { 127 | next: Node | null; 128 | prev: Node | null; 129 | client: Client; 130 | } -------------------------------------------------------------------------------- /models/types/IAscendancyClasses.d.ts: -------------------------------------------------------------------------------- 1 | interface IAscendancyClasses extends IAscendancyClassesV7 { 2 | } 3 | -------------------------------------------------------------------------------- /models/types/ICharacter.d.ts: -------------------------------------------------------------------------------- 1 | interface ICharacter { 2 | /** Base Dexterity for the character */ 3 | base_dex: number; 4 | 5 | /** Base Intelligence for the character */ 6 | base_int: number; 7 | 8 | /** Base Strength for the character */ 9 | base_str: number; 10 | } -------------------------------------------------------------------------------- /models/types/IClassImage.d.ts: -------------------------------------------------------------------------------- 1 | interface IClassImage extends IClassImageV4 { 2 | } -------------------------------------------------------------------------------- /models/types/IConstants.d.ts: -------------------------------------------------------------------------------- 1 | interface IConstants { 2 | /** A map of classes by name to number (i.e. "StrClass": 1)*/ 3 | classes: { [id: string]: number }; 4 | 5 | /** A map of attributes by name to number (i.e. "Strength": 0) */ 6 | characterAttributes: { [id: string]: number }; 7 | 8 | /** SkillNode radius from center */ 9 | PSSCentreInnerRadius: number; 10 | 11 | /** The SkillNode.oidx property maps here */ 12 | skillsPerOrbit: Array; 13 | 14 | /** The SkillNode.o property maps here */ 15 | orbitRadii: Array; 16 | } -------------------------------------------------------------------------------- /models/types/IExpansionJewel.d.ts: -------------------------------------------------------------------------------- 1 | interface IExpansionJewel { 2 | /** The size of cluster jewel that the socket can fit (i.e. 2 = Large, 1 = Medium, 0 = Small) */ 3 | size: number; 4 | 5 | /** Index of the jewel socket */ 6 | index: number; 7 | 8 | /** The node id to the proxied node */ 9 | proxy: string; 10 | 11 | /** The parent node id which was proxied from */ 12 | parent: string | undefined; 13 | } -------------------------------------------------------------------------------- /models/types/IGroup.d.ts: -------------------------------------------------------------------------------- 1 | interface IGroup extends IGroupV12 { 2 | } -------------------------------------------------------------------------------- /models/types/IMasteryEffect.d.ts: -------------------------------------------------------------------------------- 1 | interface IMasteryEffect { 2 | /** Id of the Mastery Effect */ 3 | effect: number 4 | 5 | /** The stat descriptions of the SkillNode */ 6 | stats: Array; 7 | } -------------------------------------------------------------------------------- /models/types/IPoint.d.ts: -------------------------------------------------------------------------------- 1 | interface IPoint { 2 | x: number; 3 | y: number; 4 | } -------------------------------------------------------------------------------- /models/types/IPoints.d.ts: -------------------------------------------------------------------------------- 1 | interface IPoints { 2 | totalPoints: number; 3 | ascendancyPoints: number; 4 | } -------------------------------------------------------------------------------- /models/types/ISkillNode.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNode extends ISkillNodeV13 { 2 | id?: string | undefined; 3 | } -------------------------------------------------------------------------------- /models/types/ISkillTreeCodec.d.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeData } from "./ISkillTreeData"; 2 | 3 | interface ISkillTreeCodec { 4 | encodeURL(skillTreeData: ISkillTreeData): string; 5 | decodeURL(encoding: string, skillTreeData: ISkillTreeData): SkillTreeDefinition; 6 | } 7 | 8 | type SkillTreeDefinition = { 9 | Version: number; 10 | Class: number; 11 | Ascendancy: number; 12 | WildwoodAscendancy: number; 13 | Nodes: Array; 14 | ExtendedNodes: Array; 15 | MasteryEffects: Array<[node: ISkillNode, effect: number]>; 16 | } -------------------------------------------------------------------------------- /models/types/ISkillTreeData.d.ts: -------------------------------------------------------------------------------- 1 | import { SemVer } from "semver"; 2 | 3 | interface ISkillTreeData extends ISkillTreeV15 { 4 | patch: SemVer; 5 | version: number; 6 | masteryEffects: { [id: number]: number } 7 | 8 | getStartClass(): number; 9 | getAscendancyClass(): number; 10 | getWildwoodAscendancyClass(): number; 11 | getSkilledNodes(): { [id: string]: ISkillNode }; 12 | getHoveredNodes(): { [id: string]: ISkillNode }; 13 | } -------------------------------------------------------------------------------- /models/types/ISkillTreeOptions.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeOptions { 2 | ascClasses: { [id: string]: IAscendancyClasses }; 3 | zoomLevels: Array; 4 | height: number; 5 | startClass: number; 6 | fullScreen: boolean; 7 | version: string; 8 | build: {}; 9 | circles: { [id: string]: ICircleOption[] } | undefined 10 | } 11 | 12 | interface ICircleOption { 13 | level: number; 14 | width: number; 15 | } -------------------------------------------------------------------------------- /models/types/ISkillTreeRenderer.d.ts: -------------------------------------------------------------------------------- 1 | import { SkillNode } from "../SkillNode"; 2 | 3 | interface ISkillTreeRenderer { 4 | Initialized: boolean; 5 | Initialize(): Promise; 6 | 7 | RenderActive(): void; 8 | RenderBase(): void; 9 | RenderCharacterStartsActive(): void; 10 | RenderHighlight(): void; 11 | StartRenderHover(skillNode: SkillNode): void; 12 | StopRenderHover(skillNode: SkillNode): void; 13 | CreateScreenshot(mimeType: "image/jpeg" | "image/webp"): Promise; 14 | } -------------------------------------------------------------------------------- /models/types/ISpriteSheet.d.ts: -------------------------------------------------------------------------------- 1 | type SpriteSheetKey = SpriteSheetKeyV15; 2 | 3 | interface ISpriteSheet extends ISpriteSheetV11 { 4 | } 5 | -------------------------------------------------------------------------------- /models/types/IVersions.d.ts: -------------------------------------------------------------------------------- 1 | interface IVersions { 2 | versions: Array; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/ISkillTreeBase.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeBase { 2 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/ISkillTreePreprocessor.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreePreprocessor { 2 | CanProcess(data: ISkillTreeBase, options: ISkillTreeOptionsBase | undefined): boolean; 3 | Process(data: ISkillTreeBase, options: ISkillTreeOptionsBase | undefined): ISkillTreeBase; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/ICharacterV1.d.ts: -------------------------------------------------------------------------------- 1 | interface ICharacterV1 { 2 | /** Base Dexterity for the character */ 3 | base_dex: number; 4 | 5 | /** Base Intelligence for the character */ 6 | base_int: number; 7 | 8 | /** Base Strength for the character */ 9 | base_str: number; 10 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/IConstantsV1.d.ts: -------------------------------------------------------------------------------- 1 | interface IConstantsV1 { 2 | /** A map of classes by name to number (i.e. "StrClass": 1) */ 3 | classes: { [id: string]: number }; 4 | 5 | /** A map of attributes by name to number (i.e. "Strength": 0) */ 6 | characterAttributes: { [id: string]: number }; 7 | 8 | /** SkillNode radius from center */ 9 | PSSCentreInnerRadius: number; 10 | 11 | /** The SkillNode.oidx property maps here */ 12 | skillsPerOrbit: Array; 13 | 14 | /** The SkillNode.o property maps here */ 15 | orbitRadii: Array; 16 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/IGroupV1.d.ts: -------------------------------------------------------------------------------- 1 | interface IGroupV1 { 2 | /** x-coordinate of the group */ 3 | x: number; 4 | 5 | /** y-coordinate of the group */ 6 | y: number; 7 | 8 | /** The Orbitals (i.e. SkillNode.oidx) associated with the nodes attached to the group */ 9 | oo: Array | { [id: string]: boolean }; 10 | 11 | /** A list of SkillNodes by Id */ 12 | n: Array; 13 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/IRootNodeV1.d.ts: -------------------------------------------------------------------------------- 1 | interface IRootNodeV1 { 2 | /** The group id of the SkillNode */ 3 | g: number; 4 | 5 | /** The Orbit Radii of the SkillNode 6 | * @see Constants.orbitRadii 7 | */ 8 | o: number; 9 | 10 | /** The index on the Orbit 11 | * @see Constants.skillsPerOrbit 12 | */ 13 | oidx: number; 14 | 15 | /** The amount of Dex the SkillNode gives */ 16 | da: number; 17 | 18 | /** The amount of Int the SkillNode gives */ 19 | ia: number; 20 | 21 | /** The amount of Strength the SkillNode gives */ 22 | sa: number; 23 | 24 | /** The conections from this SkillNode*/ 25 | out: Array; 26 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/ISkillNodeV1.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNodeV1 extends IRootNodeV1 { 2 | /** Id of the SkillNode */ 3 | id: number; 4 | 5 | /** Name of the SkillNode */ 6 | dn: string; 7 | 8 | /** Icon of the SkillNode (i.e. "Art/2DArt/SkillIcons/passives/Champion/AnEFortify.png") */ 9 | icon: string; 10 | 11 | /** Determines if the SkillNode is a Keystone */ 12 | ks: boolean | undefined; 13 | 14 | /** Determines if the SkillNode is a Notable */ 15 | not: boolean | undefined; 16 | 17 | /** Determines if the SkillNode is a Mastery */ 18 | m: boolean | undefined; 19 | 20 | /** Detemines the root classes of the SkillNode */ 21 | spc: Array | undefined; 22 | 23 | /** The stat descriptions of the SkillNode */ 24 | sd: Array; 25 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/ISkillTreeV1.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV1 extends ISkillTreeBase { 2 | characterData: { [id: string]: ICharacterV1 }; 3 | groups: { [id: string]: IGroupV1 }; 4 | root: IRootNodeV1; 5 | nodes: Array; 6 | min_x: number; 7 | min_y: number; 8 | max_x: number; 9 | max_y: number; 10 | assets: { [id: string]: { [zoomLevel: string]: string } }; 11 | constants: IConstantsV1; 12 | skillSprites: { [id: string]: Array }; 13 | imageZoomLevels: Array; 14 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/ISpriteSheetV1.d.ts: -------------------------------------------------------------------------------- 1 | interface ISpriteSheetV1 { 2 | filename: string; 3 | coords: { [id: string]: ISpriteV1 }; 4 | notableCoords: { [id: string]: ISpriteV1 } | undefined; 5 | keystoneCoords: { [id: string]: ISpriteV1 } | undefined; 6 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v01/ISpriteV1.d.ts: -------------------------------------------------------------------------------- 1 | interface ISpriteV1 { 2 | x: number; 3 | y: number; 4 | w: number; 5 | h: number; 6 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v02/ISkillTreeV2.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV2 extends Omit { 2 | skillSprites: { [id: string]: Array }; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v02/ISpriteSheetV2.d.ts: -------------------------------------------------------------------------------- 1 | interface ISpriteSheetV2 extends Omit { 2 | filename: string; 3 | coords: { [id: string]: ISpriteV1 }; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v03/ISkillNodeV3.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNodeV3 extends ISkillNodeV1 { 2 | /** Determines if the SkillNode is a Jewel Socket */ 3 | isJewelSocket: boolean; 4 | 5 | /** Determines if the SkillNode is Multiple Choice */ 6 | isMultipleChoice: boolean | undefined; 7 | 8 | /** Options of a Multiple Choice node */ 9 | isMultipleChoiceOption: boolean | undefined; 10 | 11 | /** Determines the number of passive points received when this SkillNode is skilled */ 12 | passivePointsGranted: number | undefined; 13 | 14 | /** The name of the Ascendancy Class the SkillNode belongs to */ 15 | ascendancyName: string | undefined; 16 | 17 | /** Determines if the SkillNode is the root of an Ascendancy Class */ 18 | isAscendancyStart: boolean | undefined; 19 | 20 | /** Node flavour text (similar to the flavour text on uniques, appears in the unique border color in game) */ 21 | flavourText: Array | undefined; 22 | 23 | /** Additional information on mechanics or the node itself (appears grey in game) */ 24 | reminderText: Array | undefined; 25 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v03/ISkillTreeV3.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV3 extends ISkillTreeV2 { 2 | nodes: Array; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v04/IClassImageV4.d.ts: -------------------------------------------------------------------------------- 1 | interface IClassImageV4 { 2 | /** x-coordinate where the image should be drawn */ 3 | x: number; 4 | 5 | /** y-coordinate where the image should be drawn */ 6 | y: number; 7 | 8 | /** Image path */ 9 | image: string; 10 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v04/ISkillTreeV4.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV4 extends ISkillTreeV3 { 2 | extraImages: { [id: string]: IClassImageV4 }; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v05/IRootNodeV5.d.ts: -------------------------------------------------------------------------------- 1 | interface IRootNodeV5 extends IRootNodeV1 { 2 | /** The connections to this SkillNode */ 3 | in: Array; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v05/ISkillNodeV5.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNodeV5 extends ISkillNodeV3, IRootNodeV5 { 2 | 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v05/ISkillTreeV5.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV5 extends Omit { 2 | root: IRootNodeV5; 3 | nodes: { [id: string]: ISkillNodeV5 }; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v06/ISkillNodeV6.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNodeV6 extends ISkillNodeV5 { 2 | /** Determines if the SkillNode is a Blighted Notable */ 3 | isBlighted: boolean; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v06/ISkillTreeV6.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV6 extends ISkillTreeV5 { 2 | nodes: { [id: string]: ISkillNodeV6 }; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v07/IAscendancyClassV7.d.ts: -------------------------------------------------------------------------------- 1 | interface IAscendancyClassV7 extends Omit { 2 | flavourTextRect: ISkillTreeRectV7; 3 | id: string; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v07/IAscendancyClassesV7.d.ts: -------------------------------------------------------------------------------- 1 | interface IAscendancyClassesV7 extends Omit { 2 | ascendancies: Array; 3 | base_dex: number; 4 | base_int: number; 5 | base_str: number; 6 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v07/IExpansionJewelV7.d.ts: -------------------------------------------------------------------------------- 1 | interface IExpansionJewelV7 { 2 | /** Index of the jewel socket */ 3 | index: number; 4 | 5 | /** The parent node id which was proxied from */ 6 | parent: string | undefined; 7 | 8 | /** The node id to the proxied node */ 9 | proxy: string; 10 | 11 | /** The size of cluster jewel that the socket can fit (i.e. 2 = Large, 1 = Medium, 0 = Small) */ 12 | size: number; 13 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v07/IGroupV7.d.ts: -------------------------------------------------------------------------------- 1 | interface IGroupV7 extends Omit { 2 | /** Determines if the group is a proxy (cluster jewel) */ 3 | isProxy: boolean; 4 | 5 | /** The Orbitals (i.e. SkillNode.oidx) associated with the nodes attached to the group */ 6 | orbits: Array; 7 | 8 | /** A list of SkillNodes by Id */ 9 | nodes: Array; 10 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v07/ISkillNodeV7.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNodeV7 extends Omit { 2 | /** Determines the root classes of the SkillNode */ 3 | classStartIndex: number | undefined; 4 | 5 | /** Expansion Jewel properties of a Jewel Socket */ 6 | expansionJewel: IExpansionJewelV7 | undefined; 7 | 8 | /** The amount of Dex the SkillNode gives */ 9 | grantedDexterity: number | undefined; 10 | 11 | /** The amount of Int the SkillNode gives */ 12 | grantedIntelligence: number | undefined; 13 | 14 | /** Determines the number of passive points received when this SkillNode is skilled */ 15 | grantedPassivePoints: number | undefined; 16 | 17 | /** The amount of Strength the SkillNode gives */ 18 | grantedStrength: number | undefined; 19 | 20 | /** The group id of the SkillNode */ 21 | group: number | undefined; 22 | 23 | /** Id of the SkillNode */ 24 | skill: number; 25 | 26 | /** The connections to this SkillNode */ 27 | in: Array; 28 | 29 | /** Determines if the SkillNode is a Keystone */ 30 | isKeystone: boolean | undefined; 31 | 32 | /** Determines if the SkillNode is a Mastery */ 33 | isMastery: boolean | undefined; 34 | 35 | /** Determines if the SkillNode is a Notable */ 36 | isNotable: boolean | undefined; 37 | 38 | /** Determines if the SkillNode is a proxy (cluster jewel) */ 39 | isProxy: boolean | undefined; 40 | 41 | /** Name of the SkillNode */ 42 | name: string; 43 | 44 | /** The Orbit Radii of the SkillNode 45 | * @see Constants.orbitRadii 46 | */ 47 | orbit: number; 48 | 49 | /** The index on the Orbit 50 | * @see Constants.skillsPerOrbit 51 | */ 52 | orbitIndex: number; 53 | 54 | /** The connections from this SkillNode */ 55 | out: Array; 56 | 57 | /** The Blight Oil Recipe for the node */ 58 | recipe: Array | undefined; 59 | 60 | /** The stat descriptions of the SkillNode */ 61 | stats: Array; 62 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v07/ISkillTreeRectV7.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeRectV7 { 2 | x: number; 3 | y: number; 4 | width: number; 5 | height: number; 6 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v07/ISkillTreeV7.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV7 extends Omit { 2 | classes: Array; 3 | groups: { [id: string]: IGroupV7 }; 4 | nodes: { [id: string]: ISkillNodeV7 }; 5 | jewelSlots: Array; 6 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v08/ISkillTreeV8.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV8 extends ISkillTreeV7 { 2 | tree: "Default" | "Royale"; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v09/ISkillNodeV9.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNodeV9 extends ISkillNodeV7 { 2 | /** Active Icon Effect of the SkillNode (i.e. "Art/2DArt/SkillIcons/passives/Champion/AnEFortify.png") */ 3 | activeEffectImage: string | undefined; 4 | 5 | /** Active Icon of the SkillNode (i.e. "Art/2DArt/SkillIcons/passives/Champion/AnEFortify.png") */ 6 | activeIcon: string | undefined; 7 | 8 | /** Inactive Icon of the SkillNode (i.e. "Art/2DArt/SkillIcons/passives/Champion/AnEFortify.png") */ 9 | inactiveIcon: string | undefined; 10 | 11 | /** Mastery Effects of the SkillNode */ 12 | masteryEffects: IMasteryEffect[] | undefined; 13 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v09/ISkillTreeV9.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV9 extends ISkillTreeV8 { 2 | nodes: { [id: string]: ISkillNodeV9 }; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v10/IGroupV10.d.ts: -------------------------------------------------------------------------------- 1 | interface IGroupV10 extends IGroupV7 { 2 | /** Determines what background to use for the group */ 3 | backgroundOverride: number | undefined; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v10/IPointsV10.d.ts: -------------------------------------------------------------------------------- 1 | interface IPointsV10 { 2 | totalPoints: number; 3 | ascendancyPoints: number; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v10/ISkillTreeV10.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV10 extends Omit { 2 | classes: Array | undefined; 3 | groups: { [id: string]: IGroupV10 }; 4 | tree: "Default" | "Royale" | "Atlas"; 5 | uiArtOptions: IUIArtOptionsV10 | undefined; 6 | points: IPoints | undefined; 7 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v10/IUIArtOptionsV10.d.ts: -------------------------------------------------------------------------------- 1 | interface IUIArtOptionsV10 { 2 | largeGroupUsesHalfImage: boolean; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v11/ISkillTreeV11.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV11 extends Omit { 2 | sprites: { [id: string]: { [zoomLevel: string]: ISpriteSheetV11 } }; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v11/ISpriteSheetKeyV11.d.ts: -------------------------------------------------------------------------------- 1 | type SpriteSheetKeyV11 = 2 | "background" 3 | | "atlasBackground" 4 | | "normalActive" 5 | | "notableActive" 6 | | "keystoneActive" 7 | | "normalInactive" 8 | | "notableInactive" 9 | | "keystoneInactive" 10 | | "mastery" 11 | | "masteryConnected" 12 | | "masteryActiveSelected" 13 | | "masteryInactive" 14 | | "masteryActiveEffect" 15 | | "masteryOverlay" 16 | | "ascendancyBackground" 17 | | "ascendancy" 18 | | "startNode" 19 | | "groupBackground" 20 | | "frame" 21 | | "jewel" 22 | | "line" 23 | | "jewelRadius"; -------------------------------------------------------------------------------- /models/types/skill-tree-json/v11/ISpriteSheetV11.d.ts: -------------------------------------------------------------------------------- 1 | interface ISpriteSheetV11 extends ISpriteSheetV2 { 2 | w: number; 3 | h: number; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v12/IGroupBackgroundV12.d.ts: -------------------------------------------------------------------------------- 1 | type BackgroundKey = 2 | 'PSGroupBackground1' 3 | | 'PSGroupBackground2' 4 | | 'PSGroupBackground3' 5 | | 'PSGroupBackground1Alt' 6 | | 'PSGroupBackground2Alt' 7 | | 'PSGroupBackground3Alt' 8 | | 'GroupBackgroundCleansingFire' 9 | | 'GroupBackgroundTangle'; 10 | 11 | interface IGroupBackgroundV12 { 12 | image: BackgroundKey; 13 | isHalfImage: boolean | undefined; 14 | offsetX: number | undefined; 15 | offsetY: number | undefined; 16 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v12/IGroupV12.d.ts: -------------------------------------------------------------------------------- 1 | interface IGroupV12 extends Omit { 2 | background: IGroupBackgroundV12 | undefined; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v12/ISkillTreeV12.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV12 extends Omit { 2 | groups: { [id: string]: IGroupV12 }; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v13/ISkillNodeV13.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillNodeV13 extends ISkillNodeV9 { 2 | /** Is the passive a wormhole to/from another skill tree (i.e. Mortal Gateway in Atlas and Ruthless) */ 3 | isWormhole: boolean | undefined; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v13/ISkillTreeV13.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV13 extends Omit { 2 | nodes: { [id: string]: ISkillNodeV13 }; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v13/ISpriteSheetKeyV13.d.ts: -------------------------------------------------------------------------------- 1 | type SpriteSheetKeyV13 = 2 | SpriteSheetKeyV11 3 | | "wormholeActive" 4 | | "wormholeInactive" 5 | | "tattooActiveEffect"; 6 | -------------------------------------------------------------------------------- /models/types/skill-tree-json/v14/ISpriteSheetKeyV14.d.ts: -------------------------------------------------------------------------------- 1 | type SpriteSheetKeyV14 = 2 | SpriteSheetKeyV13 3 | | "tattooActiveEffect"; 4 | -------------------------------------------------------------------------------- /models/types/skill-tree-json/v15/ISkillTreeV15.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeV15 extends ISkillTreeV13 { 2 | alternate_ascendancies: Array | undefined; 3 | } -------------------------------------------------------------------------------- /models/types/skill-tree-json/v15/ISpriteSheetKeyV15.d.ts: -------------------------------------------------------------------------------- 1 | type SpriteSheetKeyV15 = 2 | SpriteSheetKeyV14 3 | | "azmeri" 4 | | "azmeriBackground" 5 | | "charm"; 6 | -------------------------------------------------------------------------------- /models/types/skill-tree-options-json/ISkillTreeOptionsBase.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeOptionsBase { 2 | } -------------------------------------------------------------------------------- /models/types/skill-tree-options-json/ISkillTreeOptionsPreprocessor.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeOptionsPreprocessor { 2 | CanProcess(data: ISkillTreeOptionsBase): boolean; 3 | Process(data: ISkillTreeOptionsBase): ISkillTreeOptionsBase; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-options-json/v01/IAscendancyClassV1.d.ts: -------------------------------------------------------------------------------- 1 | interface IAscendancyClassV1 { 2 | displayName: string; 3 | flavourText: string; 4 | flavourTextColour: string; 5 | flavourTextRect: string; 6 | name: string; 7 | } -------------------------------------------------------------------------------- /models/types/skill-tree-options-json/v01/IAscendancyClassesV1.d.ts: -------------------------------------------------------------------------------- 1 | interface IAscendancyClassesV1 { 2 | classes: { [id: string]: IAscendancyClassV1 }; 3 | name: string; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-options-json/v01/ISkillTreeOptionsV1.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeOptionsV1 extends ISkillTreeOptionsBase { 2 | ascClasses: { [id: string]: IAscendancyClassesV1 }; 3 | build: any; 4 | fullscreen: boolean; 5 | height: number; 6 | startClass: number; 7 | version: string; 8 | zoomLevels: Array; 9 | } 10 | -------------------------------------------------------------------------------- /models/types/skill-tree-options-json/v02/ICircleOptionV2.d.ts: -------------------------------------------------------------------------------- 1 | interface ICircleOptionV2 { 2 | level: number; 3 | width: number; 4 | } -------------------------------------------------------------------------------- /models/types/skill-tree-options-json/v02/ISkillTreeOptionsV2.d.ts: -------------------------------------------------------------------------------- 1 | interface ISkillTreeOptionsV2 extends ISkillTreeOptionsV1 { 2 | realm: string; 3 | circles: { [id: string]: ICircleOptionV2[] } 4 | } 5 | -------------------------------------------------------------------------------- /models/url-processing/ISkillTreeUrlData.ts: -------------------------------------------------------------------------------- 1 | export interface ISkillTreeUrlData { 2 | version: number 3 | class: number 4 | ascendancy: number 5 | wildwoodAscendancy: number 6 | nodeCount: number 7 | nodes: Array 8 | extendedNodeCount: number 9 | extendedNodes: Array 10 | masteryEffectCount: number 11 | masteryEffects: Array<[id: number, effect: number]> 12 | } -------------------------------------------------------------------------------- /models/url-processing/SkillTreeCodec.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeCodec, SkillTreeDefinition } from "../types/ISkillTreeCodec"; 2 | import { ISkillTreeData } from "../types/ISkillTreeData"; 3 | import { ISkillTreeUrlData } from "./ISkillTreeUrlData"; 4 | import { ISkillTreeUrlDecoder } from "./decoders/ISkillTreeUrlDecoder"; 5 | import { SkillTreeUrlV3Decoder } from "./decoders/SkillTreeUrlV3Decoder"; 6 | import { SkillTreeUrlV4Decoder } from "./decoders/SkillTreeUrlV4Decoder"; 7 | import { SkillTreeUrlV5Decoder } from "./decoders/SkillTreeUrlV5Decoder"; 8 | import { SkillTreeUrlV6Decoder } from "./decoders/SkillTreeUrlV6Decoder"; 9 | 10 | export class SkillTreeCodec implements ISkillTreeCodec { 11 | private static _decoders: ISkillTreeUrlDecoder[] = [ 12 | new SkillTreeUrlV6Decoder(), 13 | new SkillTreeUrlV5Decoder(), 14 | new SkillTreeUrlV4Decoder(), 15 | new SkillTreeUrlV3Decoder() 16 | ]; 17 | 18 | encodeURL(skillTreeData: ISkillTreeData): string { 19 | const bytes = []; 20 | const version = 6; 21 | bytes.push(version >> 24 & 0xFF); 22 | bytes.push(version >> 16 & 0xFF); 23 | bytes.push(version >> 8 & 0xFF); 24 | bytes.push(version >> 0 & 0xFF); 25 | bytes.push(skillTreeData.getStartClass()); 26 | const ascendancy = skillTreeData.getAscendancyClass(); 27 | const wildwoodAscendancy = skillTreeData.getWildwoodAscendancyClass(); 28 | bytes.push(wildwoodAscendancy << 2 | (ascendancy & 0x3)); 29 | 30 | const skilledNodes = skillTreeData.getSkilledNodes(); 31 | const nodes = new Array(); 32 | const extendedNodes = new Array(); 33 | for (const id in skilledNodes) { 34 | const node = skilledNodes[id]; 35 | if (node.classStartIndex !== undefined || node.isAscendancyStart) { 36 | continue; 37 | } 38 | if (node.expansionJewel !== undefined) { 39 | extendedNodes.push(node); 40 | } else { 41 | nodes.push(node); 42 | } 43 | } 44 | nodes.sort((a, b) => { return +(a.id || a.skill) - +(b.id || a.skill) }); 45 | 46 | bytes.push(nodes.length); 47 | for (const node of nodes) { 48 | bytes.push(+(node.id || node.skill) >> 8 & 0xFF); 49 | bytes.push(+(node.id || node.skill) & 0xFF); 50 | } 51 | 52 | bytes.push(extendedNodes.length); 53 | for (const node of extendedNodes) { 54 | bytes.push(+(node.id || node.skill) >> 8 & 0xFF); 55 | bytes.push(+(node.id || node.skill) & 0xFF); 56 | } 57 | 58 | const masteryEffects = new Array<[id: number, effect: number]>() 59 | for (const id in skillTreeData.masteryEffects) { 60 | const effect = skillTreeData.masteryEffects[id]; 61 | masteryEffects.push([+id, effect]) 62 | } 63 | 64 | bytes.push(masteryEffects.length) 65 | for (const [id, effect] of masteryEffects) { 66 | bytes.push((effect >> 8) & 0xFF); 67 | bytes.push(effect & 0xFF); 68 | bytes.push((id >> 8) & 0xFF); 69 | bytes.push(id & 0xFF); 70 | } 71 | 72 | return this.Uint8ArryToBase64(new Uint8Array(bytes)); 73 | } 74 | 75 | decodeURL(encoding: string, skillTreeData: ISkillTreeData): SkillTreeDefinition { 76 | const bytes = this.Base64ToUint8Array(encoding); 77 | const data = this.decode(bytes); 78 | const skillTreeDefinition: SkillTreeDefinition = { 79 | Version: data.version, 80 | Class: data.class, 81 | Ascendancy: data.ascendancy, 82 | WildwoodAscendancy: data.wildwoodAscendancy, 83 | Nodes: [], 84 | ExtendedNodes: [], 85 | MasteryEffects: [] 86 | }; 87 | 88 | 89 | for (const id of data.nodes) { 90 | const node = skillTreeData.nodes[id.toString()]; 91 | if (node !== undefined) { 92 | skillTreeDefinition.Nodes.push(node); 93 | } 94 | } 95 | 96 | for (const id of data.extendedNodes) { 97 | const node = skillTreeData.nodes[id.toString()]; 98 | if (node !== undefined) { 99 | skillTreeDefinition.ExtendedNodes.push(node); 100 | } 101 | } 102 | 103 | for (const [id, effect] of data.masteryEffects) { 104 | const node = skillTreeData.nodes[id.toString()]; 105 | if (node !== undefined) { 106 | skillTreeDefinition.MasteryEffects.push([node, effect]); 107 | } 108 | } 109 | 110 | return skillTreeDefinition; 111 | } 112 | 113 | decode(bytes: Uint8Array): ISkillTreeUrlData { 114 | for (const decoder of SkillTreeCodec._decoders) { 115 | if (decoder.canDecode(bytes)) { 116 | return decoder.decode(bytes); 117 | } 118 | } 119 | 120 | return { 121 | version: 6, 122 | class: 3, 123 | ascendancy: 0, 124 | wildwoodAscendancy: 0, 125 | nodeCount: 0, 126 | nodes: [], 127 | extendedNodeCount: 0, 128 | extendedNodes: [], 129 | masteryEffectCount: 0, 130 | masteryEffects: [] 131 | } 132 | } 133 | 134 | Uint8ArryToBase64 = (arr: Uint8Array): string => { 135 | return btoa(Array.prototype.map.call(arr, (c: number) => String.fromCharCode(c)).join('')).replace(/\+/gi, "-").replace(/\//gi, "_"); 136 | } 137 | 138 | Base64ToUint8Array = (str: string): Uint8Array => { 139 | str = atob(str.replace(/-/gi, "+").replace(/_/gi, "/")); 140 | const arr = new Uint8Array(str.length); 141 | for (let i = 0; i < str.length; i++) { 142 | arr[i] = str.charCodeAt(i); 143 | } 144 | return arr; 145 | } 146 | } -------------------------------------------------------------------------------- /models/url-processing/decoders/ISkillTreeUrlDecoder.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeUrlData } from "../ISkillTreeUrlData"; 2 | 3 | export interface ISkillTreeUrlDecoder { 4 | canDecode(bytes: Uint8Array): boolean 5 | decode(bytes: Uint8Array): ISkillTreeUrlData 6 | } -------------------------------------------------------------------------------- /models/url-processing/decoders/SkillTreeUrlV3Decoder.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeUrlDecoder } from "./ISkillTreeUrlDecoder"; 2 | import { ISkillTreeUrlData } from "../ISkillTreeUrlData"; 3 | 4 | export class SkillTreeUrlV3Decoder implements ISkillTreeUrlDecoder { 5 | canDecode(bytes: Uint8Array): boolean { 6 | return bytes.length >= 6 && this.version(bytes) == 3; 7 | } 8 | 9 | decode(bytes: Uint8Array): ISkillTreeUrlData { 10 | const version = this.version(bytes); 11 | const _class = this.class(bytes); 12 | const _ = this.fullscreen(bytes); 13 | 14 | const ids = new Array() 15 | for (let i = 6; i < bytes.length; i += 2) { 16 | if (i + 1 > bytes.length) { 17 | break; 18 | } 19 | ids.push(bytes[i] << 8 | bytes[i + 1]) 20 | } 21 | 22 | return { 23 | version: version, 24 | class: _class, 25 | ascendancy: 0, 26 | wildwoodAscendancy: 0, 27 | nodeCount: ids.length, 28 | nodes: ids, 29 | extendedNodeCount: 0, 30 | extendedNodes: [], 31 | masteryEffectCount: 0, 32 | masteryEffects: [] 33 | } 34 | } 35 | 36 | private version(bytes: Uint8Array): number { 37 | return bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3] 38 | } 39 | 40 | private class(bytes: Uint8Array): number { 41 | return bytes[4] 42 | } 43 | 44 | private fullscreen(bytes: Uint8Array): number { 45 | return bytes[5] 46 | } 47 | } -------------------------------------------------------------------------------- /models/url-processing/decoders/SkillTreeUrlV4Decoder.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeUrlDecoder } from "./ISkillTreeUrlDecoder"; 2 | import { ISkillTreeUrlData } from "../ISkillTreeUrlData"; 3 | 4 | export class SkillTreeUrlV4Decoder implements ISkillTreeUrlDecoder { 5 | canDecode(bytes: Uint8Array): boolean { 6 | return bytes.length >= 7 && this.version(bytes) == 4; 7 | } 8 | 9 | decode(bytes: Uint8Array): ISkillTreeUrlData { 10 | const version = this.version(bytes); 11 | const _class = this.class(bytes); 12 | const ascendancy = this.ascendancy(bytes); 13 | const _ = this.fullscreen(bytes); 14 | 15 | const ids = new Array() 16 | for (let i = 7; i < bytes.length; i += 2) { 17 | if (i + 1 > bytes.length) { 18 | break; 19 | } 20 | ids.push(bytes[i] << 8 | bytes[i + 1]) 21 | } 22 | 23 | return { 24 | version: version, 25 | class: _class, 26 | ascendancy: ascendancy, 27 | wildwoodAscendancy: 0, 28 | nodeCount: ids.length, 29 | nodes: ids, 30 | extendedNodeCount: 0, 31 | extendedNodes: [], 32 | masteryEffectCount: 0, 33 | masteryEffects: [] 34 | } 35 | } 36 | 37 | private version(bytes: Uint8Array): number { 38 | return bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3] 39 | } 40 | 41 | private class(bytes: Uint8Array): number { 42 | return bytes[4] 43 | } 44 | 45 | private ascendancy(bytes: Uint8Array): number { 46 | return bytes[5] 47 | } 48 | 49 | private fullscreen(bytes: Uint8Array): number { 50 | return bytes[6] 51 | } 52 | } -------------------------------------------------------------------------------- /models/url-processing/decoders/SkillTreeUrlV5Decoder.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeUrlDecoder } from "./ISkillTreeUrlDecoder"; 2 | import { ISkillTreeUrlData } from "../ISkillTreeUrlData"; 3 | 4 | export class SkillTreeUrlV5Decoder implements ISkillTreeUrlDecoder { 5 | canDecode(bytes: Uint8Array): boolean { 6 | return bytes.length >= 8 && this.version(bytes) == 5; 7 | } 8 | 9 | decode(bytes: Uint8Array): ISkillTreeUrlData { 10 | const version = this.version(bytes); 11 | const _class = this.class(bytes); 12 | const ascendancy = this.ascendancy(bytes); 13 | let offset = 6; 14 | 15 | const nodeCount = bytes[offset++]; 16 | const nodes = new Array() 17 | for (let i = 0; i < nodeCount; i++) { 18 | if (offset + 1 > bytes.length) { 19 | break; 20 | } 21 | nodes.push(bytes[offset++] << 8 | bytes[offset++]) 22 | } 23 | 24 | const extendedNodeCount = bytes[offset++]; 25 | const extendedNodes = new Array() 26 | for (let i = 0; i < extendedNodeCount; i++) { 27 | if (offset + 1 > bytes.length) { 28 | break; 29 | } 30 | extendedNodes.push(bytes[offset++] << 8 | bytes[offset++]) 31 | } 32 | 33 | return { 34 | version: version, 35 | class: _class, 36 | ascendancy: ascendancy, 37 | wildwoodAscendancy: 0, 38 | nodeCount: nodes.length, 39 | nodes: nodes, 40 | extendedNodeCount: extendedNodes.length, 41 | extendedNodes: extendedNodes, 42 | masteryEffectCount: 0, 43 | masteryEffects: [] 44 | } 45 | } 46 | 47 | private version(bytes: Uint8Array): number { 48 | return bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3] 49 | } 50 | 51 | private class(bytes: Uint8Array): number { 52 | return bytes[4] 53 | } 54 | 55 | private ascendancy(bytes: Uint8Array): number { 56 | return bytes[5] 57 | } 58 | } -------------------------------------------------------------------------------- /models/url-processing/decoders/SkillTreeUrlV6Decoder.ts: -------------------------------------------------------------------------------- 1 | import { ISkillTreeUrlDecoder } from "./ISkillTreeUrlDecoder"; 2 | import { ISkillTreeUrlData } from "../ISkillTreeUrlData"; 3 | 4 | export class SkillTreeUrlV6Decoder implements ISkillTreeUrlDecoder { 5 | canDecode(bytes: Uint8Array): boolean { 6 | return bytes.length >= 9 && this.version(bytes) == 6; 7 | } 8 | 9 | decode(bytes: Uint8Array): ISkillTreeUrlData { 10 | const version = this.version(bytes); 11 | const _class = this.class(bytes); 12 | const ascendancyByte = this.ascendancyByte(bytes); 13 | const ascendancy = ascendancyByte & 0x3; 14 | const wildwoodAscendancy = ascendancyByte >> 2; 15 | let offset = 6; 16 | 17 | const nodeCount = bytes[offset++]; 18 | const nodes = new Array() 19 | for (let i = 0; i < nodeCount; i++) { 20 | if (offset + 1 > bytes.length) { 21 | break; 22 | } 23 | nodes.push(bytes[offset++] << 8 | bytes[offset++]) 24 | } 25 | 26 | const extendedNodeCount = bytes[offset++]; 27 | const extendedNodes = new Array() 28 | for (let i = 0; i < extendedNodeCount; i++) { 29 | if (offset + 1 > bytes.length) { 30 | break; 31 | } 32 | extendedNodes.push(bytes[offset++] << 8 | bytes[offset++]) 33 | } 34 | 35 | const masteryEffectCount = bytes[offset++]; 36 | const masteryEffects = new Array<[id: number, effect: number]>() 37 | for (let i = 0; i < masteryEffectCount; i++) { 38 | if (offset + 3 > bytes.length) { 39 | break; 40 | } 41 | var effect = bytes[offset++] << 8 | bytes[offset++]; 42 | var id = bytes[offset++] << 8 | bytes[offset++]; 43 | masteryEffects.push([id, effect]); 44 | } 45 | 46 | return { 47 | version: version, 48 | class: _class, 49 | ascendancy: ascendancy, 50 | wildwoodAscendancy: wildwoodAscendancy, 51 | nodeCount: nodes.length, 52 | nodes: nodes, 53 | extendedNodeCount: extendedNodes.length, 54 | extendedNodes: extendedNodes, 55 | masteryEffectCount: masteryEffects.length, 56 | masteryEffects: masteryEffects 57 | } 58 | } 59 | 60 | private version(bytes: Uint8Array): number { 61 | return bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3] 62 | } 63 | 64 | private class(bytes: Uint8Array): number { 65 | return bytes[4] 66 | } 67 | 68 | private ascendancyByte(bytes: Uint8Array): number { 69 | return bytes[5] 70 | } 71 | } -------------------------------------------------------------------------------- /models/versions/verions.ts: -------------------------------------------------------------------------------- 1 | import { SemVer } from "semver"; 2 | 3 | export class versions { 4 | public static v0_9_6 = new SemVer("0.9.6"); 5 | public static v0_9_7 = new SemVer("0.9.7"); 6 | public static v0_9_8 = new SemVer("0.9.8"); 7 | public static v0_9_9 = new SemVer("0.9.9"); 8 | public static v0_9_10 = new SemVer("0.9.10"); 9 | public static v0_9_11 = new SemVer("0.9.11"); 10 | public static v0_9_12 = new SemVer("0.9.12"); 11 | public static v0_9_12qq = new SemVer("0.9.12-qq"); 12 | public static v0_9_13 = new SemVer("0.9.13"); 13 | public static v0_10_0 = new SemVer("0.10.0"); 14 | public static v0_10_3 = new SemVer("0.10.3"); 15 | public static v0_10_8 = new SemVer("0.10.8"); 16 | public static v0_11_0 = new SemVer("0.11.0"); 17 | public static v0_11_1 = new SemVer("0.11.1"); 18 | public static v0_11_2 = new SemVer("0.11.2"); 19 | public static v0_11_4 = new SemVer("0.11.4"); 20 | public static v0_11_6 = new SemVer("0.11.6"); 21 | public static v1_0_0 = new SemVer("1.0.0"); 22 | public static v1_0_1 = new SemVer("1.0.1"); 23 | public static v1_0_2 = new SemVer("1.0.2"); 24 | public static v1_0_3 = new SemVer("1.0.3"); 25 | public static v1_0_6 = new SemVer("1.0.6"); 26 | public static v1_1_0 = new SemVer("1.1.0"); 27 | public static v1_2_0 = new SemVer("1.2.0"); 28 | public static v1_2_1 = new SemVer("1.2.1"); 29 | public static v1_2_2 = new SemVer("1.2.2"); 30 | public static v1_3_0 = new SemVer("1.3.0"); 31 | public static v2_0_0 = new SemVer("2.0.0"); 32 | public static v2_0_3 = new SemVer("2.0.3"); 33 | public static v2_1_0 = new SemVer("2.1.0"); 34 | public static v2_2_0 = new SemVer("2.2.0"); 35 | public static v2_2_2 = new SemVer("2.2.2"); 36 | public static v2_3_0 = new SemVer("2.3.0"); 37 | public static v2_3_1 = new SemVer("2.3.1"); 38 | public static v2_3_2 = new SemVer("2.3.2"); 39 | public static v2_4_0 = new SemVer("2.4.0"); 40 | public static v2_5_0 = new SemVer("2.5.0"); 41 | public static v2_6_0 = new SemVer("2.6.0"); 42 | public static v3_0_0 = new SemVer("3.0.0"); 43 | public static v3_1_0 = new SemVer("3.1.0"); 44 | public static v3_2_0 = new SemVer("3.2.0"); 45 | public static v3_3_0 = new SemVer("3.3.0"); 46 | public static v3_4_0 = new SemVer("3.4.0"); 47 | public static v3_5_0 = new SemVer("3.5.0"); 48 | public static v3_6_0 = new SemVer("3.6.0"); 49 | public static v3_6_2 = new SemVer("3.6.2"); 50 | public static v3_7_0 = new SemVer("3.7.0"); 51 | public static v3_8_0 = new SemVer("3.8.0"); 52 | public static v3_9_0 = new SemVer("3.9.0"); 53 | public static v3_10_0 = new SemVer("3.10.0"); 54 | public static v3_11_0 = new SemVer("3.11.0"); 55 | public static v3_12_0 = new SemVer("3.12.0"); 56 | public static v3_13_0 = new SemVer("3.13.0"); 57 | public static v3_14_0 = new SemVer("3.14.0"); 58 | public static v3_15_0 = new SemVer("3.15.0"); 59 | public static v3_16_0 = new SemVer("3.16.0"); 60 | 61 | public static v3_17_0_atlas = new SemVer("3.17.0-atlas"); 62 | public static v3_17_0 = new SemVer("3.17.0"); 63 | 64 | public static v3_18_0_atlas = new SemVer("3.18.0-atlas"); 65 | public static v3_18_0 = new SemVer("3.18.0"); 66 | 67 | public static v3_19_0_atlas = new SemVer("3.19.0-atlas"); 68 | public static v3_19_0 = new SemVer("3.19.0"); 69 | 70 | public static v3_20_0_atlas = new SemVer("3.20.0-atlas"); 71 | public static v3_20_0_ruthless_atlas = new SemVer("3.20.0-ruthless-atlas"); 72 | public static v3_20_0 = new SemVer("3.20.0"); 73 | 74 | public static v3_20_1_atlas = new SemVer("3.20.1-atlas"); 75 | public static v3_20_1_ruthless_atlas = new SemVer("3.20.1-ruthless-atlas"); 76 | public static v3_20_1 = new SemVer("3.20.1"); 77 | 78 | public static v3_21_0_atlas = new SemVer("3.21.0-atlas"); 79 | public static v3_21_0_ruthless_atlas = new SemVer("3.21.0-ruthless-atlas"); 80 | public static v3_21_0 = new SemVer("3.21.0"); 81 | 82 | public static v3_22_0_atlas = new SemVer("3.22.0-atlas"); 83 | public static v3_22_0_ruthless_atlas = new SemVer("3.22.0-ruthless-atlas"); 84 | public static v3_22_0_ruthless = new SemVer("3.22.0-ruthless"); 85 | public static v3_22_0 = new SemVer("3.22.0"); 86 | 87 | public static v3_22_0b_ruthless = new SemVer("3.22.0-b-ruthless"); 88 | public static v3_22_0b = new SemVer("3.22.0-b"); 89 | 90 | public static v3_22_1 = new SemVer("3.22.1"); 91 | 92 | public static v3_22_2_ruthless = new SemVer("3.22.2-ruthless"); 93 | public static v3_22_2 = new SemVer("3.22.2"); 94 | 95 | public static v3_23_0_atlas = new SemVer("3.23.0-atlas"); 96 | public static v3_23_0_ruthless_atlas = new SemVer("3.23.0-ruthless-atlas"); 97 | public static v3_23_0_ruthless = new SemVer("3.23.0-ruthless"); 98 | public static v3_23_0 = new SemVer("3.23.0"); 99 | 100 | public static v3_23_2_atlas = new SemVer("3.23.2-atlas"); 101 | public static v3_23_2_ruthless_atlas = new SemVer("3.23.2-ruthless-atlas"); 102 | public static v3_23_2_ruthless = new SemVer("3.23.2-ruthless"); 103 | public static v3_23_2 = new SemVer("3.23.2"); 104 | 105 | public static v3_24_0_atlas = new SemVer("3.24.0-atlas"); 106 | public static v3_24_0_atlas_necropolis = new SemVer("3.24.0-atlas-necropolis"); 107 | public static v3_24_0_ruthless_atlas = new SemVer("3.24.0-ruthless-atlas"); 108 | public static v3_24_0_ruthless_atlas_necropolis = new SemVer("3.24.0-ruthless-atlas-necropolis"); 109 | public static v3_24_0_ruthless = new SemVer("3.24.0-ruthless"); 110 | public static v3_24_0 = new SemVer("3.24.0"); 111 | 112 | public static v3_24_3_atlas = new SemVer("3.24.3-atlas"); 113 | public static v3_24_3_atlas_necropolis = new SemVer("3.24.3-atlas-necropolis"); 114 | public static v3_24_3_ruthless_atlas = new SemVer("3.24.3-ruthless-atlas"); 115 | public static v3_24_3_ruthless_atlas_necropolis = new SemVer("3.24.3-ruthless-atlas-necropolis"); 116 | 117 | public static v3_25_0_atlas = new SemVer("3.25.0-atlas"); 118 | public static v3_25_0_ruthless_atlas = new SemVer("3.25.0-ruthless-atlas"); 119 | public static v3_25_0_ruthless = new SemVer("3.25.0-ruthless"); 120 | public static v3_25_0 = new SemVer("3.25.0"); 121 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SkillTree_TypeScript", 3 | "repository": "https://github.com/EmmittJ/SkillTree_TypeScript", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "./app/app.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "build": "time bun run ./build.ts" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "MIT", 14 | "devDependencies": { 15 | "@types/downloadjs": "^1.4.5", 16 | "@types/klaw": "^3.0.5", 17 | "@types/semver": "^7.5.4", 18 | "bun": "^1.0.6", 19 | "bun-types": "^1.0.6", 20 | "klaw": "^4.1.0", 21 | "typescript": "^5.2.2" 22 | }, 23 | "dependencies": { 24 | "@pixi-essentials/cull": "^2.0.0", 25 | "pixi-viewport": "^5.0.2", 26 | "pixi.js": "^7.3.1", 27 | "semver": "^7.5.4" 28 | } 29 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // add Bun type definitions 4 | "types": [ 5 | "bun-types" 6 | ], 7 | // enable latest features 8 | "lib": [ 9 | "esnext" 10 | ], 11 | "module": "esnext", 12 | "target": "esnext", 13 | // typescript 14 | "moduleResolution": "bundler", 15 | "noEmit": true, 16 | "allowImportingTsExtensions": true, 17 | "moduleDetection": "force", 18 | "allowJs": false, 19 | "esModuleInterop": true, 20 | "strict": true, 21 | "forceConsistentCasingInFileNames": true, 22 | "skipLibCheck": true, 23 | "allowSyntheticDefaultImports": true, 24 | "baseUrl": "./" 25 | }, 26 | "include": [ 27 | "node_modules/@types/**.*.d.ts", 28 | "models/**/*.ts", 29 | "models/**/*.d.ts", 30 | "app/**/*.ts" 31 | ] 32 | } --------------------------------------------------------------------------------