From fbd656cb52b9d2593a97468e7fbe1d89dada5796 Mon Sep 17 00:00:00 2001 From: Leo VIALLON-GALINIER Date: Thu, 30 Apr 2020 10:07:11 +0200 Subject: [PATCH] Correct bugs in point counter and css changes --- belote.py | 2 +- db.py | 80 +++++++++++++++++++++--------------- static/belote.css | 17 +++----- templates/game_zone_jeu.html | 6 ++- 4 files changed, 57 insertions(+), 48 deletions(-) diff --git a/belote.py b/belote.py index edbe4e3..77eecfc 100644 --- a/belote.py +++ b/belote.py @@ -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') diff --git a/db.py b/db.py index f963c31..bb83111 100644 --- a/db.py +++ b/db.py @@ -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 diff --git a/static/belote.css b/static/belote.css index bf45c45..28c062c 100644 --- a/static/belote.css +++ b/static/belote.css @@ -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 { diff --git a/templates/game_zone_jeu.html b/templates/game_zone_jeu.html index 37ae26c..4c0d311 100644 --- a/templates/game_zone_jeu.html +++ b/templates/game_zone_jeu.html @@ -9,7 +9,7 @@
- +
@@ -35,7 +35,9 @@

Options

- +
+ +