Skip to content

Commit

Permalink
Merge pull request #1354 from solaris-games/dev
Browse files Browse the repository at this point in the history
Update 250.2
  • Loading branch information
SpacialCircumstances authored Jan 29, 2025
2 parents ac36e08 + 4891032 commit 6adfa01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/src/game/playerNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PlayerNames {
this.container.removeChildren()

for (let player of this.game!.galaxy.players) {
const empireCenter = gameHelper.getPlayerEmpireCenter(this.game!, player)
const empireCenter = gameHelper.getPlayerTerritoryCenter(this.game!, player)

if (empireCenter == null) {
continue
Expand Down
13 changes: 13 additions & 0 deletions client/src/services/gameHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,19 @@ class GameHelper {
return `${dayOfWeek[date.getDay()]} ${date.getDate()} ${monthOfYear[date.getMonth()]} ${date.getHours() < 10 ? '0' + date.getHours() : date.getHours()}:${date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()}`
}

getPlayerTerritoryCenter(game: Game, player: Player) {
const playerStars = this.getStarsOwnedByPlayer(player, game.galaxy.stars)

if (!playerStars.length) {
return null
}

// Work out the center point of all stars
const centerX = playerStars.reduce((sum, s) => sum + s.location.x, 0) / playerStars.length
const centerY = playerStars.reduce((sum, s) => sum + s.location.y, 0) / playerStars.length
return { x: centerX, y: centerY }
}

getPlayerEmpireCenter (game: Game, player: Player) {
// Get all of the player's stars.
const playerStars = this.getStarsOwnedByPlayer(player, game.galaxy.stars)
Expand Down

0 comments on commit 6adfa01

Please sign in to comment.