2015-01-16 22:20:34 +01:00
|
|
|
'use strict';
|
|
|
|
/*global require */
|
|
|
|
var Drone = require('drone'),
|
|
|
|
blocks = require('blocks');
|
|
|
|
/************************************************************************
|
|
|
|
### Drone.castle() method
|
|
|
|
|
|
|
|
Creates a Castle. A castle is just a big wide fort with 4 taller forts at each corner.
|
|
|
|
See also Drone.fort() method.
|
|
|
|
|
|
|
|
#### Parameters
|
|
|
|
|
|
|
|
* side - How many blocks wide and long the castle will be (default: 24. Must be greater than 19)
|
|
|
|
* height - How tall the castle will be (default: 10. Must be geater than 7)
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
|
|
|
|
At the in-game prompt you can create a castle by looking at a block and typing:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
/js castle()
|
|
|
|
```
|
|
|
|
|
|
|
|
Alternatively you can create a new Drone object from a Player or Location object and call the castle() method.
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
var d = new Drone(player);
|
|
|
|
d.castle();
|
|
|
|
```
|
|
|
|
![castle example](img/castleex1.png)
|
|
|
|
|
|
|
|
***/
|
2014-08-23 17:46:02 +02:00
|
|
|
function castle( side, height ) {
|
2014-01-29 20:49:15 +01:00
|
|
|
//
|
|
|
|
// use sensible default parameter values
|
|
|
|
// if no parameters are supplied
|
|
|
|
//
|
2015-01-16 22:20:34 +01:00
|
|
|
if ( typeof side == 'undefined' )
|
2014-01-29 20:49:15 +01:00
|
|
|
side = 24;
|
2015-01-16 22:20:34 +01:00
|
|
|
if ( typeof height == 'undefined' )
|
2014-01-29 20:49:15 +01:00
|
|
|
height = 10;
|
|
|
|
if ( height < 8 || side < 20 )
|
2015-01-16 22:20:34 +01:00
|
|
|
throw new java.lang.RuntimeException('Castles must be at least 20 wide X 8 tall');
|
2014-01-29 20:49:15 +01:00
|
|
|
//
|
|
|
|
// how big the towers at each corner will be...
|
|
|
|
//
|
|
|
|
var towerSide = 10;
|
|
|
|
var towerHeight = height+4;
|
2013-12-24 01:09:49 +01:00
|
|
|
|
2014-01-29 20:49:15 +01:00
|
|
|
//
|
|
|
|
// the main castle building will be front and right of the first tower
|
|
|
|
//
|
2015-01-16 22:20:34 +01:00
|
|
|
this
|
|
|
|
.chkpt('castle')
|
|
|
|
.fwd( towerSide / 2 )
|
|
|
|
.right( towerSide / 2 )
|
|
|
|
.fort( side, height )
|
|
|
|
.move( 'castle' );
|
2014-01-29 20:49:15 +01:00
|
|
|
//
|
|
|
|
// now place 4 towers at each corner (each tower is another fort)
|
|
|
|
//
|
|
|
|
for ( var corner = 0; corner < 4; corner++ ) {
|
|
|
|
// construct a 'tower' fort
|
2015-01-16 22:20:34 +01:00
|
|
|
this
|
|
|
|
.fort( towerSide, towerHeight )
|
|
|
|
.chkpt('tower-' + corner)
|
|
|
|
.fwd( towerSide - 1 )
|
|
|
|
.right( towerSide - 3 )
|
|
|
|
.up( towerHeight - 5 ) // create 2 doorways from main castle rampart into each tower
|
|
|
|
.box( blocks.air, 1, 2, 1 )
|
|
|
|
.back( 2 )
|
|
|
|
.right( 2 )
|
|
|
|
.box( blocks.air, 1, 2, 1 )
|
|
|
|
.move( 'tower-' + corner)
|
|
|
|
.fwd( side + towerSide - 1) // move forward the length of the castle then turn right
|
|
|
|
.turn();
|
2014-01-29 20:49:15 +01:00
|
|
|
}
|
2015-01-16 22:20:34 +01:00
|
|
|
this.move('castle');
|
2014-08-23 17:46:02 +02:00
|
|
|
}
|
|
|
|
Drone.extend(castle);
|