New source found from dndbeyond.com
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Constants,
|
||||
Creature,
|
||||
ExtraManager,
|
||||
VehicleManager,
|
||||
} from "@dndbeyond/character-rules-engine/es";
|
||||
|
||||
import { NumberDisplay } from "~/components/NumberDisplay";
|
||||
@@ -75,7 +76,7 @@ export const ExtraRow: FC<Props> = ({
|
||||
typeName = type;
|
||||
}
|
||||
|
||||
let description: string = `${size} ${typeName.toLowerCase()}`.trim();
|
||||
let description: string = `${size} ${typeName}`.trim();
|
||||
if (description) {
|
||||
metaItems.push(description);
|
||||
}
|
||||
@@ -164,12 +165,27 @@ export const ExtraRow: FC<Props> = ({
|
||||
|
||||
const { data, label, showTooltip } = movementInfo;
|
||||
|
||||
let useMph = false;
|
||||
const isVehicle = extra.isVehicle();
|
||||
if (isVehicle) {
|
||||
const vehicleData = extra.getExtraData() as VehicleManager;
|
||||
const displayType = vehicleData?.getDisplayType();
|
||||
const isElementalAirship =
|
||||
displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP;
|
||||
useMph = isElementalAirship;
|
||||
}
|
||||
|
||||
let contentNode: React.ReactNode = null;
|
||||
if (data !== null) {
|
||||
contentNode = (
|
||||
<React.Fragment>
|
||||
<div className="ct-extra-row__speed-value">
|
||||
<NumberDisplay type="distanceInFt" number={data.speed} />
|
||||
<NumberDisplay
|
||||
type="distanceInFt"
|
||||
number={data.speed}
|
||||
useMph={useMph}
|
||||
/>
|
||||
{showTooltip && renderAdditionalInfoTooltip()}
|
||||
</div>
|
||||
{data.movementId !== Constants.MovementTypeEnum.WALK && (
|
||||
|
||||
+7
-2
@@ -4,6 +4,7 @@ interface Props {
|
||||
label: string;
|
||||
value: React.ReactNode;
|
||||
extraValue: React.ReactNode;
|
||||
displayColon?: boolean;
|
||||
}
|
||||
export default class VehicleBlockAttribute extends React.PureComponent<Props> {
|
||||
static defaultProps = {
|
||||
@@ -11,11 +12,15 @@ export default class VehicleBlockAttribute extends React.PureComponent<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { label, value, extraValue } = this.props;
|
||||
const { label, value, extraValue, displayColon } = this.props;
|
||||
|
||||
const labelDisplay: string = displayColon ? `${label}:` : label;
|
||||
|
||||
return (
|
||||
<div className="ct-vehicle-block__attribute">
|
||||
<span className="ct-vehicle-block__attribute-label">{label}</span>
|
||||
<span className="ct-vehicle-block__attribute-label">
|
||||
{labelDisplay}
|
||||
</span>
|
||||
<span className="ct-vehicle-block__attribute-data">
|
||||
<span className="ct-vehicle-block__attribute-data-value">
|
||||
{value}
|
||||
|
||||
+19
-5
@@ -1,3 +1,4 @@
|
||||
import clsx from "clsx";
|
||||
import React from "react";
|
||||
|
||||
import { ManageIcon } from "@dndbeyond/character-components/es";
|
||||
@@ -42,6 +43,9 @@ export default class VehicleBlockComponent extends React.PureComponent<Props> {
|
||||
const nameLabel: string = name !== null ? name : "";
|
||||
const isSpelljammer =
|
||||
displayType === Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER;
|
||||
const isElementalAirship =
|
||||
displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP;
|
||||
|
||||
let componentCount: string = "";
|
||||
if (count > 1) {
|
||||
@@ -56,8 +60,11 @@ export default class VehicleBlockComponent extends React.PureComponent<Props> {
|
||||
requiredCrew ? ` (${requiredCrew} Crew${count > 1 ? " Each" : ""})` : ""
|
||||
}`;
|
||||
} else {
|
||||
let typesText = FormatUtils.renderNonOxfordCommaList(typeNames);
|
||||
primaryText = `${typesText}: ${nameLabel} ${componentCount}`;
|
||||
const typesNames = FormatUtils.renderNonOxfordCommaList(typeNames);
|
||||
const typeText = `${typesNames}: `;
|
||||
primaryText = `${
|
||||
isElementalAirship ? "" : typeText
|
||||
}${nameLabel} ${componentCount}`;
|
||||
}
|
||||
|
||||
let callout: React.ReactNode = null;
|
||||
@@ -79,8 +86,8 @@ export default class VehicleBlockComponent extends React.PureComponent<Props> {
|
||||
|
||||
return (
|
||||
<div className="ct-vehicle-block-component__actions">
|
||||
{actions.map((action) => (
|
||||
<VehicleBlockAction action={action} key={action.key} />
|
||||
{actions.map((action, idx) => (
|
||||
<VehicleBlockAction action={action} key={idx + action.key} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
@@ -127,7 +134,14 @@ export default class VehicleBlockComponent extends React.PureComponent<Props> {
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<div className="ct-vehicle-block-component__attributes">
|
||||
<div
|
||||
className={clsx([
|
||||
"ct-vehicle-block-component__attributes",
|
||||
displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP &&
|
||||
"ct-vehicle-block-component__attributes--inline",
|
||||
])}
|
||||
>
|
||||
<VehicleBlockPrimaryAttributes
|
||||
armorClassInfo={armorClassInfo}
|
||||
hitPointInfo={hitPointInfo}
|
||||
|
||||
+5
-2
@@ -69,8 +69,11 @@ export default class VehicleBlockComponents extends React.PureComponent<Props> {
|
||||
components = components.filter(
|
||||
(component) =>
|
||||
!(
|
||||
component.displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER &&
|
||||
(component.displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER ||
|
||||
component.displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum
|
||||
.ELEMENTAL_AIRSHIP) &&
|
||||
component.isPrimaryComponent
|
||||
)
|
||||
);
|
||||
|
||||
+7
-3
@@ -15,7 +15,7 @@ export default class VehicleBlockHeader extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
let size: string = sizeName !== null ? sizeName : "";
|
||||
let type: string = typeName !== null ? typeName.toLowerCase() : "";
|
||||
let type: string = typeName !== null ? typeName : "";
|
||||
|
||||
return [size, type].join(" ").trim();
|
||||
};
|
||||
@@ -65,14 +65,18 @@ export default class VehicleBlockHeader extends React.PureComponent<Props> {
|
||||
|
||||
const typeInfo = this.renderTypeInfo();
|
||||
const dimensions = this.renderDimensions();
|
||||
const showMeta =
|
||||
displayType !==
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER &&
|
||||
displayType !==
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP;
|
||||
|
||||
return (
|
||||
<div className="ct-vehicle-block__header">
|
||||
<div className="ct-vehicle-block__name">
|
||||
{name !== null ? name : ""}
|
||||
</div>
|
||||
{displayType !==
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER && (
|
||||
{showMeta && (
|
||||
<div className="ct-vehicle-block__meta">
|
||||
{typeInfo} {dimensions}
|
||||
</div>
|
||||
|
||||
+26
-6
@@ -120,6 +120,7 @@ export default class VehicleBlockPrimary extends React.PureComponent<Props> {
|
||||
primaryProperties,
|
||||
shouldCoalesce,
|
||||
displayType,
|
||||
creatureCapacityInfo,
|
||||
} = this.props;
|
||||
|
||||
let cargoCapacity: Array<string> = [];
|
||||
@@ -138,6 +139,11 @@ export default class VehicleBlockPrimary extends React.PureComponent<Props> {
|
||||
|
||||
const isSpelljammer =
|
||||
displayType === Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER;
|
||||
const isElementalAirship =
|
||||
displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP;
|
||||
|
||||
const showSeperator = !isSpelljammer && !isElementalAirship;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -164,18 +170,32 @@ export default class VehicleBlockPrimary extends React.PureComponent<Props> {
|
||||
extraValue={this.renderEffectiveTravelDistance()}
|
||||
/>
|
||||
)}
|
||||
<VehicleBlockAttribute
|
||||
label={isSpelljammer ? "Crew" : "Creature Capacity"}
|
||||
value={creatureCapacityDescriptions.join(", ")}
|
||||
/>
|
||||
{!isElementalAirship ? (
|
||||
<VehicleBlockAttribute
|
||||
label={isSpelljammer ? "Crew" : "Creature Capacity"}
|
||||
value={creatureCapacityDescriptions.join(", ")}
|
||||
/>
|
||||
) : (
|
||||
creatureCapacityInfo.map((capacity, idx) => (
|
||||
<VehicleBlockAttribute
|
||||
key={capacity.type || "Capacity" + idx}
|
||||
label={capacity.type || "Capacity"}
|
||||
value={capacity.capacity}
|
||||
displayColon={true}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
{cargoCapacity.length > 0 && (
|
||||
<VehicleBlockAttribute
|
||||
label={isSpelljammer ? "Cargo" : "Cargo Capacity"}
|
||||
label={
|
||||
isSpelljammer || isElementalAirship ? "Cargo" : "Cargo Capacity"
|
||||
}
|
||||
value={cargoCapacity.join(", ")}
|
||||
displayColon={isElementalAirship}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{!isSpelljammer && <VehicleBlockSeparator displayType={displayType} />}
|
||||
{showSeperator && <VehicleBlockSeparator displayType={displayType} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
+42
-17
@@ -110,16 +110,21 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
};
|
||||
|
||||
renderSpeedInfo = (
|
||||
modes: Array<VehicleComponentSpeedModeInfo>
|
||||
modes: Array<VehicleComponentSpeedModeInfo>,
|
||||
displayType: Constants.VehicleConfigurationDisplayTypeEnum
|
||||
): React.ReactNode => {
|
||||
const isElementalAirship =
|
||||
displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP;
|
||||
|
||||
let speedDisplayStrings: Array<string> = modes.map((mode) => {
|
||||
const { value, description, restrictionsText, movementInfo } = mode;
|
||||
|
||||
let stringParts: Array<string> = [];
|
||||
if (movementInfo) {
|
||||
if (movementInfo && !isElementalAirship) {
|
||||
stringParts.push(`${movementInfo.description} speed`);
|
||||
}
|
||||
stringParts.push(FormatUtils.renderDistance(value));
|
||||
stringParts.push(FormatUtils.renderDistance(value, isElementalAirship));
|
||||
if (description) {
|
||||
stringParts.push(description);
|
||||
}
|
||||
@@ -134,12 +139,16 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
};
|
||||
|
||||
renderArmorClassAttribute = (): React.ReactNode => {
|
||||
const { armorClassInfo } = this.props;
|
||||
const { armorClassInfo, displayType } = this.props;
|
||||
|
||||
if (armorClassInfo === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isElementalAirship =
|
||||
displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP;
|
||||
|
||||
const { moving, base, description } = armorClassInfo;
|
||||
|
||||
let armorClassValue: number | null = base;
|
||||
@@ -155,7 +164,7 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
|
||||
return (
|
||||
<VehicleBlockAttribute
|
||||
label="Armor Class"
|
||||
label={isElementalAirship ? "AC" : "Armor Class"}
|
||||
value={
|
||||
description
|
||||
? `${armorClassValue} (${description})`
|
||||
@@ -164,6 +173,7 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
: armorClassValue
|
||||
}
|
||||
extraValue={motionlessArmorClassValue}
|
||||
displayColon={isElementalAirship}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -206,7 +216,9 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
);
|
||||
|
||||
const costValues: Array<string> = sortedCosts.map((cost) => {
|
||||
const value: string = cost.value ? `${cost.value} gp` : "--";
|
||||
const value: string = cost.value
|
||||
? `${FormatUtils.renderLocaleNumber(cost.value)} GP`
|
||||
: "--";
|
||||
const description: string = cost.description
|
||||
? `(${cost.description})`
|
||||
: "";
|
||||
@@ -216,25 +228,33 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
|
||||
const isSpelljammer =
|
||||
displayType === Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER;
|
||||
const isElementalAirship =
|
||||
displayType ===
|
||||
Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP;
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
{armorClassInfo !== null && this.renderArmorClassAttribute()}
|
||||
{hitPointInfo !== null && (
|
||||
<VehicleBlockAttribute
|
||||
label="Hit Points"
|
||||
label={isElementalAirship ? "HP" : "Hit Points"}
|
||||
value={this.renderHitPointInfo()}
|
||||
extraValue={
|
||||
!isSpelljammer ? this.renderHitPointThresholdInfo() : undefined
|
||||
!isSpelljammer && !isElementalAirship
|
||||
? this.renderHitPointThresholdInfo()
|
||||
: undefined
|
||||
}
|
||||
displayColon={isElementalAirship}
|
||||
/>
|
||||
)}
|
||||
{isSpelljammer && !!hitPointInfo?.damageThreshold && (
|
||||
<VehicleBlockAttribute
|
||||
label="Damage Threshold"
|
||||
value={hitPointInfo?.damageThreshold}
|
||||
/>
|
||||
)}
|
||||
{(isSpelljammer || isElementalAirship) &&
|
||||
!!hitPointInfo?.damageThreshold && (
|
||||
<VehicleBlockAttribute
|
||||
label={"Damage Threshold"}
|
||||
value={hitPointInfo?.damageThreshold}
|
||||
displayColon={isElementalAirship}
|
||||
/>
|
||||
)}
|
||||
{speedInfos.map((speedInfo, idx) => {
|
||||
let speedAttributeLabel: string = "Speed";
|
||||
if (speedInfo.type !== null && !isSpelljammer) {
|
||||
@@ -248,7 +268,8 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
<VehicleBlockAttribute
|
||||
key={`${speedInfo.type}-${idx}`}
|
||||
label={speedAttributeLabel}
|
||||
value={this.renderSpeedInfo(modes)}
|
||||
value={this.renderSpeedInfo(modes, displayType)}
|
||||
displayColon={isElementalAirship}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -258,7 +279,7 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
value={`Grants ${coverType} Cover`}
|
||||
/>
|
||||
)}
|
||||
{requiredCrew !== null && !isSpelljammer && (
|
||||
{requiredCrew !== null && !isSpelljammer && !isElementalAirship && (
|
||||
<VehicleBlockAttribute label="Required Crew" value={requiredCrew} />
|
||||
)}
|
||||
{isPrimaryComponent &&
|
||||
@@ -273,7 +294,11 @@ export default class VehicleBlockPrimaryAttributes extends React.PureComponent<P
|
||||
/>
|
||||
)}
|
||||
{costValues.length > 0 && (
|
||||
<VehicleBlockAttribute label="Cost" value={costValues.join(", ")} />
|
||||
<VehicleBlockAttribute
|
||||
label="Cost"
|
||||
value={costValues.join(", ")}
|
||||
displayColon={isElementalAirship}
|
||||
/>
|
||||
)}
|
||||
</React.Fragment>
|
||||
);
|
||||
|
||||
+2
@@ -20,6 +20,8 @@ export default class VehicleBlockSeparator extends React.PureComponent<Props> {
|
||||
VehicleBlockSeparatorInfernal,
|
||||
[Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER]:
|
||||
VehicleBlockSeparatorShip,
|
||||
[Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP]:
|
||||
VehicleBlockSeparatorShip,
|
||||
};
|
||||
|
||||
//sets Ship style as default
|
||||
|
||||
+2
@@ -27,6 +27,8 @@ export default class VehicleBlockShellCap extends React.PureComponent<Props> {
|
||||
VehicleBlockShellCapInfernal,
|
||||
[Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER]:
|
||||
VehicleBlockShellCapShip,
|
||||
[Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP]:
|
||||
VehicleBlockShellCapShip,
|
||||
};
|
||||
|
||||
//sets Ship style as default
|
||||
|
||||
@@ -385,7 +385,7 @@ class VehiclePane extends React.PureComponent<Props, State> {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!vehicle.isSpelljammer()) {
|
||||
if (!vehicle.isSpelljammer() && !vehicle.isElementalAirship()) {
|
||||
const primaryComponent = vehicle.getPrimaryComponent();
|
||||
if (primaryComponent === null) {
|
||||
return null;
|
||||
@@ -442,6 +442,7 @@ class VehiclePane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
return (
|
||||
<VehicleHealthAdjuster
|
||||
key={`${componentName}${componentNumber}`}
|
||||
hitPointInfo={componentHitPointInfo}
|
||||
onSave={(diff) => this.handleHealthAdjusterSave(diff, component)}
|
||||
heading={`Hit Points (${componentName}${componentNumber})`}
|
||||
@@ -507,7 +508,8 @@ class VehiclePane extends React.PureComponent<Props, State> {
|
||||
const primaryComponentManageType = vehicle.getPrimaryComponentManageType();
|
||||
const enableConditionTracking = vehicle.getEnableConditionTracking();
|
||||
const enableFuelTracking = vehicle.getEnableFuelTracking();
|
||||
const shouldCoalesce = vehicle.isSpelljammer();
|
||||
const shouldCoalesce =
|
||||
vehicle.isSpelljammer() || vehicle.isElementalAirship();
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
@@ -550,7 +552,6 @@ class VehiclePane extends React.PureComponent<Props, State> {
|
||||
|
||||
renderVehicleName = (): React.ReactNode => {
|
||||
const { vehicle } = this.state;
|
||||
const { theme } = this.props;
|
||||
|
||||
if (!vehicle) {
|
||||
return null; //TODO could render a default empty state
|
||||
|
||||
@@ -96,6 +96,7 @@ export function generateVehicleBlockPrimaryProps(
|
||||
cargoCapacityInfo: vehicle.getVehicleCargoCapacityInfo(),
|
||||
conditionImmunities: vehicle.generateVehicleConditionImmunityNames(),
|
||||
creatureCapacityDescriptions: vehicle.getCreatureCapacityDescriptions(),
|
||||
creatureCapacityInfo: vehicle.getCreatureCapacity(),
|
||||
damageImmunities: vehicle.generateVehicleDamageImmunityNames(),
|
||||
displayType: vehicle.getDisplayType(),
|
||||
primaryProperties: deriveVehicleComponentPrimaryPropertiesProps(vehicle),
|
||||
|
||||
Reference in New Issue
Block a user