• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DaniSomoza / galactic-commander / 12728621970

11 Jan 2025 11:55PM UTC coverage: 47.963% (-4.1%) from 52.086%
12728621970

Pull #12

github

web-flow
Merge e784abf9e into a8e301a23
Pull Request #12: [fleets] Explore planets

214 of 913 branches covered (23.44%)

Branch coverage included in aggregate %.

154 of 505 new or added lines in 55 files covered. (30.5%)

10 existing lines in 9 files now uncovered.

1564 of 2794 relevant lines covered (55.98%)

3.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.73
/packages/game-engine/src/engine/units/isValidUnitAmount.ts
1
import { IFleet } from '../../types/IFleet'
2
import { IPlayer } from '../../types/IPlayer'
3
import { IPlayerUnits } from '../../types/IPlayerUnits'
4
import { IUnit } from '../../types/IUnit'
5
import calculateCurrentPlayerEnergy from './calculateCurrentPlayerEnergy'
4✔
6
import calculateCurrentPlayerPopulation from './calculateCurrentPlayerPopulation'
4✔
7
import calculateMaxPlayerEnergy from './calculateMaxPlayerEnergy'
4✔
8
import calculateMaxPlayerPopulation from './calculateMaxPlayerPopulation'
4✔
9

10
function isValidUnitAmount(
11
  unit: IUnit,
12
  amount: number,
13
  player: IPlayer,
14
  playerUnits: IPlayerUnits[],
15
  fleets: IFleet[]
16
): boolean {
UNCOV
17
  const isValidAmountValue = unit.isHero ? amount === 1 : amount > 0
×
18

19
  if (!isValidAmountValue) {
×
20
    return false
×
21
  }
22

23
  if (unit.type === 'TROOP') {
×
24
    const playerMaxPopulation = calculateMaxPlayerPopulation(player)
×
NEW
25
    const currentPlayerPopulation = calculateCurrentPlayerPopulation(player, playerUnits, fleets)
×
26

27
    return currentPlayerPopulation + amount <= playerMaxPopulation
×
28
  }
29

30
  if (unit.type === 'SPACESHIP') {
×
31
    const playerMaxEnergy = calculateMaxPlayerEnergy(player)
×
NEW
32
    const currentPlayerEnergy = calculateCurrentPlayerEnergy(player, playerUnits, fleets)
×
33

34
    return currentPlayerEnergy + amount * unit.energyCost <= playerMaxEnergy
×
35
  }
36

37
  // TODO: implement defenses population ????
38
  return true
×
39
}
40

41
export default isValidUnitAmount
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc