El Impostor v0.1 — app Flutter completa
Juego de deducción social para 3-20 jugadores. Modo un solo móvil completamente funcional. 1000 palabras en 10 categorías. Notas privadas, votación, adivinanza, revancha. Material 3 dark theme. Package: es.freetimelab.elimpostor
This commit is contained in:
79
lib/modelos/partida.dart
Normal file
79
lib/modelos/partida.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
import 'jugador.dart';
|
||||
|
||||
/// Configuración de una partida
|
||||
class ConfigPartida {
|
||||
final bool modoMultimovil;
|
||||
final String categoria; // 'todas' o nombre de categoría
|
||||
final int numImpostores;
|
||||
final bool pistaImpostor;
|
||||
final int? tiempoDebateSegundos; // null = sin límite
|
||||
|
||||
const ConfigPartida({
|
||||
this.modoMultimovil = false,
|
||||
this.categoria = 'todas',
|
||||
this.numImpostores = 1,
|
||||
this.pistaImpostor = false,
|
||||
this.tiempoDebateSegundos,
|
||||
});
|
||||
}
|
||||
|
||||
/// Fases del juego
|
||||
enum FaseJuego {
|
||||
configuracion,
|
||||
verPalabra,
|
||||
debate,
|
||||
votacion,
|
||||
resultado,
|
||||
adivinanza, // El impostor intenta adivinar la palabra
|
||||
finPartida,
|
||||
}
|
||||
|
||||
/// Resultado de una ronda de votación
|
||||
class ResultadoVotacion {
|
||||
final String eliminadoId;
|
||||
final String eliminadoNombre;
|
||||
final bool eraImpostor;
|
||||
final Map<String, String> votos; // votante -> votado
|
||||
|
||||
const ResultadoVotacion({
|
||||
required this.eliminadoId,
|
||||
required this.eliminadoNombre,
|
||||
required this.eraImpostor,
|
||||
required this.votos,
|
||||
});
|
||||
}
|
||||
|
||||
/// Estado completo de una partida
|
||||
class Partida {
|
||||
final ConfigPartida config;
|
||||
final List<Jugador> jugadores;
|
||||
final String palabraSecreta;
|
||||
final String categoriaReal;
|
||||
FaseJuego fase;
|
||||
int rondaActual;
|
||||
final List<ResultadoVotacion> historialVotaciones;
|
||||
String? ganador; // 'jugadores' | 'impostores' | null
|
||||
|
||||
Partida({
|
||||
required this.config,
|
||||
required this.jugadores,
|
||||
required this.palabraSecreta,
|
||||
required this.categoriaReal,
|
||||
this.fase = FaseJuego.verPalabra,
|
||||
this.rondaActual = 1,
|
||||
List<ResultadoVotacion>? historialVotaciones,
|
||||
this.ganador,
|
||||
}) : historialVotaciones = historialVotaciones ?? [];
|
||||
|
||||
List<Jugador> get jugadoresActivos =>
|
||||
jugadores.where((j) => !j.eliminado).toList();
|
||||
|
||||
List<Jugador> get impostoresActivos =>
|
||||
jugadoresActivos.where((j) => j.esImpostor).toList();
|
||||
|
||||
List<Jugador> get jugadoresNormalesActivos =>
|
||||
jugadoresActivos.where((j) => !j.esImpostor).toList();
|
||||
|
||||
int get impostoresTotales =>
|
||||
jugadores.where((j) => j.esImpostor).length;
|
||||
}
|
||||
Reference in New Issue
Block a user