benedizione, maledizione
This commit is contained in:
		
							parent
							
								
									25bf088c3e
								
							
						
					
					
						commit
						a7fe148ff9
					
				| @ -75,6 +75,15 @@ class Card(ABC): | |||||||
|     def is_duplicate_card(self, player): |     def is_duplicate_card(self, player): | ||||||
|         return self.name in [c.name for c in player.equipment] |         return self.name in [c.name for c in player.equipment] | ||||||
| 
 | 
 | ||||||
|  |     def check_suit(self, game, accepted): | ||||||
|  |         import bang.expansions.high_noon.card_events as ceh | ||||||
|  |         if game.check_event(ceh.Benedizione): | ||||||
|  |             return Suit.HEARTS in accepted | ||||||
|  |         elif game.check_event(ceh.Maledizione): | ||||||
|  |             return Suit.SPADES in accepted | ||||||
|  |         return self.suit in accepted | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class Barile(Card): | class Barile(Card): | ||||||
|     def __init__(self, suit, number): |     def __init__(self, suit, number): | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ from typing import List, Set, Dict, Tuple, Optional | |||||||
| import random | import random | ||||||
| import bang.cards as cs | import bang.cards as cs | ||||||
| import bang.expansions.fistful_of_cards.card_events as ce | import bang.expansions.fistful_of_cards.card_events as ce | ||||||
|  | import bang.expansions.high_noon.card_events as ceh | ||||||
| 
 | 
 | ||||||
| class Deck: | class Deck: | ||||||
|     def __init__(self, game): |     def __init__(self, game): | ||||||
| @ -22,6 +23,9 @@ class Deck: | |||||||
|         self.event_cards: List[ce.CardEvent] = [] |         self.event_cards: List[ce.CardEvent] = [] | ||||||
|         if 'fistful_of_cards' in game.expansions: |         if 'fistful_of_cards' in game.expansions: | ||||||
|             self.event_cards.extend(ce.get_all_events()) |             self.event_cards.extend(ce.get_all_events()) | ||||||
|  |         if 'high_noon' in game.expansions: | ||||||
|  |             self.event_cards.extend(ceh.get_all_events()) | ||||||
|  |         if len(self.event_cards) > 0: | ||||||
|             self.event_cards.insert(0, None) |             self.event_cards.insert(0, None) | ||||||
|             self.event_cards.insert(0, None) # 2 perchè iniziale, e primo flip dallo sceriffo |             self.event_cards.insert(0, None) # 2 perchè iniziale, e primo flip dallo sceriffo | ||||||
|         random.shuffle(self.cards) |         random.shuffle(self.cards) | ||||||
|  | |||||||
							
								
								
									
										41
									
								
								backend/bang/expansions/high_noon/card_events.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								backend/bang/expansions/high_noon/card_events.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | |||||||
|  | import random | ||||||
|  | from bang.expansions.fistful_of_cards.card_events import CardEvent | ||||||
|  | 
 | ||||||
|  | class Benedizione(CardEvent): | ||||||
|  |     def __init__(self): | ||||||
|  |         super().__init__("Benedizione", "🙏") | ||||||
|  |         self.desc = "Tutte le carte sono considerate di cuori ♥️" | ||||||
|  |         self.desc_eng = "" | ||||||
|  | 
 | ||||||
|  | class Maledizione(CardEvent): | ||||||
|  |     def __init__(self): | ||||||
|  |         super().__init__("Maledizione", "🤬") | ||||||
|  |         self.desc = "Tutte le carte sono considerate di picche ♠" | ||||||
|  |         self.desc_eng = "" | ||||||
|  | 
 | ||||||
|  | class MezzogiornoDiFuoco(CardEvent): | ||||||
|  |     def __init__(self): | ||||||
|  |         super().__init__("Mezzogiorno di Fuoco", "🔥") | ||||||
|  |         self.desc = "Ogni giocatore perde 1 punto vita all'inizio del turno" | ||||||
|  |         self.desc_eng = "Every player loses 1 HP when their turn starts" | ||||||
|  | 
 | ||||||
|  | def get_all_events(): | ||||||
|  |     cards = [ | ||||||
|  |        Benedizione(), | ||||||
|  |        Maledizione(), | ||||||
|  |     #    CittaFantasma(), | ||||||
|  |     #    CorsaAllOro(), | ||||||
|  |     #    IDalton(), | ||||||
|  |     #    IlDottore(), | ||||||
|  |     #    IlReverendo(), | ||||||
|  |     #    IlTreno(), | ||||||
|  |     #    Sbornia(), | ||||||
|  |     #    Seromone(), | ||||||
|  |     #    Sete(), | ||||||
|  |     #    Sparatoria(), | ||||||
|  |     ] | ||||||
|  |     random.shuffle(cards) | ||||||
|  |     cards.append(MezzogiornoDiFuoco()) | ||||||
|  |     for c in cards: | ||||||
|  |         c.expansion = 'high-noon' | ||||||
|  |     return cards | ||||||
| @ -24,7 +24,7 @@ class Game: | |||||||
|         self.initial_players = 0 |         self.initial_players = 0 | ||||||
|         self.password = '' |         self.password = '' | ||||||
|         self.expansions = [] |         self.expansions = [] | ||||||
|         self.available_expansions = ['dodge_city', 'fistful_of_cards'] |         self.available_expansions = ['dodge_city', 'fistful_of_cards', 'high_noon'] | ||||||
|         self.shutting_down = False |         self.shutting_down = False | ||||||
|         self.is_competitive = False |         self.is_competitive = False | ||||||
|         self.disconnect_bot = True |         self.disconnect_bot = True | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ import bang.expansions.dodge_city.cards as csd | |||||||
| import bang.characters as chars | import bang.characters as chars | ||||||
| import bang.expansions.dodge_city.characters as chd | import bang.expansions.dodge_city.characters as chd | ||||||
| import bang.expansions.fistful_of_cards.card_events as ce | import bang.expansions.fistful_of_cards.card_events as ce | ||||||
|  | import bang.expansions.high_noon.card_events as ceh | ||||||
| import eventlet | import eventlet | ||||||
| 
 | 
 | ||||||
| class PendingAction(IntEnum): | class PendingAction(IntEnum): | ||||||
| @ -403,7 +404,7 @@ class Player: | |||||||
|                         for p in self.game.players: |                         for p in self.game.players: | ||||||
|                             if p != self: |                             if p != self: | ||||||
|                                 p.notify_card(self, card, 'blackjack_special' if isinstance(self.character, chars.BlackJack) else 'foc.leggedelwest') |                                 p.notify_card(self, card, 'blackjack_special' if isinstance(self.character, chars.BlackJack) else 'foc.leggedelwest') | ||||||
|                         if card.suit == cs.Suit.HEARTS or card.suit == cs.Suit.DIAMONDS and isinstance(self.character, chars.BlackJack): |                         if card.check_suit(self.game, [cs.Suit.HEARTS, cs.Suit.DIAMONDS]) and isinstance(self.character, chars.BlackJack): | ||||||
|                             self.hand.append(self.game.deck.draw()) |                             self.hand.append(self.game.deck.draw()) | ||||||
|                 if isinstance(self.character, chd.PixiePete): |                 if isinstance(self.character, chd.PixiePete): | ||||||
|                     self.hand.append(self.game.deck.draw()) |                     self.hand.append(self.game.deck.draw()) | ||||||
| @ -422,7 +423,7 @@ class Player: | |||||||
|                         print(f'Did pick {picked}') |                         print(f'Did pick {picked}') | ||||||
|                         self.sio.emit('chat_message', room=self.game.name, |                         self.sio.emit('chat_message', room=self.game.name, | ||||||
|                                       data=f'_flipped|{self.name}|{picked}') |                                       data=f'_flipped|{self.name}|{picked}') | ||||||
|                         if picked.suit == cs.Suit.SPADES and 2 <= picked.number <= 9 and pickable_cards == 0: |                         if picked.check_suit(self.game, [cs.Suit.SPADES]) and 2 <= picked.number <= 9 and pickable_cards == 0: | ||||||
|                             self.lives -= 3 |                             self.lives -= 3 | ||||||
|                             self.game.deck.scrap(self.equipment.pop(i), True) |                             self.game.deck.scrap(self.equipment.pop(i), True) | ||||||
|                             self.sio.emit('chat_message', room=self.game.name, data=f'_explode|{self.name}') |                             self.sio.emit('chat_message', room=self.game.name, data=f'_explode|{self.name}') | ||||||
| @ -448,7 +449,7 @@ class Player: | |||||||
|                         print(f'Did pick {picked}') |                         print(f'Did pick {picked}') | ||||||
|                         self.sio.emit('chat_message', room=self.game.name, |                         self.sio.emit('chat_message', room=self.game.name, | ||||||
|                                       data=f'_flipped|{self.name}|{picked}') |                                       data=f'_flipped|{self.name}|{picked}') | ||||||
|                         if picked.suit != cs.Suit.HEARTS and pickable_cards == 0: |                         if not picked.check_suit(self.game, [cs.Suit.HEARTS]) and pickable_cards == 0: | ||||||
|                             self.game.deck.scrap(self.equipment.pop(i), True) |                             self.game.deck.scrap(self.equipment.pop(i), True) | ||||||
|                             self.end_turn(forced=True) |                             self.end_turn(forced=True) | ||||||
|                             return |                             return | ||||||
| @ -497,7 +498,7 @@ class Player: | |||||||
|         print(self.name, 'is playing ', card, ' against:', against, ' with:', _with) |         print(self.name, 'is playing ', card, ' against:', against, ' with:', _with) | ||||||
|         did_play_card = False |         did_play_card = False | ||||||
|         event_blocks_card = (self.game.check_event(ce.IlGiudice) and (card.is_equipment or (card.usable_next_turn and not card.can_be_used_now))) or (self.game.check_event(ce.Lazo) and card.usable_next_turn and card.can_be_used_now) |         event_blocks_card = (self.game.check_event(ce.IlGiudice) and (card.is_equipment or (card.usable_next_turn and not card.can_be_used_now))) or (self.game.check_event(ce.Lazo) and card.usable_next_turn and card.can_be_used_now) | ||||||
|         if not(against != None and isinstance(self.game.get_player_named(against).character, chd.ApacheKid) and card.suit == cs.Suit.DIAMONDS) and not event_blocks_card: |         if not(against != None and isinstance(self.game.get_player_named(against).character, chd.ApacheKid) and card.check_suit(self.game, [cs.Suit.DIAMONDS])) and not event_blocks_card: | ||||||
|             if against == self.name and not isinstance(card, csd.Tequila): |             if against == self.name and not isinstance(card, csd.Tequila): | ||||||
|                 did_play_card = False |                 did_play_card = False | ||||||
|             else: |             else: | ||||||
| @ -647,7 +648,7 @@ class Player: | |||||||
|             print(f'Did pick {picked}') |             print(f'Did pick {picked}') | ||||||
|             self.sio.emit('chat_message', room=self.game.name, |             self.sio.emit('chat_message', room=self.game.name, | ||||||
|                             data=f'_flipped|{self.name}|{picked}') |                             data=f'_flipped|{self.name}|{picked}') | ||||||
|             if picked.suit == cs.Suit.HEARTS: |             if picked.check_suit(self.game, [cs.Suit.HEARTS]): | ||||||
|                 self.mancato_needed -= 1 |                 self.mancato_needed -= 1 | ||||||
|                 self.notify_self() |                 self.notify_self() | ||||||
|                 if self.mancato_needed <= 0: |                 if self.mancato_needed <= 0: | ||||||
| @ -677,7 +678,7 @@ class Player: | |||||||
|             print(f'Did pick {picked}') |             print(f'Did pick {picked}') | ||||||
|             self.sio.emit('chat_message', room=self.game.name, |             self.sio.emit('chat_message', room=self.game.name, | ||||||
|                             data=f'_flipped|{self.name}|{picked}') |                             data=f'_flipped|{self.name}|{picked}') | ||||||
|             if picked.suit == cs.Suit.HEARTS: |             if picked.check_suit(self.game, [cs.Suit.HEARTS]): | ||||||
|                 self.mancato_needed -= 1 |                 self.mancato_needed -= 1 | ||||||
|                 self.notify_self() |                 self.notify_self() | ||||||
|                 if self.mancato_needed <= 0: |                 if self.mancato_needed <= 0: | ||||||
| @ -921,7 +922,7 @@ class Player: | |||||||
|             if not forced and self.game.check_event(ce.Vendetta) and self.can_play_vendetta: |             if not forced and self.game.check_event(ce.Vendetta) and self.can_play_vendetta: | ||||||
|                 picked: cs.Card = self.game.deck.pick_and_scrap() |                 picked: cs.Card = self.game.deck.pick_and_scrap() | ||||||
|                 self.sio.emit('chat_message', room=self.game.name, data=f'_flipped|{self.name}|{picked}') |                 self.sio.emit('chat_message', room=self.game.name, data=f'_flipped|{self.name}|{picked}') | ||||||
|                 if picked.suit == cs.Suit.HEARTS: |                 if picked.check_suit(self.game, [cs.Suit.HEARTS]): | ||||||
|                     self.play_turn(can_play_vendetta=False) |                     self.play_turn(can_play_vendetta=False) | ||||||
|                     return |                     return | ||||||
|             self.is_my_turn = False |             self.is_my_turn = False | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Alberto Xamin
						Alberto Xamin