Advertisement
Guest User

red mechanic

a guest
May 31st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.13 KB | None | 0 0
  1. /**
  2.  * Write a description of class Game here.
  3.  *
  4.  * @author Bidderlyn
  5.  * @version Red's mech thingy 1.0
  6.  */
  7. import java.util.Scanner;
  8. public class Game
  9. {
  10.     public String mech_name;
  11.     public int mech_hp;
  12.     public int mech_dices;
  13.     public int mech_diceDamage;
  14.     public int mech_initiative;
  15.     public int mech_defense;
  16.     public int mech_offense;
  17.     public int mech_dmgBoost;
  18.     public int mech_armor;
  19.  
  20.     public String mech2_name;
  21.     public int mech2_hp;
  22.     public int mech2_dices;
  23.     public int mech2_diceDamage;
  24.     public int mech2_initiative;
  25.     public int mech2_defense;
  26.     public int mech2_offense;
  27.     public int mech2_dmgBoost;
  28.     public int mech2_armor;
  29.     public Game()
  30.     {
  31.         Scanner scan = new Scanner(System.in);
  32.        
  33.        
  34.         System.out.println("What is the name of the first mecha?");
  35.         mech_name = scan.nextLine();
  36.         System.out.println("What is the name of the second mecha?");
  37.         mech2_name = scan.nextLine();
  38.        
  39.          System.out.println("****** INITIATING FIRST MECHA ******");
  40.           System.out.println("***");
  41.         System.out.println("How much hp does he have");
  42.         mech_hp = scan.nextInt();
  43.         System.out.println("How much damage does the mech dice inflict");
  44.         mech_diceDamage = scan.nextInt();
  45.         System.out.println("How many dices does he roll");
  46.         mech_dices = scan.nextInt();
  47.         System.out.println("How much armor does he have");
  48.         mech_armor = scan.nextInt();
  49.        
  50.         System.out.println("****** INITIATING SECOND MECHA ******");
  51.           System.out.println("***");
  52.         System.out.println("How much hp does he have");
  53.         mech2_hp = scan.nextInt();
  54.         System.out.println("How much damage does the mech dice inflict");
  55.         mech2_diceDamage = scan.nextInt();
  56.         System.out.println("How many dices does he roll");
  57.         mech2_dices = scan.nextInt();
  58.         System.out.println("How much armor does he have");
  59.         mech2_armor = scan.nextInt();
  60.        
  61.         System.out.println("***");
  62.         System.out.println("Type the CR of the environment roll");
  63.         int envCR = scan.nextInt();
  64.         System.out.println("Type the initiative bonus player mech gets if he passes or enemy gets if he fails:");
  65.         int initiativeBonus = scan.nextInt();
  66.        
  67.         int r = ((int)((Math.random()*100)+1));
  68.         System.out.println("["+mech_name+" rolls 1d100 Environment Roll against CR of "+envCR+" to get "+initiativeBonus+" initiative and scores "+r+"]");
  69.         if(r >= envCR)
  70.         {System.out.println("[Success!] "+mech_name+" increased its initiative by "+initiativeBonus+"!");mech_initiative = mech2_initiative+initiativeBonus;}
  71.         else
  72.         {System.out.println("[failure!] "+mech2_name+" increased its initiative by "+initiativeBonus+"!"); mech2_initiative = mech2_initiative+initiativeBonus;}
  73.        
  74.         System.out.println("Type the CR of the posture roll");
  75.         int posCR = scan.nextInt();
  76.        
  77.          r = ((int)((Math.random()*100)+1));
  78.          System.out.println("["+mech_name+" rolls 1d100 Posture Roll against CR of "+posCR+" and scores "+r+"]");
  79.          if(r >= posCR)
  80.          {System.out.println("[Success!] "+mech_name+" is now on [Aggresive] stance and gains 20% more damage !");mech_dmgBoost = 20;}
  81.          else
  82.          {System.out.println("[failure!] "+mech2_name+" increased its initiative by "+initiativeBonus+"!"); mech2_initiative = mech2_initiative+initiativeBonus;}
  83.          
  84.          boolean end = false;
  85.          while(end == false)
  86.          {
  87.           int in1 = ((int)((Math.random()*100)+1+mech_initiative));  
  88.           System.out.println("["+mech_name+" rolls 1d100+"+mech_initiative+" initiative Roll scores "+in1+"]");
  89.          
  90.           int in2 = ((int)((Math.random()*100)+1+mech2_initiative));  
  91.           System.out.println("["+mech2_name+" rolls 1d100+"+mech2_initiative+" initiative Roll scores "+in2+"]");
  92.           boolean KO = false;
  93.           int dmg1=0;
  94.           while(KO == false)
  95.           {
  96.            if(in1 >= in2)
  97.            {
  98.               dmg1=0;
  99.               for(int i=0; i<mech_dices; i++)
  100.               {
  101.                 dmg1 = dmg1 +((int)((Math.random()*mech_diceDamage)+1));  
  102.                
  103.               }
  104.               // adding boost
  105.                dmg1 = (dmg1*(100+mech_dmgBoost))/100;
  106.                
  107.              
  108.               System.out.println(mech_name+" rolls "+mech_dices+"d"+mech_diceDamage+" and strikes "+mech2_name+" for "+dmg1+" damage");
  109.               mech2_hp = mech2_hp - dmg1+mech2_armor;
  110.               if(mech2_hp <=0){ System.out.println(mech2_name+" is defeated");
  111.               KO = true;
  112.               end = true;}
  113.              
  114.               if(KO ==false)
  115.               {
  116.               dmg1=0;    
  117.                 for(int i=0; i<mech2_dices; i++)
  118.               {
  119.                  
  120.                dmg1 = dmg1 +((int)((Math.random()*mech2_diceDamage)+1));  
  121.                
  122.               }
  123.               // adding boost
  124.                dmg1 = (dmg1*(100+mech2_dmgBoost))/100;
  125.                 // low initiative does .5 dmg
  126.                dmg1 = dmg1/2;
  127.              
  128.               System.out.println(mech2_name+" rolls "+mech2_dices+"d"+mech2_diceDamage+" and strikes "+mech_name+" for "+dmg1+" damage");
  129.               mech_hp = mech_hp - dmg1+mech_armor;
  130.               if(mech_hp <=0){ System.out.println(mech_name+" is defeated");
  131.               KO = true;  
  132.               end = true;}
  133.                 }
  134.             }
  135.             else
  136.             {
  137.               dmg1=0;  
  138.                for(int i=0; i<mech2_dices; i++)
  139.               {
  140.                  
  141.                dmg1 = dmg1 +((int)((Math.random()*mech2_diceDamage)+1));  
  142.                
  143.               }
  144.               // adding boost
  145.                dmg1 = (dmg1*(100+mech2_dmgBoost))/100;
  146.              
  147.               System.out.println(mech2_name+" rolls "+mech2_dices+"d"+mech2_diceDamage+" and strikes "+mech_name+" for "+dmg1+" damage");
  148.               mech_hp = mech_hp - dmg1+mech_armor;
  149.               if(mech_hp <=0){ System.out.println(mech_name+" is defeated");
  150.               KO = true;  
  151.               end = true;}
  152.               if(KO ==false)
  153.               {
  154.                dmg1=0;    
  155.                for(int i=0; i<mech_dices; i++)
  156.               {
  157.                dmg1 = dmg1 +((int)((Math.random()*mech_diceDamage)+1));  
  158.                
  159.               }
  160.               // adding boost
  161.                dmg1 = (dmg1*(100+mech_dmgBoost))/100;
  162.                // low initiative does .5 dmg
  163.                dmg1 = dmg1/2;
  164.                
  165.                
  166.               System.out.println(mech_name+" rolls "+mech_dices+"d"+mech_diceDamage+" and strikes "+mech2_name+" for "+dmg1+" damage");
  167.               mech2_hp = mech2_hp - dmg1+mech2_armor;
  168.               if(mech2_hp <=0){ System.out.println(mech2_name+" is defeated");
  169.               KO = true;
  170.               end = true;}
  171.                 }  
  172.             }
  173.            
  174.           }
  175.            
  176.          }
  177.          System.out.println("");
  178.         System.out.println("");
  179.       }
  180.    
  181.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement