Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sense-q committed Jun 24, 2024
0 parents commit 79824c4
Show file tree
Hide file tree
Showing 13 changed files with 368 additions and 0 deletions.
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Other
package/
dist/
esdist/
version.txt
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

### 1.2.3 (2024-06-24)


### Bug Fixes

* update for ita (a8b424f)

### 1.2.2 (2023-11-03)

### Bug Fixes

- possible issue when save is already ancient relics (5d01349)
- Relic drops not getting toggle value at right time (e3dfc5b)

### 1.2.1 (2023-10-27)

### Bug Fixes

- downgrade button not showing (115c892)
- potential undefined obj (a4fc29e)
- Relic drops not getting toggle value at right time (e3dfc5b)

## 1.2.0 (2023-10-09)

### Features

- add option to disable mod (7a5e1d3)

## 1.1.0 (2023-10-09)

### Features

- add standard-version (97d1f8e)
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ancient Relics Mod

A Melvor Idle mod on [Mod.io](https://mod.io/g/melvoridle/m/arm)

![logo]

## Features

- Ancient and Lesser relics for any game mode
- does not retroactively grant relics
- Enables ancient relic interface elements
- Options to disable/enable ancient and lesser relics
- Mod disabled for ancient relic gamemode saves

[logo]: media/arm-full.png
Binary file added bun.lockb
Binary file not shown.
7 changes: 7 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"namespace": "ancientRelicsMod",
"name": "Ancient Relics Mod",
"setup": "setup.mjs",
"icon": "https://i.ibb.co/ypj5SrR/arm.png",
"version": "1.2.3"
}
Binary file added media/arm-full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/arm-icon-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/arm-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/arm-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "ancient-relics-mod",
"version": "1.2.3",
"type": "module",
"scripts": {
"release": "standard-version --path ./",
"dryrelease": "standard-version --dry-run --path ./"
},
"devDependencies": {
"melvor-types": "https://github.com/GamesByMalcsPtyLtd/Melvor-Typing-Project/tarball/9b8c988"
},
"standard-version": {
"tag-prefix": "Ancient-Relics-Mod@v"
}
}
23 changes: 23 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 134 additions & 0 deletions src/ts/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import manifest from '../../manifest.json';
export function setup(ctx: Modding.ModContext) {
console.log(`Ancient Relics Mod v${manifest.version} loading...`);
const ARM_SETTINGS = ctx.settings.section('Ancient Relics');
ARM_SETTINGS.add([
{
type: 'switch',
name: 'enable-mod',
label: 'Enable Ancient Relics',
hint: ' ',
default: true,
onChange: () => {
const btn = document
.getElementById(`ancientRelicsMod:enable-mod`)
?.nextElementSibling?.querySelector('small');

if (btn) {
btn.textContent = 'Reload Required';
btn.classList.add('text-warning');
updateButton();
}
},
} as unknown as Modding.Settings.SwitchConfig,
{
type: 'switch',
name: 'enable-lesser-relics',
label: 'Enable Lesser Relics',
hint: ' ',
default: true,
onChange: () => {
const btn = document
.getElementById(`ancientRelicsMod:enable-lesser-relics`)
?.nextElementSibling?.querySelector('small');

if (btn) {
btn.textContent = 'Reload Required';
btn.classList.add('text-warning');
updateButton();
}
},
} as unknown as Modding.Settings.SwitchConfig,
{
type: 'button',
name: 'save-reload',
display: 'Save & Reload',
color: 'primary',
onClick: () => {
saveData();
window.location.reload();
},
} as unknown as Modding.Settings.ButtonConfig,
]);

ctx.patch(Skill as any, 'hasMasterRelic').replace(function (o, realm) {
this.game.currentGamemode.allowAncientRelicDrops =
ARM_SETTINGS.get('enable-mod');
if (!this.game.currentGamemode.allowAncientRelicDrops) return false;
const relicSet = this.ancientRelicSets.get(realm);
return relicSet !== undefined && relicSet.isComplete;
});

function updateButton() {
const btn = document.getElementById('ancientRelicsMod:save-reload');
if (btn && btn.classList.contains('btn-primary')) {
btn.classList.replace('btn-primary', 'btn-danger');
} else return;
}

/**
* Patch ARM settings in sidebar to inform user if mod is disabled and current gamemode is already Ancient Relics
*/
ctx.patch(SidebarSubitem, 'configure').before(function (config) {
if (
this.id !== 'Ancient Relics Mod' ||
game.currentGamemode.localID !== 'AncientRelics'
)
return [config];

// overwrite default onClick function that opens settings modal
if (config)
config.onClick = () =>
Swal.fire({
icon: 'error',
title: 'Mod Disabled',
html: `<h5 class="font-w600 font-size-sm mb-1 text-danger">Ancient Relics Mod is disabled for this save</h5><h5 class="font-w600 font-size-sm m-0 text-warning"><small>(Current gamemode is already Ancient Relics)</small></h5>`,
});

return [config];
});

ctx.onCharacterLoaded(() => {
if (game.currentGamemode.localID === 'AncientRelics') return;

const lesserRelicsEnabled = ARM_SETTINGS.get('enable-lesser-relics');
console.log(
'Ancient Relics Mod v%s loaded save %c%s%c with: \n%cAncient Relics %s%c\n%cLesser Relics %s%c',
manifest.version,
'color: green; font-weight: bold;',
game.characterName,
'',
'color: #d3ba7c;',
ARM_SETTINGS.get('enable-mod') ? 'Enabled' : 'Disabled',
'',
'color: #e41e7f;',
lesserRelicsEnabled ? 'Enabled' : 'Disabled',
'',
);

// add the current gamemode to the list of gamemodes that the lesser relic can drop in
if (lesserRelicsEnabled)
game.skills
.filter((skill) =>
skill.rareDrops.some(
(drop) => drop.item?._localID.includes('Lesser_Relic'),
),
)
.forEach((skill) => {
const lesserRelicDrop = skill.rareDrops.find(
(drop) => drop.item?._localID.includes('Lesser_Relic'),
);
if (lesserRelicDrop && lesserRelicDrop.gamemodes)
lesserRelicDrop.gamemodes.push(game.currentGamemode);
});
});

ctx.onInterfaceReady(() => {
if (game.currentGamemode.localID === 'AncientRelics') return;

// Show ancient relics sidebar item
const category = sidebar.category('Ancient Relics');
if (category && category.rootEl && ARM_SETTINGS.get('enable-mod'))
category.rootEl.classList.remove('d-none');
});
}
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["./src/**/*", "node_modules/melvor-types"]
}

0 comments on commit 79824c4

Please sign in to comment.