From 714332a91d050538b69d1a8b00b741b7537dc2c5 Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 23 May 2020 10:35:30 +0200 Subject: [PATCH] Further improvements of unlock notification --- src/js/game/hub_goals.js | 11 +++-- src/js/game/hud/parts/unlock_notification.js | 7 +-- src/js/game/tutorial_goals.js | 51 +------------------- src/js/game/tutorial_goals_mappings.js | 51 ++++++++++++++++++++ translations/base-en.yaml | 5 ++ 5 files changed, 68 insertions(+), 57 deletions(-) create mode 100644 src/js/game/tutorial_goals_mappings.js diff --git a/src/js/game/hub_goals.js b/src/js/game/hub_goals.js index 531d2fda..6c155165 100644 --- a/src/js/game/hub_goals.js +++ b/src/js/game/hub_goals.js @@ -188,13 +188,11 @@ export class HubGoals extends BasicSerializableObject { return; } - const reward = enumHubGoalRewards.no_reward; - this.currentGoal = { /** @type {ShapeDefinition} */ definition: this.createRandomShape(), required: 1000 + findNiceIntegerValue(this.level * 47.5), - reward, + reward: enumHubGoalRewards.no_reward_freeplay, }; } @@ -212,6 +210,13 @@ export class HubGoals extends BasicSerializableObject { this.root.signals.storyGoalCompleted.dispatch(this.level - 1, reward); } + /** + * Returns whether we are playing in free-play + */ + isFreePlay() { + return this.level >= tutorialGoals.length; + } + /** * Returns whether a given upgrade can be unlocked * @param {string} upgradeId diff --git a/src/js/game/hud/parts/unlock_notification.js b/src/js/game/hud/parts/unlock_notification.js index 20996ffa..612d900d 100644 --- a/src/js/game/hud/parts/unlock_notification.js +++ b/src/js/game/hud/parts/unlock_notification.js @@ -4,9 +4,10 @@ import { makeDiv } from "../../../core/utils"; import { SOUNDS } from "../../../platform/sound"; import { T } from "../../../translations"; import { defaultBuildingVariant } from "../../meta_building"; -import { enumHubGoalRewards, enumHubGoalRewardsToContentUnlocked } from "../../tutorial_goals"; +import { enumHubGoalRewards } from "../../tutorial_goals"; import { BaseHUDPart } from "../base_hud_part"; import { DynamicDomAttach } from "../dynamic_dom_attach"; +import { enumHubGoalRewardsToContentUnlocked } from "../../tutorial_goals_mappings"; export class HUDUnlockNotification extends BaseHUDPart { initialize() { @@ -23,10 +24,6 @@ export class HUDUnlockNotification extends BaseHUDPart { this.buttonShowTimeout = null; } - shouldPauseGame() { - return this.visible; - } - createElements(parent) { this.element = makeDiv(parent, "ingame_HUD_UnlockNotification", []); diff --git a/src/js/game/tutorial_goals.js b/src/js/game/tutorial_goals.js index 1c957e6b..83aca89c 100644 --- a/src/js/game/tutorial_goals.js +++ b/src/js/game/tutorial_goals.js @@ -1,18 +1,8 @@ import { ShapeDefinition } from "./shape_definition"; import { finalGameShape } from "./upgrades"; -import { MetaBuilding, defaultBuildingVariant } from "./meta_building"; -import { MetaCutterBuilding, enumCutterVariants } from "./buildings/cutter"; -import { MetaRotaterBuilding, enumRotaterVariants } from "./buildings/rotater"; -import { MetaPainterBuilding, enumPainterVariants } from "./buildings/painter"; -import { MetaMixerBuilding } from "./buildings/mixer"; -import { MetaStackerBuilding } from "./buildings/stacker"; -import { MetaSplitterBuilding, enumSplitterVariants } from "./buildings/splitter"; -import { MetaUndergroundBeltBuilding, enumUndergroundBeltVariants } from "./buildings/underground_belt"; -import { MetaMinerBuilding, enumMinerVariants } from "./buildings/miner"; -import { MetaTrashBuilding, enumTrashVariants } from "./buildings/trash"; /** - * Don't forget to also update unlock_notification.js as well as the translations! + * Don't forget to also update tutorial_goals_mappings.js as well as the translations! * @enum {string} */ export const enumHubGoalRewards = { @@ -36,44 +26,7 @@ export const enumHubGoalRewards = { reward_freeplay: "reward_freeplay", no_reward: "no_reward", -}; - -/** @typedef {Array<[typeof MetaBuilding, string]>} TutorialGoalReward */ - -/** - * Helper method for proper types - * @returns {TutorialGoalReward} - */ -const typed = x => x; - -/** - * Stores which reward unlocks what - * @enum {TutorialGoalReward?} - */ -export const enumHubGoalRewardsToContentUnlocked = { - [enumHubGoalRewards.reward_cutter_and_trash]: typed([[MetaCutterBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_rotater]: typed([[MetaRotaterBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_painter]: typed([[MetaPainterBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_mixer]: typed([[MetaMixerBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_stacker]: typed([[MetaStackerBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_splitter]: typed([[MetaSplitterBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_tunnel]: typed([[MetaUndergroundBeltBuilding, defaultBuildingVariant]]), - - [enumHubGoalRewards.reward_rotater_ccw]: typed([[MetaRotaterBuilding, enumRotaterVariants.ccw]]), - [enumHubGoalRewards.reward_miner_chainable]: typed([[MetaMinerBuilding, enumMinerVariants.chainable]]), - [enumHubGoalRewards.reward_underground_belt_tier_2]: typed([ - [MetaUndergroundBeltBuilding, enumUndergroundBeltVariants.tier2], - ]), - [enumHubGoalRewards.reward_splitter_compact]: typed([ - [MetaSplitterBuilding, enumSplitterVariants.compact], - ]), - [enumHubGoalRewards.reward_cutter_quad]: typed([[MetaCutterBuilding, enumCutterVariants.quad]]), - [enumHubGoalRewards.reward_painter_double]: typed([[MetaPainterBuilding, enumPainterVariants.double]]), - [enumHubGoalRewards.reward_painter_quad]: typed([[MetaPainterBuilding, enumPainterVariants.quad]]), - [enumHubGoalRewards.reward_storage]: typed([[MetaTrashBuilding, enumTrashVariants.storage]]), - - [enumHubGoalRewards.reward_freeplay]: null, - [enumHubGoalRewards.no_reward]: null, + no_reward_freeplay: "no_reward_freeplay", }; export const tutorialGoals = [ diff --git a/src/js/game/tutorial_goals_mappings.js b/src/js/game/tutorial_goals_mappings.js new file mode 100644 index 00000000..905a623a --- /dev/null +++ b/src/js/game/tutorial_goals_mappings.js @@ -0,0 +1,51 @@ +import { MetaBuilding, defaultBuildingVariant } from "./meta_building"; +import { MetaCutterBuilding, enumCutterVariants } from "./buildings/cutter"; +import { MetaRotaterBuilding, enumRotaterVariants } from "./buildings/rotater"; +import { MetaPainterBuilding, enumPainterVariants } from "./buildings/painter"; +import { MetaMixerBuilding } from "./buildings/mixer"; +import { MetaStackerBuilding } from "./buildings/stacker"; +import { MetaSplitterBuilding, enumSplitterVariants } from "./buildings/splitter"; +import { MetaUndergroundBeltBuilding, enumUndergroundBeltVariants } from "./buildings/underground_belt"; +import { MetaMinerBuilding, enumMinerVariants } from "./buildings/miner"; +import { MetaTrashBuilding, enumTrashVariants } from "./buildings/trash"; + +/** @typedef {Array<[typeof MetaBuilding, string]>} TutorialGoalReward */ + +import { enumHubGoalRewards } from "./tutorial_goals"; + +/** + * Helper method for proper types + * @returns {TutorialGoalReward} + */ +const typed = x => x; + +/** + * Stores which reward unlocks what + * @enum {TutorialGoalReward?} + */ +export const enumHubGoalRewardsToContentUnlocked = { + [enumHubGoalRewards.reward_cutter_and_trash]: typed([[MetaCutterBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_rotater]: typed([[MetaRotaterBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_painter]: typed([[MetaPainterBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_mixer]: typed([[MetaMixerBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_stacker]: typed([[MetaStackerBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_splitter]: typed([[MetaSplitterBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_tunnel]: typed([[MetaUndergroundBeltBuilding, defaultBuildingVariant]]), + + [enumHubGoalRewards.reward_rotater_ccw]: typed([[MetaRotaterBuilding, enumRotaterVariants.ccw]]), + [enumHubGoalRewards.reward_miner_chainable]: typed([[MetaMinerBuilding, enumMinerVariants.chainable]]), + [enumHubGoalRewards.reward_underground_belt_tier_2]: typed([ + [MetaUndergroundBeltBuilding, enumUndergroundBeltVariants.tier2], + ]), + [enumHubGoalRewards.reward_splitter_compact]: typed([ + [MetaSplitterBuilding, enumSplitterVariants.compact], + ]), + [enumHubGoalRewards.reward_cutter_quad]: typed([[MetaCutterBuilding, enumCutterVariants.quad]]), + [enumHubGoalRewards.reward_painter_double]: typed([[MetaPainterBuilding, enumPainterVariants.double]]), + [enumHubGoalRewards.reward_painter_quad]: typed([[MetaPainterBuilding, enumPainterVariants.quad]]), + [enumHubGoalRewards.reward_storage]: typed([[MetaTrashBuilding, enumTrashVariants.storage]]), + + [enumHubGoalRewards.reward_freeplay]: null, + [enumHubGoalRewards.no_reward]: null, + [enumHubGoalRewards.no_reward_freeplay]: null, +}; diff --git a/translations/base-en.yaml b/translations/base-en.yaml index af13ec4b..8da39f5a 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -424,6 +424,11 @@ storyRewards: desc: >- This level gave you no reward, but the next one will!

PS: Better don't destroy your existing factory - You need all those shapes later again to unlock upgrades! + no_reward_freeplay: + title: Next level + desc: >- + Congratulations! By the way, more content is planned for the standalone! + settings: title: Settings categories: