Exemple #1
0
        public void WaitClick(object sender, System.Windows.RoutedEventArgs e)
        {
            string actionText = "Unitstack wait...";

            ActionCompleted = true;
            OnActionCompleted?.Invoke(actionText);
        }
Exemple #2
0
        public void AttackClick(object sender, System.Windows.RoutedEventArgs e)
        {
            string actionText = GameField.SelectedCell.UnitStack.Attack(GameField.CellToAttack.UnitStack);

            if (GameField.CellToAttack.UnitStack != null &&
                GameField.CellToAttack.UnitStack != GameField.SelectedCell.UnitStack &&
                GameField.CellToAttack.UnitStack.Units.Count < GameField.CellToAttack.MaxUnitNumber)
            {
                if (GameField.CellToAttack.UnitStack.Units.Count > 1)
                {
                    GameField.CellToAttack.CurrentUnitNumber =
                        (GameField.CellToAttack.UnitStack.Units.Count - 1) *
                        GameField.CellToAttack.UnitStack.Units.FirstOrDefault().HitPoints +
                        GameField.CellToAttack.UnitStack.Units.Peek().CurrentHitPoints;
                }
                else if (GameField.CellToAttack.UnitStack.Units.Count == 1)
                {
                    GameField.CellToAttack.CurrentUnitNumber =
                        GameField.CellToAttack.UnitStack.Units.Peek().CurrentHitPoints;
                }
                else
                {
                    GameField.CellToAttack.CurrentUnitNumber = 0;
                    Player2.UnitStacks.Remove(GameField.CellToAttack.UnitStack);
                    Player1.UnitStacks.Remove(GameField.CellToAttack.UnitStack);

                    if (IsPlayer1Selected)
                    {
                        GameEnded = Player2.UnitStacks.Count > 0 ? false : true;
                    }
                    else
                    {
                        GameEnded = Player1.UnitStacks.Count > 0 ? false : true;
                    }

                    GameField.CellToAttack.ClearCell();
                }
            }

            ActionCompleted = true;
            OnActionCompleted?.Invoke(actionText);
        }
Exemple #3
0
        protected virtual async Task HandleDelete()
        {
            if (!id.isNOEOW() && (!id.isNumberic() || !id.IsGuid()))
            {
                isLoading = true;
                var response = await _api.Delete($"{url}{id}");

                if (response != null)
                {
                    if (response.Status == 200 && response.Data)
                    {
                        _toastService.ShowSuccess("The data was deleted", "Completed");
                        await OnActionCompleted.InvokeAsync(true);

                        if (!Redirect.isNOEOW())
                        {
                            _NavigationManager.NavigateTo(Redirect);
                        }
                        else if (isReload)
                        {
                            _NavigationManager.NavigateTo(UrlHelper.GetAbsolutePath(_NavigationManager.Uri));
                        }
                        await modal.Close();
                    }
                    else
                    {
                        _toastService.ShowWarning(response.Message, "Failed");
                        await OnActionCompleted.InvokeAsync(false);
                    }
                }
                else
                {
                    _toastService.ShowError($"Fial to remove: {id}", "Failed");
                    await OnActionCompleted.InvokeAsync(false);
                }
                isLoading = false;
            }
        }
Exemple #4
0
        protected virtual async Task HandleValidSubmit()
        {
            if (formValidator != null)
            {
                formValidator.ClearErrors();
            }
            disabled = true;
            isSaved  = false;
            string             msg      = "Create successful";
            ApiResultModel <T> response = null;

            isLoading = true;
            _Loading.Show();
            bool is_action = false;

            if (!TextEditorField.isNOEOW())
            {
                var value = await QuillHtml.GetHTML();

                if (TrySetProperty(TextEditorField, value))
                {
                    Console.WriteLine(TextEditorField + " has value...");
                }
            }

            if (id.isNOEOW() || (id == "0" || id == Guid.Empty.ToString()))
            {
                is_action = true;
                response  = await _api.Post($"{(save_url.isNOEOW() ? url : save_url)}", model);
            }
            else if (has_id)
            {
                is_action = true;
                response  = await _api.Update($"{(save_url.isNOEOW() ? url : save_url)}{id}", model);

                msg = "Update successful";
            }
            if (is_action)
            {
                if (response != null)
                {
                    if (response.Status == 200 && response.Data != null)
                    {
                        model = response.Data;
                        _toastService.ShowSuccess(msg, "Completed");
                        await OnActionCompleted.InvokeAsync(true);

                        if (isReload)
                        {
                            _NavigationManager.NavigateTo(_NavigationManager.Uri);
                        }
                        isSaved = true;
                    }
                    else
                    {
                        if (formValidator != null && response.Errors != null && response.Errors.Count > 0)
                        {
                            formValidator.DisplayErrors(response.Errors);
                        }
                        _toastService.ShowWarning(response.Message, response.Title);
                    }
                }
                else
                {
                    _toastService.ShowError("Cannot save data", "Fail");
                }
            }
            else
            {
                _toastService.ShowError("Please check data format", "Fail");
            }
            isLoading = false;
            _Loading.Hide();
            if (isSaved)
            {
                if (Redirect.isNOEOW())
                {
                    await LoadContent(is_action);
                }
                else
                {
                    _NavigationManager.NavigateTo(Redirect);
                }
            }
            disabled = false;
        }
Exemple #5
0
 public void TriggerActionCompleted(Action action)
 {
     OnActionCompleted?.Invoke(action);
 }
Exemple #6
0
 private void OnApplyPlacement()
 {
     OnActionCompleted.Trigger();
 }
Exemple #7
0
 private void OnEnable()
 {
     OnActionCompleted.Trigger();
 }