Adds build compression on deploy.
authordsc <david.schoonover@gmail.com>
Wed, 2 Mar 2011 02:12:00 +0000 (18:12 -0800)
committerdsc <david.schoonover@gmail.com>
Wed, 2 Mar 2011 02:12:00 +0000 (18:12 -0800)
13 files changed:
data/types/levels.yaml
pavement.py
src/evt.cjs
src/tanks/constants.cjs
src/tanks/map/pathing/map-blockers.cjs
src/tanks/map/pathing/map-pathing.cjs
src/tanks/map/pathing/traversal.cjs
src/tanks/thing/accessory.cjs [new file with mode: 0644]
src/tanks/thing/bullet.cjs
src/tanks/thing/index.cjs
src/tanks/thing/thing.cjs
src/tanks/ui/grid.cjs
src/tanks/ui/pathmapui.cjs

index 35c38e8..537e832 100644 (file)
@@ -143,10 +143,10 @@ types:
             align: 2
             loc: [775,325]
         items:
+          # - type: rockets # right next to start
+          #   loc: [325,475]
           - type: rockets
             loc: [75,275]
-          - type: rockets
-            loc: [325,475]
           - type: nitro
             loc: [325,25]
     
index 01d62e3..dd1cb39 100755 (executable)
@@ -3,6 +3,7 @@ from paver.easy import *
 import yaml, json, os, sys, re
 from termcolor import colored
 
+APP_FILE = 'lttlst.min.js'
 BUILD_DIR = path('build')
 SRC_DIRS = [ path('src')/d for d in ('Y', 'ezl', 'tanks') ]
 DATA_DIR = path('data')
@@ -116,6 +117,9 @@ def update_version():
         f.write(tags.replace('src="build/', 'src="build/{}/'.format(git_version)))
     with path('build/versioned-build.html').open('w') as f:
         f.write('<script>BUILD="build/{}";</script>\n'.format(git_version))
+    with path('build/versioned-app.html').open('w') as f:
+        f.write('<script src="build/{}/{}";</script>\n'.format(git_version, APP_FILE))
+
 
 @task
 def build_version():
@@ -131,6 +135,14 @@ def build():
     pass
 
 @task
+@needs('build')
+def compress(outfile='build/'+APP_FILE, yuic_jar='~/bin/yuic.jar'):
+    yuic_jar = path(yuic_jar).expand()
+    info('Concatenating and Compressing Source (YUI Compressor=%s)' % yuic_jar)
+    mods = commonjs(file_list=True, capture=True)
+    sh('cat %s | java -jar %s --type js -o %s' % (mods.replace('\n', ' '), yuic_jar, outfile))
+
+@task
 def clean():
     "Cleans dep cache and build files"
     commonjs(clean=True)
@@ -138,7 +150,7 @@ def clean():
 
 
 @task
-@needs('build')
+@needs('compress')
 @cmdopts([
     ('exclude=', 'x', 'Exclude listed files (separate with commas).')
 ])
index 88918b4..aad3cd0 100644 (file)
@@ -115,7 +115,7 @@ exports['createInitialise'] =
 function createInitialise(cls){
     function initialise(){
         var instance = this
-        ,   proto = cls.fn          // use prototype so super() calls pick up the right lists
+        ,   proto = cls.fn          // use prototype so getSuper() calls pick up the right lists
         ,   binds = proto.__bind__  // list of names to bind
         ,   inits = proto.__inits__ // init functions
         ,   args  = Y(arguments)
@@ -127,7 +127,7 @@ function createInitialise(cls){
         if ( inits && inits.length )
             inits.invoke('apply', instance, args);
         else if ( cls.__bases__ ) {
-            var superInits = super(cls, '__inits__');
+            var superInits = getSuper(cls, '__inits__');
             if ( superInits && superInits.length )
                 superInits.invoke('apply', instance, args);
         }
@@ -449,11 +449,11 @@ function mixin(cls, _mxn){
  * @param {String} key Key to lookup.
  * @return {*} First non-undefined value found in the prototypes of the __bases__ chain. (nb. This does not include cls.)
  */
-function super(cls, key){
+function getSuper(cls, key){
     if ( !key )
         return;
     if ( !(cls instanceof Class) && cls.__class__ )
-        return super(cls.__class__, key); // cls = cls.__class__;
+        return getSuper(cls.__class__, key); // cls = cls.__class__;
     return cls.__bases__ // don't check cls.fn[key] -- we want super only
         .reduce(function(v, base){
             return (v !== undefined ? v : base.prototype[key]);
@@ -486,9 +486,9 @@ function aggregate(cls, key){
  * @param {String} key Key to lookup.
  * @return {*} First non-undefined value found in the __bases__ chain. (nb. This does not include cls.)
  */
-function superStatic(cls, key){
+function getSuperStatic(cls, key){
     if ( !(cls instanceof Class) && cls.__class__ )
-        return superStatic(cls.__class__, key); // cls = cls.__class__;
+        return getSuperStatic(cls.__class__, key); // cls = cls.__class__;
     return cls.__bases__ // don't check cls[key] -- we want super only
         .reduce(function(v, base){
             return (v !== undefined ? v : base[key]);
@@ -520,4 +520,4 @@ exports['fabricate']   = Y.fabricate;
 exports['lookupClass'] = lookupClass;
 exports['mixin']       = mixin;
 exports['aggregate']   = aggregate;
-exports['superStatic'] = superStatic;
+exports['getSuperStatic'] = getSuperStatic;
index 2404b79..225b20e 100644 (file)
@@ -1,4 +1,4 @@
-//#exports BoundsType.{PASSABLE,ZONE,BLOCKING,IRREGULAR}
+//#exports BoundsType.{PASSABLE,ZONE,BLOCKING,IRREGULAR,COMPLEX}
 //#exports DensityType.{PASSABLE,BOUNDARY,DENSE,SPARSE,IRREGULAR}
 //#exports StatInvariant.{NONE,RATIO,FULL}
 
@@ -17,7 +17,10 @@ require('Y').Y.extend(exports, {
         BLOCKING : 2,
         
         /** Potentially obstructs other objects, but requires a special test once a BoundingBox collision has been detected. */
-        IRREGULAR : 3
+        IRREGULAR : 3,
+        
+        /** Potentially obstructs other objects, but requires a special test, and may instruct a different object become the target of the collision. */
+        COMPLEX : 4
         
     },
     
index 82bede1..680fb2e 100644 (file)
@@ -58,7 +58,9 @@ Y.core.extend(Map.fn, {
     },
     
     _filterBlockers : function _filterBlockers(v){
-        return (v.blocking === BoundsType.BLOCKING || v.blocking === BoundsType.IRREGULAR);
+        return (v.blocking === BoundsType.BLOCKING
+             || v.blocking === BoundsType.IRREGULAR
+             || v.blocking === BoundsType.COMPLEX   );
     },
     
     wallObstructs : function wallObstructs(line){
index 6a34f1e..c107c46 100644 (file)
@@ -233,8 +233,10 @@ Y.subclass('Square', new Vec(0,0), {
      * @private
      */
     _filterBlocked : function filterBlocked(v, r){
+        // FIXME: calc bbox for new loc to testCollide()
+        var bbox = null;
         return ( v.blocking === BoundsType.BLOCKING  && !(v.isBoundary || v.isProjectile) )
-            || ( v.blocking === BoundsType.IRREGULAR && v.testCollide(this.agent,this,null) ); // FIXME: hm. calc bbox?
+            || ((v.blocking === BoundsType.IRREGULAR || v.blocking === BoundsType.COMPLEX) && v.testCollide(this.agent,this,bbox));
     },
     
     getNeighbors : function getNeighbors(){
index 837ed3e..9f8ab9e 100644 (file)
@@ -101,7 +101,10 @@ Y.subclass('Traversal', {
                 || (blocking === BoundsType.PASSABLE)
                 
                 // Ask irregular objects if we hit
-                || (blocking === BoundsType.IRREGULAR && !blocker.testCollide(this.thing,this.to,this.bbox))
+                || (blocking === BoundsType.IRREGULAR && !blocker.testCollide(this.thing,this.to,this.bbox,this))
+                
+                // Ask complex objects if we hit, and recall they might go busta on us
+                || blocking === BoundsType.COMPLEX && !blocker.testCollide(this.thing,this.to,this.bbox,this)
                 
                 // Filter out Sparse objects if bullet
                 || (density === DensityType.SPARSE && this.thing.isProjectile) )
@@ -118,7 +121,7 @@ Y.subclass('Traversal', {
         }
         
         this.isBlocked = true;
-        this.blocker = blocker;
+        if (!this.blocker) this.blocker = blocker; // BoundsType.COMPLEX might switch blockers on us
         return true;
     },
     
diff --git a/src/tanks/thing/accessory.cjs b/src/tanks/thing/accessory.cjs
new file mode 100644 (file)
index 0000000..b67e717
--- /dev/null
@@ -0,0 +1,61 @@
+var Y = require('Y').Y
+,   constants   = require('tanks/constants')
+,   BoundsType  = constants.BoundsType
+,   DensityType = constants.DensityType
+,   Thing       = require('tanks/thing/thing').Thing
+,
+
+Accessory =
+exports['Accessory'] =
+Thing.subclass('Accessory', {
+    __bind__ : [ 'onCollide' ],
+    
+    // Instance
+    blocking : BoundsType.BLOCKING,
+    
+    isAccessory  : true,
+    
+    active       : true,        // Agent takes actions?
+    isRenderable : true,        // Agent will present itself for rendering when ready // FIXME: stupid hack
+    isReflective : false,       // Projectiles bounce off agent rather than explode?
+    hasInventory : false,       // Agent can acquire items?
+    dropOnDeath  : false,       // Agent drops all items in inventory on death?
+    
+    width  : 6,
+    height : 6,
+    
+    color : '#0A9CFF',
+    
+    stats : {}, // radial speed in revolutions/sec
+    
+    
+    
+    init : function initAccessory(owner){
+        this.owner = owner;
+        this.game  = owner.game;
+        
+        Thing.init.call(this, owner.align);
+        
+    },
+    
+    testCollide : function testCollide(agent, to, bbox, traversal){
+        return false;
+    },
+    
+    onCollide : function onCollide(evt){
+        
+    },
+    
+    render : function render(parent){
+        this.remove();
+        
+        var loc = this.loc;
+        this.shape = new Circle(this.width/2)
+            .position(loc.x, loc.y)
+            .fill(this.color)
+            .appendTo( parent );
+        
+        return this;
+    }
+})
+;
index 790799d..03d35e3 100644 (file)
@@ -21,6 +21,8 @@ var Y  = require('Y').Y
 Bullet =
 exports['Bullet'] =
 Thing.subclass('Bullet', {
+    __bind__ : [ 'onCollide' ],
+    
     // Config
     traceTrajectories : false,
     
@@ -63,7 +65,7 @@ Thing.subclass('Bullet', {
         this.position(x1,y1);
         this.trajectory = new Trajectory(this, x1,y1, x2,y2, this.movePerMs);
         
-        this.on('collide', this.onCollide.bind(this));
+        this.on('collide', this.onCollide);
     },
     
     createStats : function createStats(){
@@ -190,7 +192,7 @@ Thing.subclass('Bullet', {
             .position(loc.x, loc.y)
             .fill(this.color)
             .appendTo( parent );
-        this.shape.layer.attr('title', ''+loc);
+        // this.shape.layer.attr('title', ''+loc);
         
         return this;
     }
index d1a1bbb..980882f 100644 (file)
@@ -1,5 +1,16 @@
-exports['Thing']  = require('tanks/thing/thing').Thing;
-exports['Bullet'] = require('tanks/thing/bullet').Bullet;
-exports['Tank']   = require('tanks/thing/tank').Tank;
-exports['Player'] = require('tanks/thing/player').Player;
-exports['Item']   = require('tanks/thing/item').Item;
+var Y = require('Y').Y
+,   tank      = require('tanks/thing/tank')
+,   bullet    = require('tanks/thing/bullet')
+,   item      = require('tanks/thing/item')
+,   accessory = require('tanks/thing/accessory')
+,   player    = require('tanks/thing/player')
+,   thing     = require('tanks/thing/thing')
+;
+Y.core.extend(exports, {
+    'Tank'      : tank.Tank,
+    'Bullet'    : bullet.Bullet,
+    'Item'      : item.Item,
+    'Accessory' : accessory.Accessory,
+    'Player'    : player.Player,
+    'Thing'     : thing.Thing
+});
index da41a46..81c71b0 100644 (file)
@@ -10,7 +10,7 @@ var Y           = require('Y').Y
 
 ,   config      = require('tanks/config').config
 ,   constants   = require('tanks/constants')
-,   BoundsType = constants.BoundsType
+,   BoundsType  = constants.BoundsType
 ,   DensityType = constants.DensityType
 ,   stat        = require('tanks/effects/stat')
 ,   Quantified  = require('tanks/mixins/quantified').Quantified
@@ -61,6 +61,7 @@ new evt.Class('Thing', {
     isCombatant  : false,
     isWall       : false,
     isProjectile : false,
+    isAccessory  : false,
     
     active       : true,        // Agent takes actions?
     isRenderable : false,       // Agent will present itself for rendering when ready // FIXME: stupid hack
@@ -72,6 +73,9 @@ new evt.Class('Thing', {
     loc : null,
     bbox : null,
     
+    // subclasses with BoundsType.{IRREGULAR,COMPLEX} should override: 
+    testCollision : function testCollide(agent, to, bbox, traversal){ return false; },
+    
     // Rotation (rads)
     rotation : 0,
     
index 141aa4a..ff383b1 100644 (file)
@@ -73,7 +73,8 @@ Rect.subclass('Grid', {
             }
             
             ctx.stroke();
-        }
+        } else
+            this.canvas.remove();
     }
     
 });
index 1f7d5ad..fa7816a 100644 (file)
@@ -20,7 +20,7 @@ Rect.subclass('PathMapUI', {
     overlayAiPaths : null,
     
     // Shape Config
-    _layerClasses : 'map rect shape layer ezl',
+    _layerClasses : 'pathmap rect shape layer ezl',
     
     
     // Blocking objects