From 7d4feac204334f3b65e30453ca664d32b68a41e3 Mon Sep 17 00:00:00 2001 From: Rev Date: Thu, 20 May 2021 13:18:46 +0900 Subject: [PATCH] initial commit --- LICENSE | 30 ++++++++++++++++++++++++++++++ README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ package.js | 4 ++++ package.json | 8 ++++++++ src/config.json | 15 +++++++++++++++ src/mod.js | 34 ++++++++++++++++++++++++++++++++++ src/weatherSet.json | 35 +++++++++++++++++++++++++++++++++++ 7 files changed, 170 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 package.js create mode 100644 package.json create mode 100644 src/config.json create mode 100644 src/mod.js create mode 100644 src/weatherSet.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f54abda --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2021 Revingly. All rights reserved. + +Developed by: Revingly + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation files +(the "Software"), to deal with the Software without restriction, +including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + +* Neither the names of Ereshkigal, SPT-Aki nor the names of its + contributors may be used to endorse or promote products derived from + this Software without specific prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..dfb1c1d --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# Choose the weather + +### Choose from the list the weather you want. If you want your own weather setting then please choose 'custom' from the list and then modify the settings to your liking + +If you decided to make your own custom weather settings then please choose values between min and max for each weather config part. + +```json +"cloud": { + "min": -1.5, + "max": 1.5 +}, +"wind_speed": { + "min": 0, + "max": 3 +}, +"wind_direction": { + "min": 0, + "max": 3 +}, +"wind_gustiness": { + "min": 0, + "max": 1 +}, +"rain": { + "min": 1, + "max": 4 +}, +"rain_intensity": { + "min": 0.1, + "max": 1 +}, +"fog": { + "min": 0.002, + "max": 0.15 +}, +"temp": { + "min": 0, + "max": 16 +}, +"pressure": { + "min": 760, + "max": 764 +} +``` \ No newline at end of file diff --git a/package.js b/package.js new file mode 100644 index 0000000..e53332b --- /dev/null +++ b/package.js @@ -0,0 +1,4 @@ +const { Mod } = require("./src/mod.js"); + + +module.exports.mod = new Mod(); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ab153bd --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "ChooseTheWeather", + "author": "Revingly", + "license": "License", + "version": "1.0.0", + "dependencies": {}, + "main": "package.js" +} \ No newline at end of file diff --git a/src/config.json b/src/config.json new file mode 100644 index 0000000..bb9a90b --- /dev/null +++ b/src/config.json @@ -0,0 +1,15 @@ +{ + "weatherTypes": ["sunny", "cloudy", "stormy", "custom"], + "weather": "stormy", + "customSettings": { + "cloud": 0, + "wind_speed": 0, + "wind_direction": 0, + "wind_gustiness": 0, + "rain": 1, + "rain_intensity": 0, + "fog": 0.001, + "temp": 0, + "pressure": 760 + } +} \ No newline at end of file diff --git a/src/mod.js b/src/mod.js new file mode 100644 index 0000000..a7335e4 --- /dev/null +++ b/src/mod.js @@ -0,0 +1,34 @@ +"use strict"; + +class ChooseTheWeather { + constructor() { + this.mod = "Revingly-BraceTheStorm"; + Logger.info(`Loading: ${this.mod}`); + WeatherController.generateWeather = this.chooseWeather; + } + + chooseWeather(data) { + // Get the config file for the weather + const { weather, customSettings } = require('./config.json'); + // Get the weather sets to choose from + const weatherSets = require('./weatherSet.json'); + // Put the choosen weather from the config in a variable + const choosenWeather = weatherSets[weather]; + + // If user choose custom then we loop over the customSettings + // and add each property to the data.weather object + if (weather === "custom") { + Object.entries(customSettings).forEach(([key, value]) => { + data.weather[key] = customSettings[key]; + }); + } else { // If user select one of the predefined weather sets then we just add it to the data.weather + Object.entries(choosenWeather).forEach(([key, value]) => { + data.weather[key] = value; + }); + } + + return data; + } +} + +module.exports.Mod = ChooseTheWeather; \ No newline at end of file diff --git a/src/weatherSet.json b/src/weatherSet.json new file mode 100644 index 0000000..61cdead --- /dev/null +++ b/src/weatherSet.json @@ -0,0 +1,35 @@ +{ + "sunny": { + "cloud": -0.4, + "wind_speed": 0, + "wind_direction": 3, + "wind_gustiness": 0.022, + "rain": 0, + "rain_intensity": 0, + "fog": 0.004, + "temp": 18, + "pressure": 760 + }, + "cloudy": { + "cloud": 0.9, + "wind_speed": 1, + "wind_direction": 3, + "wind_gustiness": 0.5, + "rain": 0, + "rain_intensity": 0, + "fog": 0.02, + "temp": 10, + "pressure": 762 + }, + "stormy": { + "cloud": 2, + "wind_speed": 4, + "wind_direction": 8, + "wind_gustiness": 1, + "rain": 4, + "rain_intensity": 1, + "fog": 0.7, + "temp": 5, + "pressure": 764 + } +} \ No newline at end of file