Esempio n. 1
0
        private async Task CreateRoomActionAsync()
        {
            using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Chargement"))
            {
                Room room = await App.DatabaseUtil.GetRoom(RoomId);

                if (room != null)
                {
                    MaterialDialog.Instance.SnackbarAsync("Une Partie a déjà cet identifiant, veuillez en choisir un autre svp", MaterialSnackbar.DurationLong);
                }
                else
                {
                    await App.DatabaseUtil.AddRoom(RoomId);

                    App.CurrentRoom = RoomId;
                    App.IsAdmin     = true;
                    ListPlayersPageViewModel listPlayersPageVM = new ListPlayersPageViewModel();
                    await listPlayersPageVM.Init();

                    await App.Current.MainPage.Navigation.PushAsync(new ListPlayersPage(listPlayersPageVM), true);
                }
            }
        }
Esempio n. 2
0
        private async Task JoinRoomActionAsync()
        {
            using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Chargement"))
            {
                Room room = await App.DatabaseUtil.GetRoom(RoomId);

                if (room == null)
                {
                    MaterialDialog.Instance.SnackbarAsync("Aucune partie trouvée, veuillez réessayer", MaterialSnackbar.DurationLong);
                }
                if (room.Players == null)
                {
                    room.Players = new List <Player>();
                }
                if (room.Players.Where(a => a.Name == PlayerName).FirstOrDefault() != null)
                {
                    MaterialDialog.Instance.SnackbarAsync("Un joueur ou une équipe a déjà ce nom, veuillez réessayer", MaterialSnackbar.DurationLong);
                }
                else
                {
                    App.CurrentRoom   = RoomId;
                    App.CurrentPlayer = PlayerName;
                    App.IsAdmin       = false;

                    room.Players.Add(new Player()
                    {
                        Name = PlayerName, StringColor = ListColor.First(x => x.Value == SelectedColor).Name
                    });
                    await App.DatabaseUtil.EditRoom(room);

                    ListPlayersPageViewModel listPlayersPageVM = new ListPlayersPageViewModel();
                    await listPlayersPageVM.Init();

                    await App.Current.MainPage.Navigation.PushAsync(new ListPlayersPage(listPlayersPageVM), true);
                }
            }
        }