diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..489b748 --- /dev/null +++ b/.pylintrc @@ -0,0 +1 @@ +disable=missing-function-docstring diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c1850b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.9-slim + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY site /app/site + +EXPOSE 5000 + +CMD ["python", "site/app.py"] \ No newline at end of file diff --git a/README.md b/README.md index ab7633f..1988acc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# Baulder-s-Gate-test +# Baulder-s-Gate-test A test to find out who you are from the game Baldur's Gate. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..26bba31 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Flask==2.0.1 +Werkzeug==2.3.7 \ No newline at end of file diff --git a/site/app.py b/site/app.py index f0f5131..4aa9c37 100644 --- a/site/app.py +++ b/site/app.py @@ -1,24 +1,121 @@ -from flask import Flask, render_template, request - -app = Flask(__name__) - -@app.route('/') -def index(): - return render_template("index.html") - -@app.route("/result", mathods=["POST"]) -def result(): - answers = request.form - character = determine_character(answers) - return render_template("result.html", character=character) - -def datermine_character(answers): - if answers.get("question1") == "brave": - return "Minsc" - elif answers.get("question1") == "wise": - return "Jeheira" - else: - return "Imoem" - -if __name__=="__main__": - app.run(debug=True) \ No newline at end of file +from flask import Flask, render_template, request + +class BaldursGateQuizApp: + def __init__(self): + self.app = Flask(__name__, template_folder="templates", static_folder="static") + self.add_routes() + + def add_routes(self): + self.app.add_url_rule('/', 'index', self.index) + self.app.add_url_rule('/result', 'result', self.result, methods=["POST"]) + self.app.add_url_rule('/tests', 'tests', self.tests) + self.app.add_url_rule('/about', 'about', self.about) + + def index(self): + return render_template("index.html") + + def tests(self): + return render_template("tests.html") + + def result(self): + answers = request.form + character = self.determine_character(answers) + return render_template("result.html", character=character) + + def about(self): + return render_template("about.html") + + @staticmethod + def determine_character(answers): + traits = { + "brave": "Минск", + "wise": "Гейл", + "kind": "Карлах", + "cunning": "Астарион", + "strict": "Лаэзель", + "dark": "Шэдоухарт" + } + roles = { + "leader": "Минск", + "healer": "Хальсин", + "fighter": "Карлах", + "rogue": "Астарион", + "mage": "Гейл" + } + goals = { + "glory": "Минск", + "knowledge": "Гейл", + "protect": "Шэдоухарт", + "power": "Лаэзель" + } + rules = { + "strict": "Лаэзель", + "flexible": "Гейл", + "pragmatic": "Астарион", + "chaotic": "Шэдоухарт" + } + weapons = { + "sword": "Минск", + "staff": "Гейл", + "dagger": "Астарион", + "mace": "Карлах", + "bow": "Лаэзель" + } + places = { + "tavern": "Карлах", + "library": "Гейл", + "wilderness": "Хальсин", + "castle": "Лаэзель", + "dark_alley": "Шэдоухарт" + } + mood_fix = { + "training": "Лаэзель", + "reading": "Гейл", + "adventure": "Минск", + "meditation": "Шэдоухарт", + "drinking": "Карлах" + } + colors = { + "red": "Карлах", + "blue": "Гейл", + "green": "Хальсин", + "black": "Шэдоухарт", + "gold": "Лаэзель" + } + + choices = [ + traits.get(answers.get("question1")), + roles.get(answers.get("question2")), + goals.get(answers.get("question3")), + rules.get(answers.get("question4")), + weapons.get(answers.get("question5")), + places.get(answers.get("question6")), + mood_fix.get(answers.get("question7")), + colors.get(answers.get("question8")) + ] + + choices = [choice for choice in choices if choice is not None] + + if not choices: + return {"name": "Неизвестно", "image": "unknown.jpg", "description": "Не удалось определить персонажа."} + + most_common = max(set(choices), key=choices.count) + + characters_info = { + "Минск": {"name": "Минск", "image": "minsk.jpg", "description": "Герой, идущий напролом с верным хомяком Бу"}, + "Гейл": {"name": "Гейл", "image": "gale.jpg", "description": "Могущественный маг, жаждущий знаний и силы"}, + "Карлах": {"name": "Карлах", "image": "karlach.jpg", "description": "Добрая, но грозная воительница"}, + "Астарион": {"name": "Астарион", "image": "astarion.jpeg", "description": "Хитрый вампир, любящий свободу"}, + "Лаэзель": {"name": "Лаэзель", "image": "laezel.jpg", "description": "Жесткая и бескомпромиссная гитянка-воительница"}, + "Шэдоухарт": {"name": "Шэдоухарт", "image": "shadowheart.jpg", "description": "Таинственная жрица с темным прошлым"}, + "Хальсин": {"name": "Хальсин", "image": "halsin.jpg", "description": "Мудрый друид, защитник природы."} + } + + return characters_info.get(most_common, {"name": "Неизвестно", "image": "unknown.jpg", "description": "Не удалось определить персонажа."}) + + def run(self): + self.app.run(debug=True, host="0.0.0.0", port=5000) + +if __name__ == "__main__": + app_instance = BaldursGateQuizApp() + app_instance.run() diff --git a/site/static/css/style.css b/site/static/css/style.css index b7994eb..d958b0e 100644 --- a/site/static/css/style.css +++ b/site/static/css/style.css @@ -1,29 +1,183 @@ -body { - font-family: Arial, sans-serif; - background-color: #f4f4f4; - text-align: center; - margin: 0; - padding: 0; -} - -h1 { - color: #333; -} - -form { - margin: 20px auto; - padding: 20px; - background: #fff; - border-radius: 8px; - width: 300px; - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); -} - -button { - padding: 10px 20px; - background: #007bff; - color: #fff; - border: none; - border-radius: 4px; - cursor: pointer; -} +body { + font-family: 'Arial', sans-serif; + background: url('../images/bg.jpeg') no-repeat center center fixed; + background-size: cover; + color: #fff; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + min-height: 100vh; +} + +.navbar { + width: 100%; + background: rgba(0, 0, 0, 0.8); + padding: 10px 0; + position: fixed; + top: 0; + left: 0; + text-align: center; +} + +.navbar ul { + list-style: none; + padding: 0; + margin: 0; + display: flex; + justify-content: center; + gap: 20px; +} + +.navbar ul li { + display: inline; +} + +.navbar ul li a { + color: #fff; + text-decoration: none; + font-size: 18px; + padding: 10px 20px; + transition: 0.3s; +} + +.navbar ul li a:hover { + background: #4CAF50; + border-radius: 5px; +} + +.container { + text-align: center; + background: rgba(44, 44, 68, 0.9); + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); + margin-top: 80px; +} + +h1 { + margin-bottom: 20px; + font-size: 24px; +} + +/* Новые стили для блока с будущими статьями */ +.article-container { + background-color: rgba(0, 0, 0, 0.8); /* Темный фон */ + color: #fff; /* Светлый текст */ + padding: 20px; + margin-top: 20px; + border-radius: 8px; + border: none; /* Без обрамления, если не нужно */ + text-align: center; +} + +.article-container h2 { + margin-top: 0; + font-size: 22px; +} + +.article-container p { + font-size: 16px; +} + +/* Стили для тестовых вопросов */ +.question { + margin: 20px 0; + font-size: 18px; +} + +input[type="radio"] { + margin-right: 10px; +} + +button { + display: inline-block; + padding: 10px 20px; + margin-top: 20px; + background-color: #4CAF50; + color: white; + text-decoration: none; + border-radius: 5px; + font-size: 18px; + transition: 0.3s; +} + +button:hover { + background-color: #45a049; +} + +.character-image { + width: 100%; + max-width: 600px; + height: auto; + border-radius: 10px; + margin-top: 20px; + box-shadow: 0 0 15px rgba(255, 255, 255, 0.5); +} + +.description { + font-size: 18px; + margin-top: 15px; +} + +.button { + display: inline-block; + padding: 10px 20px; + margin-top: 20px; + background-color: #4CAF50; + color: white; + text-decoration: none; + border-radius: 5px; + font-size: 18px; + transition: 0.3s; +} + +.button:hover { + background-color: #45a049; +} + +.author-container { + background: rgba(44, 44, 68, 0.9); /* Темный фон для блока */ + padding: 20px; + border-radius: 10px; + margin-top: 30px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); + text-align: center; +} + +.author-content { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + gap: 20px; + flex-wrap: wrap; +} + +.author-photo { + flex: 0 0 150px; /* Фиксированная ширина для фото */ + max-width: 150px; +} + +.author-image { + width: 100%; + height: auto; + border-radius: 50%; /* Сделать изображение круглым */ + border: 3px solid #fff; /* Белая обводка вокруг фото */ +} + +.author-bio { + max-width: 600px; + font-size: 18px; + color: #fff; + text-align: left; +} + +.author-container h2 { + font-size: 24px; + margin-bottom: 20px; + color: #fff; +} + diff --git a/site/static/images/astarion.jpeg b/site/static/images/astarion.jpeg new file mode 100644 index 0000000..09fc10d Binary files /dev/null and b/site/static/images/astarion.jpeg differ diff --git a/site/static/images/author.jpg b/site/static/images/author.jpg new file mode 100644 index 0000000..3bccd81 Binary files /dev/null and b/site/static/images/author.jpg differ diff --git a/site/static/images/bg.jpeg b/site/static/images/bg.jpeg new file mode 100644 index 0000000..b43855e Binary files /dev/null and b/site/static/images/bg.jpeg differ diff --git a/site/static/images/gale.jpg b/site/static/images/gale.jpg new file mode 100644 index 0000000..154eb6f Binary files /dev/null and b/site/static/images/gale.jpg differ diff --git a/site/static/images/halsin.jpg b/site/static/images/halsin.jpg new file mode 100644 index 0000000..61618c5 Binary files /dev/null and b/site/static/images/halsin.jpg differ diff --git a/site/static/images/karlach.jpg b/site/static/images/karlach.jpg new file mode 100644 index 0000000..36eb5ae Binary files /dev/null and b/site/static/images/karlach.jpg differ diff --git a/site/static/images/laezel.jpg b/site/static/images/laezel.jpg new file mode 100644 index 0000000..0510c94 Binary files /dev/null and b/site/static/images/laezel.jpg differ diff --git a/site/static/images/minsk.jpg b/site/static/images/minsk.jpg new file mode 100644 index 0000000..d189ba7 Binary files /dev/null and b/site/static/images/minsk.jpg differ diff --git a/site/static/images/shadowheart.jpg b/site/static/images/shadowheart.jpg new file mode 100644 index 0000000..60121bb Binary files /dev/null and b/site/static/images/shadowheart.jpg differ diff --git a/site/static/images/uill.jpg b/site/static/images/uill.jpg new file mode 100644 index 0000000..8a6f12c Binary files /dev/null and b/site/static/images/uill.jpg differ diff --git a/site/templates/about.html b/site/templates/about.html new file mode 100644 index 0000000..6498052 --- /dev/null +++ b/site/templates/about.html @@ -0,0 +1,42 @@ + + +
+ + +Здесь будут размещены статьи, посвященные героям и вселенной Baldur's Gate 3. Ожидайте интересные материалы!
+