Change 1st player at each partie
This commit is contained in:
parent
2651e77b85
commit
c1d5a792d0
@ -55,10 +55,7 @@ class CustomNamespacePlay(fio.Namespace):
|
|||||||
fio.emit('text', {'text': "Couleur d'atout inconnue ({})".format(atout), 'username':None, 'name':NAME_ARBITRE})
|
fio.emit('text', {'text': "Couleur d'atout inconnue ({})".format(atout), 'username':None, 'name':NAME_ARBITRE})
|
||||||
return
|
return
|
||||||
# OK !
|
# OK !
|
||||||
print('atout choix')
|
|
||||||
print(atout)
|
|
||||||
if(game.tour_choix(atout, current_user)):
|
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)
|
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:
|
else:
|
||||||
fio.emit('text', {'text': "Erreur E0101", 'username':None, 'name':NAME_ARBITRE})
|
fio.emit('text', {'text': "Erreur E0101", 'username':None, 'name':NAME_ARBITRE})
|
||||||
@ -107,6 +104,10 @@ class CustomNamespacePlay(fio.Namespace):
|
|||||||
else:
|
else:
|
||||||
fio.emit('text', {'text': "Demandez au maitre du jeu pour reprendre une partie.", 'username':None, 'name':NAME_ARBITRE})
|
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):
|
def game(self):
|
||||||
return Game.query.get(self._id)
|
return Game.query.get(self._id)
|
||||||
|
|
||||||
|
11
db.py
11
db.py
@ -70,6 +70,7 @@ class Game(db.Model):
|
|||||||
cumul_0 = db.Column(db.Integer, default=0)
|
cumul_0 = db.Column(db.Integer, default=0)
|
||||||
cumul_1 = db.Column(db.Integer, default=0)
|
cumul_1 = db.Column(db.Integer, default=0)
|
||||||
partie = db.Column(db.Integer, default=1)
|
partie = db.Column(db.Integer, default=1)
|
||||||
|
distributeur = db.Column(db.Integer, default=0)
|
||||||
|
|
||||||
def start_game(self, ordered_players):
|
def start_game(self, ordered_players):
|
||||||
# Ordering players
|
# Ordering players
|
||||||
@ -256,7 +257,7 @@ class Game(db.Model):
|
|||||||
if self.points_0 == 162 or self.points_1 == 162:
|
if self.points_0 == 162 or self.points_1 == 162:
|
||||||
winequipe = 0 if self.points_0 == 162 else 1
|
winequipe = 0 if self.points_0 == 162 else 1
|
||||||
# Capote possible.
|
# Capote possible.
|
||||||
winnr = 0
|
winnr = self.distributeur
|
||||||
ccc = self.cards_to_distribute.split(',')
|
ccc = self.cards_to_distribute.split(',')
|
||||||
for i in range(N_TURN):
|
for i in range(N_TURN):
|
||||||
win, xxx = winner(ccc[i*N_PLAYERS:(i+1)*N_PLAYERS], self.atout)
|
win, xxx = winner(ccc[i*N_PLAYERS:(i+1)*N_PLAYERS], self.atout)
|
||||||
@ -269,7 +270,7 @@ class Game(db.Model):
|
|||||||
else:
|
else:
|
||||||
self.points_1 += 90
|
self.points_1 += 90
|
||||||
# belote possible
|
# belote possible
|
||||||
winnr = 0
|
winnr = self.distributeur
|
||||||
belote =-1
|
belote =-1
|
||||||
ccc = self.cards_to_distribute.split(',')
|
ccc = self.cards_to_distribute.split(',')
|
||||||
for i in range(N_TURN):
|
for i in range(N_TURN):
|
||||||
@ -317,7 +318,11 @@ class Game(db.Model):
|
|||||||
self.cumul_1 += self.points_1
|
self.cumul_1 += self.points_1
|
||||||
self.points_0 = 0
|
self.points_0 = 0
|
||||||
self.points_1 = 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()
|
self.distribute()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user