Skip to content

Commit

Permalink
Add a Power to the Cannon skill.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 8e2582d19a76be27a15d8f5b7df66eecd2e75a12
  • Loading branch information
cpojer committed Oct 28, 2024
1 parent 3551338 commit ddb51f3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
17 changes: 16 additions & 1 deletion apollo/actions/applyPower.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export function getUnitsToDamage(
}

export function onPowerUnitUpgrade(skill: Skill, unit: Unit) {
if (skill === Skill.RecoverAirUnits) {
if (
skill === Skill.RecoverAirUnits ||
(skill === Skill.BuyUnitCannon && unit.isUnfolded() && unit.isCompleted())
) {
return unit.recover();
}

Expand Down Expand Up @@ -152,6 +155,18 @@ export default function applyPower(skill: Skill, map: MapData) {
});
}

if (skill === Skill.BuyUnitCannon) {
map = map.copy({
units: map.units.map((unit) =>
unit.isUnfolded() &&
unit.isCompleted() &&
map.matchesPlayer(player, unit)
? unit.recover()
: unit,
),
});
}

if (skill === Skill.Shield) {
map = map.copy({
units: map.units.map((unit) =>
Expand Down
14 changes: 13 additions & 1 deletion athena/info/Skill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const skillConfig: Record<
cost: 800,
group: SkillGroup.Attack,
},
[Skill.BuyUnitCannon]: { cost: 1000, group: SkillGroup.Unlock },
[Skill.BuyUnitCannon]: { charges: 4, cost: 1000, group: SkillGroup.Unlock },
[Skill.BuyUnitBrute]: { charges: 5, cost: 1000, group: SkillGroup.Unlock },
[Skill.DecreaseUnitCostAttackAndDefenseDecreaseMinor]: {
charges: 3,
Expand Down Expand Up @@ -1127,6 +1127,18 @@ const getSkillActiveUnitTypes = (

const list = [];

if (skill === Skill.BuyUnitCannon) {
for (const [vector, unit] of map.units) {
if (
unit.isUnfolded() &&
unit.isCompleted() &&
map.matchesPlayer(unit, player)
) {
list.push(vector);
}
}
}

for (const [vector, unit] of map.units) {
if (
map.matchesPlayer(unit, player) &&
Expand Down
1 change: 1 addition & 0 deletions hera/behavior/activatePower/activatePowerAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default async function activatePowerAction(
skill === Skill.RecoverAirUnits ||
skill === Skill.SpawnUnitInfernoJetpack ||
skill === Skill.UnlockZombie ||
skill === Skill.BuyUnitCannon ||
skill === Skill.Shield) &&
state.map.matchesPlayer(unit, player) &&
matchesActiveType(unitTypes, unit, vector),
Expand Down
6 changes: 6 additions & 0 deletions hera/ui/SkillDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ const getExtraDescription = (skill: Skill, color: BaseColor) => {

const getExtraPowerDescription = (skill: Skill, color: BaseColor) => {
switch (skill) {
case Skill.BuyUnitCannon:
return (
<fbt desc="Additional skill description">
All unfolded units recover and can act again.
</fbt>
);
case Skill.UnitBattleShipMoveAndAct:
return (
<fbt desc="Additional skill description">
Expand Down

0 comments on commit ddb51f3

Please sign in to comment.