2019-07-26 02:24:13 +02:00
|
|
|
from jinja2 import Environment, FileSystemLoader
|
2019-07-28 23:54:25 +02:00
|
|
|
from rules import get_tictactoe_rules
|
2019-07-23 04:03:31 +02:00
|
|
|
|
|
|
|
|
2019-07-26 02:24:13 +02:00
|
|
|
def write_html(html_file):
|
|
|
|
env = Environment(loader=FileSystemLoader("."))
|
|
|
|
template = env.get_template('template.' + html_file)
|
2019-07-23 04:03:31 +02:00
|
|
|
with open(html_file, 'w') as f:
|
2019-07-26 02:24:13 +02:00
|
|
|
f.write(template.render())
|
2019-07-23 04:03:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def write_css(css_file):
|
2019-07-28 23:54:25 +02:00
|
|
|
bot_move_rules, draw_rules, win_rules = get_tictactoe_rules()
|
2019-07-26 02:24:13 +02:00
|
|
|
kwargs = {
|
|
|
|
"turns_player": [0, 2, 4, 6, 8],
|
|
|
|
"turns_bot": [1, 3, 5, 7],
|
2019-07-28 23:54:25 +02:00
|
|
|
"bot_move_rules": bot_move_rules,
|
|
|
|
"draw_rules": draw_rules,
|
|
|
|
"win_rules": win_rules,
|
2019-07-26 02:24:13 +02:00
|
|
|
}
|
|
|
|
env = Environment(loader=FileSystemLoader("."))
|
|
|
|
template = env.get_template('template.' + css_file)
|
|
|
|
with open(css_file, 'w') as f:
|
|
|
|
f.write(template.render(**kwargs))
|
2019-07-23 04:03:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
write_html("tictactoe.html")
|
|
|
|
write_css("tictactoe.css")
|