Change 1st player at each partie

This commit is contained in:
Léo 2020-04-28 09:29:44 +02:00
parent 2651e77b85
commit c1d5a792d0
2 changed files with 12 additions and 6 deletions

View File

@ -55,10 +55,7 @@ class CustomNamespacePlay(fio.Namespace):
fio.emit('text', {'text': "Couleur d'atout inconnue ({})".format(atout), 'username':None, 'name':NAME_ARBITRE})
return
# OK !
print('atout choix')
print(atout)
if(game.tour_choix(atout, current_user)):
print('Emit atout choix')
fio.emit('choose_color', {'turn':game.turn, 'first_player':game.first_player, 'atout':game.atout, 'preneur':game.preneur if game.preneur is not None else current_user.login}, broadcast=True)
else:
fio.emit('text', {'text': "Erreur E0101", 'username':None, 'name':NAME_ARBITRE})
@ -107,6 +104,10 @@ class CustomNamespacePlay(fio.Namespace):
else:
fio.emit('text', {'text': "Demandez au maitre du jeu pour reprendre une partie.", 'username':None, 'name':NAME_ARBITRE})
def on_state_game(self, data):
game = self.game()
fio.emit('state_game', game.serialize_state_anonymous())
def game(self):
return Game.query.get(self._id)

11
db.py
View File

@ -70,6 +70,7 @@ class Game(db.Model):
cumul_0 = db.Column(db.Integer, default=0)
cumul_1 = db.Column(db.Integer, default=0)
partie = db.Column(db.Integer, default=1)
distributeur = db.Column(db.Integer, default=0)
def start_game(self, ordered_players):
# Ordering players
@ -256,7 +257,7 @@ class Game(db.Model):
if self.points_0 == 162 or self.points_1 == 162:
winequipe = 0 if self.points_0 == 162 else 1
# Capote possible.
winnr = 0
winnr = self.distributeur
ccc = self.cards_to_distribute.split(',')
for i in range(N_TURN):
win, xxx = winner(ccc[i*N_PLAYERS:(i+1)*N_PLAYERS], self.atout)
@ -269,7 +270,7 @@ class Game(db.Model):
else:
self.points_1 += 90
# belote possible
winnr = 0
winnr = self.distributeur
belote =-1
ccc = self.cards_to_distribute.split(',')
for i in range(N_TURN):
@ -317,7 +318,11 @@ class Game(db.Model):
self.cumul_1 += self.points_1
self.points_0 = 0
self.points_1 = 0
self.first_player = 0
if self.distributeur <3:
self.distributeur += 1
else:
self.distributeur = 0
self.first_player = self.distributeur
self.distribute()
db.session.commit()
return True