Skip to content

Commit

Permalink
games info in series, with platform, genres, release_year, and sub-se…
Browse files Browse the repository at this point in the history
…ries
  • Loading branch information
Die4Ever committed Jun 22, 2024
1 parent abeee69 commit d337f1d
Show file tree
Hide file tree
Showing 297 changed files with 3,470 additions and 74 deletions.
70 changes: 70 additions & 0 deletions src/schemaCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import date
from datetime import datetime
import re
import traceback

# https://json-schema.org/learn/getting-started-step-by-step#going-deeper-with-properties
# https://cswr.github.io/JsonSchema/spec/introduction/
Expand All @@ -22,6 +23,54 @@
{"type": "null"},
]}

genres = {
"type": "array",
"minItems": 0,
"items": {
"type": "string",
"enum": [
"Adventure", "RPG", "Platformer", "Shooter", "Strategy", "Puzzle",
]
}
}

platforms = {
"type": "array",
"minItems": 0,
"items": {
"type": "string",
"enum": [
"PC",
"NES", "SNES", "N64", "GameCube", "Wii", "Wii U", "Switch",
"GameBoy", "GBA", "DS", "3DS",
"Master System", "Genesis", "Saturn", "Dreamcast",
"PS1", "PS2", "PS3", "PS4", "PS5",
"PSP", "Vita",
"Xbox", "Xbox 360", "Xbox One", "Xbox Series",
"Arcade", "MSX",
]
}
}

games_schema = {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"genres": genres,
"platforms": platforms,
"release_year": {
"type": ["number", 'null'],
"minimum": 1900,
"maximum": datetime.now().year + 1
},
"sub-series": ValidString
},
"required": ["genres", "platforms", "release_year"],
"additionalProperties": False
}
}

def randomizer_schema(data):
ret = {
"type": "object",
Expand Down Expand Up @@ -56,6 +105,8 @@ def randomizer_schema(data):
return ret
if updated >= date(2024, 6, 19):
ret['required'].append('opensource')
if updated >= date(2024, 7, 1):
ret['properties'].pop('sub-series') # deprecated, moved to games_schema
return ret

def series_schema(data):
Expand All @@ -67,6 +118,7 @@ def series_schema(data):
"sub-series": {
"type": ["array", "null"],
},
"games": games_schema,
"randomizers": {
"type": "array",
"minItems": 1,
Expand Down Expand Up @@ -117,6 +169,7 @@ def validateSeriesConfig(path: Path):
failures = 0
#modified = get_modified_time(path) # currently we don't need this expensive check
writeback = False
games = set()
text = path.read_text()
data = yaml.load(text, Loader=yaml.CLoader)

Expand All @@ -132,15 +185,21 @@ def validateSeriesConfig(path: Path):
except ValidationError as e:
failures += 1
print('ERROR in', path, ': series definition -\n', e.path, e.message)
#raise # uncomment for bigger error messages

for rando in data['randomizers']:
try:
validateRando(rando)
for game in rando.get('games', []):
if 'games' in data and game not in data['games']:
raise ValidationError('game: ' + game + ' is not defined')
games.add(game)
except ValidationError as e:
failures += 1
print('\nIn Randomizer definition:', rando)
id = str(rando.get('game', '')) + ' ' + str(rando.get('identifier', ''))
print('\nERROR in', path, ': randomizer definition', id, '-\n', e.path, e.message)
#raise # uncomment for bigger error messages

# update rando data
if not rando.get('info-updated'):
Expand All @@ -150,6 +209,15 @@ def validateSeriesConfig(path: Path):
writeback = True
rando['added-date'] = date(2024, 5, 25)

if 'games' not in data:
newdata: dict = data.copy()
newdata.pop('randomizers')
games = {key: {'genres':[], 'platforms':[], 'release_year': None} for key in sorted(games)}
newdata['games'] = games
newdata['randomizers'] = data['randomizers']
data = newdata
writeback=True

if failures == 0 and writeback:
out = yaml.dump(data, sort_keys=False, indent=4)
path.write_text(out)
Expand All @@ -169,7 +237,9 @@ def validateYamlFiles():
failures += new_failures
except Exception as e:
failures += 1
print(traceback.format_exc())
print('\nERROR in', file, '-\n', e)
#raise # uncomment for bigger error messages

print('\n\n')
assert success > 0
Expand Down
5 changes: 5 additions & 0 deletions src/series/A_Short_Hike.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: A Short Hike
comment: null
sub-series: null
games:
A Short Hike:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- A Short Hike
Expand Down
5 changes: 5 additions & 0 deletions src/series/ActRaiser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: ActRaiser
comment: null
sub-series: null
games:
ActRaiser:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- ActRaiser
Expand Down
5 changes: 5 additions & 0 deletions src/series/Adventure.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Adventure
comment: null
sub-series: null
games:
Adventure:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- Adventure
Expand Down
9 changes: 9 additions & 0 deletions src/series/Adventure_Island.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
name: Adventure Island
comment: null
sub-series: null
games:
Adventure Island II:
genres: []
platforms: []
release_year: null
Super Adventure Island II:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- Adventure Island II
Expand Down
5 changes: 5 additions & 0 deletions src/series/Aerobiz.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Aerobiz
comment: null
sub-series: null
games:
Aerobiz Supersonic:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- Aerobiz Supersonic
Expand Down
13 changes: 13 additions & 0 deletions src/series/Age_of_Empires.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: Age of Empires
comment: null
sub-series: null
games:
'Age of Empires II (2013) / Age of Empires II: Definitive Edition':
genres: []
platforms: []
release_year: null
'Age of Empires II: The Age of Kings':
genres: []
platforms: []
release_year: null
'Age of Mythology: Extended Edition':
genres: []
platforms: []
release_year: null
randomizers:
- games:
- 'Age of Empires II: The Age of Kings'
Expand Down
5 changes: 5 additions & 0 deletions src/series/Alien.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Alien
comment: null
sub-series: null
games:
'Alien: Isolation':
genres: []
platforms: []
release_year: null
randomizers:
- games:
- 'Alien: Isolation'
Expand Down
5 changes: 5 additions & 0 deletions src/series/Alundra.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Alundra
comment: null
sub-series: null
games:
Alundra:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- Alundra
Expand Down
5 changes: 5 additions & 0 deletions src/series/Americas_Army.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: America's Army
comment: null
sub-series: null
games:
America's Army:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- America's Army
Expand Down
5 changes: 5 additions & 0 deletions src/series/Amnesia.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Amnesia
comment: null
sub-series: null
games:
'Amnesia: The Bunker':
genres: []
platforms: []
release_year: null
randomizers:
- games:
- 'Amnesia: The Bunker'
Expand Down
5 changes: 5 additions & 0 deletions src/series/An_Untitled_Story.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: An Untitled Story
comment: null
sub-series: null
games:
An Untitled Story:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- An Untitled Story
Expand Down
5 changes: 5 additions & 0 deletions src/series/Axiom_Verge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Axiom Verge
comment: null
sub-series: null
games:
Axiom Verge:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- Axiom Verge
Expand Down
9 changes: 9 additions & 0 deletions src/series/Azure_Dreams.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
name: Azure Dreams
comment: null
sub-series: null
games:
Azure Dreams:
genres: []
platforms: []
release_year: null
Azure Dreams (Game Boy Color):
genres: []
platforms: []
release_year: null
randomizers:
- games:
- Azure Dreams
Expand Down
52 changes: 37 additions & 15 deletions src/series/Baldurs_Gate.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,63 @@
name: Baldur's Gate
comment: null
sub-series: null
games:
'Baldur''s Gate - Baldur''s Gate: Enhanced Edition - Baldur''s Gate II: Shadows of Amn':
genres: []
platforms: []
release_year: null
'Baldur''s Gate II: Enhanced Edition':
genres: []
platforms: []
release_year: null
'Baldur''s Gate II: Shadows of Amn':
genres: []
platforms: []
release_year: null
Baldur's Gate Trilogy (mod):
genres: []
platforms: []
release_year: null
'Baldur''s Gate: Enhanced Edition Trilogy (mod)':
genres: []
platforms: []
release_year: null
EasyTutu (mod):
genres: []
platforms: []
release_year: null
randomizers:
- games:
- 'Baldur''s Gate
- Baldur''s Gate: Enhanced Edition
- Baldur''s Gate II: Shadows of Amn'
- 'Baldur''s Gate - Baldur''s Gate: Enhanced Edition - Baldur''s Gate II: Shadows
of Amn'
- 'Baldur''s Gate II: Enhanced Edition'
- 'Baldur''s Gate: Enhanced Edition Trilogy (mod)'
identifier: Enemy Randomizer
url: https://www.gibberlings3.net/files/file/1031-enemy-randomizer/
added-date: 2024-05-25
info-updated: 2024-05-25
- games:
- 'Baldur''s Gate
- Baldur''s Gate: Enhanced Edition
- Baldur''s Gate II: Shadows of Amn'
- 'Baldur''s Gate - Baldur''s Gate: Enhanced Edition - Baldur''s Gate II: Shadows
of Amn'
- 'Baldur''s Gate II: Enhanced Edition'
- 'EasyTutu (mod)'
- 'Baldur''s Gate Trilogy (mod)'
- EasyTutu (mod)
- Baldur's Gate Trilogy (mod)
- 'Baldur''s Gate: Enhanced Edition Trilogy (mod)'
identifier: Item Randomiser
url: https://www.gibberlings3.net/mods/items/item_rand/
added-date: 2024-05-25
info-updated: 2024-05-25
- games:
- 'Baldur''s Gate
- Baldur''s Gate: Enhanced Edition
- Baldur''s Gate II: Shadows of Amn'
- 'Baldur''s Gate - Baldur''s Gate: Enhanced Edition - Baldur''s Gate II: Shadows
of Amn'
- 'Baldur''s Gate II: Enhanced Edition'
- 'EasyTutu (mod)'
- 'Baldur''s Gate Trilogy (mod)'
- EasyTutu (mod)
- Baldur's Gate Trilogy (mod)
- 'Baldur''s Gate: Enhanced Edition Trilogy (mod)'
identifier: Sword Coast Stratagems
url: https://www.gibberlings3.net/mods/tweaks/scs/
comment: 'Mod collection that can randomize the maze in Watcher''s Keep for
Baldur''s Gate II'
comment: Mod collection that can randomize the maze in Watcher's Keep for Baldur's
Gate II
added-date: 2024-05-25
info-updated: 2024-05-25
- games:
Expand Down
5 changes: 5 additions & 0 deletions src/series/Banjo-Kazooie.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Banjo-Kazooie
comment: null
sub-series: null
games:
Banjo-Kazooie:
genres: []
platforms: []
release_year: null
randomizers:
- games:
- Banjo-Kazooie
Expand Down
Loading

1 comment on commit d337f1d

@Die4Ever
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.