--- /dev/null
+- types/buffs
+- types/bullets
+- types/items
+# - types/weapons
+- types/units
+- types/levels
+# - types/player
+# - campaign
+# - hotkeys
name: buffs
defaults:
symbol: tanks/effects/buff.Buff
+ desc: ''
+ tags: []
timeout: -1 # the YAML .Inf (Infinity literal) is not valid JSON according to the native decoders
priority: 0
stack_limit: 1
speedup:
name: Speed Up
desc: Speeds up your tank temporarily.
- tags: [ 'movement' ]
+ tags: []
timeout: 3.0
stats:
move: 0.5
- effects: []
- art:
- icon: ''
- inv_icon: ''
name: items
defaults:
symbol: tanks/thing/item.Item
+ desc: ''
passives: []
effects: []
cooldowns: []
backpack:
name: Backpack
bagName: backpack
- desc: Your backpack.
tags: [ 'bag', 'backpack' ]
symbol: tanks/inventory/bag.Bag
max: 12
nitro:
name: Nitro
desc: Speeds up your tank temporarily.
- tags: [ 'movement' ]
+ tags: []
passives: []
# effects: [ 'speedup' ]
effects:
@task
def build_data():
"Converts all data files and core injects config."
+
info('Building data files...')
for dirpath, dirs, files in os.walk(DATA_DIR):
indir = path(dirpath)
with in_.open('rU') as infile, out.open('w') as outfile:
json.dump(yaml.load(infile), outfile, indent=4)
- info('Injecting config JSON...')
- conf = path('build/tanks/config.js')
- conf_json = path('build/data/config.json')
- with conf.open('rU') as f:
- conf_txt = f.read()
- with conf_json.open('rU') as jf, conf.open('w') as out:
- conf_data = jf.read()
- out.write( conf_txt.replace('/*CONFIG_JSON*/', conf_data) )
+ info('Injecting config values...')
+
+ def inject_json(into, data, replacing):
+ into = path(into)
+ data = path(data)
+ with into.open('rU') as f:
+ into_txt = f.read()
+ with data.open('rU') as df, into.open('w') as f:
+ data_txt = df.read()
+ f.write( into_txt.replace(replacing, data_txt) )
+
+ inject_json(into='build/tanks/config.js', data='build/data/config.json', replacing='/*CONFIG_DEFAULTS*/')
+ inject_json(into='build/tanks/config.js', data='build/data/loadlist.json', replacing='/*DATA_LOAD_LIST*/')
@task
def build_scripts():
, Loader = require('ezl/util/data/loader').Loader
,
-/// Config (Inserted Here) ///
-
+/// Config ///
defaults =
-exports['defaults'] = /*CONFIG_JSON*/
+exports['defaults'] = /*CONFIG_DEFAULTS*/
,
config =
// Updates the midpoint square when square-size changes
config.on('set:pathing.pathSquare', function(evt){
- var sq = evt.data.newval;
- config.set('pathing.pathSquareMid', new Vec(sq/2, sq/2));
+ var sq = evt.data.newval, half = sq/2;
+ config.set('pathing.pathSquareMid', new Vec(half, half));
});
config.set('pathing.pathSquare', config.get('pathing.pathSquare'));
/// Load Data Files ///
-var loader;
-exports['dataLoader'] = function dataLoader(){
- if (!loader){
- var files =
- 'types/buffs types/items types/bullets types/units types/levels' // levels game
- .split(' ')
- .map(function(type){
- var name = type.split('/').pop();
- ensure(tanks.data, name);
- return new DataFile('build/data/'+type+'.json', tanks.data[name]);
- });
- loader = new Loader(files);
+var
+loadlist =
+exports['loadlist'] = /*DATA_LOAD_LIST*/
+,
+
+loader =
+exports['loader'] = null
+,
+
+getLoader =
+exports['getLoader'] =
+ function getLoader(){
+ if (!loader){
+ var datafiles =
+ loadlist.map(
+ function(path){
+ var name = path.split('/').pop();
+ ensure(tanks.data, name);
+ return new DataFile('build/data/'+path+'.json', tanks.data[name]);
+ });
+ loader = exports['loader'] = new Loader(datafiles);
+ }
+ return loader;
}
- return loader;
-};
+;
init : function initGame(levelId){
- // Y.bindAll(this);
-
if (levelId) this.levelId = levelId;
this.byId = {};
this.on('tick', this.tick);
this.level.setup(tanks.data);
-
- // if (this.player) {
- // this.backpack = new Backpack(this.player)
- // .appendTo( this.root )
- // .refresh();
- // }
-
this.emit('ready', this);
},
destroy : function destroy(){
this.stop();
if (this.player) this.player.destroy();
- Thing.removeListener('create', this.noteUnit);
+ Thing.removeListener('create', this.setGame);
Thing.removeListener('created', this.addUnit);
Thing.removeListener('destroy', this.killUnit);
this.root.remove();
this._equipSlots.pluck('ui').invoke('refresh');
this.equipSlots = this._equipSlots.end();
-
- // instantiate:
- // - equip slots (w bookkeeping: equipment, equipBags)
- // - belt
+ // TODO: belt
this.owner.game.ui.layer.append('<div class="clearer"/>');
},
return new Vec(floor(x)*SIZE, floor(y)*SIZE);
}
-})
-,
+});
// Would be nice if I could make this an inner class (for once)
-Square =
+var Square =
exports['Square'] =
Y.subclass('Square', new Vec(0,0), {
pathId : null, // instance of A* being run, to track when to reset
},
createStats : function createStats(){
+ // createStats() will copy owner's stats, and then apply values from prototype
this.stats = stat.createStats(this.owner.stats, this.stats);
},
Item.on('speciate',
function onSpeciate(evt){
var NewItem = evt.data.species
- , proto = NewItem.fn;
+ , proto = NewItem.fn
+ ;
proto.passives = Y(proto.passives.map(Buff.lookupOrSpeciate, Buff));
- proto.effects = Y(proto.effects.map(Buff.lookupOrSpeciate, Buff));
+ proto.effects = Y(proto.effects.map(Buff.lookupOrSpeciate, Buff));
});
this.activeKeys = new Y.YArray();
this.inventory = new Inventory(this);
- // this.keydown = this.keydown.bind(this);
- // this.keyup = this.keyup.bind(this);
- // this.mousedown = this.mousedown.bind(this);
- // this.mouseup = this.mouseup.bind(this);
- // this.mousemove = this.mousemove.bind(this);
-
if (this.replayMode) {
this.replay = replay
this.nextMove = replay.shift();
} else {
-
$(document)
.bind('keydown', this.keydown)
.bind('keyup', this.keyup)
});
// Load all data files
- cfg.dataLoader()
+ cfg.getLoader()
.on('complete', function(evt){
$('#loading').hide();
$('#welcome').show();