• 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

16.67
/packages/game-api-microservice/src/utils/cleanPlanetFields.ts
1
import { IPlanetDocument } from 'game-engine/models/PlanetModel'
2
import { IPlayerDocument } from 'game-engine/models/PlayerModel'
3
import { IPlanet } from 'game-engine/types/IPlanet'
4
import { PlanetType } from '../types/Planet'
5

6
function cleanPlanetFields(planet: IPlanetDocument | IPlanet, player: IPlayerDocument): PlanetType {
7
  const {
8
    name,
9
    universeId,
10
    imgUrl,
11
    ownerId,
12
    colonizedAt,
13
    resources,
14
    resourceQuality,
15
    lastResourceProductionTime,
16
    coordinates,
17
    isSpecial,
18
    isPrincipal,
19
    isUnderConquer,
20
    specials,
21
    unitBuild,
22
    units,
23
    exploredBy
UNCOV
24
  } = planet
×
25

NEW
26
  const isExplored = exploredBy.some((playerId) => playerId === player._id.toString())
×
27

NEW
28
  if (!isExplored) {
×
NEW
29
    const UNEXPLORED_PLANET: PlanetType = {
×
30
      name: '',
31
      universeId,
32
      imgUrl: '/planets/unexplored_planet.jpeg',
33
      ownerId: null,
34
      colonizedAt: 0,
35
      resources: 0,
36
      resourceQuality: 0,
37
      lastResourceProductionTime: 0,
38
      coordinates: planet.coordinates,
39
      isSpecial: false,
40
      isPrincipal: false,
41
      isUnderConquer: false,
42
      isExplored: false,
43
      specials: [],
44
      unitBuild: EMPTY_BUILD_UNITS_QUEUE,
45
      units: [],
46
      exploredBy: []
47
    }
48

NEW
49
    return UNEXPLORED_PLANET
×
50
  }
51

NEW
52
  const isPlayerPlanet = player._id.toString() === ownerId
×
53

UNCOV
54
  return {
×
55
    name,
56
    universeId,
57
    imgUrl,
58
    ownerId,
59
    colonizedAt,
60
    resources,
61
    resourceQuality,
62
    lastResourceProductionTime,
63
    coordinates,
64
    isSpecial,
65
    isPrincipal,
66
    isUnderConquer,
67
    isExplored,
68
    specials,
69
    unitBuild: isPlayerPlanet ? unitBuild : EMPTY_BUILD_UNITS_QUEUE,
×
70
    units,
71
    exploredBy: []
72
  }
73
}
74

75
export default cleanPlanetFields
2✔
76

77
const EMPTY_BUILD_UNITS_QUEUE = {
2✔
78
  troops: {
79
    activeBuild: undefined,
80
    queue: []
81
  },
82
  spaceships: {
83
    activeBuild: undefined,
84
    queue: []
85
  },
86
  defenses: {
87
    activeBuild: undefined,
88
    queue: []
89
  }
90
}
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

© 2025 Coveralls, Inc