Exemplo n.º 1
0
this.Units = new function() {
	var U = function(a, d) {
		this.attack = a;
		this.defence = d;
	};

	var RU = function(u1, u2, u3) {
		this[1] = u1;
		this[2] = u2;
		this[3] = u3;
	};

<?php 
$units_data = DataTable::constructFromCsvFile(new CsvFile('data/units.csv'));
foreach (Race::values() as $race) {
    $units = $units_data->get(array('race_english' => $race));
    $first = true;
    echo "\t" . 'this[\'' . $race . '\'] = new RU(';
    foreach ($units as $unit_array) {
        if (!$first) {
            echo ', ';
        }
        $unit = Unit::constructFromArray($unit_array);
        echo 'new U(' . $unit->getAttack() . ',' . $unit->getDefence() . ')';
        $first = false;
    }
    echo ');' . PHP_EOL;
}
?>
};