Beispiel #1
0
        public void Use(Ability ability, Sharpmon target)
        {
            Random rand = new Random();

            switch (ability.getEffect())
            {
            case 0:
                if (rand.Next(100) < this.getAccuracy() / (this.getDodge() + target.getAccuracy()) + 10)
                {
                    target.setHeath(target.getHealth() - this.getPower() * ability.getEffectValue() / target.getDefense());
                }
                break;

            case 1:
                target.setPower(target.getPower() + ability.getEffectValue());
                break;

            case 2:
                target.setDodge(target.getDodge() + ability.getEffectValue());
                break;

            case 3:
                target.setDefense(target.getDefense() + ability.getEffectValue());
                break;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Allow to get the current sharpmon
 /// </summary>
 /// <param name="Target"></param>
 public void setTarget(Sharpmon Target)
 {
     foreach (var item in All)
     {
         item.setTarget(Target);
     }
 }
Beispiel #3
0
 public Item(string _name, int _price, string _description, int _hp, int _power, int _defense, int _dodge, int _accuracy, int _speed, int _experience, Sharpmon _target)
 {
     Name        = _name;
     Price       = _price;
     SellPrice   = Price / 2;
     Description = _description;
     Hp          = _hp;
     Power       = _power;
     Defense     = _defense;
     Dodge       = _dodge;
     Accuracy    = _accuracy;
     Speed       = _speed;
     Experience  = _experience;
     Target      = _target;
 }
Beispiel #4
0
 private Sharpmon HighestSpeed(Sharpmon sharpmon1, Sharpmon sharpmon2)
 {
     if (sharpmon1.getSpeed() == sharpmon2.getSpeed())
     {
         Random random = new Random();
         if (random.Next(100) < 50)
         {
             return(sharpmon1);
         }
         else
         {
             return(sharpmon2);
         }
     }
     else if (sharpmon1.getSpeed() > sharpmon2.getSpeed())
     {
         return(sharpmon1);
     }
     else
     {
         return(sharpmon2);
     }
 }
Beispiel #5
0
 //Add new sharpmon into Sharpdex
 public void AddSharpmon(Sharpmon newSharpon)
 {
     Sharpdex.Add(newSharpon);
 }
Beispiel #6
0
 private bool Turn(Sharpmon attacker, Sharpmon enemy)
 {
     return(true);
 }
Beispiel #7
0
 public void SetEnemy(Sharpmon enemy)
 {
     this.Enemy = enemy;
 }
Beispiel #8
0
 public void setTheSelfSharpmon(Sharpmon selfSharpmon)
 {
     SelfSharpmon = selfSharpmon;
 }
Beispiel #9
0
 public void setTheEnemy(Sharpmon targetSharpmon)
 {
     TheEnemy = targetSharpmon;
 }
Beispiel #10
0
 public void setTarget(Sharpmon target)
 {
     Target = target;
 }
Beispiel #11
0
        public void FightSystem()
        {
            Console.Clear();

            //If isPlayer = false so it's the enemy sharpmon turn
            bool isPlayer = false;

            while ((thePlayer.EnemySharpmon.GetHp() >= 1) && (thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetHp() >= 1))
            {
                Console.Clear();
                Console.WriteLine("-------------------------");
                Console.WriteLine("         FIGHT !            ");
                Console.WriteLine("-------------------------");

                Console.WriteLine("| " + thePlayer.EnemySharpmon.GetName() + "            |");
                Console.WriteLine("| HP: " + thePlayer.EnemySharpmon.GetHp() + "/" + thePlayer.EnemySharpmon.GetBaseHp() + "       Lvl: " + thePlayer.EnemySharpmon.GetExperience() + "|");
                Console.WriteLine("| Pow: " + thePlayer.EnemySharpmon.GetPower() + "         Def: " + thePlayer.EnemySharpmon.GetDefense() + "|");
                Console.WriteLine("| Acc: " + thePlayer.EnemySharpmon.GetAccuracy() + "          Dod: " + thePlayer.EnemySharpmon.GetDodge() + "|");
                Console.WriteLine("+-----------------------+");
                Console.WriteLine("| " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetName() + "           |");
                Console.WriteLine("| HP: " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetHp() + "/" + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetBaseHp() + "       Lvl: " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetExperience() + "|");
                Console.WriteLine("| Pow: " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetPower() + "         Def: " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetDefense() + "|");
                Console.WriteLine("| Acc: " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetAccuracy() + "          Dod: " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetDodge() + "|");
                Console.WriteLine("+-----------------------+");



                if (isPlayer == false) //enemy turn
                {
                    Console.WriteLine(thePlayer.EnemySharpmon.GetName() + " begin !");

                    int    attackchose;
                    Random rand = new Random();
                    attackchose = rand.Next(0, thePlayer.EnemySharpmon.Attacks.Count);
                    thePlayer.EnemySharpmon.Attacks[attackchose].TheEnemy     = thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()];
                    thePlayer.EnemySharpmon.Attacks[attackchose].SelfSharpmon = thePlayer.EnemySharpmon;
                    thePlayer.EnemySharpmon.setExperience(thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetExperience());  //Set Enemy's Experience to player's experience.

                    Console.WriteLine(thePlayer.EnemySharpmon.GetName() + " launch " + thePlayer.EnemySharpmon.Attacks[attackchose].GetAttackName());

                    Console.WriteLine("This sharpmon has attacked.");

                    for (int i = 0; i < thePlayer.EnemySharpmon.Attacks[attackchose].getDamage(); i++)
                    {
                        thePlayer.EnemySharpmon.Attacks[attackchose].LaunchAttack();
                    }
                }
                else //your turn
                {
                    Console.WriteLine("Your " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetName() + " begin !");

                    int Choice = 0;
                    try
                    {
                        Console.WriteLine("What will you do ?");
                        Console.WriteLine("0: Attack");
                        Console.WriteLine("1: Change Sharpmon");
                        Console.WriteLine("2: Use Object");
                        Console.WriteLine("3: Capture");
                        Console.WriteLine("4: Run Away");

                        Choice = Convert.ToInt32(Console.ReadLine());

                        switch (Choice)
                        {
                        case 0:
                            Console.WriteLine("Choose your attack: ");

                            for (int i = 0; i < thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].Attacks.Count; i++)
                            {
                                Console.WriteLine(i + ": " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].Attacks[i].GetAttackName());
                            }

                            int attackchose = -1;
                            try
                            {
                                attackchose = Convert.ToInt32(Console.ReadLine());

                                if ((attackchose >= 0) && (attackchose < thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].Attacks.Count))
                                {
                                    thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].Attacks[attackchose].TheEnemy     = thePlayer.EnemySharpmon;
                                    thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].Attacks[attackchose].SelfSharpmon = thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()];

                                    for (int i = 0; i < thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].Attacks[attackchose].getDamage(); i++)
                                    {
                                        thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].Attacks[attackchose].LaunchAttack();
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("You made an error !");
                                }
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("You made an error !");
                            }

                            Console.WriteLine(thePlayer.EnemySharpmon.GetName() + " launch " + thePlayer.EnemySharpmon.Attacks[attackchose].GetAttackName());
                            break;

                        case 1:
                            Console.WriteLine("Choose an other sharpmon: ");

                            for (int i = 0; i < thePlayer.Sharpdex.Count; i++)
                            {
                                Console.WriteLine(i + ": " + thePlayer.Sharpdex[i].GetName());
                            }

                            try
                            {
                                int sharpchoice;
                                sharpchoice = Convert.ToInt32(Console.ReadLine());

                                if ((sharpchoice >= 0) && (sharpchoice < thePlayer.Sharpdex.Count))
                                {
                                    thePlayer.SetCurrentSharpmon(sharpchoice);
                                    GameItems.setTarget(thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()]);
                                }
                                else
                                {
                                    Console.WriteLine("You made an error !");
                                }
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("You made an error !");
                                IntoTheWild();
                            }

                            Console.WriteLine("You chose " + thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetName());
                            Console.WriteLine("Press any key to continue.. ");
                            Console.ReadLine();
                            break;

                        case 2:
                            if (thePlayer.Items.Count == 0)
                            {
                                Console.WriteLine("You have no Item !");
                                Console.WriteLine("Press any key to continue.. ");
                                Console.ReadLine();
                                break;
                            }
                            Console.WriteLine("My Items List:");
                            for (int i = 0; i < thePlayer.Items.Count; i++)
                            {
                                Console.WriteLine(i + " - " + thePlayer.Items[i].Name + " Description: " + thePlayer.Items[i].Description);
                            }
                            int id;
                            Console.WriteLine("Enter the Item Id:");
                            try
                            {
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine(thePlayer.Items[id].Name + " is used !");
                                thePlayer.Items[id].Use();
                                thePlayer.Items.RemoveAt(id);
                                Console.WriteLine("Press any key to continue.. ");
                                Console.ReadLine();
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("You made an error !");
                                Console.WriteLine("Press any key to continue.. ");
                                Console.ReadLine();
                            }
                            break;

                        case 3:
                            //Capture
                            //(Enemy MaxHP – HP) / 100 – 0.5 % chance
                            float capture = ((float)thePlayer.EnemySharpmon.GetBaseHp() - (float)thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetHp()) / ((float)(100 - 0.5));

                            if (capture > 0.05)
                            {
                                Sharpmon copySharpmon = null;

                                foreach (var sharp in thePlayer.Sharpdex.Where(sharp => sharp.GetName() == thePlayer.EnemySharpmon.GetName()))
                                {
                                    copySharpmon = sharp;
                                }


                                thePlayer.Sharpdex.Add((thePlayer.EnemySharpmon).Clone());
                                Console.WriteLine("You had capture this sharpmon !");
                                Console.WriteLine("Press any key to continue.. ");
                                Console.ReadLine();
                                Menu();
                            }
                            else
                            {
                                Console.WriteLine("You failed to capture this sharpmon.");
                                Console.WriteLine("Press any key to continue.. ");
                                Console.ReadLine();
                            }

                            break;

                        case 4:
                            //Run Away
                            //PlayerSharpmon / (PlayerSharpmon + EnemySharpmon) % chance
                            float runAway = (float)((float)(thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetSpeed()) / (float)(thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetSpeed() + thePlayer.EnemySharpmon.GetSpeed()));

                            if (runAway > 0.5)
                            {
                                Console.WriteLine("you fled !");
                                Console.WriteLine("Press any key to continue.. ");
                                Console.ReadLine();
                                Menu();
                            }
                            else
                            {
                                Console.WriteLine("you failed to run away.");
                                Console.WriteLine("Press any key to continue.. ");
                                Console.ReadLine();
                            }

                            break;

                        default:
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Press any key to continue.. ");
                        Console.ReadLine();
                    }
                }

                Console.ReadLine();

                //We change the player turn
                if (isPlayer == true)
                {
                    isPlayer = false;
                }
                else
                {
                    isPlayer = true;
                }
            }

            //If player loose
            if (thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].GetHp() <= 0)
            {
                Console.WriteLine("You lost the fight..");
                Console.WriteLine("Press any key to continue.. ");
                thePlayer.EnemySharpmon = null;
                thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].RestoreProperties();
                Console.ReadLine();
            }
            else if (thePlayer.EnemySharpmon.GetHp() <= 0)   //If computer loose
            {
                Console.WriteLine("You win the fight !");

                Random rand        = new Random();
                Random rand2       = new Random();
                int    earnedMoney = rand.Next(100, 500);
                thePlayer.AddSharpdollars(earnedMoney);
                Console.WriteLine("You win +" + earnedMoney + " $");

                int EnemyExp  = thePlayer.EnemySharpmon.GetExperience();
                int earnedExp = 1;
                thePlayer.Sharpdex[thePlayer.GetCurrentSharpmon()].AddExperience(earnedExp);
                Console.WriteLine("Your sharpmon win +" + earnedExp + " Experience(s).");
                thePlayer.EnemySharpmon = null;
                Console.WriteLine("Press any key to continue.. ");
                Console.ReadLine();
            }
        }