Skip to content

Commit

Permalink
Armor Types in custom equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
gvorbeck committed Jan 27, 2024
1 parent 4e5373f commit c94c74a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/components/ModalCustomEquipment/ArmorType/ArmorType.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Form, Switch } from "antd";
import React from "react";

interface ArmorTypeProps {}

const ArmorType: React.FC<
ArmorTypeProps & React.ComponentPropsWithRef<"div">
> = ({ className }) => {
return (
<Form.Item
label="Armor Type"
name="type"
className={className}
rules={[{ required: true }]}
>
<Switch
checkedChildren="Light Armor"
unCheckedChildren="Heavy Armor"
defaultChecked
/>
</Form.Item>
);
};

export default ArmorType;
5 changes: 4 additions & 1 deletion src/components/ModalCustomEquipment/ModalCustomEquipment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
EquipmentItem,
} from "@/data/definitions";
import SubCategory from "./SubCategory/SubCategory";
import ArmorType from "./ArmorType/ArmorType";

interface ModalCustomEquipmentProps {
character: CharData;
Expand All @@ -33,7 +34,7 @@ type CategoryFieldMappings = {

const categoryFieldMapping: CategoryFieldMappings = {
[EquipmentCategories.AMMUNITION]: ["Damage"],
[EquipmentCategories.ARMOR]: ["ArmorClass"],
[EquipmentCategories.ARMOR]: ["ArmorClass", "ArmorType"],
[EquipmentCategories.AXES]: ["Size", "Damage", "AttackType", "Range"],
[EquipmentCategories.BARDING]: ["AnimalWeight", "ArmorClass"],
[EquipmentCategories.BOWS]: ["Size", "Ammo", "AttackType", "Range"],
Expand Down Expand Up @@ -152,6 +153,8 @@ const ModalCustomEquipment: React.FC<
return <Damage key={index} />;
case "ArmorClass":
return <ArmorClass key={index} />;
case "ArmorType":
return <ArmorType key={index} />;
case "AttackType":
return <AttackType key={index} disabled={attackTypeDisabled} />;
case "Range":
Expand Down
7 changes: 6 additions & 1 deletion src/support/statSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export const getMovement = (characterData: CharData) => {
};

const currentArmor = characterData?.wearing?.armor || "";
const currentCategory = armorCategoryMap[currentArmor];
const currentCategory =
armorCategoryMap[currentArmor] ||
characterData?.equipment.filter((item) => item.name === currentArmor)[0]
?.type
? "lightArmor"
: "heavyArmor";
const [lightSpeed, heavySpeed] =
armorSpeedMap[currentCategory || "lightArmor"];
const weight = getCharacterWeight(characterData);
Expand Down

0 comments on commit c94c74a

Please sign in to comment.