Guest User

Old TeamBots

a guest
Aug 8th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function stunBot(self,others,storage){
  2.     let turnsLeft=999-turn()
  3.     let lowestHpBots=others.sort((a,b)=>a.hp-b.hp)
  4.     const shieldTurns=2;
  5.     const farmTurns=3;
  6.     if(!storage.teammateUid){
  7.         if(turn()<=shieldTurns){
  8.             return shield()
  9.         }else if(turn()<=farmTurns+shieldTurns){
  10.             return farm()
  11.         }else if(turn()===farmTurns+shieldTurns+1){
  12.             try{
  13.                 teammate=others.find(bot=>bot.hp===self.hp+self.shield)
  14.                 storage.teammateUid=teammate.uid
  15.                 return shield()
  16.             }catch(e){//failed to id teammate
  17.                 return shield()
  18.             }
  19.         }else{
  20.             return farm()
  21.         }
  22.     }else if(self.hp<=(95-self.levels.heal)){
  23.         return heal()
  24.     }else if(self.shield<=100||self.shield<=5500/others.length&&self.shield<=1200&&turn()>=20||lowestHpBots[1]&&lowestHpBots[1].hp>self.hp+self.shield){
  25.         return shield()
  26.     }else if(self.gold>=cost(self.levels.shield)&&self.levels.shield<=4&&turnsLeft>20){
  27.         return upgrade("shield")
  28.     }else{
  29.         enemies=others.filter(bot=>bot.uid!==storage.teammateUid)
  30.         if(enemies.length>0){
  31.             return stun(enemies.sort((a,b)=>b.worth-a.worth)[0].uid)
  32.         }else{
  33.             if((others[0].attack*1.25+7)*(turnsLeft-1)<=self.hp+self.shield+15){//suicide so its teammate gets more gold
  34.                 return farm()
  35.             }else if(self.hp<=(20-self.levels.heal)){
  36.                 return heal()
  37.             }else if(self.gold>=cost(self.levels.farm)&&turnsLeft>100){
  38.                 return upgrade("farm")
  39.             }else{
  40.                 return farm()
  41.             }  
  42.         }
  43.     }
  44. }      
  45. function attackBot(self,others,storage){
  46.     let turnsLeft=999-turn()
  47.     let lowestHpBots=others.sort((a,b)=>a.hp-b.hp)
  48.     let maxDamage=others.map(c=>c.attack).reduce((a, b) => Math.max(a, b))*1.25+5
  49.     const shieldTurns=2;
  50.     const farmTurns=3;
  51.     if(!storage.worth){
  52.         storage.worth=5
  53.         storage.prevGold=self.gold
  54.     }else if(self.gold>storage.prevGold){
  55.         storage.worth+=self.gold-storage.prevGold
  56.     }
  57.     if(!storage.teammateUid){
  58.         if(turn()<=shieldTurns){
  59.             return shield()
  60.         }else if(turn()<=farmTurns+shieldTurns){
  61.             return farm()
  62.         }else if(turn()===farmTurns+shieldTurns+1){
  63.             try{
  64.                 teammate=others.find(bot=>bot.hp===self.hp+self.shield)
  65.                 storage.teammateUid=teammate.uid
  66.                 return shield()
  67.             }catch(e){//failed to id teammate
  68.                 //console.log("Failed")
  69.                 return shield()
  70.             }
  71.         }else{//failed to id teammate
  72.            
  73.             if(others.length===1&&storage.worth>others[0].worth){
  74.                 //stun lock the other bot if there are only 2 left and I can win
  75.                 return stun(others[0].uid)
  76.             }else if(self.hp<=(95-self.levels.heal)){
  77.                 return heal()
  78.             }else if(lowestHpBots[0]&&lowestHpBots[0].hp<20&&lowestHpBots[0].worth/2>2*self.levels.farm+5&&self.hp+self.shield>=110){
  79.                 //kill assist
  80.                 return attack(lowestHpBots[0].uid)
  81.             } else if(self.shield<=100||self.shield<=5500/others.length&&self.shield<=1200&&turn()>=20||lowestHpBots[1]&&lowestHpBots[1].hp>self.hp+self.shield){
  82.                 return shield()
  83.             }else if(self.gold>=cost(self.levels.shield)&&self.levels.shield<=8){
  84.                 return upgrade("shield")
  85.             } else if(self.gold>=cost(self.levels.farm)&&(turnsLeft+1)*(2*(self.levels.farm)+5)<turnsLeft*(2*(self.levels.farm+1)+5)){
  86.                 return upgrade("farm")
  87.             } else if(self.gold>=cost(self.levels.heal)&&(turnsLeft+1)/(self.levels.heal+5)*(2*self.levels.farm+5)<turnsLeft/(self.levels.heal+6)*(2*self.levels.farm+5)&&self.levels.heal<=2){
  88.                 return upgrade("heal")
  89.             }else{
  90.                 return farm()
  91.             }
  92.         }
  93.     }else if(self.hp<=(95-self.levels.heal)){
  94.         return heal()
  95.     }else if(lowestHpBots[0]&&lowestHpBots[0].hp<=maxDamage+self.levels.attack*1.25+5&&lowestHpBots[0].worth/2>2*self.levels.farm+5&&self.hp+self.shield>=110){
  96.         //kill assist
  97.         return attack(lowestHpBots[0].uid)
  98.     }else if(self.shield<=100||self.shield<=5500/others.length&&self.shield<=1200&&turn()>=20||lowestHpBots[1]&&lowestHpBots[1].hp>self.hp+self.shield){
  99.         return shield()
  100.     } else if(self.gold>=cost(self.levels.attack)&&turnsLeft>20){
  101.         return upgrade("attack")
  102.     }else if(self.gold>=cost(self.levels.shield)&&self.levels.shield<=4&&turnsLeft>20){
  103.         return upgrade("shield")
  104.     }else{
  105.         enemies=others.filter(bot=>bot.uid!==storage.teammateUid)
  106.         if(enemies.length>0){
  107.             return attack(enemies.sort((a,b)=>b.worth-a.worth)[0].uid)
  108.         }else{
  109.             if((self.attack*1.25+7)*(turnsLeft-1)<=others[0].hp+15&&(2*self.levels.farm+5)*turnsLeft<others[0].worth/2){//kill its teammate for more gold at the end of the game
  110.                 return attack(storage.teammateUid)
  111.             }else if(self.hp<=(95-self.levels.heal)){
  112.                 return heal()
  113.             }else if(self.gold>=cost(self.levels.farm)&&turnsLeft>100){
  114.                 return upgrade("farm")
  115.             }else{
  116.                 return farm()
  117.             }  
  118.         }
  119.     }
  120. }
Add Comment
Please, Sign In to add comment