From b1becbe8667990c39d47ccd82b3249b6b401f8b2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 17:05:48 +0100 Subject: [PATCH] Improved tools --- tools/level_generator/LICENSE | 0 tools/level_generator/README.md | 0 tools/level_generator/application.py | 42 +++++++++++++++++- tools/level_generator/appsettings.json | 15 ------- tools/ontime_calculator/LICENSE | 0 tools/ontime_calculator/README.md | 0 tools/ontime_calculator/application.py | 11 ++++- tools/ontime_calculator/appsettings.json | 15 ------- .../ontime_calculator/ontime-calculator.json | 43 ------------------- 9 files changed, 51 insertions(+), 75 deletions(-) delete mode 100644 tools/level_generator/LICENSE delete mode 100644 tools/level_generator/README.md delete mode 100644 tools/level_generator/appsettings.json delete mode 100644 tools/ontime_calculator/LICENSE delete mode 100644 tools/ontime_calculator/README.md delete mode 100644 tools/ontime_calculator/appsettings.json delete mode 100644 tools/ontime_calculator/ontime-calculator.json diff --git a/tools/level_generator/LICENSE b/tools/level_generator/LICENSE deleted file mode 100644 index e69de29..0000000 diff --git a/tools/level_generator/README.md b/tools/level_generator/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/tools/level_generator/application.py b/tools/level_generator/application.py index 34a68c8..6f142b5 100644 --- a/tools/level_generator/application.py +++ b/tools/level_generator/application.py @@ -1,3 +1,5 @@ +import json + from cpl_core.application import ApplicationABC from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console @@ -13,4 +15,42 @@ class Application(ApplicationABC): pass def main(self): - Console.write_line('Hello World') + f = open("./Levels.txt", "r", encoding='utf-8') + i = 0 + lines = f.readlines() + json_list = [] + + for line in lines: + if i > 0: + line = line.split('\n')[0] + words = line.split(' ') + use_words = [] + for word in words: + if word != '': + use_words.append(word) + + if len(use_words) == 6: + string = use_words[2] + use_words.remove(use_words[2]) + use_words[1] += f' {string}' + + loc_json = { + "id": int(use_words[0]), + "alias": use_words[1], + "min_ontime": int(use_words[2]), + "min_message_count": int(use_words[3]), + "color": use_words[4], + "hoist": "False", + "mentionable": "True", + "PermissionBagId": 0 + } + json_list.append(loc_json) + + i += 1 + + f.close() + + Console.write_line(json_list) + json_format = json.dumps(json_list, ensure_ascii=False) + with open("../src/sh_dobby_bot/assets/Level.json", "w", encoding='utf-8') as outfile: + outfile.write(json_format) diff --git a/tools/level_generator/appsettings.json b/tools/level_generator/appsettings.json deleted file mode 100644 index 629e6eb..0000000 --- a/tools/level_generator/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "TimeFormatSettings": { - "DateFormat": "%Y-%m-%d", - "TimeFormat": "%H:%M:%S", - "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", - "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" - }, - - "LoggingSettings": { - "Path": "logs/", - "Filename": "log_$start_time.log", - "ConsoleLogLevel": "ERROR", - "FileLogLevel": "WARN" - } -} diff --git a/tools/ontime_calculator/LICENSE b/tools/ontime_calculator/LICENSE deleted file mode 100644 index e69de29..0000000 diff --git a/tools/ontime_calculator/README.md b/tools/ontime_calculator/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/tools/ontime_calculator/application.py b/tools/ontime_calculator/application.py index 34a68c8..c860ec2 100644 --- a/tools/ontime_calculator/application.py +++ b/tools/ontime_calculator/application.py @@ -13,4 +13,13 @@ class Application(ApplicationABC): pass def main(self): - Console.write_line('Hello World') + ontime = 0 + mc = 0 + for i in range(0, 31): + Console.write_line(f'i: {i} {ontime} {mc}') + if i == 0: + ontime = 4 + mc = 10 + else: + ontime = round((ontime * 1.2561), 0) + mc = round((mc * 1.26), 0) diff --git a/tools/ontime_calculator/appsettings.json b/tools/ontime_calculator/appsettings.json deleted file mode 100644 index 629e6eb..0000000 --- a/tools/ontime_calculator/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "TimeFormatSettings": { - "DateFormat": "%Y-%m-%d", - "TimeFormat": "%H:%M:%S", - "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", - "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" - }, - - "LoggingSettings": { - "Path": "logs/", - "Filename": "log_$start_time.log", - "ConsoleLogLevel": "ERROR", - "FileLogLevel": "WARN" - } -} diff --git a/tools/ontime_calculator/ontime-calculator.json b/tools/ontime_calculator/ontime-calculator.json deleted file mode 100644 index 9ec006b..0000000 --- a/tools/ontime_calculator/ontime-calculator.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "ProjectSettings": { - "Name": "tools/ontime-calculator", - "Version": { - "Major": "0", - "Minor": "0", - "Micro": "0" - }, - "Author": "", - "AuthorEmail": "", - "Description": "", - "LongDescription": "", - "URL": "", - "CopyrightDate": "", - "CopyrightName": "", - "LicenseName": "", - "LicenseDescription": "", - "Dependencies": [ - "sh_cpl>=2021.10.2" - ], - "PythonVersion": ">=3.9.2", - "PythonPath": { - "linux": "" - }, - "Classifiers": [] - }, - "BuildSettings": { - "ProjectType": "console", - "SourcePath": "", - "OutputPath": "../../dist", - "Main": "tools/_ontime_calculator.main", - "EntryPoint": "tools/ontime-calculator", - "IncludePackageData": false, - "Included": [], - "Excluded": [ - "*/__pycache__", - "*/logs", - "*/tests" - ], - "PackageData": {}, - "ProjectReferences": [] - } -} \ No newline at end of file