style: move randInRange to utils
This commit is contained in:
@@ -4,7 +4,7 @@ import { useState, useMemo } from 'react';
|
|||||||
import shared from '../../styles/shared.module.css';
|
import shared from '../../styles/shared.module.css';
|
||||||
import styles from '../../styles/Items.module.css';
|
import styles from '../../styles/Items.module.css';
|
||||||
import QuantityCard from '../../components/QuantityCard';
|
import QuantityCard from '../../components/QuantityCard';
|
||||||
import { Item, ItemType, ITEM_TYPE_LABELS, getItemType, getItemIconUrl, randInRange } from './types';
|
import { Item, ItemType, ITEM_TYPE_LABELS, getItemType, getItemIconUrl } from './types';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
items: Item[];
|
items: Item[];
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useState, useMemo } from 'react';
|
|||||||
import shared from '../../styles/shared.module.css';
|
import shared from '../../styles/shared.module.css';
|
||||||
import styles from '../../styles/Items.module.css';
|
import styles from '../../styles/Items.module.css';
|
||||||
import QuantityCard from '../../components/QuantityCard';
|
import QuantityCard from '../../components/QuantityCard';
|
||||||
import { Offering, OfferingRole, getOfferingIconUrl, randInRange } from './types';
|
import { Offering, OfferingRole, getOfferingIconUrl } from './types';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
offerings: Offering[];
|
offerings: Offering[];
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export const getItemType = (id: string): ItemType => {
|
|||||||
return 'other';
|
return 'other';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const getItemIconUrl = (iconFilePath: string) => {
|
export const getItemIconUrl = (iconFilePath: string) => {
|
||||||
const file = (iconFilePath.split('/').pop() ?? '').split('.')[0];
|
const file = (iconFilePath.split('/').pop() ?? '').split('.')[0];
|
||||||
return `${DB_BASE_URL}/icons/item-icons/${file}.png`;
|
return `${DB_BASE_URL}/icons/item-icons/${file}.png`;
|
||||||
@@ -40,9 +39,3 @@ export const getOfferingIconUrl = (iconFilePath: string) => {
|
|||||||
const file = (iconFilePath.split('/').pop() ?? '').split('.')[0];
|
const file = (iconFilePath.split('/').pop() ?? '').split('.')[0];
|
||||||
return `${DB_BASE_URL}/icons/offering-icons/${file}.png`;
|
return `${DB_BASE_URL}/icons/offering-icons/${file}.png`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const randInRange = (min: number, max: number) => {
|
|
||||||
const lo = Math.min(min, max);
|
|
||||||
const hi = Math.max(min, max);
|
|
||||||
return Math.floor(Math.random() * (hi - lo + 1)) + lo;
|
|
||||||
};
|
|
||||||
+7
-2
@@ -18,5 +18,10 @@ export const cleanFolderName = (name: string): string =>
|
|||||||
|
|
||||||
export const isKiller = (idx: number): boolean => idx >= 268435456;
|
export const isKiller = (idx: number): boolean => idx >= 268435456;
|
||||||
|
|
||||||
export const isNamedDLC = (dlc: DLC): dlc is DLC & { name: string } =>
|
export const isNamedDLC = (dlc: DLC): dlc is DLC & { name: string } => !!dlc.name && !dlc.name.startsWith('@');
|
||||||
!!dlc.name && !dlc.name.startsWith('@');
|
|
||||||
|
export const randInRange = (min: number, max: number) => {
|
||||||
|
const lo = Math.min(min, max);
|
||||||
|
const hi = Math.max(min, max);
|
||||||
|
return Math.floor(Math.random() * (hi - lo + 1)) + lo;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user