1
0
Fork 0

flag checker implementation

This commit is contained in:
Lili (Tlapka) 2021-03-30 19:08:09 +02:00
parent 30769aa454
commit d18ef13d6d
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import yaml
class FlagChecker:
def __init__(self, filename):
self.wrong_flags = {}
self.read_keys(filename)
def read_keys(self, filename):
with open(filename) as f:
self.flags = yaml.load(f, Loader=yaml.FullLoader)
def check_flag(self, level, flag):
if self.flags[level] == flag:
return True
else:
if not level in self.wrong_flags:
self.wrong_flags[level] = []
self.wrong_flags[level].append(flag)
return False
def log_to_file(self, filename):
with open(filename, 'a') as f:
yaml.dump(self.wrong_flags, f)

7
resources/level_keys.yml Normal file
View File

@ -0,0 +1,7 @@
---
level1: "Sherlock"
level2: "NAKA_is_watching_you"
level3: "CrazyHacker"
level4: "KimPutin"
level5: "RandomWordGenerator"
...