Hello,
I have got a problem to solve levels with funcions like Village warder/Village rover using Java.
E.g. for Village Warder, when I start original code, I receive the error “Expected a ; to finish the local variable on line 4 but end of input found.”
In line 4 of the code I has function findAndAttackEnemy() {
The same issue was in Village rover level.
As I only delete first function, I receive error from line with function findAndCleaveEnemy() {
Original, default code of Village Level, which I have is:
Public class AI {
public static void main(String[] args) {
// This function attacks the nearest enemy.
function findAndAttackEnemy() {
var enemy = hero.findNearestEnemy();
if (enemy) {
hero.attack(enemy);
}
}
// Define a function to cleave enemies (but only when the ability is ready).
function findAndCleaveEnemy() {
// Find the nearest enemy:
var enemy = hero.findNearestEnemy();
// If an enemy exists:
// And if "cleave" is ready:
// It's time to cleave!
}
// In your main loop, patrol, cleave, and attack.
while (true) {
// Move to the patrol point, cleave, and attack.
hero.moveXY(35, 34);
findAndCleaveEnemy();
findAndAttackEnemy();
// Move to the other point:
// Use findAndCleaveEnemy function:
// Use findAndAttackEnemy function:
When I switch to python I could solve these level.
Could you help me how to solve it?
I would like to pass these levels using Java.
Best Regard,
Piotress