public string HandleRamasser(HarryPeloteur_DAL.GameInformationDTO gameInfos, string[] parameters) { HarryPeloteur_DAL.SalleDTO currentRoom = FindRoomById(gameInfos.Rooms, gameInfos.Character.SalleActuelle).found; if (currentRoom.TypeContenu != 1) { dt.dbg("Pas d'objet à ramasser dans la salle !"); return("Pas d'objet à ramasser dans la salle !"); } HarryPeloteur_DAL.ObjetDTO currentObject = db.GetObjet(currentRoom.IdContenu); switch (currentObject.ProprieteCible) { case "pv": gameInfos.Character.Pv = this.increaseByPercentage(gameInfos.Character.Pv, currentObject.Montant); break; case "force": gameInfos.Character.Force = this.increaseByPercentage(gameInfos.Character.Force, currentObject.Montant); break; case "fuite": gameInfos.Character.Fuite = this.increaseByPercentage(gameInfos.Character.Fuite, currentObject.Montant); break; case "dexterite": gameInfos.Character.Dexterite = this.increaseByPercentage(gameInfos.Character.Dexterite, currentObject.Montant); break; case "po": gameInfos.Character.Po += currentObject.Montant; break; } string returnText = "Vous avez ramasé " + currentObject.Nom + " (" + currentObject.Description + ")"; currentRoom.TypeContenu = 0; db.UpdateSalle(currentRoom); db.UpdatePersonne(gameInfos.Character); return(returnText); }
public ObjetDTO GetObjet(int?id) { this.con.Open(); string commande = "select * from objet where Id=" + id; SqlCommand cmd1 = new SqlCommand(commande, this.con); SqlDataReader reader = cmd1.ExecuteReader(); ObjetDTO objet = new ObjetDTO(); while (reader.Read()) { objet.Id = (int?)reader.GetValue(0); objet.Nom = (string)reader.GetValue(1); objet.Description = (string)reader.GetValue(2); objet.ProprieteCible = (string)reader.GetValue(3); objet.Montant = (int?)reader.GetValue(4); } this.con.Close(); return(objet); }