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

DaniSomoza / galactic-commander / 12444891208

21 Dec 2024 11:46AM UTC coverage: 52.036% (-13.6%) from 65.587%
12444891208

Pull #11

github

web-flow
Merge 9b5ea0e56 into 4f9f087f0
Pull Request #11: Build units

206 of 789 branches covered (26.11%)

Branch coverage included in aggregate %.

366 of 898 new or added lines in 85 files covered. (40.76%)

10 existing lines in 7 files now uncovered.

1417 of 2330 relevant lines covered (60.82%)

3.82 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 { IPlayer } from '../../types/IPlayer'
2
import { IUnit } from '../../types/IUnit'
3
import calculateCurrentPlayerEnergy from './calculateCurrentPlayerEnergy'
4✔
4
import calculateCurrentPlayerPopulation from './calculateCurrentPlayerPopulation'
4✔
5
import calculateMaxPlayerEnergy from './calculateMaxPlayerEnergy'
4✔
6
import calculateMaxPlayerPopulation from './calculateMaxPlayerPopulation'
4✔
7

8
function isValidUnitAmount(unit: IUnit, amount: number, player: IPlayer): boolean {
NEW
9
  const isValidAmountValue = unit.isHero ? amount === 1 : amount > 0
×
10

NEW
11
  if (!isValidAmountValue) {
×
NEW
12
    return false
×
13
  }
14

NEW
15
  if (unit.type === 'TROOP') {
×
NEW
16
    const playerMaxPopulation = calculateMaxPlayerPopulation(player)
×
NEW
17
    const currentPlayerPopulation = calculateCurrentPlayerPopulation(player)
×
18

NEW
19
    return currentPlayerPopulation + amount <= playerMaxPopulation
×
20
  }
21

NEW
22
  if (unit.type === 'SPACESHIP') {
×
NEW
23
    const playerMaxEnergy = calculateMaxPlayerEnergy(player)
×
NEW
24
    const currentPlayerEnergy = calculateCurrentPlayerEnergy(player)
×
25

NEW
26
    return currentPlayerEnergy + amount * unit.energyCost <= playerMaxEnergy
×
27
  }
28

29
  // TODO: implement defenses population ????
NEW
30
  return true
×
31
}
32

33
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