-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_dsl.py
More file actions
37 lines (27 loc) · 937 Bytes
/
Copy pathgame_dsl.py
File metadata and controls
37 lines (27 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
class GameDSL:
"""
Structured game definition system.
Converts IR or plugin outputs into safe game specs.
"""
def __init__(self):
self.games = {}
# =====================================================
# REGISTER GAME
# =====================================================
def define_game(self, name, spec):
self.games[name] = spec
# =====================================================
# GET GAME
# =====================================================
def get(self, name):
return self.games.get(name)
# =====================================================
# VALIDATION (IMPORTANT SAFETY LAYER)
# =====================================================
def validate(self, spec):
required = ["name", "rules"]
for r in required:
if r not in spec:
return False
return True