More efficient fort building.

This commit is contained in:
walterhiggins 2014-02-16 18:29:36 +00:00
parent 5bec21d381
commit 7e03c6d3d7

View file

@ -14,6 +14,10 @@ Drone.extend('fort', function( side, height ) {
if ( side % 2 ) { if ( side % 2 ) {
side++; side++;
} }
var battlementWidth = 3;
if ( side <= 12 ) {
battlementWidth = 2;
}
if ( height < 4 || side < 10 ) { if ( height < 4 || side < 10 ) {
throw new java.lang.RuntimeException('Forts must be at least 10 wide X 4 tall'); throw new java.lang.RuntimeException('Forts must be at least 10 wide X 4 tall');
} }
@ -43,13 +47,15 @@ Drone.extend('fort', function( side, height ) {
// build battlement's floor // build battlement's floor
// //
this.move('fort'); this.move('fort');
this.up(height-2).fwd().right().box('126:0',side-2,1,side-2); this.up(height-2).fwd().right();
var battlementWidth = 3; for ( var i = 0; i < battlementWidth; i++ ) {
if ( side <= 12 ) { this.box0('126:0', side - ( 2 + (i * 2) ), 1, side - ( 2 + ( i * 2) ));
battlementWidth = 2; this.fwd().right();
} }
this.fwd(battlementWidth).right(battlementWidth) // .box('126:0',side-2,1,side-2);
.box(0,side-((1+battlementWidth)*2),1,side-((1+battlementWidth)*2));
// this.fwd(battlementWidth).right(battlementWidth)
// .box(0,side-((1+battlementWidth)*2),1,side-((1+battlementWidth)*2));
// //
// add door // add door
// //