Skip to content

Commit

Permalink
Do not consume charges when a power activates through a crystal.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 2f8946a284d4d5169f7c5c987eb7bd58f90eae72
  • Loading branch information
cpojer committed Oct 28, 2024
1 parent 1f7a6d4 commit 5f779cc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apollo/ActionMap.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
["Rescue", [37, ["type", "from", "to", "player", "name"]]],
["ReceiveReward", [38, ["type", "player", "reward", "permanent"]]],
["BuySkill", [39, ["type", "from", "skill", "player"]]],
["ActivatePower", [40, ["type", "skill", "units"]]],
["ActivatePower", [40, ["type", "skill", "units", "free"]]],
["PreviousTurnGameOver", [41, ["type", "fromPlayer"]]],
["SecretDiscovered", [42, ["type", "objective", "toPlayer"]]],
["OptionalObjective", [43, ["type", "objective", "objectiveId", "toPlayer"]]],
Expand Down
1 change: 1 addition & 0 deletions apollo/ActionResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export type BuySkillActionResponse = Readonly<{
}>;

export type ActivatePowerActionResponse = Readonly<{
free?: boolean;
skill: Skill;
type: 'ActivatePower';
units?: ImmutableMap<Vector, Unit>;
Expand Down
1 change: 1 addition & 0 deletions apollo/Effects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const handleDefaultEffects = (
const { activateOnInvasion } = getSkillConfig(skill);
if (activateOnInvasion) {
const activatePowerActionResponse = {
free: true,
skill,
type: 'ActivatePower',
} as const;
Expand Down
4 changes: 2 additions & 2 deletions apollo/actions/applyActionResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ export default function applyActionResponse(
});
}
case 'ActivatePower': {
const { skill, units } = actionResponse;
const { free, skill, units } = actionResponse;
const playerA = map.getCurrentPlayer();
const { charges } = getSkillConfig(skill);

Expand All @@ -584,7 +584,7 @@ export default function applyActionResponse(
map.teams,
playerA
.activateSkill(skill)
.setCharge(playerA.charge - (charges || 0) * Charge),
.setCharge(playerA.charge - (free ? 0 : (charges || 0) * Charge)),
),
units: units ? map.units.merge(units) : map.units,
}),
Expand Down
8 changes: 4 additions & 4 deletions tests/__tests__/AIBehavior.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ test('skills will only be activated if there are enough units that can be acted
);

expect(snapshotGameState(gameStateA)).toMatchInlineSnapshot(`
"ActivatePower { skill: 3, units: [] }
"ActivatePower { skill: 3, units: [], free: null }
AttackUnit (3,3 → 3,2) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 84, ammo: [ [ 1, 6 ] ] }, unitB: DryUnit { health: 5, ammo: [ [ 1, 6 ] ] }, chargeA: 186, chargeB: 356 }
AttackUnit (2,3 → 2,2) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 84, ammo: [ [ 1, 6 ] ] }, unitB: DryUnit { health: 5, ammo: [ [ 1, 6 ] ] }, chargeA: 372, chargeB: 712 }
AttackUnit (1,2 → 2,2) { hasCounterAttack: false, playerA: 2, playerB: 1, unitA: DryUnit { health: 100, ammo: [ [ 1, 6 ] ] }, unitB: null, chargeA: 378, chargeB: 730 }
Expand Down Expand Up @@ -1107,7 +1107,7 @@ test('skills will only be activated if there are enough units that can be acted
"AttackUnit (3,3 → 3,2) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 90, ammo: [ [ 1, 7 ] ] }, unitB: DryUnit { health: 45, ammo: [ [ 1, 7 ] ] }, chargeA: 7654, chargeB: 302 }
AttackUnit (2,3 → 2,2) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 90, ammo: [ [ 1, 7 ] ] }, unitB: DryUnit { health: 45, ammo: [ [ 1, 7 ] ] }, chargeA: 7808, chargeB: 604 }
AttackUnit (1,2 → 2,2) { hasCounterAttack: false, playerA: 2, playerB: 1, unitA: DryUnit { health: 100, ammo: [ [ 1, 7 ] ] }, unitB: null, chargeA: 7889, chargeB: 851 }
ActivatePower { skill: 24, units: [] }
ActivatePower { skill: 24, units: [], free: null }
Move (1,2 → 3,1) { fuel: 46, completed: null, path: [2,2 → 2,1 → 3,1] }
AttackUnit (3,1 → 3,2) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 95, ammo: [ [ 1, 6 ] ] }, unitB: DryUnit { health: 24, ammo: [ [ 1, 6 ] ] }, chargeA: 454, chargeB: 966 }
Move (2,3 → 2,2) { fuel: 48, completed: null, path: [2,2] }
Expand All @@ -1129,7 +1129,7 @@ test('skills will only be activated if there are enough units that can be acted
);

expect(snapshotGameState(gameStateD)).toMatchInlineSnapshot(`
"ActivatePower { skill: 24, units: [] }
"ActivatePower { skill: 24, units: [], free: null }
CompleteUnit (1,2)
Move (2,3 → 1,3) { fuel: 48, completed: null, path: [1,3] }
Move (3,3 → 2,3) { fuel: 48, completed: null, path: [2,3] }
Expand Down Expand Up @@ -1168,7 +1168,7 @@ test('activates skills where the unit ratio does not matter', async () => {
);

expect(snapshotGameState(gameStateA)).toMatchInlineSnapshot(`
"ActivatePower { skill: 12, units: [1,2 → Bazooka Bear { id: 53, health: 100, player: 2, fuel: 100, ammo: [ [ 1, 5 ] ], name: 'Bazoo' }, 2,3 → Bazooka Bear { id: 53, health: 100, player: 2, fuel: 100, ammo: [ [ 1, 5 ] ], name: 'Taylor' }] }
"ActivatePower { skill: 12, units: [1,2 → Bazooka Bear { id: 53, health: 100, player: 2, fuel: 100, ammo: [ [ 1, 5 ] ], name: 'Bazoo' }, 2,3 → Bazooka Bear { id: 53, health: 100, player: 2, fuel: 100, ammo: [ [ 1, 5 ] ], name: 'Taylor' }], free: null }
AttackUnit (2,3 → 2,2) { hasCounterAttack: false, playerA: 2, playerB: 1, unitA: DryUnit { health: 100, ammo: [ [ 1, 4 ] ] }, unitB: null, chargeA: 123, chargeB: 375 }
AttackUnit (1,2 → 1,1) { hasCounterAttack: false, playerA: 2, playerB: 1, unitA: DryUnit { health: 100, ammo: [ [ 1, 4 ] ] }, unitB: null, chargeA: 246, chargeB: 750 }
AttackUnit (3,3 → 3,2) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 89, ammo: [ [ 1, 6 ] ] }, unitB: DryUnit { health: 48, ammo: [ [ 1, 6 ] ] }, chargeA: 351, chargeB: 945 }
Expand Down
8 changes: 4 additions & 4 deletions tests/__tests__/Objective.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ test('game over through activating a power', async () => {
expect(snapshotEncodedActionResponse(gameActionResponseA))
.toMatchInlineSnapshot(`
"EndTurn { current: { funds: 500, player: 1 }, next: { funds: 500, player: 2 }, round: 1, rotatePlayers: false, supply: null, miss: false }
ActivatePower { skill: 26, units: [] }
ActivatePower { skill: 26, units: [], free: false }
AttackUnitGameOver { fromPlayer: 1, toPlayer: 2 }
GameEnd { objective: null, objectiveId: null, toPlayer: 2, chaosStars: null }"
`);
Expand Down Expand Up @@ -528,7 +528,7 @@ test('game over through activating a power', async () => {
expect(snapshotEncodedActionResponse(gameActionResponseB))
.toMatchInlineSnapshot(`
"EndTurn { current: { funds: 500, player: 1 }, next: { funds: 500, player: 2 }, round: 1, rotatePlayers: false, supply: null, miss: false }
ActivatePower { skill: 26, units: [] }
ActivatePower { skill: 26, units: [], free: false }
GameEnd { objective: { amount: 1, bonus: undefined, completed: Set(0) {}, hidden: false, optional: false, players: [], reward: null, type: 9 }, objectiveId: 0, toPlayer: 2, chaosStars: null }"
`);
});
Expand Down Expand Up @@ -584,7 +584,7 @@ test('game over through activating a power can beat more than one player', async
expect(snapshotEncodedActionResponse(gameActionResponseA))
.toMatchInlineSnapshot(`
"EndTurn { current: { funds: 500, player: 1 }, next: { funds: 500, player: 2 }, round: 1, rotatePlayers: false, supply: null, miss: false }
ActivatePower { skill: 26, units: [] }
ActivatePower { skill: 26, units: [], free: false }
AttackUnitGameOver { fromPlayer: 1, toPlayer: 2 }"
`);

Expand All @@ -600,7 +600,7 @@ test('game over through activating a power can beat more than one player', async
expect(snapshotEncodedActionResponse(gameActionResponseB))
.toMatchInlineSnapshot(`
"EndTurn { current: { funds: 500, player: 1 }, next: { funds: 500, player: 2 }, round: 1, rotatePlayers: false, supply: null, miss: false }
ActivatePower { skill: 26, units: [] }
ActivatePower { skill: 26, units: [], free: false }
AttackUnitGameOver { fromPlayer: 1, toPlayer: 2 }
AttackUnitGameOver { fromPlayer: 3, toPlayer: 2 }
GameEnd { objective: null, objectiveId: null, toPlayer: 2, chaosStars: null }"
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/Power.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test('skills are active until the beginning of the next turn', async () => {
AttackUnit (1,2 → 1,1) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 87, ammo: [ [ 1, 6 ] ] }, unitB: DryUnit { health: 40, ammo: [ [ 1, 6 ] ] }, chargeA: 133, chargeB: 15259 }
EndTurn { current: { funds: 500, player: 2 }, next: { funds: 500, player: 1 }, round: 2, rotatePlayers: false, supply: null, miss: false }
AttackUnit (1,1 → 1,2) { hasCounterAttack: true, playerA: 1, playerB: 2, unitA: DryUnit { health: 9, ammo: [ [ 1, 5 ] ] }, unitB: DryUnit { health: 70, ammo: [ [ 1, 5 ] ] }, chargeA: 15154, chargeB: 196 }
ActivatePower { skill: 3, units: [] }
ActivatePower { skill: 3, units: [], free: false }
AttackUnit (2,2 → 2,3) { hasCounterAttack: true, playerA: 1, playerB: 2, unitA: DryUnit { health: 84, ammo: [ [ 1, 6 ] ] }, unitB: DryUnit { health: 5, ammo: [ [ 1, 6 ] ] }, chargeA: 6186, chargeB: 552 }
EndTurn { current: { funds: 500, player: 1 }, next: { funds: 500, player: 2 }, round: 2, rotatePlayers: false, supply: null, miss: false }
AttackUnit (3,2 → 2,2) { hasCounterAttack: true, playerA: 2, playerB: 1, unitA: DryUnit { health: 92, ammo: [ [ 1, 6 ] ] }, unitB: DryUnit { health: 6, ammo: [ [ 1, 5 ] ] }, chargeA: 693, chargeB: 6522 }
Expand Down

0 comments on commit 5f779cc

Please sign in to comment.