bot recursion fix and bot lazo fix

This commit is contained in:
Alberto Xamin 2020-12-20 15:03:33 +01:00
parent 2e73b96499
commit 9eafeb4569
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
2 changed files with 5 additions and 2 deletions

View File

@ -8,6 +8,9 @@ import socketio
from bang.game import Game
from bang.players import Player
import sys
sys.setrecursionlimit(10**6) # this should prevents bots from stopping
sio = socketio.Server(cors_allowed_origins="*")
static_files={
'/': {'content_type': 'text/html', 'filename': 'index.html'},

View File

@ -227,7 +227,7 @@ class Player:
self.play_card(i)
has_played = True
break
elif len([c for c in self.hand if c.need_target and not (self.has_played_bang and not any([isinstance(c, cs.Volcanic) for c in self.equipment]))]) > 0:
elif len([c for c in self.hand if c.need_target and not (self.has_played_bang and not (any([isinstance(c, cs.Volcanic) for c in self.equipment]) and not self.game.check_event(ce.Lazo)))]) > 0:
for i in range(len(self.hand)):
if self.hand[i].need_target and not (self.has_played_bang and not any([isinstance(c, cs.Volcanic) for c in self.equipment])):
if self.hand[i].need_with and len(self.hand) < 2:
@ -245,7 +245,7 @@ class Player:
self.play_card(i, against=target['name'], _with=sample([j for j in range(len(self.hand)) if j != i], 1)[0])
has_played = True
break
elif any([not isinstance(c, cs.Mancato) and c.usable_next_turn and c.can_be_used_now for c in self.equipment]):
elif any([not isinstance(c, cs.Mancato) and c.usable_next_turn and c.can_be_used_now for c in self.equipment if not self.game.check_event(ce.Lazo)]):
print('hmm', [not isinstance(c, cs.Mancato) and c.usable_next_turn and c.can_be_used_now for c in self.equipment])
for i in range(len(self.equipment)):
c = self.equipment[i]