### Install Dependencies and Start Development Server
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/README.md
Run these commands to install project dependencies and start the local development server. Open http://localhost:3000 to view the application.
```bash
npm install
npm run dev
```
--------------------------------
### Example: Get Experience Multiplier
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/experience-and-tier-utilities.md
Demonstrates how to obtain the experience multiplier for a given relic tier. This example first determines the tier using `getTier` and then retrieves the multiplier using `getExpMultiplier`, both imported from `./util/getTier`.
```javascript
import { getTier, getExpMultiplier } from './util/getTier';
const tier = getTier(10000);
const multiplier = getExpMultiplier(tier);
console.log(`Experience multiplier: ${multiplier}x`);
```
--------------------------------
### Development Commands
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/README.md
Common npm commands for managing the development environment, including installing dependencies, starting the dev server, building for production, and running tests.
```bash
# Install dependencies
npm install
# Start development server (with hot reload)
npm run dev
# Build production bundle
npm run build
# Run tests
npm run test
```
--------------------------------
### Breakpoint Usage Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/configuration.md
Example of how to use the `useBreakpoint` hook with defined media queries to check if the screen size is smaller than the SM breakpoint.
```javascript
const isMobile = useBreakpoint(MEDIA_QUERIES.SM, MODE.LESS);
```
--------------------------------
### Skill Configuration Examples
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/types.md
Illustrates how to access skill configuration objects, such as for 'Attack' and 'Cooking'.
```javascript
STATS.Attack // { label: 'Attack', panelOrder: 0, icon: '...', productionProdigyEligible: false }
STATS.Cooking // { label: 'Cooking', panelOrder: 11, productionProdigyEligible: true }
```
--------------------------------
### Persist State to Local Storage Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/README.md
Shows how to update the application's state in local storage using the `updateLocalStorage` function. This example specifically updates the theme setting.
```javascript
import { updateLocalStorage, LOCALSTORAGE_KEYS } from './client/localstorage-client';
updateLocalStorage(LOCALSTORAGE_KEYS.SETTINGS, { theme: 'dark' });
```
--------------------------------
### Skill Filter Usage Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/task-filters.md
An example of how to configure the filter state to show only Fishing and Cooking tasks that the player can currently perform.
```javascript
// Only show Fishing and Cooking tasks that the player can currently do
const filterState = {
skills: ['Fishing', 'Cooking'],
showNoRequirements: false,
showUnmetRequirements: false,
isProductionProdigy: true
};
```
--------------------------------
### Get Current Tier and Exp Multiplier Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/README.md
Demonstrates how to determine a player's current tier based on their experience points and retrieve the corresponding experience multiplier. Uses `getTier` and `getExpMultiplier` utilities.
```javascript
import { getTier, getExpMultiplier } from './util/getTier';
const tier = getTier(5000); // points → tier
const multiplier = getExpMultiplier(tier); // tier → exp multiplier
```
--------------------------------
### Login Button Usage
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/account-hook.md
Example of how to attach the login function to a button click event.
```javascript
```
--------------------------------
### Fetch Hiscores Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/README.md
Demonstrates how to fetch player hiscores using the `getHiscores` client function. It logs the hiscores if the fetch is successful.
```javascript
import getHiscores from './client/hiscores-client';
getHiscores('player-name', (result) => {
if (result.success) {
console.log(result.hiscores);
}
});
```
--------------------------------
### Hiscores Client Usage Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/hiscores-client.md
Demonstrates how to import and use the getHiscores function to fetch and display player hiscores.
```javascript
import getHiscores from './client/hiscores-client';
getHiscores('lynx titan', (result) => {
if (result.success) {
console.log('Hiscores fetched:', result.hiscores);
} else {
console.error('Failed to fetch hiscores:', result.message);
}
});
```
--------------------------------
### Example: Convert Experience to Level
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/experience-and-tier-utilities.md
Demonstrates how to use the `experienceToLevel` function to find a skill level from a given experience value. Ensure the `xpAndLevelConversions` utility is imported.
```javascript
import { experienceToLevel } from './util/xpAndLevelConversions';
const level = experienceToLevel(1234567);
console.log(`Level: ${level}`); // Output: Level: 62
```
--------------------------------
### App Component Usage Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/account-hook.md
Demonstrates how to use the useAccount hook within a React component to manage authentication state and UI.
```javascript
import useAccount from './hooks/useAccount';
export function App() {
const { isLoggedIn, isAuthenticating, login, logout } = useAccount({
redirectReturnToUrl: window.location.origin
});
if (isAuthenticating) {
return
Loading...
;
}
return (
);
}
```
--------------------------------
### Add Multiplier Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/multipliers-hook.md
Demonstrates how to add a new relic multiplier to the collection using the addMultiplier function. This example boosts experience and output for Smithing activities.
```javascript
const multiplier = {
multiplier: 1.5,
categories: ['Smithing'],
actions: [],
matchers: null,
exceptions: [],
appliesTo: { exp: true, inputs: false, outputs: true }
};
addMultiplier('relic-exp-boost', multiplier);
```
--------------------------------
### Filter Tasks Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/README.md
Provides an example of filtering a list of tasks based on a set of predefined filters. It uses `taskFilters` utility to apply multiple filtering conditions.
```javascript
import taskFilters from './util/taskFilters';
const filtered = allTasks.filter(task =>
taskFilters.every(filter => filter(task, filterState, context))
);
```
--------------------------------
### Calculator Experience Values Definition
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/types.md
Tracks the starting and target experience for a calculator session. The difference between target and start experience is used for action calculations.
```javascript
{
start: { xp: number }, // Starting experience
target: { xp: number } // Target experience
}
```
--------------------------------
### Example: Convert Level to Experience
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/experience-and-tier-utilities.md
Shows how to use the `levelToExperience` function to calculate the total experience needed to reach a specific level, such as level 99. Import the function from `xpAndLevelConversions`.
```javascript
import { levelToExperience } from './util/xpAndLevelConversions';
const xpFor99 = levelToExperience(99);
console.log(`XP for level 99: ${xpFor99}`); // 13,034,431
```
--------------------------------
### Account Slice Actions and Usage
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/redux-integration.md
Exports the action to update the account cache. A usage example shows how to dispatch this action with authentication details.
```javascript
export const { updateAccountCache } = accountSlice.actions;
// Usage:
dispatch(updateAccountCache({
isAuthenticated: true,
user: auth0User,
accessToken: token
}));
```
--------------------------------
### Apply Multipliers to Value Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/README.md
Shows how to apply various multipliers to a base value using the `useMultipliers` hook. This is useful for calculating adjusted values based on game mechanics.
```javascript
const multipliers = useMultipliers();
const finalValue = multipliers.applyMultipliers(
1000, // Base value
{ id: 'action-1', category: 'Smithing' },
{ name: 'Steel bar' },
{ exp: true, inputs: false, outputs: false }
);
```
--------------------------------
### Filters Slice Actions and Usage
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/redux-integration.md
Exports actions for updating and resetting various filters. Usage examples demonstrate dispatching these actions.
```javascript
export const {
updateTaskFilter,
updateQuestFilter,
updateDiariesFilter,
updateCalculatorsFilter,
resetTasks,
resetQuests,
resetDiaries,
resetCalculators,
reset
} = filterSlice.actions;
// Usage examples:
dispatch(updateTaskFilter({ field: 'difficulty', value: ['Hard', 'Elite'] }));
dispatch(updateCalculatorsFilter({ field: 'regions', value: ['Misthalin', 'Karamja'] }));
dispatch(resetTasks()); // Reset only task filters
dispatch(reset()); // Reset all filters
```
--------------------------------
### useBreakpoint Usage Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/react-hooks.md
Illustrates how to use the useBreakpoint hook to conditionally render different navigation components based on screen size. It imports predefined breakpoints and modes for flexible responsive design.
```javascript
import useBreakpoint, { MEDIA_QUERIES, MODE } from './hooks/useBreakpoint';
export function ResponsiveNav() {
const isSmallScreen = useBreakpoint(MEDIA_QUERIES.SM, MODE.LESS);
const isMediumUp = useBreakpoint(MEDIA_QUERIES.MD);
return (
);
}
```
--------------------------------
### Example: Determine Relic Tier
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/experience-and-tier-utilities.md
Illustrates how to use the `getTier` function to find the current relic tier for a given number of league points. The `getTier` function should be imported from `./util/getTier`.
```javascript
import { getTier } from './util/getTier';
const tier = getTier(5000);
console.log(`Current tier: ${tier}`); // Output: 4
```
--------------------------------
### Example: Determine Trophy Tier
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/experience-and-tier-utilities.md
Demonstrates the usage of the `getTrophyTier` function to determine a trophy tier from a given number of league points. The function should be imported from `./util/getTier`.
```javascript
import { getTrophyTier } from './util/getTier';
const trophyTier = getTrophyTier(8000);
console.log(`Trophy tier: ${trophyTier}`);
```
--------------------------------
### Example: Determine Region Tier
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/experience-and-tier-utilities.md
Shows how to use the `getRegionTier` function to find the appropriate region tier based on the count of completed tasks. Ensure the function is imported from `./util/getTier`.
```javascript
import { getRegionTier } from './util/getTier';
const regionTier = getRegionTier(150);
console.log(`Region tier: ${regionTier}`); // Output: 0
```
--------------------------------
### Usage Example: SkillCalculator with useMultipliers
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/multipliers-hook.md
Demonstrates how to integrate the useMultipliers hook into a React component to manage and apply experience multipliers. It shows adding multipliers based on relic selection and calculating adjusted experience for activities.
```javascript
import useMultipliers from './hooks/useMultipliers';
export function SkillCalculator() {
const {
multipliers,
addMultiplier,
removeMultiplier,
applyMultipliers
} = useMultipliers();
const handleRelicSelect = (relic) => {
addMultiplier(relic.id, {
multiplier: relic.exp.multiplier,
categories: ['All'],
actions: [],
matchers: null,
exceptions: [],
appliesTo: { exp: true, inputs: false, outputs: false }
});
};
const calculateActivity = (activity) => {
const finalExp = applyMultipliers(activity.exp, activity, undefined, {
exp: true,
inputs: false,
outputs: false
});
return {
...activity,
expWithMultipliers: finalExp
};
};
return (
{/* Component implementation */}
);
}
```
--------------------------------
### Redux State Shape Example
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/README.md
Illustrates the structure of the Redux state, detailing the organization of filters, settings, tasks, unlocks, character, account, and calculator states.
```javascript
{
filters: { tasks, quests, diaries, calculators },
settings: { theme, ... },
tasks: { tasks, taskStats, tier },
unlocks: { regions, quests, questStats },
character: { characters, activeCharacter, hiscoresState },
account: { accountCache },
calculators: { /* calculator state */ }
}
```
--------------------------------
### Default Regions Configuration
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/configuration.md
Specifies the default regions unlocked at the start of a league. Includes Misthalin (id: 0) and Karamja (id: 1).
```javascript
export const DEFAULT_REGIONS = [0, 1];
// Misthalin (id: 0) and Karamja (id: 1)
```
--------------------------------
### Usage Example: Importing Character Data
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/plugin-importer.md
Demonstrates how to use the importFromPlugin function within a React component, including Redux hooks for state management and dispatching actions.
```javascript
import importFromPlugin from './client/plugin-importer';
import { useDispatch, useSelector } from 'react-redux';
export function ImportCharacterModal() {
const dispatch = useDispatch();
const userState = useSelector(state => ({
tasks: state.tasks,
regions: state.unlocks.regions
}));
const characterState = useSelector(state => state.character);
const handleImportClick = () => {
const pluginData = {
displayName: 'MyPlayer123',
tasks: {
'task-001': { completed: 1234567890, tracked: 0, ignored: 0 },
'task-002': { completed: 0, tracked: 5, ignored: 0 }
},
quests: { 'quest-1': 'FINISHED' }
};
importFromPlugin(pluginData, userState, dispatch, characterState);
};
return ;
}
```
--------------------------------
### expValues Structure for useCalculatorData
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/react-hooks.md
Illustrates the expected structure for the `expValues` object, which should contain `start` and `target` properties, each with an `xp` number. This is used by the `useCalculatorData` hook.
```javascript
{
start: { xp: number },
target: { xp: number }
}
```
--------------------------------
### SmithingCalculator Component using useCalculatorData
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/react-hooks.md
A React component example demonstrating how to use the `useCalculatorData` hook to fetch and display Smithing calculator data. It shows how to pass necessary parameters and render the processed activity information.
```javascript
import useCalculatorData from './hooks/useCalculatorData';
export function SmithingCalculator() {
const calculatorData = useCalculatorData(
'Smithing',
{ start: { xp: 0 }, target: { xp: 1000000 } },
5, // 5x experience multiplier
multipliersState,
equilibriumState
);
return calculatorData.data.map(activity => (
{activity.name}: {activity.exp} XP per action
Actions needed: {activity.actionsRequired}
));
}
```
--------------------------------
### Dispatch Async Thunk to Fetch Data
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/redux-integration.md
Example of dispatching an asynchronous thunk action, such as fetching hiscores data from the backend. The .then() block can be used to handle the data after it's loaded.
```javascript
// In character slice
dispatch(fetchHiscores(characterState, null, skipDbUpdate))
.then(() => {
// Hiscores loaded
});
```
--------------------------------
### Get User Data By Storage Key (JavaScript)
Source: https://github.com/osrs-reldo/os-league-tools/blob/master/_autodocs/api-reference/user-data-client.md
Retrieves specific user data associated with a given storage key. Requires the user's email, the storage key (e.g., 'tasks', 'settings'), and an Auth0 access token. Returns a promise that resolves to an object indicating success and the requested data.
```javascript
export function getUserData(userEmail: string, storageKey: string, accessToken: string): Promise