Skip to content

Commit

Permalink
terrain priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Dec 6, 2024
1 parent 67bb1c3 commit 95a9d13
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/components/turn/botAction/ActionTransformAndBuild.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
</template>
<template v-else>
<li v-if="isPowerMongers"><AppIcon type="action" name="faction-action" class="factionActionIcon"/><span v-html="t('botAction.transformAndBuild.tiebreaker.factionPowerMongers')"></span></li>
<li v-html="t('botAction.transformAndBuild.tiebreaker.terrainPriority',{terrainPriority:botAction.terrainPriority})"></li>
<li>
<span v-html="t('botAction.transformAndBuild.tiebreaker.terrainPriority',{terrainPriority:botAction.terrainPriority})"></span>
<TerrainPriorities v-if="botAction.terrainPriority" :terrainPriority="botAction.terrainPriority" :navigationState="navigationState"/>
</li>
<li v-html="t('botAction.transformAndBuild.tiebreaker.structureClosest')"></li>
<li v-html="t('botAction.transformAndBuild.tiebreaker.directionalSelection')"></li>
</template>
Expand Down Expand Up @@ -65,6 +68,7 @@ import { useStateStore } from '@/store/state'
import NavigationState from '@/util/NavigationState'
import BotFaction from '@/services/enum/BotFaction'
import Structure from '@/services/enum/Structure'
import TerrainPriorities from './TerrainPriorities.vue'
export default defineComponent({
name: 'ActionTransformAndBuild',
Expand All @@ -73,7 +77,8 @@ export default defineComponent({
AppIcon,
SupportInfo,
Upgrade,
ModalDialog
ModalDialog,
TerrainPriorities
},
setup() {
const { t } = useI18n()
Expand Down
59 changes: 59 additions & 0 deletions src/components/turn/botAction/TerrainPriorities.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div class="mt-1 mb-1">
<div v-for="(terrain,index) of terrains" :key="terrain" class="terrain">
<svg width="30" height="30" viewBox="0 0 100 100" class="arrow" v-if="index > 0">
<polygon points="25,15 55,50 25,85" fill="#fff" stroke="#000" stroke-width="5px"/>
</svg>
<AppIcon type="terrain" :name="terrain" extension="webp" class="terrainIcon"/>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue'
import AppIcon from '@/components/structure/AppIcon.vue'
import NavigationState from '@/util/NavigationState'
import TerrainPriority from '@/services/enum/TerrainPriority'
import Terrain from '@/services/enum/Terrain'
import getPriorityTerrains from '@/util/getPriorityTerrains'
export default defineComponent({
name: 'TerrainPriorities',
components: {
AppIcon
},
props: {
terrainPriority: {
type: Object as PropType<TerrainPriority>,
required: true
},
navigationState: {
type: NavigationState,
required: true
}
},
computed: {
terrains() : Terrain[] {
const botTerrain = this.navigationState.botTerrain ?? Terrain.LAKE
return getPriorityTerrains(botTerrain, this.terrainPriority)
}
}
})
</script>

<style lang="scss" scoped>
.terrain {
position: relative;
display: inline-block;
.arrow {
top: 5px;
left: -10px;
position: absolute;
z-index: 10;
}
.terrainIcon {
height: 2.5rem;
filter: drop-shadow(2px 2px 2px #888);
}
}
</style>
3 changes: 3 additions & 0 deletions src/util/NavigationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MAX_TURN } from '@/util/getTurnOrder'
import ScienceDiscipline from '@/services/enum/ScienceDiscipline'
import getRoundScoreTile, { RoundScoreTile } from './getRoundScoreTile'
import getRoundScoreFinalTile from './getRoundScoreFinalTile'
import Terrain from '@/services/enum/Terrain'

export default class NavigationState {

Expand All @@ -21,6 +22,7 @@ export default class NavigationState {
readonly player : number
readonly bot : number
readonly botFaction? : BotFaction
readonly botTerrain? : Terrain
readonly cardDeck? : CardDeck
readonly passVictoryPoints?: number
readonly preferredScienceDiscipline?: ScienceDiscipline
Expand All @@ -39,6 +41,7 @@ export default class NavigationState {

if (this.bot > 0) {
this.botFaction = setup.playerSetup.botFaction[this.bot - 1]
this.botTerrain = (setup.botTerrain ?? [])[this.bot - 1]

// card deck: draw next card for bot
this.cardDeck = getCardDeck(state, this.round, this.turn, this.bot)
Expand Down
2 changes: 1 addition & 1 deletion src/util/getPriorityTerrains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function getPriorityTerrains(terrain: Terrain, terrainPriority: T
case TerrainPriority.B:
switch (terrain) {
case Terrain.LAKE: return [Terrain.LAKE, Terrain.FOREST, Terrain.SWAMP, Terrain.MOUNTAIN, Terrain.DESERT, Terrain.PLAINS, Terrain.WASTELAND]
case Terrain.PLAINS: return [Terrain.PLAINS,Terrain.SWAMP,Terrain.DESERT,Terrain.LAKE,Terrain.MOUNTAIN,Terrain.WASTELAND,Terrain.FOREST]
case Terrain.PLAINS: return [Terrain.PLAINS, Terrain.SWAMP, Terrain.DESERT, Terrain.LAKE, Terrain.MOUNTAIN, Terrain.WASTELAND, Terrain.FOREST]
case Terrain.FOREST: return [Terrain.FOREST, Terrain.MOUNTAIN, Terrain.LAKE, Terrain.WASTELAND, Terrain.PLAINS, Terrain.SWAMP, Terrain.DESERT]
case Terrain.WASTELAND: return [Terrain.WASTELAND, Terrain.DESERT, Terrain.MOUNTAIN, Terrain.PLAINS, Terrain.LAKE, Terrain.FOREST, Terrain.SWAMP]
case Terrain.SWAMP: return [Terrain.SWAMP, Terrain.LAKE, Terrain.PLAINS, Terrain.FOREST, Terrain.WASTELAND, Terrain.DESERT, Terrain.MOUNTAIN]
Expand Down

0 comments on commit 95a9d13

Please sign in to comment.