can anyone suggest me working summit’s gate level strategy
here my current code
auto weakest(){
auto minHealth = 9999;
auto lowest = null;
auto friends = hero.findFriends();
for(int i = 0; i < friends.length; i ++){
auto friend = friends[i];
if(friend.type == paladin){
if(friend.health < friend.maxHealth * 0.5){
minHealth = friend.health;
lowest = friend;
}
}
}
if(hero.health < hero.maxHealth * 0.5){
lowest = hero;
}
return lowest;
}
auto summon(){
if(hero.gold >= hero.costOf("griffin-rider")){
hero.summon("griffin-rider");
}
}
auto griffin(auto friend){
auto enemy = friend.findNearestEnemy();
if(enemy){
hero.command(friend, "attack", enemy);
}else{
hero.command(friend, "defend", hero);
}
}
auto paladin(auto friend){
auto target = null;
if(friend.canCast("heal")){
auto low = weakest();
if(low){
hero.command(friend, "cast", "heal", low);
}else if(friend.health < friend.maxHealth * 0.4){
hero.command(friend, "shield");
}else{
auto enemy = friend.findNearestEnemy();
if(enemy && enemy.type == "fangrider"){
target = enemy;
if(enemy.health <= 0){
target = friend.findNearestEnemy();
}
}
if(target){
hero.command(friend, "attack", enemy);
}else{
hero.command(friend, "move", hero.pos);
}
}
}
}
auto archer(auto friend){
auto enemy = friend.findNearestEnemy();
if(enemy){
hero.command(friend, "attack", enemy);
}
}
auto soldier(auto friend){
auto enemy = friend.findNearestEnemy();
if(enemy){
hero.command(friend, "attack", enemy);
}
}
auto moveForward(){
auto targetPos = {290, 34};
hero.move(targetPos);
}
auto pickTarget(){
auto enemies = hero.findEnemies();
auto target = null;
auto minDist = 300;
for(int i = 0; i < enemies.length; i++){
auto enemy = enemies[i];
if(enemy.type != "door"){
if(enemy.type == "catapult"){
target = enemy;
break;
} else if(enemy.type == "warlock"){
target = enemy;
break;
} else if(enemy.type == "witch"){
target = enemy;
break;
} else if(enemy.type == "chieftain"){
target = enemy;
break;
} else {
if(hero.distanceTo(enemy) < minDist) {
minDist = hero.distanceTo(enemy);
target = enemy;
}
}
}
}
if(target){
return target;
}
}
auto attack(auto enemy){
if(enemy){
if(hero.isReady("jump")){
hero.jumpTo(enemy.pos);
}else if(hero.isReady("bash")){
hero.bash(enemy);
}else if(hero.isReady("cleave")){
hero.cleave(enemy);
}else{
hero.attack(enemy);
moveForward();
}
}
}
auto commandTroops(){
auto friends = hero.findFriends();
for(int i = 0; i < friends.length; i ++){
auto friend = friends[i];
if(friend.type == "soldier"){
soldier(friend);
}else if(friend.type == "archer"){
archer(friend);
}else if(friend.type == "griffin-rider"){
griffin(friend);
}else if(friend.type == "paladin"){
paladin(friend);
}
}
}
auto hero_attack(){
auto target = pickTarget();
auto friends = hero.findFriends();
if(target){
attack(target);
}else{
moveForward();
}
}
auto main(){
while(true) {
summon();
commandTroops();
hero_attack();
}
return 0;
}
the hero just stuck to the walls and the troops get killed by the tower beam