Advertisement
Guest User

Final.

a guest
Feb 7th, 2016
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 28.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Boat
  10. {
  11.          
  12.         public class Places
  13.         {
  14.             public int radarLocation;
  15.             public int numberOfFighters;
  16.             public static int difficulity;
  17.  
  18.  
  19.         }
  20.         public  class HuntersLagoone : Places
  21.         {
  22.             public int radarLocation = 0;
  23.             public int numberOfFighters = 0;
  24.             public static int difficulity = 2;
  25.  
  26.         }
  27.         public class Swift : Places
  28.         {
  29.             public int radarLocation = 1;
  30.             public int numberOfFighters = 1;
  31.             public static int difficulity = 6;
  32.         }
  33.  
  34.         public class BoatInfo
  35.         {
  36.             public const string connectionString = @"Data Source=84.111.30.76,59339; Network=DBMSSOCN;Initial Catalog=GameDB; User Id=FN; Password=denis891; ";
  37.  
  38.             public static int numberOfWorkers;
  39.             public static int levelOfRadar;
  40.             public static int levelOfLivingPlace;
  41.             public int levelOfGunShop;
  42.             public static int cash;
  43.             public static bool cooldown;
  44.             public static int signedIn;
  45.  
  46.             public static void Register()
  47.             {
  48.                 Console.Write("Type Your User Name: ");
  49.                 string NAM = Console.ReadLine();
  50.                 Console.WriteLine(" ");
  51.                 Console.Write("And now your password: ");
  52.                 string password = Console.ReadLine();
  53.                 BoatInfo.SaveUser(password, NAM);
  54.                 Console.WriteLine("Continuing...");
  55.                
  56.             }
  57.            
  58.             ////////////////////////////////// STORED PROCEDURE BLOCK ///////////////////////////////////////////
  59.            
  60.             //public static void SaveBoatInfo() & GetBoatInfo()
  61.             public static void SaveUser(string PASS,string name)
  62.             {
  63.                
  64.                 DataSet ds = new DataSet();
  65.                 const string savedData = "usp_UserSaveData";
  66.                 const string users = "Users";
  67.                 Console.WriteLine("Connecting... Please Wait... ");
  68.                 using (SqlConnection conn = new SqlConnection(connectionString))
  69.                 {
  70.                     try
  71.                     {
  72.                         using (SqlDataAdapter da = new SqlDataAdapter())
  73.                         {
  74.                             da.SelectCommand = new SqlCommand(savedData, conn);
  75.                             da.SelectCommand.CommandType = CommandType.StoredProcedure;
  76.  
  77.                            
  78.  
  79.                             SqlParameter pass = da.SelectCommand.Parameters.Add("@pass", System.Data.SqlDbType.NVarChar,100);
  80.                             pass.Direction = ParameterDirection.Input;
  81.                             pass.Value = PASS;
  82.  
  83.  
  84.                             SqlParameter Name = da.SelectCommand.Parameters.Add("@name", System.Data.SqlDbType.NVarChar,100);
  85.                             Name.Direction = ParameterDirection.Input;
  86.                             Name.Value = name;
  87.  
  88.                          
  89.                        
  90.  
  91.  
  92.  
  93.  
  94.  
  95.                             da.Fill(ds);
  96.  
  97.                            
  98.                         }
  99.                     }
  100.                     catch (Exception e)
  101.                     {
  102.                         Console.WriteLine("Saving the data was unsuccesful. starting a new game..." + e.Message);
  103.                         return;
  104.  
  105.                     }
  106.                     foreach (DataRow dr in ds.Tables[0].Rows)
  107.                     {
  108.                         signedIn = Convert.ToInt32(dr["id"]);
  109.                     }
  110.  
  111.                 }
  112.             }
  113.             public static void SaveBoatInfo(int NumberOfWorkers, int LevelOfRadar, int LevelOfLivingPlace, int Cash,int id)
  114.             {
  115.                 DataSet ds = new DataSet();
  116.                 const string savedData = "usp_SaveBoatInfo";
  117.                 const string users = "Users";
  118.                 Console.WriteLine("Connecting... Please Wait... ");
  119.                 using (SqlConnection conn = new SqlConnection(connectionString))
  120.                 {
  121.                     try
  122.                     {
  123.                         using (SqlDataAdapter da = new SqlDataAdapter())
  124.                         {
  125.                             da.SelectCommand = new SqlCommand(savedData, conn);
  126.                             da.SelectCommand.CommandType = CommandType.StoredProcedure;
  127.  
  128.  
  129.  
  130.  
  131.  
  132.                             SqlParameter numberofworkers = da.SelectCommand.Parameters.Add("@numberOfWorkers", System.Data.SqlDbType.Int);
  133.                             numberofworkers.Direction = ParameterDirection.Input;
  134.                             numberofworkers.Value = NumberOfWorkers;
  135.  
  136.                             SqlParameter levelofradar = da.SelectCommand.Parameters.Add("@levelOfRadar", System.Data.SqlDbType.Int);
  137.                             levelofradar.Direction = ParameterDirection.Input;
  138.                             levelofradar.Value = levelOfRadar;
  139.  
  140.                             SqlParameter leveloflivingplace = da.SelectCommand.Parameters.Add("@levelOfLivingPlace", System.Data.SqlDbType.Int);
  141.                             leveloflivingplace.Direction = ParameterDirection.Input;
  142.                             leveloflivingplace.Value = LevelOfLivingPlace;
  143.  
  144.                             SqlParameter cash = da.SelectCommand.Parameters.Add("@cash", System.Data.SqlDbType.Int);
  145.                             cash.Direction = ParameterDirection.Input;
  146.                             cash.Value = Cash;
  147.  
  148.                             SqlParameter whom = da.SelectCommand.Parameters.Add("@b_id", System.Data.SqlDbType.Int);
  149.                             whom.Direction = ParameterDirection.Input;
  150.                             whom.Value = id;
  151.  
  152.  
  153.  
  154.  
  155.  
  156.                             da.Fill(ds);
  157.                         }
  158.                     }
  159.                     catch (Exception e)
  160.                     {
  161.                         Console.WriteLine("saving the data was unsuccesful. starting a new game..." + e.Message);
  162.  
  163.                     }
  164.  
  165.                 }
  166.                 Console.WriteLine("Data has been saved");
  167.             }
  168.             public static void GetBoatInfo(string username, string password)
  169.             {
  170.                 DataSet ds = new DataSet();
  171.                 const string savedData = "usp_GetBoatInfo";
  172.                 const string users = "Users";
  173.                 Console.WriteLine("Connecting... Please Wait... ");
  174.                 using (SqlConnection conn = new SqlConnection(connectionString))
  175.                 {
  176.                     try
  177.                     {
  178.                         using (SqlDataAdapter da = new SqlDataAdapter())
  179.                         {
  180.                             da.SelectCommand = new SqlCommand(savedData, conn);
  181.                             da.SelectCommand.CommandType = CommandType.StoredProcedure;
  182.  
  183.  
  184.  
  185.  
  186.  
  187.                             SqlParameter sql_username = da.SelectCommand.Parameters.Add("@g_username", System.Data.SqlDbType.NVarChar,100);
  188.                             sql_username.Direction = ParameterDirection.Input;
  189.                             sql_username.Value = username;
  190.  
  191.                             SqlParameter sql_password = da.SelectCommand.Parameters.Add("@g_password", System.Data.SqlDbType.NVarChar, 100);
  192.                             sql_password.Direction = ParameterDirection.Input;
  193.                             sql_password.Value = password;
  194.  
  195.                            
  196.  
  197.  
  198.  
  199.  
  200.  
  201.                             da.Fill(ds);
  202.                         }
  203.                     }
  204.                     catch (Exception e)
  205.                     {
  206.                         Console.WriteLine("Loading the data was unsuccesful. starting a new game..." + e.Message);
  207.                        
  208.                         Console.ReadLine();
  209.                         return;
  210.                     }
  211.                    
  212.                     foreach (DataRow dr in ds.Tables[0].Rows) /////פה זה רץ פשוט על כל הסלקט שעשיתי בסטורד פרוסידור
  213.                     {
  214.  
  215.                         Console.WriteLine("Data took succesfully");
  216.                         cash = Convert.ToInt32(dr["s_Cash"]);
  217.                         numberOfWorkers = Convert.ToInt32(dr["s_numberOfWorkers"]);
  218.                         levelOfRadar = Convert.ToInt32(dr["s_levelOfRadar"]);
  219.                         levelOfLivingPlace = Convert.ToInt32(dr["s_levelOfLivingPlace"]);
  220.                         int id = Convert.ToInt32(dr["playerId"]);
  221.  
  222.                         BoatInfo.signedIn = id;
  223.                        
  224.                     }
  225.                    
  226.                    
  227.                    
  228.                    
  229.  
  230.                 }
  231.                 if(cash == 0 && numberOfWorkers == 0 && levelOfRadar == 0 && levelOfLivingPlace == 0)
  232.                 {
  233.                     Console.WriteLine("Sorry, it appears your \npass or username is incorrect");
  234.                     Console.WriteLine("If your cash is 0, and it's actually not 0, you might want to \ntry again.");
  235.                 }
  236.             }
  237.  
  238.  
  239.  
  240.            
  241.              /////////////////////////////////////////////// END OF STORED PROCEDURE BLOCK ////////////////////////////////////
  242.            
  243.            
  244.            
  245.  
  246.             public BoatInfo()
  247.             {
  248.                
  249.                 levelOfGunShop = 1;
  250.                
  251.             }
  252.  
  253.         }
  254.     class Program
  255.     {
  256.         public const double VERSION = 1.5;
  257.        
  258.         static void Main(string[] args)
  259.         {
  260.            
  261.             Console.WriteLine("Boats! Press 'Enter' To Continue");
  262.             Console.ReadKey();
  263.             Console.WriteLine("Signin or register?");
  264.             string input = Console.ReadLine();
  265.             if (input.ToUpper() == "SIGNIN")
  266.             {
  267.                 Console.Write("Type in your username: ");
  268.                 string un = Console.ReadLine();
  269.                 Console.Write("Type in your password: ");
  270.                 string p = Console.ReadLine();
  271.                 BoatInfo.GetBoatInfo(un, p);
  272.                 if (BoatInfo.signedIn == 10000)
  273.                 {
  274.  
  275.                     Console.WriteLine("Sorry, password or username is not correct. Registering...");
  276.                     Console.WriteLine("if you don't wish to register, exit the program.");
  277.                     BoatInfo.Register();
  278.                 }
  279.             }
  280.             else if (input.ToUpper() == "REGISTER" || BoatInfo.signedIn <= -1)
  281.             {
  282.  
  283.                 BoatInfo.Register();
  284.  
  285.             }
  286.             else
  287.                 Console.WriteLine("Try Again.");
  288.            
  289.            
  290.            
  291.            
  292.             Console.ReadKey();
  293.  
  294.             Console.WriteLine("");
  295.             BoatInfo Dennis = new BoatInfo();
  296.            
  297.             bool gameIsWorking = true;
  298.             if(BoatInfo.signedIn <= -1 )
  299.             {
  300.                 Console.WriteLine("Sorry, you didn't sign in. please exit. and try again.");
  301.                 Console.ReadLine();
  302.             }
  303.             while (BoatInfo.signedIn > 0)
  304.             {
  305.                
  306.                 Console.WriteLine(" ");
  307.                 Console.WriteLine("What Do You Wish To Know? (Info,Attack,Shop,Help,Save,Load(to sign in to anotheraccount) \nTo Quit However, Type Exit.)");
  308.                
  309.                
  310.                 string choosed = Console.ReadLine();
  311.                 Console.WriteLine(" ");
  312.                 switch (choosed.ToUpper())
  313.                 {
  314.                     case "LOAD":
  315.                         Console.WriteLine("Awww sorry... i'm too lazy to make a function to do that, \nso just type 'exit' and re-enter the program...");
  316.                         break;
  317.                     case "SAVE":
  318.                         BoatInfo.SaveBoatInfo(BoatInfo.numberOfWorkers, BoatInfo.levelOfRadar, BoatInfo.levelOfLivingPlace, BoatInfo.cash,BoatInfo.signedIn);
  319.                         break;
  320.                     case "INFO":
  321.                         Console.WriteLine("Number Of Workers:" + BoatInfo.numberOfWorkers + " " + "\nRadar Lvl:" + BoatInfo.levelOfRadar + " " + "\nLiving Place Lvl:" + BoatInfo.levelOfLivingPlace + " " + "\nGun Shop Lvl:" + Dennis.levelOfGunShop +" " +"\nCash:" + BoatInfo.cash );
  322.                         break;
  323.                     case "ATTACK":
  324.                         if (BoatInfo.cooldown == false)
  325.                         {
  326.                             for (int i = 0; i < 1; i++)
  327.                             {
  328.                                 Console.WriteLine(" ");
  329.                                 Console.WriteLine("Choose the place you want to get to, for your workers to hunt the fish you wish.");
  330.                                 Console.WriteLine(" ");
  331.                                 Console.WriteLine("Sometimes you are too strong to catch a small fish. that's why you won't be able to catch\n an easy fish.");
  332.                                 Console.WriteLine(" ");
  333.                                 Console.WriteLine("Available: HuntersLagoone, Swift.");
  334.  
  335.                                 string choosenPlace = Console.ReadLine();
  336.  
  337.                                 ////////////////Locations Requieremtns And Difficulity and Awards///////////////
  338.                                 switch (choosenPlace.ToUpper())
  339.                                 {
  340.                                     case "HUNTERSLAGOONE":
  341.                                         Console.WriteLine(" ");
  342.                                         Console.WriteLine("Requieremtns: \nRadar Lvl: 0 \nNumber Of Workers: 0 \nDifficulity: 2 \nReward: Varied cash");
  343.                                         Console.WriteLine("Since it's the first place to go, you don't need a radar or workers. \njust you, the captain, and you trusty sword!");
  344.                                         break;
  345.                                     case "SWIFT":
  346.                                         Console.WriteLine(" ");
  347.                                         Console.WriteLine("Requieremtns: \nRadar Lvl: 1 \nNumber Of Workers: 1 \nDifficulity: 6 \nReward: Cash Varies with number of workers... ");
  348.                                         break;
  349.                                 }
  350.                                 /////////////////////////////////////////////////////////////////////
  351.  
  352.                                 bool result = IsPermmited(BoatInfo.numberOfWorkers, BoatInfo.levelOfRadar, choosenPlace);
  353.  
  354.                                 if (result == true)
  355.                                 {
  356.                                     Console.WriteLine(" ");
  357.                                     Console.WriteLine("Press 'Enter' to enter, or 'return' to return to your boat.");
  358.                                     string act = Console.ReadLine();
  359.                                     if (act.ToUpper() == "")
  360.                                     {
  361.                                         if(choosenPlace.ToUpper() == "HUNTERSLAGOONE")
  362.                                         {
  363.                                             Places.difficulity = HuntersLagoone.difficulity;
  364.                                         }
  365.                                         else if(choosenPlace.ToUpper() == "SWIFT")
  366.                                         {
  367.                                             Places.difficulity = Swift.difficulity;
  368.                                         }
  369.  
  370.                                         int EarnedCash = Fight(Places.difficulity); //diff  + 1 as parameter for diff//
  371.                                         if (EarnedCash == 0)
  372.                                         {
  373.                                             Console.WriteLine("After You fought, it appears that you didn't catch any fish, \nand therefore you didn't earn anything.");
  374.                                             BoatInfo.cash = (EarnedCash + BoatInfo.cash);
  375.                                             BoatInfo.cooldown = true;
  376.  
  377.  
  378.                                         }
  379.                                         else
  380.                                         {
  381.                                            
  382.                                             Console.WriteLine("You have earned: " + EarnedCash + "$ !");
  383.                                             BoatInfo.cash = (EarnedCash + BoatInfo.cash);
  384.                                             BoatInfo.cooldown = true;
  385.  
  386.                                         }
  387.                                     }
  388.                                     else
  389.                                         continue;
  390.  
  391.                                 }
  392.  
  393.  
  394.  
  395.                                 else
  396.                                 {
  397.                                     Console.WriteLine(" ");
  398.                                     Console.WriteLine("Sorry, but you do not meet the requirments. \nUpgrade Workers Or The Radar! (or don't just press enter)");
  399.                                 }
  400.  
  401.  
  402.  
  403.                             }
  404.                         }
  405.                         else if (BoatInfo.cooldown == true)
  406.                         {
  407.                             DateTime now = DateTime.Now;
  408.                             int thisnum = now.Second;
  409.                             Console.WriteLine("Your Workers are tired. they will be able to fight in about 1 minute.");
  410.                             Console.WriteLine("");
  411.                             Console.WriteLine("Sometimes they are really tired, and sometimes they just needed that one second break.");
  412.                            
  413.                                 System.DateTime moment = new System.DateTime(2015, 12, 15, 17, 17, 10 + 30, 0); //change the (30) to make longer wait-times. 30>x longer, 30<x shorter
  414.                            
  415.                             int second = moment.Second;
  416.                            
  417.                             if(thisnum <= second)
  418.                             {
  419.                                 BoatInfo.cooldown = false;
  420.                             }
  421.                            
  422.                         }
  423.                             break;
  424.                     case "SHOP":
  425.                             Console.WriteLine("Welcome To The Upgrade Shop! you have: " + BoatInfo.cash+"$ !");
  426.                             Console.WriteLine(" ");
  427.                             Console.WriteLine("Number Of Workers:" + BoatInfo.numberOfWorkers.ToString() + " " + "\nRadar Lvl:" + BoatInfo.levelOfRadar.ToString() + " " + "\nLiving Place Lvl:" + BoatInfo.levelOfLivingPlace.ToString());
  428.                             Console.WriteLine(" ");
  429.                             Console.WriteLine("Which thing will you upgrade? notes:\n (before having 4 workers, you must have living place lvl 2)");
  430.                             Console.WriteLine(" ");
  431.                             Console.WriteLine("To Buy A Worker: type NOW. \nTo Upgrade Radar Level: type RLV. \nTo Upgrade Living Place Level: type LPL. \nTo Leave Type Exit.");
  432.                             string desiredUpgrade = Console.ReadLine();
  433.                         switch(desiredUpgrade.ToUpper())
  434.                         {
  435.                             case "NOW":
  436.                                 Console.WriteLine(" ");
  437.                                 Console.WriteLine("A new worker is costing 9,000$");
  438.                                 Console.WriteLine(" ");
  439.                                 Console.WriteLine("Press 'enter' to Buy, or 'return' to Return");
  440.                                 int l = 1;
  441.                                 string fsure = Console.ReadLine();
  442.                                 if (fsure == "" && BoatInfo.cash >= 9000)
  443.                                 {
  444.                                    
  445.                                     l++;
  446.                                     if (BoatInfo.numberOfWorkers == 4 * l && BoatInfo.levelOfLivingPlace > 1 * l) // put = if mistaken.
  447.                                     {
  448.                                         Console.WriteLine("You can't purchase more workers if your living place is level 1");
  449.                                     }
  450.                                     else
  451.                                     {
  452.                                         BoatInfo.cash = BoatInfo.cash - 9000;
  453.                                         BoatInfo.numberOfWorkers = BoatInfo.numberOfWorkers + 1;
  454.                                         Console.WriteLine("You now have: {0} Workers!", BoatInfo.numberOfWorkers);
  455.                                     }
  456.                                 }
  457.                                 else if(BoatInfo.cash < 9000 && fsure == "")
  458.                                 {
  459.                                     Console.WriteLine("You don't have enough cash.");
  460.                                 }
  461.                                 else
  462.                                     continue;
  463.  
  464.                                 break;
  465.  
  466.                             case "RLV":
  467.                                  Console.WriteLine(" ");
  468.                                 Console.WriteLine("Radar Upgrade Lvl is Costing 10,000$");
  469.                                 Console.WriteLine(" ");
  470.                                 Console.WriteLine("Press 'enter' to Buy, or 'return' to Return");
  471.                                
  472.                                 string qsure = Console.ReadLine();
  473.                                 if (qsure == "" && BoatInfo.cash >= 10000)
  474.                                 {
  475.                                     BoatInfo.cash = BoatInfo.cash - 10000;
  476.                                     BoatInfo.levelOfRadar = BoatInfo.levelOfRadar + 1;
  477.                                     Console.WriteLine("Purchase Was Completed!");
  478.                                  
  479.                                    
  480.                                 }
  481.                                 else if(BoatInfo.cash < 10000 && qsure == "")
  482.                                 {
  483.                                     Console.WriteLine("You don't have enough cash.");
  484.                                 }
  485.                                 else
  486.                                     continue;
  487.                                 break;
  488.                                
  489.                             case "LPL":
  490.                                  Console.WriteLine(" ");
  491.                                 Console.WriteLine("Living Place Upgrade Lvl Is Costing 100,000$");
  492.                                 Console.WriteLine(" ");
  493.                                 Console.WriteLine("You don't need another living place, therefore you buy it only once.");
  494.                                 Console.WriteLine("Press 'enter' to Buy, or 'return' to Return");
  495.                                
  496.                                 string lsure = Console.ReadLine();
  497.                                 if (lsure == "" && BoatInfo.cash >= 100000)
  498.                                 {
  499.                                     BoatInfo.cash = BoatInfo.cash - 100000;
  500.  
  501.  
  502.                                     Console.WriteLine("Your Living Place Lvl Is Now {0} ", BoatInfo.levelOfLivingPlace = BoatInfo.levelOfLivingPlace + 1);
  503.                                 }
  504.                                 else if(BoatInfo.cash < 100000 && lsure == "")
  505.                                 {
  506.                                     Console.WriteLine("You don't have enough cash.");
  507.                                 }
  508.                                 else
  509.                                     continue;
  510.                                 break;
  511.                             case "EXIT":
  512.                                 continue;
  513.                                    
  514.                                
  515.                         }
  516.                             break;
  517.                     case "EXIT":
  518.                             BoatInfo.signedIn = -1;
  519.                             Environment.Exit(0);
  520.                             break;
  521.  
  522.                     case "HELP":
  523.                             Console.WriteLine("This is Version {0}, Creator: Dennis.",VERSION);
  524.                         Console.WriteLine("If you have any questions please ask me and i will try to answer.\nthese questions will be put here for your better understanding this simple game\nand don't forget to tell me any bugs you encounter!");
  525.                         Console.WriteLine(" ");
  526.                         Console.WriteLine("Future Updates Are Coming Soon!");
  527.                         Console.WriteLine("Update notes: \nVersion 1.2: *Some minor changes.");
  528.                         Console.WriteLine("Update notes: \nVersoin 1.5: *Some tweaks\n*Saving and loading is now available!");
  529.                         Console.WriteLine("Press 'Enter' To continue.");
  530.                         break;
  531.  
  532.                        
  533.                        
  534.                        
  535.                    
  536.  
  537.                 }
  538.                 Console.ReadKey();
  539.             }
  540.  
  541.         }
  542.  
  543.         public static bool IsPermmited(int NumberOfWorkers, int RadarLvl,string choosenPlace)
  544.         {
  545.            
  546.            
  547.             switch (choosenPlace.ToUpper())
  548.             {
  549.                 case "HUNTERSLAGOONE":
  550.                     HuntersLagoone nl = new HuntersLagoone();
  551.                    
  552.                    
  553.  
  554.                     if (nl.numberOfFighters <= NumberOfWorkers && nl.radarLocation <= RadarLvl)
  555.                     {
  556.                      
  557.                         return true;
  558.                     }
  559.                     else if(nl.numberOfFighters < NumberOfWorkers)
  560.                     {
  561.                         return false;
  562.                     }
  563.                     else
  564.                     {
  565.                         return false;
  566.                     }
  567.                     break;
  568.                 case "SWIFT":
  569.                     Swift ns = new Swift();
  570.                     if (ns.numberOfFighters <= NumberOfWorkers && ns.radarLocation <= RadarLvl)
  571.                     {
  572.                         return true;
  573.                     }
  574.                     else
  575.                         return false;
  576.                     break;
  577.                    
  578.             }
  579.             return false;
  580.            
  581.  
  582.         }
  583.  
  584.         public static int Fight(int diff)
  585.         {
  586.             Console.WriteLine("You have found some fish, to attack, press enter. \nand as always type exit to leave. ");
  587.             string input = Console.ReadLine();
  588.             if (input.ToUpper() == "EXIT")
  589.                 return 0;
  590.             else if(input == "")
  591.             {
  592.  
  593.                 Random rnd = new Random();
  594.                 BoatInfo forfight = new BoatInfo();
  595.                 int health = (BoatInfo.numberOfWorkers * 2);
  596.                 for (int i = 0; i <= health; i++)
  597.                 {
  598.                     if (BoatInfo.numberOfWorkers >= diff)
  599.                     {
  600.                         diff = diff + BoatInfo.numberOfWorkers;
  601.                         i = 0;
  602.                         continue;
  603.                     }
  604.  
  605.                     int chance = rnd.Next(0, diff);
  606.  
  607.                     if (chance == BoatInfo.numberOfWorkers)
  608.                     {
  609.                         Random chancesForWeaponPart = new Random();
  610.                         int returendChance = chancesForWeaponPart.Next(1, 20);
  611.                         Console.WriteLine("You Have Succeded. you have been awarded.");
  612.                         int num = 10;
  613.                         if(num == returendChance)
  614.                         {
  615.                             Console.WriteLine("Congratulations! you have earned a gun part!");
  616.                         }
  617.                         Console.WriteLine("Returning to the boat...");
  618.                         Console.ReadKey();
  619.                        
  620.                         return 1000 * diff;
  621.                     }
  622.                     else
  623.                     {
  624.                         Console.WriteLine("Sorry, you didn't catch any fish. \nand you lost some life");
  625.                         Console.WriteLine("Continuing..");
  626.                         Console.ReadKey();
  627.                         i++;
  628.                         if(i == health)
  629.                         return 0;
  630.                        
  631.                     }
  632.                    
  633.                 }
  634.                 return 0;
  635.             }
  636.             return 0;
  637.         }
  638.        
  639.     }
  640. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement