Skip to content

Commit

Permalink
Flatten components directory
Browse files Browse the repository at this point in the history
  • Loading branch information
tiliv committed Apr 25, 2024
1 parent 354d39c commit d778664
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 39 deletions.
12 changes: 6 additions & 6 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState, useEffect } from 'react';

import StatsDisplay from './components/displays/StatsDisplay';
import WorldDisplay from './components/displays/WorldDisplay';
import MenuDisplay from './components/displays/MenuDisplay';
import DisplayStats from './components/DisplayStats';
import DisplayWorld from './components/DisplayWorld';
import DisplayMenu from './components/DisplayMenu';
import Analysis from './components/Analysis';
import useAnalyzer from './hooks/useAnalyzer';
import useSave from './hooks/useSave';
Expand Down Expand Up @@ -143,7 +143,7 @@ export default function App({
</p>

<div style={{display: 'flex', flexDirection: 'row', justifyContent: 'space-around'}}>
<StatsDisplay
<DisplayStats
width={width}
height={height}
magnification={magnification}
Expand All @@ -156,7 +156,7 @@ export default function App({
cancel: 'Escape',
}}
/>
<WorldDisplay
<DisplayWorld
startWorld={startWorld}
startX={startX}
startY={startY}
Expand All @@ -172,7 +172,7 @@ export default function App({
use: 'Enter',
}}
/>
<MenuDisplay
<DisplayMenu
width={width}
height={height}
magnification={magnification}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Analysis.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';

import Progress from '../components/Progress';
import Progress from './Progress';

export default function Analysis({ name, version, labels, hypothesis, output }) {
// const [labels, setLabels] = useState(["job", "eating", "recreation"]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useState, useEffect } from 'react';

import ScreenStack from './ScreenStack';
import { ACTIONS } from '../../Actions';
import useSave from '../../hooks/useSave';
import { minifyNumbers, bufferize } from '../../utils';
import { ACTIONS } from '../Actions';
import useSave from '../hooks/useSave';
import { minifyNumbers, bufferize } from '../utils';

const OPTION_KEYS = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const SUB_MENU_CHOICES = [ACTIONS.BUY, "Load"];

export default function MenuDisplay({
export default function DisplayMenu({
width, height,
target, targetData, activeChoice,
options,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useEffect, useState } from 'react';

import ScreenStack from './ScreenStack';
import useStats from '../../hooks/useStats';
import useEquipment from '../../hooks/useEquipment';
import useInventory from '../../hooks/useInventory';
import { keyAlias, minifyNumbers, bufferizeList } from '../../utils';
import useStats from '../hooks/useStats';
import useEquipment from '../hooks/useEquipment';
import useInventory from '../hooks/useInventory';
import { keyAlias, minifyNumbers, bufferizeList } from '../utils';

const TABS = ['Equip', 'Map', 'Log', 'GP']
const TABS = ['Equip', 'Magic', 'Log']

const ABBREVIATIONS = {
weapon: 'Wp',
Expand Down Expand Up @@ -37,7 +37,7 @@ function farColumns(info1, info2) {
);
}

export default function StatsDisplay({
export default function DisplayStats({
width, height, world,
keyMap={
up: 'w',
Expand All @@ -50,7 +50,7 @@ export default function StatsDisplay({
magnification=1,
}) {
const { inventory, equipment, setEquipment } = useInventory();
const { name, hp, maxHp, mp, strength, defense, speed } = useStats();
const { name, hp, maxHp, gold, strength, defense, speed } = useStats();
const { buffers, ...slots } = useEquipment(equipment);
const [equippedBuffer, setEquippedBuffer] = useState(null);

Expand Down Expand Up @@ -204,7 +204,7 @@ export default function StatsDisplay({
{ fg: '#c7c7c7', buffer: [
`➧${name}`,
['HP:', `${hp}`.padStart(3, ' '), 'ヽ', `${minifyNumbers(maxHp)}`.padStart(3, ' '),
' M:', mp].join(''),
' G:', gold].join(''),
[
'A:', `${strength}`.padStart(2, ' '),
' D:', `${defense}`.padStart(2, ' '),
Expand All @@ -218,7 +218,7 @@ export default function StatsDisplay({
]},
...(
// Equipment
TABS[menuChoice] === 'Equip' ? (
menuChoice === 0 ? (
equipChoice === null ? (
[].concat((buffers || []).map(({ fg, buffer }) => ({
fg: fg, buffer: [].concat(['', '', '', ''], buffer.map(
Expand All @@ -241,14 +241,12 @@ export default function StatsDisplay({
equipmentScrollBuffer && { fg: '#c7c7c7', buffer: equipmentScrollBuffer },
equipmentScrollBuffer && { bg: '#aaa', fg: 'black', buffer: equipmentScrollSelectionBuffer },
])
) : TABS[menuChoice] === 'Map' ? (
// Map
[{fg: 'red', buffer: ['', '', '', '', "Map"]}]
) : TABS[menuChoice] === 'Log' ? (
// Quests
[{fg: 'green', buffer: ['', '', '', '', "Quests"]}]
) : TABS[menuChoice] === 'GP' ? (
[{fg: 'gold', buffer: ['', '', '', '', "GP"]}]
) : menuChoice === 1 ? (
// Magic
[{fg: 'red', buffer: ['', '', '', '', TABS[menuChoice]]}]
) : menuChoice === 2 ? (
// Log
[{fg: 'green', buffer: ['', '', '', '', TABS[menuChoice]]}]
) : []),
].filter(Boolean)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { useState, useEffect } from 'react';

import ScreenStack from './ScreenStack';
import useLocation from '../../hooks/useLocation';
import useInteraction from '../../hooks/useInteraction';
import useStats from '../../hooks/useStats';
import useSave from '../../hooks/useSave';
import { list } from '../../actions/Load';
import { ACTIONS } from '../../Actions';
import * as Buy from '../../actions/Buy';
import { renderTemplate, keyAlias } from '../../utils';
import useLocation from '../hooks/useLocation';
import useInteraction from '../hooks/useInteraction';
import useStats from '../hooks/useStats';
import useSave from '../hooks/useSave';
import { list } from '../actions/Load';
import { ACTIONS } from '../Actions';
import * as Buy from '../actions/Buy';
import { renderTemplate, keyAlias } from '../utils';

export default function WorldDisplay({
export default function DisplayWorld({
width, height,
startWorld, startX, startY,
target,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/hooks/useStats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { useState } from 'react';
export default function useStats() {
const [hp, setHp] = useState(100);
const [maxHp, setMaxHp] = useState(100);
const [mp, setMp] = useState(100);
const [gold, setGold] = useState(100);
const [strength, setStrength] = useState(10);
const [defense, setDefense] = useState(5);
const [speed, setSpeed] = useState(5);

return {
name: localStorage.getItem('latest'),
hp, maxHp,
mp,
gold,
strength,
defense,
speed,
Expand Down

0 comments on commit d778664

Please sign in to comment.