Ticket #2671: attack_prototype_scoped_instead_of_file_scoped_globals_to_allow_mods_to_reuse_the_schema_definition.diff

File attack_prototype_scoped_instead_of_file_scoped_globals_to_allow_mods_to_reuse_the_schema_definition.diff, 4.2 KB (added by Radagast, 10 years ago)
  • binaries/data/mods/public/simulation/components/Attack.js

    diff --git a/binaries/data/mods/public/simulation/components/Attack.js b/binaries/data/mods/public/simulation/components/Attack.js
    index 64bec00..05e26ae 100644
    a b  
    11function Attack() {}
    22
    3 var bonusesSchema =
     3Attack.prototype.bonusesSchema =
    44    "<optional>" +
    55        "<element name='Bonuses'>" +
    66            "<zeroOrMore>" +
    var bonusesSchema =  
    1818        "</element>" +
    1919    "</optional>";
    2020
    21 var preferredClassesSchema =
     21Attack.prototype.preferredClassesSchema =
    2222    "<optional>" +
    2323        "<element name='PreferredClasses' a:help='Space delimited list of classes preferred for attacking. If an entity has any of theses classes, it is preferred. The classes are in decending order of preference'>" +
    2424            "<attribute name='datatype'>" +
    var preferredClassesSchema =  
    2828        "</element>" +
    2929    "</optional>";
    3030
    31 var restrictedClassesSchema =
     31Attack.prototype.restrictedClassesSchema =
    3232    "<optional>" +
    3333        "<element name='RestrictedClasses' a:help='Space delimited list of classes that cannot be attacked by this entity. If target entity has any of these classes, it cannot be attacked'>" +
    3434            "<attribute name='datatype'>" +
    Attack.prototype.Schema =  
    112112                "<element name='RepeatTime' a:help='Time between attacks (in milliseconds). The attack animation will be stretched to match this time'>" + // TODO: it shouldn't be stretched
    113113                    "<data type='positiveInteger'/>" +
    114114                "</element>" +
    115                 bonusesSchema +
    116                 preferredClassesSchema +
    117                 restrictedClassesSchema +
     115                Attack.prototype.bonusesSchema +
     116                Attack.prototype.preferredClassesSchema +
     117                Attack.prototype.restrictedClassesSchema +
    118118            "</interleave>" +
    119119        "</element>" +
    120120    "</optional>" +
    Attack.prototype.Schema =  
    139139                    "<ref name='nonNegativeDecimal'/>" +
    140140                "</element>" +
    141141                "<element name='Spread' a:help='Radius over which missiles will tend to land (when shooting to the maximum range). Roughly 2/3 will land inside this radius (in metres). Spread is linearly diminished as the target gets closer.'><ref name='nonNegativeDecimal'/></element>" +
    142                 bonusesSchema +
    143                 preferredClassesSchema +
    144                 restrictedClassesSchema +
     142                Attack.prototype.bonusesSchema +
     143                Attack.prototype.preferredClassesSchema +
     144                Attack.prototype.restrictedClassesSchema +
    145145                "<optional>" +
    146146                    "<element name='Splash'>" +
    147147                        "<interleave>" +
    Attack.prototype.Schema =  
    151151                            "<element name='Hack' a:help='Hack damage strength'><ref name='nonNegativeDecimal'/></element>" +
    152152                            "<element name='Pierce' a:help='Pierce damage strength'><ref name='nonNegativeDecimal'/></element>" +
    153153                            "<element name='Crush' a:help='Crush damage strength'><ref name='nonNegativeDecimal'/></element>" +
    154                             bonusesSchema +
     154                            Attack.prototype.bonusesSchema +
    155155                        "</interleave>" +
    156156                    "</element>" +
    157157                "</optional>" +
    Attack.prototype.Schema =  
    166166                "<element name='Crush' a:help='Crush damage strength'><ref name='nonNegativeDecimal'/></element>" +
    167167                "<element name='MaxRange'><ref name='nonNegativeDecimal'/></element>" + // TODO: how do these work?
    168168                "<element name='MinRange'><ref name='nonNegativeDecimal'/></element>" +
    169                 bonusesSchema +
    170                 preferredClassesSchema +
    171                 restrictedClassesSchema +
     169                Attack.prototype.bonusesSchema +
     170                Attack.prototype.preferredClassesSchema +
     171                Attack.prototype.restrictedClassesSchema +
    172172            "</interleave>" +
    173173        "</element>" +
    174174    "</optional>" +
    Attack.prototype.Schema =  
    179179                "<element name='Pierce' a:help='Pierce damage strength'><ref name='nonNegativeDecimal'/></element>" +
    180180                "<element name='Crush' a:help='Crush damage strength'><ref name='nonNegativeDecimal'/></element>" +
    181181                "<element name='MaxRange'><ref name='nonNegativeDecimal'/></element>" + // TODO: how do these work?
    182                 bonusesSchema +
    183                 preferredClassesSchema +
    184                 restrictedClassesSchema +
     182                Attack.prototype.bonusesSchema +
     183                Attack.prototype.preferredClassesSchema +
     184                Attack.prototype.restrictedClassesSchema +
    185185            "</interleave>" +
    186186        "</element>" +
    187187    "</optional>";