Skip to content

Commit

Permalink
fix(game): 修复建筑配置不存在的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lovezhangchuangxin committed Dec 4, 2024
1 parent ce61265 commit bd20f22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/processor/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const produce = (planet: PlanetData, userDataMap: UserDataMap) => {
capacity: 0,
}

// 按优先级处理建筑
// 处理建筑
const allStructureIdSet = new Set(Object.keys(StructureConfigs))
const structureIds = Object.keys(planet.structures).filter((id) =>
allStructureIdSet.has(id),
Expand Down
11 changes: 6 additions & 5 deletions packages/game/src/views/planet/PlanetPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ const planetId = ref('')
const planetData = ref<PlanetData>()
const structures = ref<AllStructureData[]>([])
const timerId = ref<number | null>(null)
const allStructureIdSet = new Set(Object.keys(StructureConfigs))
// 已经使用的电力
const electricityUsed = computed(() => {
Expand Down Expand Up @@ -274,11 +275,11 @@ const getMyData = () => {
// 暂时只考虑一个星球
planetId.value = Object.keys(data.planets)[0]
planetData.value = data.planets[planetId.value]
structures.value = Object.values(
data.planets[planetId.value].structures,
).sort((a, b) => {
return StructureOrder[a.id] - StructureOrder[b.id]
})
structures.value = Object.values(data.planets[planetId.value].structures)
.filter((s) => allStructureIdSet.has(s.id))
.sort((a, b) => {
return StructureOrder[a.id] - StructureOrder[b.id]
})
} else {
toast.error(response.msg)
}
Expand Down

0 comments on commit bd20f22

Please sign in to comment.