Skip to content

Commit

Permalink
Enh/cleanup (#1151)
Browse files Browse the repository at this point in the history
* small cleanup

* clean unused bank files

* Move type to type file + rebase

* fix knip
  • Loading branch information
bob0005 authored Aug 6, 2024
1 parent 67caeda commit b47d5be
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 209 deletions.
8 changes: 1 addition & 7 deletions .knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
"eternum-docs/package.json",
"eternum-docs/vocs.config.ts",
"sdk/packages/eternum/global.d.ts",

"config/bank/index.ts",
"**/**__test__**/**",
"**/**__tests__**/**",

"client/src/dojo/events/bankEventQueries.ts",
"client/src/hooks/store/useBankStore.tsx",
"client/src/ui/components/bank/BankEntityList.tsx",
"client/src/ui/components/bank/BankStats.tsx",
"config/bank/index.ts",

"client/src/three/components/FogManager.ts",
"client/src/hooks/useUISound.tsx"
]
Expand Down
109 changes: 0 additions & 109 deletions client/src/dojo/events/bankEventQueries.ts

This file was deleted.

31 changes: 0 additions & 31 deletions client/src/hooks/store/useBankStore.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/hooks/useUISound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import useSound from "use-sound";
import useUIStore from "./store/useUIStore";
import { BuildingType, ResourcesIds } from "@bibliothecadao/eternum";
import { useCallback, useState } from "react";
import { ResourceMiningTypes } from "@/ui/utils/utils";
import { ResourceMiningTypes } from "@/types";

const dir = "/sound/";

Expand Down
7 changes: 7 additions & 0 deletions client/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ export interface Health {
current: bigint;
lifetime: bigint;
}

export enum ResourceMiningTypes {
Forge = "forge",
Mine = "mine",
LumberMill = "lumber_mill",
Dragonhide = "dragonhide",
}
5 changes: 0 additions & 5 deletions client/src/ui/components/bank/BankEntityList.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions client/src/ui/components/bank/BankStats.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import { ResourceCost } from "@/ui/elements/ResourceCost";
import { ResourceIcon } from "@/ui/elements/ResourceIcon";
import { unpackResources } from "@/ui/utils/packedData";
import { hasEnoughPopulationForBuilding } from "@/ui/utils/realms";
import { ResourceIdToMiningType, ResourceMiningTypes } from "@/ui/utils/utils";
import { ResourceIdToMiningType } from "@/ui/utils/utils";
import { BUILDING_COSTS_SCALED } from "@bibliothecadao/eternum";
import React, { useMemo, useState } from "react";
import { HintSection } from "../hints/HintModal";
import { ResourceMiningTypes } from "@/types";

// TODO: THIS IS TERRIBLE CODE, PLEASE REFACTOR

Expand Down
2 changes: 1 addition & 1 deletion client/src/ui/components/military/TroopChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const TroopMenuRow = ({
className?: string;
}) => {
return (
<div className={`grid w-full grid-cols-3 gap-2 relative w-full text-gold font-bold ${className}`}>
<div className={`grid grid-cols-3 gap-2 relative w-full text-gold font-bold ${className}`}>
<div className="px-2 py-1 bg-gold/10 clip-angled-sm flex flex-col justify-between gap-2 border border-gold/10">
<ResourceIcon withTooltip={false} resource={"Crossbowman"} size="lg" />
<div className="text-green text-xs self-center">{currencyFormat(troops?.crossbowman_count || 0, 0)}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
import useUIStore from "@/hooks/store/useUIStore";
import {
BUILDING_CAPACITY,
BUILDING_POPULATION,
BuildingType,
EternumGlobalConfig,
HYPERSTRUCTURE_POINTS_PER_CYCLE,
ID,
RESOURCE_INFORMATION,
RESOURCE_INPUTS_SCALED,
STRUCTURE_COSTS_SCALED,
StructureType,
findResourceById,
} from "@bibliothecadao/eternum";

import { getResourceBalance } from "@/hooks/helpers/useResources";
import { useQuestStore } from "@/hooks/store/useQuestStore";
import useRealmStore from "@/hooks/store/useRealmStore";
import { QuestId } from "@/ui/components/quest/questDetails";
import { Headline } from "@/ui/elements/Headline";
import { ResourceCost } from "@/ui/elements/ResourceCost";
import { ResourceIcon } from "@/ui/elements/ResourceIcon";
import { BUILDING_COSTS_SCALED } from "@bibliothecadao/eternum";
import clsx from "clsx";
import React from "react";
import { StructureCard } from "./StructureCard";
Expand Down
8 changes: 1 addition & 7 deletions client/src/ui/config.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { ResourceMiningTypes } from "@/types";
import { BuildingType } from "@bibliothecadao/eternum";

export const FELT_CENTER = 2147483647;

enum ResourceMiningTypes {
Forge = "forge",
Mine = "mine",
LumberMill = "lumber_mill",
Dragonhide = "dragonhide",
}

const BUILD_IMAGES_PREFIX = "/images/buildings/construction/";
export const BUILDING_IMAGES_PATH = {
[BuildingType.Castle]: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const BattleDetails = ({ armies }: { armies: (ArmyInfo | undefined)[] | u
const { getAddressName } = useRealm();
return (
<div className="w-full">
<div className="p-2 w-full grid grid-cols-2 text-gold border-gold/20 border-gradient clip-angled p-2">
<div className="w-full grid grid-cols-2 text-gold border-gold/20 border-gradient clip-angled p-2">
<div key={0} className="mb-4 tile h-6 text-left border border-gold/20">
Army
</div>
Expand Down
8 changes: 1 addition & 7 deletions client/src/ui/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FELT_CENTER } from "../config";
import { SortInterface } from "../elements/SortButton";
import * as THREE from "three";
import { HEX_HORIZONTAL_SPACING, HEX_VERTICAL_SPACING } from "@/three/scenes/HexagonScene";
import { ResourceMiningTypes } from "@/types";

export { getEntityIdFromKeys };

Expand Down Expand Up @@ -170,13 +171,6 @@ export const pseudoRandom = (x: number, y: number) => {
return n - Math.floor(n);
};

export enum ResourceMiningTypes {
Forge = "forge",
Mine = "mine",
LumberMill = "lumber_mill",
Dragonhide = "dragonhide",
}

export const ResourceIdToMiningType: Partial<Record<ResourcesIds, ResourceMiningTypes>> = {
[ResourcesIds.Copper]: ResourceMiningTypes.Forge,
[ResourcesIds.ColdIron]: ResourceMiningTypes.Forge,
Expand Down

0 comments on commit b47d5be

Please sign in to comment.