Advertisement
mess0011

Project1_Massih

Apr 2nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace PokemonGen1
  8. {
  9.     class Pokemon
  10.     {
  11.         private string name;
  12.         private int size;
  13.         private int strength;
  14.         private int weight;
  15.         private int energy;
  16.         private int victory;
  17.         private bool life = false;
  18.  
  19.  
  20.         public void fill_name()
  21.         {
  22.             Console.WriteLine("Welcome gamer! please chose your Pokemon:"); // pick a 1st gen Pokemon
  23.             name = Console.ReadLine();
  24.         }
  25.         public void fill_values() // generate the Pokemons data
  26.         {
  27.             int count = 100;
  28.  
  29.             Console.WriteLine("Please fill in your Pokemons data:");
  30.             Console.WriteLine("Size:");
  31.             size = Convert.ToInt32(Console.ReadLine());
  32.             int result = count - size;
  33.             Console.WriteLine("Its size is:{0} and remaining points left: {1}", size, result);
  34.  
  35.             Console.WriteLine("Strength:");
  36.             strength = Convert.ToInt32(Console.ReadLine());
  37.             result = result - strength;
  38.             Console.WriteLine("Its power is:{0} and remaining points left: {1}", strength, result);
  39.  
  40.  
  41.             Console.WriteLine("Weight:");
  42.             weight = Convert.ToInt32(Console.ReadLine());
  43.             result = result - weight;
  44.             Console.WriteLine("Its weight is:{0} and remaining points left: {1}", weight, result);
  45.  
  46.             Console.WriteLine("Energy:");
  47.             energy = Convert.ToInt32(Console.ReadLine());
  48.             result = result - energy;
  49.             Console.WriteLine("Its energy is:{0} and remaining points left: {1}", energy, result);
  50.  
  51.         }
  52.         public void check_values() // check if the Data inserted match the discription
  53.         {
  54.             if (weight >= (energy + strength))
  55.             {
  56.                 Console.WriteLine("the sum of the energy and strength must be atleast as great than the weight");
  57.             }
  58.             if ((weight + size + strength + energy) > 100)
  59.             {
  60.                 Console.WriteLine("the entire sum must be under 100");
  61.             }
  62.             else
  63.             {
  64.                 victory = 0;
  65.                 life = true;
  66.                 Console.WriteLine("Your pokemon {0} is ready for combat!", name);
  67.             }
  68.         }
  69.  
  70.         public void fill_random() // 2nd possibility is to randomize the data
  71.         {
  72.             Random rnd_size = new Random();
  73.             size = rnd_size.Next(0, 25);
  74.  
  75.             Random rnd_str = new Random();
  76.             strength = rnd_str.Next(0, 25);
  77.  
  78.             Random rnd_wei = new Random();
  79.             weight = rnd_wei.Next(0, 25);
  80.  
  81.             Random rnd_ene = new Random();
  82.             energy = rnd_ene.Next(0, 25);
  83.  
  84.             life = true;
  85.             Console.WriteLine("The random generated nrs for the Pokemon: Size {0}, Strength {1}, Weight {2}, Energy {3}", size, strength, weight, energy);
  86.         }
  87.  
  88.         public Pokemon fightmenu(Pokemon rival) // pick the method to battle your rival
  89.         {
  90.             Console.WriteLine(" {0} is ready to fight!", name);
  91.             Console.WriteLine("Choose (1) for creating your rival pokemon, choose (2) to random a rival ");
  92.             int choice = Convert.ToInt32(Console.ReadLine());
  93.             if (choice == 1)
  94.             {
  95.                 rival.fill_name();
  96.                 do
  97.                 {
  98.                     rival.fill_values();
  99.                     rival.check_values();
  100.                 } while (rival.life == false);
  101.  
  102.                 return rival;
  103.             }
  104.             else if (choice == 2)
  105.             {
  106.                 rival.fill_name();
  107.                 rival.fill_random();
  108.  
  109.                 return rival;
  110.             }
  111.             else
  112.             {
  113.                 Console.WriteLine("Wrong Input!");
  114.                 return rival;
  115.             }
  116.         }
  117.  
  118.         public void fight(Pokemon rival) // commence battle        
  119.         {
  120.             Console.WriteLine("Prepare for battle!");
  121.             Pokemon big = new Pokemon();
  122.             Pokemon small = new Pokemon();
  123.  
  124.             if (this.size == rival.size)
  125.             {
  126.  
  127.                 if (this.victory == rival.victory)
  128.                 {
  129.  
  130.                     Random zz1 = new Random();
  131.  
  132.                     if (zz1.Next(0, 1) == 0)
  133.                     {
  134.  
  135.                         big = this;
  136.                         small = rival;
  137.  
  138.                     }
  139.                     else
  140.                     {
  141.  
  142.                         big = rival;
  143.                         small = this;
  144.                     }
  145.  
  146.                 }
  147.                 else if (this.victory > rival.victory)
  148.                 {
  149.  
  150.                     big = this;
  151.                     small = rival;
  152.  
  153.                 }
  154.                 else
  155.                 {
  156.  
  157.                     big = rival;
  158.                     small = this;
  159.                 }
  160.  
  161.             }
  162.             else if (this.size > rival.size)
  163.             {
  164.  
  165.                 big = this;
  166.                 small = rival;
  167.  
  168.             }
  169.             else
  170.             {
  171.  
  172.                 big = rival;
  173.                 small = this;
  174.             }
  175.  
  176.             while (small.energy > 1 && big.energy > 1)
  177.             {
  178.  
  179.                 if (small.strength < big.weight)
  180.                 {
  181.  
  182.                     small.energy /= 2;
  183.  
  184.                 }
  185.                 else
  186.                 {
  187.  
  188.                     small.strength -= big.weight;
  189.                 }
  190.  
  191.                 if (big.strength < small.weight)
  192.                 {
  193.  
  194.                     big.energy /= 2;
  195.  
  196.                 }
  197.                 else
  198.                 {
  199.  
  200.                     big.strength -= small.weight;
  201.  
  202.                 }
  203.             }
  204.             if (small.energy <= 1)
  205.             {
  206.  
  207.                 small.life = false;
  208.                 big.victory++;
  209.  
  210.             }
  211.             else if (big.energy <= 1)
  212.             {
  213.  
  214.                 big.life = false;
  215.                 small.victory++;
  216.             }
  217.  
  218.             big.output();
  219.             small.output();
  220.             Console.WriteLine();
  221.            
  222.         }
  223.         public void output()
  224.         {
  225.  
  226.             Console.WriteLine("Name = " + name);
  227.             Console.WriteLine("Size = " + size);
  228.             Console.WriteLine("strength = " + strength);
  229.             Console.WriteLine("weight = " + weight);
  230.             Console.WriteLine("Energy = " + energy);
  231.             Console.WriteLine("Victory = " + victory);
  232.             Console.WriteLine("Life = " + life);
  233.  
  234.         }
  235.  
  236.  
  237.         class Program
  238.         {
  239.  
  240.             static void Main(string[] args)
  241.             {
  242.                 Pokemon myPoke1 = new Pokemon();
  243.  
  244.                 bool temp_menu = false;
  245.  
  246.                 myPoke1.fill_name();
  247.                 do
  248.                 {
  249.                     myPoke1.fill_values();
  250.                     myPoke1.check_values();
  251.                 } while (myPoke1.life == false);
  252.  
  253.                 do
  254.                 {
  255.                     Console.WriteLine("Battle?\n(1)Y!\n(2)N!");
  256.                     int input = Convert.ToInt32(Console.ReadLine());
  257.                     if (input == 1)
  258.                     {
  259.                         Pokemon myPoke2 = new Pokemon();
  260.                         myPoke1.fightmenu(myPoke2);
  261.                         myPoke1.fight(myPoke2);
  262.                         temp_menu = true;
  263.                     }
  264.                     else
  265.                     {
  266.                         Console.WriteLine("Oh well! . . .Better luck next time");
  267.                         temp_menu = true;
  268.                     }
  269.                 } while (temp_menu == true);
  270.  
  271.                 Console.ReadLine();
  272.                 }
  273.             }
  274.         }
  275.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement