Compare commits

..
6 Commits
Author SHA1 Message Date
lm e48842ee69 [Add] New static .json data 2023-07-18 17:00:29 +02:00
lm b1b71dc2ef [Delete] Old static .json data 2023-07-18 17:00:17 +02:00
lm a413f8ce5e [Style] Change filename of generated static .json files 2023-07-18 16:59:44 +02:00
lm bb816c52d8 [Add] static .json data 2023-07-12 15:30:56 +02:00
lm 7412f5678c [Add] Ability to generate static .json data 2023-07-12 15:30:31 +02:00
lm 9bd74275aa [Chore] Fix wrong wording 2023-07-12 14:45:28 +02:00
5 changed files with 160180 additions and 1 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ def main():
Showcasing example usage Showcasing example usage
""" """
# Create an instances of the calculators # Create instances of the calculators
fade_calc = FadeCalculator() fade_calc = FadeCalculator()
amber_calc = AmberFadeCalculator() amber_calc = AmberFadeCalculator()
acid_calc = AcidFadeCalculator() acid_calc = AcidFadeCalculator()
+44
View File
@@ -0,0 +1,44 @@
__author__ = "Lukas Mahler"
__version__ = "1.0.0"
__date__ = "18.07.2023"
__email__ = "m@hler.eu"
__status__ = "Production"
import json
from src.FadeCalculator import FadeCalculator
from src.AmberFadeCalculator import AmberFadeCalculator
from src.AcidFadeCalculator import AcidFadeCalculator
def main():
"""
Generate static .json files, this is different from the original typescript repository.
I like this .json format more for accessing the seeds later.
e.g. ['AWP]['42']['percentage'] where 42 is the seed.
"""
# Create instances of the calculators
fade_calc = FadeCalculator()
amber_calc = AmberFadeCalculator()
acid_calc = AcidFadeCalculator()
# Build a new dict using format [WEAPON][SEED] = seed, percentage, ranking
for calc, name in [(fade_calc, 'fade'), (amber_calc, 'fade_amber'), (acid_calc, 'fade_acid')]:
rebuild = {}
for obj in calc.get_all_fade_percentages():
rebuild[obj.weapon] = {}
for subobj in obj.percentages:
rebuild[obj.weapon][subobj.seed] = {
'seed': subobj.seed,
'percentage': subobj.percentage,
'ranking': subobj.ranking
}
# dump the new dicts to a json file using 4 indents under ./generated
with open(f"./generated/{name}.json", 'w') as jf:
json.dump(rebuild, jf, indent=4)
if __name__ == '__main__':
main()
+125082
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff