fix stuff
This commit is contained in:
parent
c9efd63ef2
commit
83359eb497
@ -232,7 +232,10 @@ def chat_message(sid, msg):
|
|||||||
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and removed a card'})
|
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and removed a card'})
|
||||||
cmd = msg.split()
|
cmd = msg.split()
|
||||||
if len(cmd) == 2:
|
if len(cmd) == 2:
|
||||||
ses.hand.pop(int(cmd[1]))
|
if len(ses.hand) > int(cmd[1]):
|
||||||
|
ses.hand.pop(int(cmd[1]))
|
||||||
|
else:
|
||||||
|
ses.hand.pop(int(cmd[1])-len(ses.hand))
|
||||||
ses.notify_self()
|
ses.notify_self()
|
||||||
elif '/getcard' in msg:
|
elif '/getcard' in msg:
|
||||||
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and got a card'})
|
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and got a card'})
|
||||||
@ -246,6 +249,9 @@ def chat_message(sid, msg):
|
|||||||
sio.emit('chat_message', room=sid, data={'color': f'','text':f'info: {ses.game.__dict__}'})
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'info: {ses.game.__dict__}'})
|
||||||
elif '/meinfo' in msg:
|
elif '/meinfo' in msg:
|
||||||
sio.emit('chat_message', room=sid, data={'color': f'','text':f'info: {ses.__dict__}'})
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'info: {ses.__dict__}'})
|
||||||
|
elif '/mebot' in msg:
|
||||||
|
ses.is_bot = not ses.is_bot
|
||||||
|
ses.notify_self()
|
||||||
else:
|
else:
|
||||||
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} COMMAND NOT FOUND'})
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} COMMAND NOT FOUND'})
|
||||||
else:
|
else:
|
||||||
|
@ -122,6 +122,7 @@ class Prigione(Card):
|
|||||||
data=f'_play_card_against|{player.name}|{self.name}|{against}')
|
data=f'_play_card_against|{player.name}|{self.name}|{against}')
|
||||||
player.game.get_player_named(against).equipment.append(self)
|
player.game.get_player_named(against).equipment.append(self)
|
||||||
player.game.get_player_named(against).notify_self()
|
player.game.get_player_named(against).notify_self()
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class Remington(Card):
|
class Remington(Card):
|
||||||
|
@ -187,7 +187,7 @@ class Game:
|
|||||||
self.get_player_named(target_username).notify_self()
|
self.get_player_named(target_username).notify_self()
|
||||||
|
|
||||||
def emporio(self):
|
def emporio(self):
|
||||||
self.available_cards = [self.deck.draw(True) for i in range(len(self.players))]
|
self.available_cards = [self.deck.draw(True) for i in range(len([p for p in self.players if p.lives > 0]))]
|
||||||
self.players[self.turn].pending_action = pl.PendingAction.CHOOSE
|
self.players[self.turn].pending_action = pl.PendingAction.CHOOSE
|
||||||
self.players[self.turn].available_cards = self.available_cards
|
self.players[self.turn].available_cards = self.available_cards
|
||||||
self.players[self.turn].notify_self()
|
self.players[self.turn].notify_self()
|
||||||
|
@ -223,37 +223,35 @@ class Player:
|
|||||||
elif self.pending_action == PendingAction.DRAW:
|
elif self.pending_action == PendingAction.DRAW:
|
||||||
self.draw('')
|
self.draw('')
|
||||||
elif self.pending_action == PendingAction.PLAY:
|
elif self.pending_action == PendingAction.PLAY:
|
||||||
has_played = False
|
equippables = [c for c in self.hand if (c.is_equipment or c.usable_next_turn) and not isinstance(c, cs.Prigione) and not self.game.check_event(ce.IlGiudice) and not any([type(c) == type(x) for x in self.equipment])]
|
||||||
if len([c for c in self.hand if (c.is_equipment or c.usable_next_turn) and not self.game.check_event(ce.IlGiudice)]) > 0:
|
if len(equippables) > 0:
|
||||||
for i in range(len(self.hand)):
|
for c in equippables:
|
||||||
if self.hand[i].is_equipment or self.hand[i].usable_next_turn:
|
if self.play_card(self.hand.index(c)):
|
||||||
self.play_card(i)
|
return
|
||||||
has_played = True
|
|
||||||
break
|
|
||||||
elif any([isinstance(c, cs.WellsFargo) or isinstance(c, cs.Diligenza) or isinstance(c, cs.Emporio) or isinstance(c, cs.Birra) for c in self.hand]):
|
elif any([isinstance(c, cs.WellsFargo) or isinstance(c, cs.Diligenza) or isinstance(c, cs.Emporio) or isinstance(c, cs.Birra) for c in self.hand]):
|
||||||
for i in range(len(self.hand)):
|
for i in range(len(self.hand)):
|
||||||
c = self.hand[i]
|
c = self.hand[i]
|
||||||
if isinstance(c, cs.WellsFargo) or isinstance(c, cs.Diligenza) or isinstance(c, cs.Emporio) or (isinstance(c, cs.Birra) and self.lives < self.max_lives):
|
if isinstance(c, cs.WellsFargo) or isinstance(c, cs.Diligenza) or isinstance(c, cs.Emporio) or (isinstance(c, cs.Birra) and self.lives < self.max_lives):
|
||||||
self.play_card(i)
|
if self.play_card(i):
|
||||||
has_played = True
|
return
|
||||||
break
|
|
||||||
elif len([c for c in self.hand if c.need_target and c.can_be_used_now and not (c.is_equipment and self.game.check_event(ce.IlGiudice)) 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:
|
elif len([c for c in self.hand if c.need_target and c.can_be_used_now and not (c.is_equipment and self.game.check_event(ce.IlGiudice)) 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)):
|
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_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:
|
if self.hand[i].need_with and len(self.hand) < 2:
|
||||||
continue
|
continue
|
||||||
_range = self.get_sight() if self.hand[i].name == 'Bang!' or self.hand[i].name == "Pepperbox" else self.hand[i].range
|
_range = self.get_sight() if self.hand[i].name == 'Bang!' or self.hand[i].name == "Pepperbox" else self.hand[i].range
|
||||||
others = [p for p in self.game.get_visible_players(self) if _range >= p['dist'] and not (isinstance(self.role, r.Vice) and p['is_sheriff'])]
|
others = [p for p in self.game.get_visible_players(self) if _range >= p['dist'] and not (isinstance(self.role, r.Vice) and p['is_sheriff']) and p['lives'] > 0]
|
||||||
if len(others) == 0:
|
if len(others) == 0:
|
||||||
continue
|
continue
|
||||||
target = others[randrange(0, len(others))]
|
target = others[randrange(0, len(others))]
|
||||||
if target['is_sheriff'] and isinstance(self.role, r.Renegade):
|
if target['is_sheriff'] and isinstance(self.role, r.Renegade):
|
||||||
target = others[randrange(0, len(others))]
|
target = others[randrange(0, len(others))]
|
||||||
if not self.hand[i].need_with:
|
if not self.hand[i].need_with:
|
||||||
self.play_card(i, against=target['name'])
|
if self.play_card(i, against=target['name']):
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
self.play_card(i, against=target['name'], _with=sample([j for j in range(len(self.hand)) if j != i], 1)[0])
|
if 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
|
return
|
||||||
break
|
break
|
||||||
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)]):
|
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])
|
print('hmm', [not isinstance(c, cs.Mancato) and c.usable_next_turn and c.can_be_used_now for c in self.equipment])
|
||||||
@ -261,7 +259,8 @@ class Player:
|
|||||||
c = self.equipment[i]
|
c = self.equipment[i]
|
||||||
if not isinstance(c, cs.Mancato) and c.usable_next_turn and c.can_be_used_now:
|
if not isinstance(c, cs.Mancato) and c.usable_next_turn and c.can_be_used_now:
|
||||||
if not c.need_target:
|
if not c.need_target:
|
||||||
self.play_card(len(self.hand)+i)
|
if self.play_card(len(self.hand)+i):
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
_range = self.get_sight() if c.name == "Pepperbox" else c.range
|
_range = self.get_sight() if c.name == "Pepperbox" else c.range
|
||||||
others = [p for p in self.game.get_visible_players(self) if _range >= p['dist'] and not (isinstance(self.role, r.Vice) and p['is_sheriff'])]
|
others = [p for p in self.game.get_visible_players(self) if _range >= p['dist'] and not (isinstance(self.role, r.Vice) and p['is_sheriff'])]
|
||||||
@ -270,8 +269,8 @@ class Player:
|
|||||||
target = others[randrange(0, len(others))]
|
target = others[randrange(0, len(others))]
|
||||||
if target['is_sheriff'] and isinstance(self.role, r.Renegade):
|
if target['is_sheriff'] and isinstance(self.role, r.Renegade):
|
||||||
target = others[randrange(0, len(others))]
|
target = others[randrange(0, len(others))]
|
||||||
self.play_card(len(self.hand)+i, against=target['name'])
|
if self.play_card(len(self.hand)+i, against=target['name']):
|
||||||
has_played = True
|
return
|
||||||
break
|
break
|
||||||
maxcards = self.lives if not isinstance(self.character, chd.SeanMallory) else 10
|
maxcards = self.lives if not isinstance(self.character, chd.SeanMallory) else 10
|
||||||
if len(self.hand) > maxcards:
|
if len(self.hand) > maxcards:
|
||||||
@ -507,8 +506,12 @@ class Player:
|
|||||||
elif card.is_equipment or (card.usable_next_turn and not card.can_be_used_now):
|
elif card.is_equipment or (card.usable_next_turn and not card.can_be_used_now):
|
||||||
if not did_play_card:
|
if not did_play_card:
|
||||||
self.hand.insert(hand_index, card)
|
self.hand.insert(hand_index, card)
|
||||||
|
else:
|
||||||
|
did_play_card = True
|
||||||
print("did play card:", did_play_card)
|
print("did play card:", did_play_card)
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
|
if self.is_bot:
|
||||||
|
return did_play_card or card.is_equipment or (card.usable_next_turn and not card.can_be_used_now)
|
||||||
|
|
||||||
def choose(self, card_index):
|
def choose(self, card_index):
|
||||||
if self.pending_action != PendingAction.CHOOSE:
|
if self.pending_action != PendingAction.CHOOSE:
|
||||||
|
Loading…
Reference in New Issue
Block a user