Skip to content

Commit

Permalink
map building rules
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Nov 29, 2024
1 parent 653ae14 commit ebcf716
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/setup/MapRandomizer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<button class="btn btn-sm btn-secondary me-2" @click="mapGenerator.randomize()">{{t('action.randomize')}}</button>
<button class="btn btn-sm btn-secondary me-2" @click="mapGenerator.reset()">{{t('action.reset')}}</button>
<button class="btn btn-sm btn-secondary me-2" @click="mapGenerator.reset()" v-if="!hatLostFleet">{{t('action.reset')}}</button>
<div class="row mt-3">
<div class="col">
<div class="mapWrapper" :class="{'alert':!isValid, 'alert-danger':!isValid}">
Expand Down
19 changes: 15 additions & 4 deletions src/services/map/MapGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,19 @@ export default class MapGenerator {
else {
this._spaceSectors.value = INITIAL_SETUP_LOST_FLEET_PLAYER_2
}
this._deepSpaceSectors.value = this.getRandomDeepSpaceSectors()
this._interspaces.value = this.getRandomInterspaces()
}
this.randomize()
}
else {
if (this.playerCount > 2) {
this._spaceSectors.value = INITIAL_SETUP_PLAYER_34
}
else {
this._spaceSectors.value = INITIAL_SETUP_PLAYER_2
}
this._spaceSectors.value.forEach(sector => sector.reset())
this._deepSpaceSectors.value = []
this._interspaces.value = []
}
this._spaceSectors.value.forEach(sector => sector.reset())
}

randomize() : void {
Expand Down Expand Up @@ -99,6 +98,18 @@ export default class MapGenerator {
}
}
}
if (this.hasLostFleet) {
const centerSectors = ['01','02','03','04']
if (this.playerCount == 2 && !centerSectors.includes(this.spaceSectors[3].id)) {
return false
}
if (this.playerCount == 3 && !centerSectors.includes(this.spaceSectors[4].id)) {
return false
}
if (this.playerCount == 4 && (!centerSectors.includes(this.spaceSectors[4].id) || !centerSectors.includes(this.spaceSectors[5].id))) {
return false
}
}
return true
}

Expand Down

0 comments on commit ebcf716

Please sign in to comment.