Auto-sync: 20260320_200000
This commit is contained in:
parent
b4ab3590be
commit
d68068117a
1 changed files with 9 additions and 2 deletions
|
|
@ -305,7 +305,10 @@ class _HomeScreenState extends State<HomeScreen> with WidgetsBindingObserver {
|
|||
String roomCode = String.fromCharCodes(Iterable.generate(5, (_) => chars.codeUnitAt(rnd.nextInt(chars.length))));
|
||||
|
||||
try {
|
||||
// 1. Creiamo la stanza sul database
|
||||
// 1. IL SEGRETO DELLA SINCRONIZZAZIONE: Generiamo un "Seme" (Seed) comune!
|
||||
int gameSeed = rnd.nextInt(9999999);
|
||||
|
||||
// Creiamo la stanza privata con tutti i crismi (e il seed!)
|
||||
await FirebaseFirestore.instance.collection('games').doc(roomCode).set({
|
||||
'status': 'waiting',
|
||||
'hostName': StorageService.instance.playerName,
|
||||
|
|
@ -313,8 +316,12 @@ class _HomeScreenState extends State<HomeScreen> with WidgetsBindingObserver {
|
|||
'radius': 4,
|
||||
'shape': 'classic',
|
||||
'timeMode': true,
|
||||
'isPublic': false, // È una stanza privata!
|
||||
'isPublic': false, // È una stanza privata
|
||||
'createdAt': FieldValue.serverTimestamp(),
|
||||
'players': [FirebaseAuth.instance.currentUser?.uid],
|
||||
'turn': 0,
|
||||
'moves': [],
|
||||
'seed': gameSeed, // <--- ECCO IL PEZZO MANCANTE CHE GARANTISCE GRIGLIE IDENTICHE!
|
||||
});
|
||||
|
||||
// 2. Inviamo l'invito al nostro avversario
|
||||
|
|
|
|||
Loading…
Reference in a new issue