event cards
This commit is contained in:
		
							parent
							
								
									9f15925bf1
								
							
						
					
					
						commit
						6562f5c1e8
					
				| @ -82,6 +82,7 @@ def get_me(sid, room): | |||||||
|                 sio.get_session(sid).game = de_games[0] |                 sio.get_session(sid).game = de_games[0] | ||||||
|                 sio.enter_room(sid, de_games[0].name) |                 sio.enter_room(sid, de_games[0].name) | ||||||
|                 de_games[0].notify_room(sid) |                 de_games[0].notify_room(sid) | ||||||
|  |             de_games[0].notify_event_card() | ||||||
|         else: |         else: | ||||||
|             create_room(sid, room['name']) |             create_room(sid, room['name']) | ||||||
|         if sio.get_session(sid).game == None: |         if sio.get_session(sid).game == None: | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| from typing import List, Set, Dict, Tuple, Optional | 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 | ||||||
| 
 | 
 | ||||||
| class Deck: | class Deck: | ||||||
|     def __init__(self, game): |     def __init__(self, game): | ||||||
| @ -18,10 +19,19 @@ class Deck: | |||||||
|             if c.name not in self.all_cards_str: |             if c.name not in self.all_cards_str: | ||||||
|                 self.all_cards_str.append(c.name) |                 self.all_cards_str.append(c.name) | ||||||
|         self.game = game |         self.game = game | ||||||
|  |         self.event_cards: List[ce.CardEvent] = [] | ||||||
|  |         if 'fistful_of_cards' in game.expansions: | ||||||
|  |             self.event_cards.extend(ce.get_all_events()) | ||||||
|  |         random.shuffle(self.event_cards) | ||||||
|         random.shuffle(self.cards) |         random.shuffle(self.cards) | ||||||
|         self.scrap_pile: List[cs.Card] = [] |         self.scrap_pile: List[cs.Card] = [] | ||||||
|         print(f'Deck initialized with {len(self.cards)} cards') |         print(f'Deck initialized with {len(self.cards)} cards') | ||||||
| 
 | 
 | ||||||
|  |     def flip_event(self): | ||||||
|  |         if len(self.event_cards) > 0: | ||||||
|  |             self.event_cards.append(self.event_cards.pop(0)) | ||||||
|  |             self.game.notify_event_card() | ||||||
|  | 
 | ||||||
|     def peek(self, n_cards: int) -> list: |     def peek(self, n_cards: int) -> list: | ||||||
|         return self.cards[:n_cards] |         return self.cards[:n_cards] | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,96 +1,115 @@ | |||||||
| from abc import ABC, abstractmethod | from abc import ABC, abstractmethod | ||||||
| 
 | 
 | ||||||
| def CardEvent(ABC): | class CardEvent(ABC): | ||||||
|     def __init__(self, name, icon): |     def __init__(self, name, icon): | ||||||
|         self.name = name |         self.name = name | ||||||
|         self.icon = icon |         self.icon = icon | ||||||
| 
 | 
 | ||||||
| def Agguato(CardEvent): | class Agguato(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Agguato', '🛁') |         super().__init__('Agguato', '🛁') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def Cecchino(CardEvent): | class Cecchino(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Cecchino', '👁') |         super().__init__('Cecchino', '👁') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def DeadMan(CardEvent): | class DeadMan(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Dead Man', '⚰️') |         super().__init__('Dead Man', '⚰️') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def FratelliDiSangue(CardEvent): | class FratelliDiSangue(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Fratelli Di Sangue', '🩸') |         super().__init__('Fratelli Di Sangue', '🩸') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def IlGiudice(CardEvent): | class IlGiudice(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Il Giudice', '👨⚖️') |         super().__init__('Il Giudice', '👨⚖️') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def Lazo(CardEvent): | class Lazo(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Lazo', '📿') |         super().__init__('Lazo', '📿') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def LeggeDelWest(CardEvent): | class LeggeDelWest(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Legge Del West', '⚖️') |         super().__init__('Legge Del West', '⚖️') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def LiquoreForte(CardEvent): | class LiquoreForte(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Liquore Forte', '🥃') |         super().__init__('Liquore Forte', '🥃') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def MinieraAbbandonata(CardEvent): | class MinieraAbbandonata(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Miniera Abbandonata', '⛏') |         super().__init__('Miniera Abbandonata', '⛏') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def PerUnPugnoDiCarte(CardEvent): | class PerUnPugnoDiCarte(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Per Un Pugno Di Carte', '🎴') |         super().__init__('Per Un Pugno Di Carte', '🎴') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def Peyote(CardEvent): | class Peyote(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Peyote', '🌵') |         super().__init__('Peyote', '🌵') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def Ranch(CardEvent): | class Ranch(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Ranch', '🐮') |         super().__init__('Ranch', '🐮') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def Rimbalzo(CardEvent): | class Rimbalzo(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Rimbalzo', '⏮') |         super().__init__('Rimbalzo', '⏮') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def RouletteRussa(CardEvent): | class RouletteRussa(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Roulette Russa', '🇷🇺') |         super().__init__('Roulette Russa', '🇷🇺') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
| 
 | 
 | ||||||
| def Vendetta(CardEvent): | class Vendetta(CardEvent): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super.__init__('Vendetta', '😤') |         super().__init__('Vendetta', '😤') | ||||||
|         self.desc = '' |         self.desc = '' | ||||||
|         self.desc_eng = '' |         self.desc_eng = '' | ||||||
|  | 
 | ||||||
|  | def get_all_events(): | ||||||
|  |     return [ | ||||||
|  |         Agguato(), | ||||||
|  |         Cecchino(), | ||||||
|  |         DeadMan(), | ||||||
|  |         FratelliDiSangue(), | ||||||
|  |         IlGiudice(), | ||||||
|  |         Lazo(), | ||||||
|  |         LeggeDelWest(), | ||||||
|  |         LiquoreForte(), | ||||||
|  |         MinieraAbbandonata(), | ||||||
|  |         PerUnPugnoDiCarte(), | ||||||
|  |         Peyote(), | ||||||
|  |         Ranch(), | ||||||
|  |         Rimbalzo(), | ||||||
|  |         RouletteRussa(), | ||||||
|  |         Vendetta(), | ||||||
|  |     ] | ||||||
| @ -95,7 +95,7 @@ class Game: | |||||||
|             current_roles = [type(x.role).__name__ for x in self.players] |             current_roles = [type(x.role).__name__ for x in self.players] | ||||||
|             current_roles = {x:current_roles.count(x) for x in current_roles} |             current_roles = {x:current_roles.count(x) for x in current_roles} | ||||||
|             self.sio.emit('chat_message', room=self.name, data=f'_allroles|{current_roles}') |             self.sio.emit('chat_message', room=self.name, data=f'_allroles|{current_roles}') | ||||||
|             self.players[self.turn].play_turn() |             self.play_turn() | ||||||
| 
 | 
 | ||||||
|     def choose_characters(self): |     def choose_characters(self): | ||||||
|         char_cards = random.sample(characters.all_characters(self.expansions), len(self.players)*2) |         char_cards = random.sample(characters.all_characters(self.expansions), len(self.players)*2) | ||||||
| @ -216,6 +216,8 @@ class Game: | |||||||
|         return self.players[(self.turn + 1) % len(self.players)] |         return self.players[(self.turn + 1) % len(self.players)] | ||||||
| 
 | 
 | ||||||
|     def play_turn(self): |     def play_turn(self): | ||||||
|  |         if isinstance(self.players[self.turn].role, roles.Sheriff): | ||||||
|  |             self.deck.flip_event() | ||||||
|         self.players[self.turn].play_turn() |         self.players[self.turn].play_turn() | ||||||
| 
 | 
 | ||||||
|     def next_turn(self): |     def next_turn(self): | ||||||
| @ -224,6 +226,10 @@ class Game: | |||||||
|             self.turn = (self.turn + 1) % len(self.players) |             self.turn = (self.turn + 1) % len(self.players) | ||||||
|             self.play_turn() |             self.play_turn() | ||||||
| 
 | 
 | ||||||
|  |     def notify_event_card(self): | ||||||
|  |         if len(self.deck.event_cards) > 0: | ||||||
|  |             self.sio.emit('event_card', room=self.name, data=self.deck.event_cards[0].__dict__) | ||||||
|  | 
 | ||||||
|     def notify_scrap_pile(self): |     def notify_scrap_pile(self): | ||||||
|         print('scrap') |         print('scrap') | ||||||
|         if self.deck.peek_scrap_pile(): |         if self.deck.peek_scrap_pile(): | ||||||
|  | |||||||
| @ -73,12 +73,12 @@ export default { | |||||||
| 		0 0 0 3pt  #6aa16e, 0 0 0 6pt white, 0 0 5pt 6pt #aaa | 		0 0 0 3pt  #6aa16e, 0 0 0 6pt white, 0 0 5pt 6pt #aaa | ||||||
| } | } | ||||||
| .card.high-noon{ | .card.high-noon{ | ||||||
| 	box-shadow: 0 0 0pt 6pt #181a1b, 0 0 5pt 6pt #aaa; | 	box-shadow: 0 0 0pt 4pt white, 0 0 5pt 4pt #aaa; | ||||||
| 	border: 2pt dotted rgb(198 78 45); | 	border: 2pt dotted rgb(198 78 45); | ||||||
| } | } | ||||||
| .card.fistful-of-cards{ | .card.fistful-of-cards{ | ||||||
| 	box-shadow: 0 0 0pt 6pt #181a1b, 0 0 5pt 6pt #aaa; | 	box-shadow: 0 0 0pt 4pt white, 0 0 5pt 4pt #aaa; | ||||||
| 	border: 2pt dotted rgb(50 122 172); | 	border: 2pt dashed rgb(50 122 172); | ||||||
| } | } | ||||||
| .card h4 { | .card h4 { | ||||||
| 	position: absolute; | 	position: absolute; | ||||||
| @ -143,5 +143,11 @@ export default { | |||||||
| 		box-shadow:  | 		box-shadow:  | ||||||
| 			0 0 0 3pt #6aa16e, 0 0 0 6pt #181a1b, 0 0 5pt 6pt #aaa | 			0 0 0 3pt #6aa16e, 0 0 0 6pt #181a1b, 0 0 5pt 6pt #aaa | ||||||
| 	} | 	} | ||||||
|  | 	.card.high-noon{ | ||||||
|  | 		box-shadow: 0 0 0pt 4pt #181a1b, 0 0 5pt 4pt #aaa; | ||||||
|  | 	} | ||||||
|  | 	.card.fistful-of-cards{ | ||||||
|  | 		box-shadow: 0 0 0pt 4pt #181a1b, 0 0 5pt 4pt #aaa; | ||||||
|  | 	} | ||||||
| } | } | ||||||
| </style> | </style> | ||||||
| @ -2,6 +2,11 @@ | |||||||
| 	<div> | 	<div> | ||||||
| 		<div class="deck"> | 		<div class="deck"> | ||||||
| 			<card v-if="endTurnAction && isPlaying" v-show="pending_action == 2" :card="endTurnCard" class="end-turn" @click.native="endTurnAction"/> | 			<card v-if="endTurnAction && isPlaying" v-show="pending_action == 2" :card="endTurnCard" class="end-turn" @click.native="endTurnAction"/> | ||||||
|  | 			<div v-if="eventCard" style="position:relative"> | ||||||
|  | 				<div class="card fistful-of-cards" style="position:relative; bottom:-3pt;right:-3pt;"/> | ||||||
|  | 				<div class="card fistful-of-cards" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/> | ||||||
|  | 				<card :card="eventCard" :key="eventCard" :class="{'last-event':true,'fistful-of-cards':true}"/> | ||||||
|  | 			</div> | ||||||
| 			<div style="position:relative"> | 			<div style="position:relative"> | ||||||
| 				<div class="card back" style="position:absolute; bottom:-3pt;right:-3pt;"/> | 				<div class="card back" style="position:absolute; bottom:-3pt;right:-3pt;"/> | ||||||
| 				<div class="card back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/> | 				<div class="card back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/> | ||||||
| @ -15,6 +20,7 @@ | |||||||
| 			</div> | 			</div> | ||||||
| 		</div> | 		</div> | ||||||
| 		<transition name="list"> | 		<transition name="list"> | ||||||
|  | 			<p v-if="eventCard" class="center-stuff"><i>{{($i18n.locale=='it'?eventCard.desc:eventCard.desc_eng)}}</i></p> | ||||||
| 			<p v-if="desc" class="center-stuff"><i>{{desc}}</i></p> | 			<p v-if="desc" class="center-stuff"><i>{{desc}}</i></p> | ||||||
| 		</transition> | 		</transition> | ||||||
| 	</div> | 	</div> | ||||||
| @ -37,6 +43,7 @@ export default { | |||||||
| 			icon: '💥', | 			icon: '💥', | ||||||
| 		}, | 		}, | ||||||
| 		lastScrap: null, | 		lastScrap: null, | ||||||
|  | 		eventCard: null, | ||||||
| 		previousScrap: null, | 		previousScrap: null, | ||||||
| 		pending_action: false, | 		pending_action: false, | ||||||
| 		isPlaying: true, | 		isPlaying: true, | ||||||
| @ -50,7 +57,10 @@ export default { | |||||||
| 		}, | 		}, | ||||||
| 		scrap(card) { | 		scrap(card) { | ||||||
| 			this.lastScrap = card | 			this.lastScrap = card | ||||||
| 		} | 		}, | ||||||
|  | 		event_card(card) { | ||||||
|  | 			this.eventCard = card | ||||||
|  | 		}, | ||||||
| 	}, | 	}, | ||||||
| 	computed: { | 	computed: { | ||||||
| 		endTurnCard() { | 		endTurnCard() { | ||||||
| @ -81,10 +91,10 @@ export default { | |||||||
| </script> | </script> | ||||||
| <style scoped> | <style scoped> | ||||||
| .deck { | .deck { | ||||||
|   display:flex; | 	display:flex; | ||||||
|   margin:0; | 	margin:0; | ||||||
|   align-items: center; | 	align-items: center; | ||||||
|   justify-content: center; | 	justify-content: center; | ||||||
| 	flex-direction: row-reverse; | 	flex-direction: row-reverse; | ||||||
| } | } | ||||||
| .last-scrap { | .last-scrap { | ||||||
| @ -105,6 +115,20 @@ export default { | |||||||
| 		transform: translate(0, 0) scale(1); | 		transform: translate(0, 0) scale(1); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | .last-event { | ||||||
|  | 	position: absolute; | ||||||
|  | 	top: 0; | ||||||
|  | 	animation-duration: 0.8s; | ||||||
|  | 	animation-name: slidein; | ||||||
|  | } | ||||||
|  | @keyframes slidein { | ||||||
|  | 	from { | ||||||
|  | 		transform: translate(30px, 20px) scale(1.3) rotate(-10deg); | ||||||
|  | 	} | ||||||
|  | 	to { | ||||||
|  | 		transform: translate(0, 0) scale(1); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| .pick:hover { | .pick:hover { | ||||||
| 	transform: translate(-10px,0); | 	transform: translate(-10px,0); | ||||||
| 	z-index: 1; | 	z-index: 1; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Alberto Xamin
						Alberto Xamin