public void BoirePotion(Potions potion) { TypePotion type = potion.GetType(); int pointDeViePotion = potion.GetPointDeVie(); switch (type) { case TypePotion.poison: if (pointDeVie - pointDeViePotion < 0) { pointDeVie = 0; Mourrir(); } else { pointDeVie = pointDeVie - pointDeViePotion; } this.etatSante = "Empoisonée"; break; case TypePotion.neutre: if (pointDeVie + pointDeViePotion > pointDeVieMaximum) { pointDeVie = pointDeVieMaximum; } else { pointDeVie = pointDeVie + pointDeViePotion; } break; case TypePotion.antipoison: if (pointDeVie + pointDeViePotion > pointDeVieMaximum) { pointDeVie = pointDeVieMaximum; } else { pointDeVie = pointDeVie + pointDeViePotion; } this.etatSante = "ok"; break; } }
public Potions(int pointDeVie, TypePotion type) { int rand; this.pointDeVie = pointDeVie; if (type == TypePotion.poison) { this.type = TypePotion.poison; rand = random.Next(1, 10); if (rand < 9) { this.couleur = "rouge"; } else { if (rand == 9) { this.couleur = "verte"; } else { this.couleur = "bleu"; } } } if (type == TypePotion.antipoison) { this.type = TypePotion.antipoison; rand = random.Next(1, 10); if (rand < 9) { this.couleur = "verte"; } else { if (rand == 9) { this.couleur = "rouge"; } else { this.couleur = "bleu"; } } } if (type == TypePotion.neutre) { this.type = TypePotion.neutre; rand = random.Next(1, 10); if (rand < 9) { this.couleur = "bleu"; } else { if (rand == 9) { this.couleur = "rouge"; } else { this.couleur = "verte"; } } } }