Skip to content

Commit

Permalink
Filter units/buildings with biome restrictions in the Unit and TileCard.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: ea20e8db437c79ab3efe7ee02e0ca9932ac255ef
  • Loading branch information
cpojer committed Aug 6, 2024
1 parent 8f000b4 commit b29169f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion hera/card/TileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { mapUnitsWithContentRestriction } from '@deities/athena/info/Unit.tsx';
import getAttributeRange, {
getAttributeRangeValue,
} from '@deities/athena/lib/getAttributeRange.tsx';
import getBiomeUnitRestrictions from '@deities/athena/lib/getBiomeUnitRestrictions.tsx';
import { singleTilesToModifiers } from '@deities/athena/lib/singleTilesToModifiers.tsx';
import { Biome } from '@deities/athena/map/Biome.tsx';
import {
Expand Down Expand Up @@ -181,10 +182,11 @@ const TileMovement = memo(function TileMovement({
return null;
}

const biomeUnitRestrictions = getBiomeUnitRestrictions(biome);
const availableUnits = mapUnitsWithContentRestriction(
(unit) => unit.create(player),
allSkills,
);
).filter((unit) => !biomeUnitRestrictions?.has(unit.info.type));
const movementTypes = sortBy(
[
...groupBy(Object.values(MovementTypes), (movementType) =>
Expand Down
16 changes: 13 additions & 3 deletions hera/card/UnitCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import getAttackStatusEffect from '@deities/athena/lib/getAttackStatusEffect.tsx
import getAttributeRange, {
getAttributeRangeValue,
} from '@deities/athena/lib/getAttributeRange.tsx';
import getBiomeBuildingRestrictions from '@deities/athena/lib/getBiomeBuildingRestrictions.tsx';
import getBiomeStyle from '@deities/athena/lib/getBiomeStyle.tsx';
import getBiomeUnitRestrictions from '@deities/athena/lib/getBiomeUnitRestrictions.tsx';
import getDefenseStatusEffect from '@deities/athena/lib/getDefenseStatusEffect.tsx';
import withModifiers from '@deities/athena/lib/withModifiers.tsx';
import { Biome } from '@deities/athena/map/Biome.tsx';
Expand Down Expand Up @@ -487,10 +489,12 @@ const Weapon = memo(function WeaponAttack({
() => new Set(map.getPlayers().flatMap(({ skills }) => [...skills])),
[map],
);
const biomeBuildingRestrictions = getBiomeBuildingRestrictions(biome);
const biomeUnitRestrictions = getBiomeUnitRestrictions(biome);
const availableUnits = mapUnitsWithContentRestriction(
(unit) => unit.create(opponent),
allSkills,
);
).filter((unit) => !biomeUnitRestrictions?.has(unit.info.type));
const isLeader = unit.isLeader();
const attackStatusEffect = getAttackStatusEffect(map, unit, vector, tile);
const damageRange = getAttributeRange(
Expand Down Expand Up @@ -561,12 +565,18 @@ const Weapon = memo(function WeaponAttack({
);

const buildings = [];
if (entities.has(EntityType.Building)) {
if (
entities.has(EntityType.Building) &&
!biomeBuildingRestrictions.has(House)
) {
const house = House.create(opponent);
buildings.push(house);
damage.push([getLikelyDamage(house, -1)]);
}
if (entities.has(EntityType.Structure)) {
if (
entities.has(EntityType.Structure) &&
!biomeBuildingRestrictions.has(VerticalBarrier)
) {
const structure = VerticalBarrier.create(0);
buildings.push(structure);
damage.push([getLikelyDamage(structure, -1)]);
Expand Down

0 comments on commit b29169f

Please sign in to comment.