public Spice ChoixSpice() { Spice empty = null; try { Console.WriteLine("-- Choisissez une épice --"); Console.WriteLine("\t1) Paprika x " + FindItems(Game.spices[0]) + " --> " + Game.spices[0].effect); Console.WriteLine("\t2) Canelle x " + FindItems(Game.spices[1]) + " --> " + Game.spices[1].effect); Console.WriteLine("\t3) Gingembre x " + FindItems(Game.spices[2]) + " --> " + Game.spices[2].effect); Console.WriteLine("\t4) Retour au menu"); int i = int.Parse(Console.ReadLine()); switch (i) { case 1: if (FindItems(Game.spices[0]) > 0) { inventory.spiceList.Remove(Game.spices[0]); return(Game.spices[0]); } else { return(empty); } case 2: if (FindItems(Game.spices[1]) > 0) { inventory.spiceList.Remove(Game.spices[1]); return(Game.spices[1]); } else { return(empty); } case 3: if (FindItems(Game.spices[2]) > 0) { inventory.spiceList.Remove(Game.spices[0]); return(Game.spices[2]); } else { return(empty); } } if (i > 4) { Console.WriteLine("erreur, reessayez svp: "); } } catch (Exception) { Console.WriteLine("erreur, reessayez svp: "); } return(empty); }
public bool Fight(HeroConstructor hero, Enemy enemy) { string option; bool tourJoueur = true; bool victoire; int enemyHpReset = enemy.GetHp(); int enemyAttReset = enemy.GetAtt(); int enemyDefReset = enemy.GetDef(); int heroHpReset = hero.GetHp(); int heroAttReset = hero.GetAtt(); int heroDefReset = hero.GetDef(); //début du combat while (true) { //tour de l'ennemi if (tourJoueur == false) { Attack atk = enemy.ChoixAttackEnemy(); if (enemy.GetTheType() == "plaine" && atk == enemy.attackList[2]) { EnemyPlaine.DoOgm(enemy); } else if (enemy.GetTheType() == "plaine" && atk == enemy.attackList[3]) { EnemyPlaine.DoPotager(hero, enemy); } else if (enemy.GetTheType() == "foret" && atk == enemy.attackList[2]) { EnemyForet.DoOgm2(enemy); } else if (enemy.GetTheType() == "foret" && atk == enemy.attackList[3]) { EnemyForet.DoDoubleBaffe(hero, enemy); } else if (enemy.GetTheType() == "bossPlaine") { Enemy.DoBasicAttack(atk, hero, enemy); } else if (enemy.GetTheType() == "bossforet" && atk == enemy.attackList[0] || atk == enemy.attackList[1]) { Enemy.DoBasicAttack(atk, hero, enemy); } else if (enemy.GetTheType() == "bossforet" && atk == enemy.attackList[2]) { EnemyForet.DoDoubleBaffe(hero, enemy); } else if (enemy.GetTheType() == "bossforet" && atk == enemy.attackList[3]) { Boss.DoSpores(hero, enemy); } else if (atk == enemy.attackList[0] || atk == enemy.attackList[1]) { Enemy.DoBasicAttack(atk, hero, enemy); } tourJoueur = true; } if (hero.GetHp() <= 0) { Console.WriteLine("Vous vous etes fait tuer par " + enemy.GetName()); //on reset les stats du joueur et de l'ennemi hero.SetHp(heroHpReset); hero.SetAtt(heroAttReset); hero.SetDef(heroDefReset); enemy.SetHp(enemyHpReset); enemy.SetAtt(enemyAttReset); enemy.SetDef(enemyDefReset); return(victoire = false); } if (tourJoueur == true) { Console.WriteLine("c'est votre tour!"); Console.WriteLine("Hp = " + hero.GetHp() + " /// Att = " + hero.GetAtt() + " /// Def = " + hero.GetDef()); option = FightMenu(enemy); if (option == "attack") { hero.AttackMenu(); Attack atk = hero.ChoixAttaqueHero(); if (hero.GetClasse() == "Découpe" && atk == hero.GetAttacKList()[2]) { AttackDecoupe.DoJulienne(hero, enemy); } else if (hero.GetClasse() == "Découpe" && atk == hero.GetAttacKList()[3]) { AttackDecoupe.DoHachage(hero, enemy, enemyHpReset); } else if (hero.GetClasse() == "Cuisson" && atk == hero.GetAttacKList()[2]) { AttackCuisson.DoFlambage(hero, enemy); } else if (hero.GetClasse() == "Cuisson" && atk == hero.GetAttacKList()[3]) { AttackCuisson.DoPyrolise(hero, enemy); } else if (hero.GetClasse() == "Pâte" && atk == hero.GetAttacKList()[2]) { AttackPate.DoMalaxage(hero, enemy); } else if (hero.GetClasse() == "Pâte" && atk == hero.GetAttacKList()[3]) { AttackPate.DoEtalage(hero, enemy); } else if (atk == hero.GetAttacKList()[0] || atk == hero.GetAttacKList()[1]) { Attack.DoBasicAttack(atk, hero, enemy); } tourJoueur = false; } else if (option == "herb") { Herb herb = hero.ChoixHerbs(); if (herb != null) { Console.WriteLine(hero.GetName() + " a utilisé: " + herb.GetName() + "!"); if (herb == herbs[0]) { Herb.UseRomarin(enemy); } else if (herb == herbs[1]) { Herb.UseThym(enemy); } else if (herb == herbs[2]) { Herb.UseCoriandre(enemy); } } else { Console.WriteLine("vous n'en n'avez pas dans votre inventaire!!"); } } else if (option == "spice") { Spice spice = hero.ChoixSpice(); if (spice != null) { Console.WriteLine(hero.GetName() + " a utilisé: " + spice.GetName() + "!"); if (spice == spices[0]) { Spice.UsePaprika(hero); } else if (spice == spices[1]) { Spice.UseCanelle(hero); } else if (spice == spices[2]) { Spice.UseGingembre(hero, heroHpReset); } } else { Console.WriteLine("vous n'en n'avez pas dans votre inventaire!!"); } } else if (option == "infos") { enemy.StatsMenuEnemy(); enemy.AttackMenuEnemy(); } if (enemy.GetHp() > 0) { Console.WriteLine(enemy.GetName() + " a " + enemy.GetHp() + "hp"); } } if (enemy.GetHp() <= 0) { Console.WriteLine(enemy.GetName() + " est mort!!"); //on reset les stats du joueur et de l'ennemis hero.SetHp(heroHpReset); hero.SetAtt(heroAttReset); hero.SetDef(heroDefReset); enemy.SetHp(enemyHpReset); enemy.SetAtt(enemyAttReset); enemy.SetDef(enemyDefReset); if (hero.getXp() + enemy.xp >= hero.getNextLvl()) { Console.WriteLine("Vous avez gagné un niveau!!"); Console.WriteLine(hero.GetName() + " passe niveau " + (hero.getLvl() + 1) + "!!!"); Console.WriteLine("Hp --> +100 | Att --> +10 | Def --> +10"); hero.SetXp(enemy.xp - (hero.getNextLvl() - hero.getXp())); hero.SetLvl(hero.getLvl() + 1); hero.SetNextLvl(hero.getNextLvl() * 2 + 50); hero.SetHp(hero.GetHp() + 100); hero.SetAtt(hero.GetAtt() + 10); hero.SetDef(hero.GetDef() + 10); } else if (hero.getXp() + enemy.xp < hero.getNextLvl()) { hero.SetXp(hero.getXp() + enemy.xp); } if (enemy.GetTheType() == "bossplaine" || enemy.GetTheType() == "bossforet" || enemy.GetTheType() == "bossmer" || enemy.GetTheType() == "bossdesert" || enemy.GetTheType() == "bossmontagne" || enemy.GetTheType() == "bossruine") { Console.WriteLine("Vous avez gagné \"" + enemy.reward.GetName() + "\"!!!"); hero.inventory.ingredientList.Add(enemy.reward); } Console.ReadLine(); return(victoire = true); } } }