refactor: ♻️ merge multiple trait getter into single function

This commit is contained in:
Sebin Nyshkim 2025-04-10 02:31:59 +02:00
parent a4416c1811
commit 1ca13d330f
2 changed files with 70 additions and 24 deletions

View file

@ -217,19 +217,61 @@ const getWeight = () => `${weight} kg (${toLbs(weight)} lbs)`;
const getTailLength = () => `${tailLength / 100} m (${toImperial(tailLength)})`;
const getWingspan = () => `${wingspan / 100} m (${toImperial(wingspan)})`;
const getTraits = () => [
{ icon: 'cake-candles', type: 'Date of Birth', text: getDateOfBirth() },
{ icon: 'mars', type: 'Sex/Gender', text: `${gender} (${pronouns})` },
{ icon: 'ruler', type: 'Height', text: getHeight() },
{ icon: 'weight-hanging', type: 'Weight', text: getWeight() },
{ icon: 'ruler', type: 'Tail Length', text: getTailLength() },
{ icon: 'ruler', type: 'Wingspan', text: getWingspan() }
];
const getTraits = (type) => {
switch (type) {
case 'general':
return [
{ icon: 'ruler', type: 'Tail Length', text: getTailLength() },
{ icon: 'shoe-prints', type: 'Walk', text: 'plantigrade' },
{ icon: 'info', type: 'Claws', text: 'sharp, hands & feet' },
{ icon: 'info', type: 'Nipples', text: 'yes' }
];
const getSexTraits = () => [
{ icon: 'heart', type: 'Orientation', text: orientation },
{ icon: 'arrows-up-down', type: 'Position', text: position }
];
case 'wings':
return [
{ icon: 'ruler', type: 'Wingspan', text: getWingspan() },
{ icon: 'feather', type: 'Arms', text: 2 },
{ icon: 'feather', type: 'Fingers', text: 3 },
{ icon: 'star', type: 'Special Features', text: 'talon on top' }
];
case 'head':
return [
{ icon: 'eye', type: 'Pupils', text: 'round' },
{ icon: 'eye', type: 'Eyebrows', text: 'yellow spikes' },
{ icon: 'info', type: 'Cheeks', text: 'yellow spikes' },
{ icon: 'dragon', type: 'Horns', text: 'curved' },
{ icon: 'info', type: 'Hair', text: 'mid-long, mullet' },
{ icon: 'ear-listen', type: 'Ears', text: 'long, pointy, movable' },
{ icon: 'tooth', type: 'Teeth', text: 'sharp fangs' },
{ icon: 'face-grin-tongue', type: 'Tongue', text: 'pointy tip' }
];
case 'muscle':
return [
{ icon: 'dumbbell', type: 'Build', text: 'muscular' },
{ icon: 'dumbbell', type: 'Pecs', text: 'big' },
{ icon: 'dumbbell', type: 'abs', text: 'defined' }
];
case 'naughty':
return [
{ icon: 'ruler', type: 'Length', text: `${penis.size} cm (${toInch(penis.size)})` },
{ icon: 'ruler', type: 'Girth', text: `${penis.girth} cm (${toInch(penis.girth)})` },
{ icon: 'shapes', type: 'Shape', text: penis.shape },
{ icon: 'maximize', type: 'Type', text: penis.type },
{ icon: 'star', type: 'Special Features', text: penis.special }
];
default:
return [
{ icon: 'cake-candles', type: 'Date of Birth', text: getDateOfBirth() },
{ icon: 'mars', type: 'Sex/Gender', text: `${gender} (${pronouns})` },
{ icon: 'ruler', type: 'Height', text: getHeight() },
{ icon: 'weight-hanging', type: 'Weight', text: getWeight() }
];
}
};
const getColors = () => [
{ name: 'Scales', value: colors.scalesPrimary },
@ -252,6 +294,5 @@ export default {
overdriveAttacks,
getFullName,
getTraits,
getSexTraits,
getColors
};

View file

@ -114,17 +114,23 @@ const getDateOfBirth = () => `${dateFormat.format(dateOfBirth)} (${getAge(dateOf
const getHeight = () => `${height} cm (${toImperial(height)})`;
const getWeight = () => `${weight} kg (${toLbs(weight)} lbs)`;
const getTraits = () => [
{ icon: 'cake-candles', type: 'Date of Birth', text: getDateOfBirth() },
{ icon: 'mars', type: 'Sex/Gender', text: `${gender} (${pronouns})` },
{ icon: 'ruler', type: 'Height', text: getHeight() },
{ icon: 'weight-hanging', type: 'Weight', text: getWeight() }
];
const getTraits = (type) => {
switch (type) {
case 'naughty':
return [
{ icon: 'heart', type: 'Orientation', text: orientation },
{ icon: 'arrows-up-down', type: 'Role', text: role }
];
const getSexTraits = () => [
{ icon: 'heart', type: 'Orientation', text: orientation },
{ icon: 'arrows-up-down', type: 'Role', text: role }
];
default:
return [
{ icon: 'cake-candles', type: 'Date of Birth', text: getDateOfBirth() },
{ icon: 'mars', type: 'Sex/Gender', text: `${gender} (${pronouns})` },
{ icon: 'ruler', type: 'Height', text: getHeight() },
{ icon: 'weight-hanging', type: 'Weight', text: getWeight() }
];
}
};
const getColors = () => [
{ name: 'Front', value: color.front },
@ -147,6 +153,5 @@ export default {
jobs,
getFullName,
getTraits,
getSexTraits,
getColors
};