Correct bugs in point counter and css changes

This commit is contained in:
Léo 2020-04-30 10:07:11 +02:00
parent c1d5a792d0
commit fbd656cb52
4 changed files with 57 additions and 48 deletions

View File

@ -242,7 +242,7 @@ def edituser(user):
else:
user.name = name
if len(password)>=2:
user.password = password
user.set_password(password)
user.level = level
db.session.commit()
return flask.redirect('/admin/users')

80
db.py
View File

@ -243,18 +243,47 @@ class Game(db.Model):
self.cards_to_distribute += self.played
self.played = None
self.first_player = (self.first_player + winnr)%4
if self.turn == N_TURN*N_PLAYERS: # Dix de der, chute, belote et capote !
if (self.first_player + winnr)%2 == 0:
# Dix de der
if self.first_player%2 == 0:
self.points_0 += 10
else:
self.points_1 += 10
if self.get_player(self.preneur).nr %2 ==0 and self.points_0 < self.points_1:
self.points_0 = 0
self.points_1 = 162
if self.get_player(self.preneur).nr %2 ==1 and self.points_1 < self.points_0:
self.points_0 = 162
self.points_1 = 0
if self.points_0 == 162 or self.points_1 == 162:
# Belote possible
winnr = self.distributeur
belote =-1
belote_0 = 0
belote_1 = 0
ccc = self.cards_to_distribute.split(',')
for i in range(N_TURN):
cccc = ccc[i*N_PLAYERS:(i+1)*N_PLAYERS]
if 'R'+self.atout in cccc:
if belote>=0:
if (cccc.index('R'+self.atout) + winnr)%4 == belote %4:
if belote %2 ==0:
self.points_0 += 20
belote_0 = 20
else:
self.points_1 += 20
belote_1 = 20
else:
belote = winnr + cccc.index('R'+self.atout)
if 'D'+self.atout in cccc:
if belote>=0:
if (cccc.index('D'+self.atout) + winnr)%4 == belote %4:
if belote %2 ==0:
self.points_0 += 20
else:
self.points_1 += 20
else:
belote = winnr + cccc.index('D'+self.atout)
win, xxx = winner(cccc, self.atout)
winnr = win+winnr
# Capote
if self.points_0 >= 162 or self.points_1 >= 162:
winequipe = 0 if self.points_0 == 162 else 1
# Capote possible.
winnr = self.distributeur
@ -269,32 +298,15 @@ class Game(db.Model):
self.points_0 += 90
else:
self.points_1 += 90
# belote possible
winnr = self.distributeur
belote =-1
ccc = self.cards_to_distribute.split(',')
for i in range(N_TURN):
cccc = ccc[i*N_PLAYERS:(i+1)*N_PLAYERS]
if 'R'+self.atout in cccc:
if belote>=0:
if (cccc.index('R'+self.atout) + winnr)%4 == belote %4:
if belote %2 ==0:
self.points_0 += 20
else:
self.points_1 += 20
else:
belote = winnr + cccc.index('R'+self.atout)
if 'D'+self.atout in cccc:
if belote>=0:
if (cccc.index('D'+self.atout) + winnr)%4 == belote %4:
if belote %2 ==0:
self.points_0 += 20
else:
self.points_1 += 20
else:
belote = winnr + cccc.index('D'+self.atout)
win, xxx = winner(cccc, self.atout)
winnr = win+winnr
# Chute
if self.get_player(self.preneur).nr %2 ==0 and self.points_0 < self.points_1:
self.points_0 = belote_0
self.points_1 = 162
if self.get_player(self.preneur).nr %2 ==1 and self.points_1 < self.points_0:
self.points_0 = 162
self.points_1 = belote_1
# Retirer la carte du jeu !
p = self.get_player(user)
ccc = p.cards

View File

@ -195,10 +195,10 @@ div, p, li, a, th, td {
#suivant {
position: absolute;
bottom: 15px;
right: 90px;
right: 40px;
}
#suivant input {
width: 80px;
width: 130px;
}
#ov {
@ -224,10 +224,9 @@ position: absolute;
margin: 0px auto 0px auto;
}
#choix {
height: 160px;
margin-top: 25px;
height: 150px;
margin-top: 20px;
padding: 6px;
border: 1px solid #092E1E;
overflow-x: hidden;
overflow-y: auto;
}
@ -304,20 +303,19 @@ position: absolute;
}
.joueur {
width: 90px;
height: 18px;
overflow: hidden;
text-decoration: underscore;
}
.carte {
height: 77px;
width: 50px;
width: 53px;
/* carte : hauteur = 1,54 * largueur; */
border: 1px solid #092E1E;
background-color: #117F4A;
}
.carte-en-main, .carte-dernier-pli {
float: left;
margin-right: 12px;
margin-right: 9px;
}
.item-choix {
padding: 4px;
@ -335,9 +333,6 @@ position: absolute;
#zone-de-conversation {
height: 84px;
margin: 2px;
/*
border: 1px solid #092E1E;
*/
position: relative;
}
#chat {

View File

@ -9,7 +9,7 @@
<div id="jeu-2" class="carte"></div><!-- jeu-2 -->
<div id="jeu-3" class="carte"></div><!-- jeu-3 -->
<div id="suivant">
<input type="submit" name="suivant" value="Recommencer" onclick="javascript:restart_jeu()">
<input type="submit" name="suivant" value="Redistribuer" onclick="javascript:restart_jeu()">
</div><!-- suivant -->
</div><!-- plateau -->
<div id="ov">
@ -35,7 +35,9 @@
</div><!-- dernier-pli -->
<div id="options">
<p class="item-choix">Options <img id="options-fleche" src="/static/fleche-bas.gif" /></p>
<!--<div id="options-valeur" class="item-choix-valeur">Texte</div>-->
<div id="options-valeur" class="item-choix-valeur">
<!--<div id="item-choix-1" class="menu-item">Do sth</div>-->
</div>
</div><!-- options -->
</div><!-- choix -->
</div><!-- ov -->