Skip to content

Commit

Permalink
Merge pull request #246 from tchryssos/tc-bonus-damage
Browse files Browse the repository at this point in the history
Bonus Damage
  • Loading branch information
tchryssos authored Sep 26, 2024
2 parents de9e2f9 + a3bca92 commit 20008b4
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/components/rulebookSpecific/sotww/CharacterSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { AttributeInputs } from './inputs/AttributeInputs';
import { BackgroundInputs } from './inputs/BackgroundInputs';
import { BasicInfoInputs } from './inputs/BasicInfoInputs';
import { BoonBaneInputs } from './inputs/BoonBaneInputs';
import { ConditionInputs } from './inputs/ConditionInputs';
import { CombatModifierInputs } from './inputs/CombatModifierInputs';
import { CurrencyInputs } from './inputs/CurrencyInputs';
import { DefenseInputs } from './inputs/DefenseInputs';
import { EquipmentInputs } from './inputs/EquipmentInputs';
Expand Down Expand Up @@ -167,7 +167,7 @@ export function CharacterSheet({ character }: SotwwCharacterSheetProps) {
>
<GridBox columns={{ base: 1, sm: 2 }}>
<DefenseInputs />
<ConditionInputs />
<CombatModifierInputs />
</GridBox>
<WeaponInputs />
<ArmorInputs />
Expand Down
71 changes: 41 additions & 30 deletions src/components/rulebookSpecific/sotww/QuickAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,46 @@ const LongEffect = styled(Text)`
white-space: pre-line;
`;

interface QuickKeyValProps {
label: string;
value: string;
longVal?: boolean;
}
function QuickKeyVal({ label, value, longVal }: QuickKeyValProps) {
if (longVal) {
return (
<FlexBox flexDirection="column">
<Text>{label}:</Text>
<LongEffect color="textAccent" variant="body-xs">
{value}
</LongEffect>
</FlexBox>
);
}
return (
<Text>
{label}: <Text color="textAccent">{value}</Text>
</Text>
);
}

export function QuickAccess() {
const { watch } = useFormContext<SotwwCharacterData>();
const { totalDefense, recalculateDefense } = useContext(DefenseContext);

const equippedWeapon = watch('weapons').find((w) => w.weapon_equipped);
const equippedWeapon = watch('weapons').filter((w) => w.weapon_equipped);
const weaponText = equippedWeapon
? `${equippedWeapon.weapon_name} ${equippedWeapon.weapon_damage}`
? equippedWeapon
.map((w) => `${w.weapon_name} ${w.weapon_damage}`)
.join(' / ')
: 'Unarmed 1d6';
const equippedArmor = watch('armors').filter((a) => a.armor_equipped);
const equippedArmorText = equippedArmor.map((a) => a.armor_name).join(', ');
const damage = watch('damage');
const health = watch('health_current');
const conditions = watch('conditions');
const boonBane = watch('boons_and_banes');
const bonusDamage = watch('bonus_attack_damage');

useEffect(() => {
recalculateDefense();
Expand All @@ -37,7 +63,6 @@ export function QuickAccess() {
return (
<FormSection
borderColor="primary"
// borderStyle="dotted"
columns={1}
isCollapsible={false}
title="Quick Access"
Expand All @@ -47,39 +72,25 @@ export function QuickAccess() {
gridTemplateColumns={{ base: '1fr', sm: '1fr 1fr', lg: '1fr 2fr' }}
>
<FlexBox flexDirection="column" gap={8}>
<Text>
Damage:{' '}
<Text color="textAccent">
{damage}/{health}
</Text>
</Text>
<Text>
Weapon: <Text color="textAccent">{weaponText}</Text>
</Text>
<Text>
Defense:{' '}
<Text color="textAccent">
{totalDefense} ({equippedArmorText || 'Natural Defense'})
</Text>
</Text>
<QuickKeyVal label="Damage" value={`${damage}/${health}`} />
<QuickKeyVal label="Weapon" value={weaponText} />
{trim(bonusDamage) && (
<QuickKeyVal label="Bonus Atk Damage" value={`+${bonusDamage}`} />
)}
<QuickKeyVal
label="Defense"
value={`${totalDefense} (${
equippedArmorText || 'Natural Defense'
})`}
/>
</FlexBox>

<GridBox columns={{ base: 1, lg: 2 }} gap={{ base: 8, lg: 16 }}>
{trim(boonBane) && (
<FlexBox flexDirection="column">
<Text>Boons/Banes:</Text>
<LongEffect color="textAccent" variant="body-xs">
{boonBane}
</LongEffect>
</FlexBox>
<QuickKeyVal label="Boons/Banes" longVal value={boonBane} />
)}
{trim(conditions) && (
<FlexBox flexDirection="column">
<Text>Conditions:</Text>
<LongEffect color="textAccent" variant="body-xs">
{conditions}
</LongEffect>
</FlexBox>
<QuickKeyVal label="Conditions" longVal value={conditions} />
)}
</GridBox>
</GridBox>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { FlexBox } from '~/components/box/FlexBox';
import { FormSection } from '~/components/form/containers/FormSection';
import { TextAreaInput } from '~/components/form/TextAreaInput';
import { TextInput } from '~/components/form/TextInput';
import { RpgIcons } from '~/constants/icons';
import { SotwwCharacterData } from '~/typings/sotww/characterData';

export function ConditionInputs() {
export function CombatModifierInputs() {
return (
<FormSection columns={1} icon={RpgIcons.StackedSkulls} title="Conditions">
<FormSection
columns={1}
icon={RpgIcons.StackedSkulls}
title="Combat Modifiers"
>
<FlexBox flexDirection="column" gap={16}>
<TextAreaInput<SotwwCharacterData> name="conditions" />
<TextInput<SotwwCharacterData> name="bonus_attack_damage" />
<TextAreaInput<SotwwCharacterData> alwaysEditable name="conditions" />
</FlexBox>
</FormSection>
);
Expand Down
1 change: 1 addition & 0 deletions src/constants/sotww/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const DEFAULT_VALUES: SotwwCharacterData = {
ancestry_traits: '',
boons_and_banes: '',
conditions: '',
bonus_attack_damage: '',
description: '',
professions: '',
languages: '',
Expand Down
1 change: 1 addition & 0 deletions src/typings/sotww/characterData.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type SotwwCharacterData = {
ancestry_traits: string;
boons_and_banes: string;
conditions: string;
bonus_attack_damage: string;
description: string;
professions: string;
languages: string;
Expand Down

0 comments on commit 20008b4

Please sign in to comment.