Exemplo n.º 1
0
    private bool CheckCost(FightingEntity user, ActionChoiceResult response)
    {
        PlayerStats stats = user.stats;

        if (stats.hp.GetValue() <= actionCost.HP)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "HP", name, actionCost.HP));
            return(false);
        }
        else if (stats.mana.GetValue() < actionCost.mana)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "MANA", name, actionCost.mana));
            return(false);
        }
        else if (currPP < actionCost.PP)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "PP", name, actionCost.PP));
            return(false);
        }
        else if (user is Mook && ((Mook)user).stamina.GetStamina() < actionCost.stamina)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "STAMINA", name, actionCost.stamina));
            return(false);
        }

        return(true);
    }
Exemplo n.º 2
0
    private bool CheckValidTarget(FightingEntity user, string[] splitCommand, ActionChoiceResult response)
    {
        bool res = false;

        if (targetInfo.targetType == TargetType.SINGLE && splitCommand.Length == 2)
        {
            int targetId = this.GetTargetIdFromString(splitCommand[1], user);
            res = targetId != -1;
        }
        else if (targetInfo.targetType == TargetType.ALL && splitCommand.Length == 1)
        {
            res = true;
        }
        else if (targetInfo.targetType == TargetType.RANDOM && splitCommand.Length == 1)
        {
            res = true;
        }
        else if (targetInfo.targetType == TargetType.NONE && splitCommand.Length == 1)
        {
            res = true;
        }

        if (!res)
        {
            response.SetState(ActionChoiceResult.State.INVALID_TARGET);
            response.AddMessage(string.Format(Messages.WRONG_NUMBER_OF_TARGETS, name, this.GetExampleCommandString()));
        }
        return(res);
    }
Exemplo n.º 3
0
    private bool CheckArgQuantity(int argQuantity, FightingEntity user, ActionChoiceResult response)
    {
        bool res = argQuantity == commandArgs;

        if (!res)
        {
            response.SetState(ActionChoiceResult.State.INVALID_SYNTAX);
            response.AddMessage(string.Format(Messages.INCORRECT_ARGUMENTS, name, this.GetExampleCommandString()));
        }
        return(res);
    }
Exemplo n.º 4
0
    private bool CheckKeyword(string keyword, ActionChoiceResult response)
    {
        bool res = keyword == commandKeyword;

        if (!res)
        {
            response.SetState(ActionChoiceResult.State.UNMATCHED);
            response.AddMessage(string.Format(Messages.KEYWORD_UNMATCHED, commandKeyword, keyword));
        }
        return(res);
    }
Exemplo n.º 5
0
    public virtual ActionChoiceResult TryChooseAction(FightingEntity user, string[] splitCommand)
    {
        ActionChoiceResult res = new ActionChoiceResult();

        if (CheckKeyword(splitCommand.Length == 0 ? "" : splitCommand[0], res) &&
            CheckArgQuantity(splitCommand.Length - 1, user, res) &&
            CheckCost(user, res) &&
            CheckValidTarget(user, splitCommand, res))
        {
            res.SetState(ActionChoiceResult.State.QUEUED);
            res.AddMessage(string.Format(Messages.QUEUED_MOVE, name, description));
            QueueAction(user, splitCommand);
            user.PlaySound("confirm"); //TODO: Look towards consolidating use here
        }

        return(res);
    }