Skip to content

Commit 9300c78

Browse files
committed
add : player page added.
1 parent 4755d94 commit 9300c78

File tree

7 files changed

+60
-3
lines changed

7 files changed

+60
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ The game continues until a faction achieves its win condition; for the Residents
9090
| Resident | <img width="100" height="100" src="https://raw.githubusercontent.com/sadrasabouri/mafia/master/static/images/roles/Resident_1.png"><img width="100" height="100" src="https://raw.githubusercontent.com/sadrasabouri/mafia/master/static/images/roles/Resident_2.png"><img width="100" height="100" src="https://raw.githubusercontent.com/sadrasabouri/mafia/master/static/images/roles/Resident_3.png"><img width="100" height="100" src="https://raw.githubusercontent.com/sadrasabouri/mafia/master/static/images/roles/Resident_4.png"> | Resident is the typical player of the game. he/she has no power but to blame mafia in order to remove them from the game in day mode. |
9191

9292
## References
93-
Icons made by <a href="https://www.flaticon.com/authors/vectors-market" title="Vectors Market">Vectors Market</a> and <a href="https://www.flaticon.com/authors/pixel-perfect" title="Pixel perfect">Pixel perfect</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>
93+
Icons made by <a href="https://www.flaticon.com/authors/vectors-market" title="Vectors Market">Vectors Market</a> and <a href="https://www.flaticon.com/authors/pixel-perfect" title="Pixel perfect">Pixel perfect</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a> and <a href="http://www.freepik.com/" title="Freepik">Freepik</a>.
9494

9595
+ [https://en.wikipedia.org/wiki/Mafia_(party_game)](https://en.wikipedia.org/wiki/Mafia_(party_game))

mafia.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ def index():
3535
print("_" * 54)
3636

3737
if ip in ip2role_index_name.keys():
38-
role = ip2role_index_name[ip][0]
39-
image_name = ip2role_index_name[ip][0] + "_" + str(ip2role_index_name[ip][1])
38+
return render_template("Player.html", player_name=ip2role_index_name[ip][2])
4039
else:
4140
if id > nPlayers:
4241
return render_template("404.html", is_farsi=True)

static/css/style.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ th, td {
6464
background-color: red;
6565
}
6666

67+
#myProgress {
68+
width: 100%;
69+
background-color: #ddd;
70+
border-radius: 3px;
71+
}
72+
73+
#myBar {
74+
width: 0%;
75+
height: 30px;
76+
background-color: #4f8ace;
77+
text-align: center;
78+
line-height: 30px;
79+
border-radius: 3px;
80+
}
81+
6782
#player_name {
6883
width: 20%;
6984
}

static/images/Warns/play.png

28.4 KB
Loading

static/js/main.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var i = 0;
2+
function start() {
3+
if (i == 0) {
4+
i = 1;
5+
var elem = document.getElementById("myBar");
6+
var width = 0;
7+
var time_from_start = 0;
8+
var id = setInterval(frame, 1000);
9+
function frame() {
10+
if (width >= 100) {
11+
clearInterval(id);
12+
i = 0;
13+
} else {
14+
width += 100 / 45;
15+
time_from_start ++;
16+
elem.style.width = width + "%";
17+
elem.innerHTML = time_from_start;
18+
elem.style.backgroundColor = "rgb(" + time_from_start * 5 +", 138, 223)";
19+
}
20+
}
21+
}
22+
}

templates/Player.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{% extends 'base_action.html' %}
2+
3+
{% block sub_table %}
4+
<tr>
5+
<td class="role">
6+
<h1>{{ player_name }}</h1>
7+
</td>
8+
</tr>
9+
<tr>
10+
<td>
11+
<img class="avatar" src="static/images/Warns/play.png" onclick="start()">
12+
<div id="myProgress">
13+
<div id="myBar">0</div>
14+
</div>
15+
</td>
16+
</tr>
17+
{% endblock %}
18+
19+
{% block messages %}
20+
{% endblock %}

templates/base_action.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<link rel = "icon" href="static/images/roles/{{ image_name }}.png" type = "image/x-icon">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
7+
<script src="static/js/main.js" type="text/javascript"></script>
78
</head>
89
<table style="border-collapse: collapse">
910
{% block sub_table %}{% endblock %}

0 commit comments

Comments
 (0)