Exemplo n.º 1
0
        /**
         * DEBUG VERSION
         * Func: Basic dice roll test function for the use of abilities in the game
         * @version: changes specifics of 'ability'
         * @minRP: minimum Restpunkte required for a successful test
         * @ability: the one that will be executed
         * @user: entity using the ability
         * @targets: potential targets for the ability (if necessary)
         */
        public void testInstant(int version, int minRP, AbstractAbility ability, EntityController user, List<PraeObject> targets)
        {
            if (ability.canUse(version, user, targets))
            {
                int c = ability.getTestModifier(version, user, targets);            // Erschwernis/Erleichterung
                Debug.Log(charInfo);
                int aw = charInfo.getAttributeValue(ability.attributeGroup);        // Value of assigned attribute
                int fw = ability.fw;                                                // Fertigkeitswert of ability
                ELuck luck = ELuck.normal;

                int diceroll = UnityEngine.Random.Range(1, 21); // [inclusive, exclusive]
                int rp = fw + aw - c - diceroll;

                if (diceroll == 1)
                {
                    // test for luck, "Glücksgriff"
                    int second_roll = UnityEngine.Random.Range(1, 21);
                    if (second_roll <= aw)
                    {
                        rp += 20 + second_roll - aw; // normal rp + second_roll rp + 20
                        luck = ELuck.luck;
                    }
                }
                else if (diceroll == 20)
                {
                    // test for slipup "Patzer"
                    int reroll = UnityEngine.Random.Range(1, 21);
                    if (reroll > aw + Math.Max(0, rp)) // if aw + fp > 20, we add positive rp to the pool
                        luck = ELuck.slipup;
                }

                Debug.Log("Ability: " + ability + "| Dice: " + diceroll + " rp: " + rp + " fw: " + fw + " aw: " + aw + " luck: " + luck);
                Constants.chatManager.addLine("Ability: " + ability);
                Constants.chatManager.addLine("Dice: " + diceroll + " rp: " + rp + " fw: " + fw + " aw: " + aw + " luck: " + luck);

                if (rp >= minRP)
                {
                    Constants.chatManager.addLine("Success!");
                    ability.applySuccess(version, rp, luck, user, targets);
                }
                else
                {
                    Constants.chatManager.addLine("Failed!");
                    ability.applyFailure(version, rp, luck, user, targets);
                }
            }
            else
            {
                Debug.Log("Cannot use ability " + ability.ToString() + ".");
            }
        }
Exemplo n.º 2
0
 /**
  * Func: Basic dice roll test function for the use of abilities in the game
  * Func: this version should be called by entity controller when using interfaces for targets
  * Func: uses GameManager to determine minimal required RP
  * @version: changes specifics of 'ability'
  * @ability: the one that will be executed
  * @user: entity using the ability
  * @targets: potential targets for the ability (if necessary)
  */
 public void testInstant(int version, AbstractAbility ability, EntityController user, List<PraeObject> targets)
 {
     int minRP = 0; //TODO: the GameManager should somehow determine this value
     testInstant(version, minRP, ability, user, targets);
 }