nPhoenix

Pokemon battle turn-based

Jun 1st, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Pokémon Battle Turn-Based 0.0.0.2
  3. By Phoenix
  4. For Pokémon AZ Project (http://pastebin.com/zwkmqWXq)
  5. http://pastebin.com/u/nPhoenix
  6. (c) 2014
  7. */
  8.  
  9. log = $("#battle_log");
  10.  
  11. function damage(Lvl, Atk, Def, pow) {
  12.     return (((((2 * Lvl) / 5 + 2) * pow * Atk) / Def) / 50 + 2) * (Math.random() * (1.0 - 0.85) + 0.85);;
  13. };
  14. me = {
  15.     HP: 324,
  16.     atk: 306,
  17.     def: 229,
  18.     spd: 329,
  19.     Name: 'Raichu',
  20.     Lv: 100
  21. };
  22. wild = {
  23.     HP: 314,
  24.     atk: 287,
  25.     def: 240,
  26.     spd: 322,
  27.     Name: 'Raticate',
  28.     Lv: 100
  29. };
  30.  
  31. function battle_start() {
  32.     log.html("Um " + wild.Name + " selvagem apareceu!");
  33.     if (me.spd > wild.spd) {
  34.         log.html(log.html() + "\n" + me.Name + " começa atacando!");
  35.         my_turn(90);
  36.     } else {
  37.         log.html(log.html() + "\n" + wild.Name + " começa atacando!");
  38.         wild_turn(80);
  39.     };
  40. };
  41.  
  42. function my_turn(pow) {
  43.     console.log(wild.Name + " HP:" + wild.HP);
  44.     wild.HP = wild.HP - damage(me.Lv, me.atk, wild.def, pow);
  45.     log.html(log.html() + "\n" + me.Name + " usou Thunderbolt!");
  46.     log.html(log.html() + "\n" + wild.Name + " HP:" + wild.HP);
  47.     if (wild.HP <= 0) {
  48.         log.html(log.html() + "\nO " + wild.Name + " selvagem desmaiou! \n");
  49.         return false;
  50.     };
  51.     wild_turn(80);
  52. };
  53.  
  54. function wild_turn(pow) {
  55.     console.log(me.Name + " HP:" + me.HP);
  56.     log.html(log.html() + "\n" + wild.Name + " usou Hyper Fang!");
  57.     me.HP = me.HP - damage(wild.Lv, wild.atk, me.def, pow);
  58.     log.html(log.html() + "\n" + me.Name + " HP:" + me.HP);
  59.     if (me.HP <= 0) {
  60.         log.html(log.html() + "\nSeu " + me.Name + " desmaiou! \n");
  61.         return false;
  62.     };
  63.     my_turn(90);
  64. };
Advertisement
Add Comment
Please, Sign In to add comment