From 0c802b3ae74e0df6e8f41f1d6fcf019eb8d079e8 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Wed, 25 Dec 2019 23:52:16 -0600 Subject: [PATCH] Add news based on food production. This commit also adds a template for such news and makes news item pop up more frequently --- constants.js | 69 ++++++++++++++++++++++++++++++++++------------------ gorge.css | 4 +-- gorge.js | 4 +-- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/constants.js b/constants.js index 62b086e..c5af33d 100644 --- a/constants.js +++ b/constants.js @@ -308,8 +308,10 @@ function createTemplateUpgrades() { createClickVictimUpgrades(); createPowerupFreqUpgrades(); createFreeBuildingPowerups(); + createNews(); deepFreeze(upgrades); deepFreeze(powerups); + deepFreeze(news); } const prodUpgradeCounts = [1, 5, 10, 25, 50, 75, 100]; @@ -1176,33 +1178,52 @@ const news = [ state => "This is also news.", state => "SPORTS!" ] - }, - { - condition: state => { - return state.resources.food > 100; - }, - lines: [ - state => "You have at least 100 food. Wow!" - ] - }, - { - condition: state => { - return state.currentProductivity.food > 100; - }, - lines: [ - state => "You're eating more than 100 food per second. Wow!" - ] - }, - { - condition: state => { - return state.belongings.micro.count >= 50; - }, - lines: [ - state => "You have at least 50 micros. Wow!" - ] } ] +function createNews() { + createNewsFoodAmount(); + createNewsFoodRate(); + createNewsBuildingCount(); +} + +function createNewsFoodAmount() { + +} + +function createNewsFoodRate() { + let counter = 0; + for (let set of newsFoodRateText) { + const factor = counter; + news.push({ + condition: state => { + return state.currentProductivity.food >= 5*Math.pow(10, factor) && + state.currentProductivity.food < 5*Math.pow(10, (factor+1)) + }, + lines: set + }); + counter += 1; + }; +} + +function createNewsBuildingCount() { + +} + +const newsFoodRateText = [ + [ + state => "Your neighbors are complaining about the noise", + state => "You are a very hungry caterpillar" + ], + [ + state => "You ate your neighbors", + state => "Your former neighbors' neighbors are complaining about the noise" + ], + [ + state => "You no longer have any neighbors" + ] +] + const powerups = { "instant-food": { name: "Free Food", diff --git a/gorge.css b/gorge.css index 54fca8b..300129a 100644 --- a/gorge.css +++ b/gorge.css @@ -527,10 +527,10 @@ div::-webkit-scrollbar-corner { pointer-events: none; text-align: center; position: fixed; - top: 90vh; + top: 98vh; left: 50vw; transform-origin: 0% 0%; - animation: news-text-frames 10s cubic-bezier(0.68, -0.55, 0.265, 1.55); + animation: news-text-frames 5s cubic-bezier(0.68, -0.55, 0.265, 1.55); animation-fill-mode: both; font-size: 24px; } diff --git a/gorge.js b/gorge.js index bb304fa..5819230 100644 --- a/gorge.js +++ b/gorge.js @@ -971,7 +971,7 @@ function doNews() { setTimeout(() => { doNews(); - }, 15000 + Math.random() * 2500); + }, 6000); } function showNews(text) { @@ -986,7 +986,7 @@ function showNews(text) { setTimeout(() => { body.removeChild(div); - }, 10000); + }, 6000); } function doPowerup() {