Skip to content

Commit

Permalink
Show unit outline for units that can be sabotaged, even if they canno…
Browse files Browse the repository at this point in the history
…t be attacked by the saboteur.

GitOrigin-RevId: efdef113cc35a91c89abffca2abb98335e615801
  • Loading branch information
cpojer committed May 9, 2024
1 parent 5bf853f commit 4dab57a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
10 changes: 6 additions & 4 deletions athena/lib/getSabotageableVectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import { Ability } from '../info/Unit.tsx';
import Vector from '../map/Vector.tsx';
import MapData from '../MapData.tsx';

export default function getSabotageableVectors(map: MapData, position: Vector) {
export default function getSabotageableVectors(
map: MapData,
position: Vector,
): ReadonlySet<Vector> {
const unitA = map.units.get(position);
const sabotageTypes = unitA?.info.configuration.sabotageTypes;
return new Set(
sabotageTypes && unitA.info.hasAbility(Ability.Sabotage)
unitA?.info.hasAbility(Ability.Sabotage)
? position.adjacent().filter((vector) => {
const unitB = map.units.get(vector);
return (
unitB &&
map.isOpponent(unitB, unitA) &&
sabotageTypes.has(unitB.info.type)
unitA.info.canSabotageUnitType(unitB.info)
);
})
: [],
Expand Down
14 changes: 9 additions & 5 deletions hera/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const MapComponent = ({
radius &&
((hasRadius &&
(radius.type === RadiusType.Attackable ||
radius.type === RadiusType.Sabotage ||
radius.type === RadiusType.Defense ||
radius.type === RadiusType.Rescue ||
radius.type === RadiusType.Highlight)) ||
Expand Down Expand Up @@ -255,7 +256,8 @@ const MapComponent = ({
radius &&
(radius.type === RadiusType.Defense ||
radius.type === RadiusType.Rescue ||
radius.type === RadiusType.Attackable))
radius.type === RadiusType.Attackable ||
radius.type === RadiusType.Sabotage))
)
}
onAnimationComplete={onAnimationComplete}
Expand All @@ -265,11 +267,13 @@ const MapComponent = ({
? 'defense'
: radius.type === RadiusType.Rescue
? 'rescue'
: radius.type !== RadiusType.Highlight
? canAttackEntity(unit)
? 'attack'
: radius.type === RadiusType.Sabotage
? 'sabotage'
: radius.type !== RadiusType.Highlight
? canAttackEntity(unit)
? 'attack'
: undefined
: undefined
: undefined
: undefined
}
position={vector}
Expand Down
2 changes: 2 additions & 0 deletions hera/Radius.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export enum RadiusType {
Lightning,
Move,
Rescue,
Sabotage,
}

export type RadiusInfo = Readonly<{
Expand Down Expand Up @@ -396,6 +397,7 @@ const colors: Record<RadiusType, string> = {
[RadiusType.Move]: css`
${vars.set('color', '19, 19, 209')}
`,
[RadiusType.Sabotage]: ``,
};

const alternateAttackStyle = css`
Expand Down
4 changes: 2 additions & 2 deletions hera/Unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export default function UnitTile({
highlightStyle?: 'move' | 'idle' | 'idle-null' | 'move-null' | undefined;
maybeOutline?: boolean;
onAnimationComplete?: (position: Vector, animation: UnitAnimation) => void;
outline?: 'attack' | 'defense' | 'rescue' | undefined;
outline?: 'attack' | 'sabotage' | 'defense' | 'rescue' | undefined;
position?: Vector;
power?: boolean;
requestFrame?: RequestFrameFunction;
Expand Down Expand Up @@ -823,7 +823,7 @@ export default function UnitTile({
baseUnitStyle,
player === 0 && neutralStyle,
(maybeOutline || highlightOutline) && maybeOutlineStyle,
outline === 'attack'
outline === 'attack' || outline === 'sabotage'
? biome === Biome.Volcano || biome === Biome.Luna
? alternateAttackOutlineStyle
: attackOutlineStyle
Expand Down
2 changes: 1 addition & 1 deletion hera/behavior/Sabotage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Sabotage {
radius: {
fields,
path: first ? [first] : null,
type: RadiusType.Attackable,
type: RadiusType.Sabotage,
},
};
}
Expand Down

0 comments on commit 4dab57a

Please sign in to comment.