Skip to content

Commit

Permalink
Feat #19: Park rating warning days countdown (#23)
Browse files Browse the repository at this point in the history
* feat: move stalls & facilities group
Move stalls & facilities statistics group to make space for further additions.

* feat #19: Park rating warning days
  • Loading branch information
mrmagic2020 authored Jun 2, 2024
1 parent 77587e4 commit f41e9f0
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 60 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ and this project adheres to [Semantic Versioning].

- Add objective days left (if required).

- Add [#19](https://github.com/mrmagic2020/openrct2-dynamicdashboard/issues/19): park rating warning countdown.

### Changed

- Minor UI layout adjustments to prevent text omission.

- Move Stalls & Facilities statistics group to the third column, under Ride group.

### Removed

### Fixed

- Fix [[#16](https://github.com/mrmagic2020/openrct2-dynamicdashboard/issues/16)]: Month/Year park rating average bug.
- Fix [#16](https://github.com/mrmagic2020/openrct2-dynamicdashboard/issues/16): Month/Year park rating average bug.

- Fix data updating while not playing in a scenario.

Expand Down
1 change: 1 addition & 0 deletions lib/exporter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type ParkAndScenarioDataType =
| "park_rating_month_ave"
| "objective_status"
| "objective_days_left"
| "park_rating_warning_days"
| "entity_count_total"
| "entity_count_guest"
| "entity_count_staff"
Expand Down
5 changes: 5 additions & 0 deletions src/data/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ const baseData: BaseData = {
}
)
}),
park_rating_warning_days: new DataEntry({
key: LOCAL + ".park_rating_warning_days",
temporary: true,
store: store<number>(0)
}),

objective_status: new DataEntry({
key: LOCAL + ".objective_status",
Expand Down
51 changes: 38 additions & 13 deletions src/data/park_and_scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ import DateUtils from "../utils/date"
import MathUtils from "../utils/math_utils"

namespace ParkAndScenarioData {
export const MIN_PARK_RATING = 0
export const MAX_PARK_RATING = 1000

/**
* Updates the park data by setting the park value, park rating, and calculating the average park rating.
*/
function updateParkData(): void {
baseData.local.park_and_scenario.park_value.store.set(park.value)
baseData.local.park_and_scenario.park_rating.store.set(park.rating)
}

export namespace Objective {
export function parseStatus(status: ScenarioStatus): string {
switch (status) {
Expand Down Expand Up @@ -74,6 +63,24 @@ namespace ParkAndScenarioData {
}
}

export const MIN_PARK_RATING = 0
export const MAX_PARK_RATING = 1000
/**
* The maximum number of days with ratings lower than the minimum park rating before the park is forced to close.
*
* Derived from {@link https://github.com/OpenRCT2/OpenRCT2/blob/d4f97d3875ee6d11d37d8648874f80c421a76b04/src/openrct2/scenario/Scenario.cpp#L721 Scenario.cpp}
*/
export const MAX_RATING_WARNING_DAYS = 29
export const RATING_WARNING_DAYS_THRESHOLD = 0.25

/**
* Updates the park data by setting the park value and park rating.
*/
function updateParkData(): void {
baseData.local.park_and_scenario.park_value.store.set(park.value)
baseData.local.park_and_scenario.park_rating.store.set(park.rating)
}

function updateEntityCount(): void {
const guestCount = map.getAllEntities("guest").length
const staffCount = map.getAllEntities("staff").length
Expand Down Expand Up @@ -165,12 +172,29 @@ namespace ParkAndScenarioData {
baseData.local.park_and_scenario.park_size.store.set(park.parkSize)
}

function updateWarningDays(): void {
baseData.local.park_and_scenario.park_rating_warning_days.store.set(
scenario.parkRatingWarningDays
)
}

export function getWarningDaysPercentage(): number {
return (
1 -
MathUtils.normalise(
scenario.parkRatingWarningDays,
0,
MAX_RATING_WARNING_DAYS
)
)
}

export function update(): void {
updateParkData()
Objective.updateStatus()
Objective.updateDaysLeft()
updateEntityCount()
updateResearchProgress()
Objective.updateStatus()
Objective.updateDaysLeft()
}

/**
Expand Down Expand Up @@ -198,6 +222,7 @@ namespace ParkAndScenarioData {
HookManager.hook("interval.day", () => {
if (interval.isPaused) return
Objective.updateDaysLeft()
updateWarningDays()
})

interval.register(update, baseData.global.update_frequency.get() * 1000)
Expand Down
2 changes: 2 additions & 0 deletions src/languages/locale/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"park_rating_ave": "Average (all time): {PALESILVER}",
"park_rating_year_ave": "Average (year): {PALESILVER}",
"park_rating_month_ave": "Average (month): {PALESILVER}",
"park_rating_warning_days": "Warning countdown: {PALESILVER}",

"objective_status": "Status: {PALESILVER}",
"objective_status_inProgress": "In progress",
Expand Down Expand Up @@ -132,6 +133,7 @@
},
"tooltip": {
"entity_count_total_limitation": "An unsigned 16-bit integer has a range limit of 0~65535. If the entity count goes beyond that, the number ceases to change.",
"park_rating_warning_days": "When the park rating drops below 700, you will have 30 days to improve it before the park is forced to close.",
"options_update_running": "Dynamic Dashboard is running and updating automatically.",
"options_update_manual": "Dynamic Dashboard is partially paused. Update manually by clicking the 'Sync now' button.",
"options_update_paused": "Dynamic Dashboard is paused and not updating any data."
Expand Down
2 changes: 2 additions & 0 deletions src/languages/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"park_rating_ave": "平均值:{PALESILVER}",
"park_rating_year_ave": "平均值(当年):{PALESILVER}",
"park_rating_month_ave": "平均值(当月):{PALESILVER}",
"park_rating_warning_days": "警告天数:{PALESILVER}",

"objective_status": "状态:{PALESILVER}",
"objective_status_inProgress": "进行中",
Expand Down Expand Up @@ -132,6 +133,7 @@
},
"tooltip": {
"entity_count_total_limitation": "16位无符号整数的取值范围限制是0~65535。如果实体数量超过这个值,这个数字就会停止变化。",
"park_rating_warning_days": "一旦游乐园评分低于700,你会有30天时间改善评分,否则游乐园会被强制关闭。",
"options_update_running": "动态仪表正在运行。数据将自动刷新。",
"options_update_manual": "动态仪表正在运行。部分数据需要手动刷新。",
"options_update_paused": "动态仪表已暂停。数据不会刷新。"
Expand Down
Loading

0 comments on commit f41e9f0

Please sign in to comment.