Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instant repair #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const SettingsUI = require('tera-mod-ui').Settings;

module.exports = function InstantEverything(mod) {
const PURPOSES = ['enchant', 'upgrade', 'soulbind', 'merge', 'dismantle'];
const PURPOSES = ['enchant', 'upgrade', 'soulbind', 'merge', 'dismantle', 'repair'];

let hooks = {};
function hook(purpose, ...args) {
Expand All @@ -13,6 +13,8 @@ module.exports = function InstantEverything(mod) {

let enchanting = null;
let upgrading = null;
let repairing = null;

function enable(purpose) {
switch (purpose) {
case 'enchant': {
Expand Down Expand Up @@ -49,6 +51,22 @@ module.exports = function InstantEverything(mod) {
break;
}

case 'repair': {
if(mod.majorPatchVersion >= 79) {
hook('repair', 'C_REGISTER_REPAIR_ITEM', 1, event => { repairing = event });

hook('repair', 'C_START_REPAIR_ITEM', 1, event => {
if (repairing && event.contract === repairing.contract) {
mod.send('C_REQUEST_REPAIR_ITEM', 1, repairing);
return false;
}
});

hook('repair', 'C_REQUEST_REPAIR_ITEM', 'event', () => false);
}
break;
}

case 'soulbind': {
hook('soulbind', 'C_BIND_ITEM_BEGIN_PROGRESS', 1, event => {
mod.send('C_BIND_ITEM_EXECUTE', 1, {
Expand Down
6 changes: 5 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"files": {
"index.js": "7dd1ebd434d6557995aa3a2cbfe970012dd934320065dd3f4af2efba59b0c1b4",
"index.js": "d8747e0dda8c6a02e6ac0522b8810e84c01b23739a87b59aecc7e73c73d248fc",
"settings_migrator.js": "823fc1c204003a4a782e23b1a0781b9ee48d2865004a8acb73359777c0c067bc",
"settings_structure.js": "76520793fad024750498529f19c830819b5d9e3b0ab6aa408caaf32c0c7b2000",
"module.json": "874965336c161ab99edd2196c34fd3b5a03f63724a390a9f34712e0df487fbcb"
Expand All @@ -13,6 +13,10 @@
"C_REGISTER_EVOLUTION_ITEM": 1,
"C_REQUEST_EVOLUTION": ["raw", 1],
"C_START_EVOLUTION": 1,

"C_REGISTER_REPAIR_ITEM": 1,
"C_REQUEST_REPAIR_ITEM": ["raw", 1],
"C_START_REPAIR_ITEM": 1,

"C_BIND_ITEM_BEGIN_PROGRESS": 1,
"C_BIND_ITEM_EXECUTE": ["raw", 1],
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"servers": ["https://raw.githubusercontent.com/tera-toolbox-mods/instant-everything/master/"],
"options": {
"niceName": "InstantEverything",
"settingsVersion": 1,
"settingsVersion": 2,
"settingsFile": "config.json",
"settingsMigrator": "settings_migrator.js"
},
"conflicts": ["instant-enchant", "instant-upgrade", "instant-soulbind", "instant-dismantle", "instant-merge"]
}
}
3 changes: 2 additions & 1 deletion settings_migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const DefaultSettings = {
"soulbind": true,
"merge": true,
"dismantle": true,
"repair": true,
}

module.exports = function MigrateSettings(from_ver, to_ver, settings) {
Expand All @@ -15,6 +16,6 @@ module.exports = function MigrateSettings(from_ver, to_ver, settings) {
return DefaultSettings;
} else {
// Migrate from older version (using the new system) to latest one
throw new Error('So far there is only one settings version and this should never be reached!');
return Object.assign(Object.assign({}, DefaultSettings), settings);
}
}
5 changes: 5 additions & 0 deletions settings_structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ module.exports = [
"key": "dismantle",
"name": "Instant Dismantling",
"type": "bool"
},
{
"key": "repair",
"name": "Instant Repairing",
"type": "bool"
}
];