Example #1
0
    private void _on_Attack_DiceRolled(string rolledValue)
    {
        var selectedPlayer = (Player)Map.GetSelectedNode();
        var weapon         = _cardManager.GetPlayerWeapon(selectedPlayer.GetInstanceId());
        var currentMove    = _movementManager.CurrentPlayerMove;

        _movementManager.ProcessAttackOutput(rolledValue, weapon, (string text) =>
        {
            _displayText.SetText($"[center]{text}[/center]");
            _displayText.Display();

            _cardManager.RemoveWeapon(selectedPlayer.GetInstanceId());

            return(1);
        },
                                             (string text) =>
        {
            _displayText.SetText($"[center]{text}[/center]");
            _displayText.Display();

            return(1);
        },
                                             (string text) =>
        {
            _displayText.SetText($"[center]{text}[/center]");
            _displayText.Display();

            if (GridHelper.CanMoveForward(Map, currentMove.Position.Column, currentMove.Position.Row, currentMove.Direction) &&
                GridHelper.HasPlayerUnits(this, currentMove.Position.Column, currentMove.Position.Row, currentMove.Direction))
            {
                if (HasEnemyUnit(currentMove.Position.Column, currentMove.Position.Row, selectedPlayer.GetPlayerNumber(), out var enemy))
                {
                    enemy.PushFrom(currentMove.Direction);
                }
            }

            return(1);
        },
                                             (string text) =>
        {
            _displayText.SetText($"[center]{text}[/center]");
            _displayText.Display();

            if (HasEnemyUnit(currentMove.Position.Column, currentMove.Position.Row, selectedPlayer.GetPlayerNumber(), out var enemy))
            {
                _playerManager.KillUnit(enemy);
                _victoryManager.CheckForVictory();
            }

            return(1);
        });

        selectedPlayer.SetAP(selectedPlayer.AP - currentMove.APWeight, emitSignal: true);

        var attackDice = _diceManager.GetAttackDice();

        attackDice.HideDice();
    }