tictactoecss/tictactoe.py

30 lines
873 B
Python

from jinja2 import Environment, FileSystemLoader
from rules import get_tictactoe_rules
def write_html(html_file):
env = Environment(loader=FileSystemLoader("."))
template = env.get_template('template.' + html_file)
with open(html_file, 'w') as f:
f.write(template.render())
def write_css(css_file):
bot_move_rules, draw_rules, win_rules = get_tictactoe_rules()
kwargs = {
"turns_player": [0, 2, 4, 6, 8],
"turns_bot": [1, 3, 5, 7],
"bot_move_rules": bot_move_rules,
"draw_rules": draw_rules,
"win_rules": win_rules,
}
env = Environment(loader=FileSystemLoader("."))
template = env.get_template('template.' + css_file)
with open(css_file, 'w') as f:
f.write(template.render(**kwargs))
if __name__ == "__main__":
write_html("tictactoe.html")
write_css("tictactoe.css")