Skip to content

Commit

Permalink
add skills
Browse files Browse the repository at this point in the history
  • Loading branch information
Aero56 committed Oct 26, 2023
1 parent d360c13 commit 76671e5
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 16 deletions.
Binary file added src/assets/skills/agility.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 src/assets/skills/attack.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 src/assets/skills/construction.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 src/assets/skills/cooking.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 src/assets/skills/crafting.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 src/assets/skills/defence.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 src/assets/skills/farming.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 src/assets/skills/firemaking.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 src/assets/skills/fishing.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 src/assets/skills/fletching.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 src/assets/skills/herblore.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 src/assets/skills/hitpoints.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 src/assets/skills/hunter.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 src/assets/skills/magic.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 src/assets/skills/mining.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 src/assets/skills/prayer.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 src/assets/skills/ranged.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 src/assets/skills/runecrafting.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 src/assets/skills/slayer.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 src/assets/skills/smithing.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 src/assets/skills/strength.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 src/assets/skills/thieving.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 src/assets/skills/woodcutting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions src/components/Stats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Skills } from '@/types/skills';
import { Stats as StatsType } from '@/types/stats';

interface StatsProps {
stats: StatsType;
}

const SKILLS: Array<keyof Skills> = [
'attack',
'hitpoints',
'mining',
'strength',
'agility',
'smithing',
'defence',
'herblore',
'fishing',
'ranged',
'thieving',
'cooking',
'prayer',
'crafting',
'firemaking',
'magic',
'fletching',
'woodcutting',
'runecrafting',
'slayer',
'farming',
'construction',
'hunter',
];

const Stats = ({ stats }: StatsProps) => {
return (
<div className="col-span-1 rounded-xl bg-black-pearl-900 sm:col-span-3">
<div className="flex items-center justify-between rounded-t-xl border-b-2 border-black-pearl-700 bg-black-pearl-800 p-4 font-semibold">
Stats
<div className="badge badge-primary">
{`Total: ${stats.skills.overall.level}`}
</div>
</div>
<div className="flex justify-center">
<div className="w-96 py-4 sm:p-4">
<div className="flex flex-wrap justify-center gap-2">
{SKILLS.map((skill) => (
<div className="flex w-1/4 rounded-xl border-2 border-black-pearl-700 bg-black-pearl-800 p-1">
<img
src={`src/assets/skills/${skill}.png`}
alt={`Skill icon of ${skill}`}
className="ml-1 h-6 w-6 object-contain"
/>
<p className="mx-auto">{stats.skills[skill]?.level ?? 1}</p>
</div>
))}
</div>
</div>
</div>
</div>
);
};

export default Stats;
18 changes: 2 additions & 16 deletions src/pages/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useParams } from 'react-router-dom';
import { format } from 'date-fns';

import usePlayerQuery from '@hooks/queries/usePlayerQuery';
import Stats from '@components/Stats';

const Player = () => {
const { username = '' } = useParams();
Expand All @@ -21,29 +22,14 @@ const Player = () => {
<div className="col-span-1 rounded-xl bg-black-pearl-900 p-4 sm:col-span-2">
<p className="text-center text-xl font-bold">{username}</p>
<div className="divider my-1" />
<p className="text-xs font-bold">ABOUT ME</p>
<p className="text-xs font-bold">
{'Member since: '}
<span className="font-normal">
{format(new Date(player.created_at), 'd MMM yyyy')}
</span>
</p>
</div>
<div className="col-span-1 rounded-xl bg-black-pearl-900 sm:col-span-3">
<div className="rounded-t-xl border-b-2 border-black-pearl-700 bg-black-pearl-800 p-4 font-semibold">
Stats
</div>
<div className="p-4">
<div className="flex flex-col">
{player?.stats &&
Object.entries(player.stats.skills).map(([key, value]) => (
<p key={key}>
{key}: {value.level}
</p>
))}
</div>
</div>
</div>
{player.stats && <Stats stats={player.stats} />}
</div>
);
};
Expand Down

0 comments on commit 76671e5

Please sign in to comment.