Simple Command Call
Call one API method to make one cannon action.
artillery.fireRentaka(ship.id);
command.log("Rentaka fired.");The War Room
Write real-time JavaScript to command Rentaka swivel guns and Meriam cannons.
Preferred: define cannon1(radar, artillery, command), cannon2(...), cannon3(...)radar.getShips() -> [{ id, type, distance, hp, maxHp }]artillery.fireRentaka(shipId) -> 10 damage, max 3 bullets per cannon per tickartillery.fireMeriam(shipId) -> 50 damage, max 1 shot per cannon per tick, 3 tick cooldowncommand.log(message) -> print to terminalCall one API method to make one cannon action.
artillery.fireRentaka(ship.id);
command.log("Rentaka fired.");Repeat an action. Rentaka allows 3 bullets per cannon per tick.
for (let bullet = 0; bullet < 3; bullet++) {
artillery.fireRentaka(ship.id);
}Choose different weapons based on ship type or HP.
if (ship.type === "Colonizer Galleon") {
artillery.fireMeriam(ship.id);
} else {
artillery.fireRentaka(ship.id);
}A function can call itself, but always include a base case.
const countShips = (ships, index = 0) => {
if (index >= ships.length) return 0;
return 1 + countShips(ships, index + 1);
};Strait of Melaka Radar
Fort at X = 0. Hostile ships enter from X = 1000.
Fort HP
100
Score
0
Wave
1/10
1/5 ships
Reloading
Melaka command console online. Write JavaScript to defend the fort.
50/50 HP | 1000m