public ClueRoom(ClueTypes clueType, Room room) { this.clueType = clueType; this.room = room; if (clueType == ClueTypes.Unsure) { // Find the pool the object shares List <Room> samePool = Game.S.building.allRooms; // Copy the pool List <Room> samePoolCopy = new List <Room>(); samePoolCopy.AddRange(samePool); //Remove all duplicates from list samePoolCopy.RemoveAll(f => f.displayName == room.displayName); // Pick from non-duplicated list fakeRoom = samePoolCopy.PickRandom(); //Sort clues so we don't identify the clue by it being first List <Room> fakeAndRealRooms = new List <Room> { room, fakeRoom }; sortedRooms = fakeAndRealRooms.OrderBy(x => x.displayName).ToList(); } else { sortedRooms = new List <Room> { room }; } }
private static ClueTypes PickClueCategory(int randomRoll, Dictionary <ClueTypes, int> probabilities) { ClueTypes clue = ClueTypes.Useless; int totalWeight = 0; foreach (KeyValuePair <ClueTypes, int> entry in probabilities) { totalWeight += entry.Value; } foreach (KeyValuePair <ClueTypes, int> entry in probabilities) { //If value has 0, then it is skipped. if (entry.Value == 0) { continue; } //If randomRoll is under entry.Value, then it is under the threshold, and so takes entry.Key if (randomRoll <= entry.Value) { clue = entry.Key; break; } //Otherwise, we reduce the roll by the Value to allow the other weights to potentially be picked. randomRoll -= entry.Value; } return(clue); }
public ClueFloor(ClueTypes clueType, Floor floor) { this.clueType = clueType; this.floor = floor; if (clueType == ClueTypes.Unsure) { // Find the pool the object shares List <Floor> samePool = Game.S.building.allFloors; // Copy the pool List <Floor> samePoolCopy = new List <Floor>(); samePoolCopy.AddRange(samePool); //Remove all duplicates from list samePoolCopy.RemoveAll(f => f.displayName == floor.displayName); // Pick from non-duplicated list fakeFloor = samePoolCopy.PickRandom(); //Sort clues so we don't identify the clue by it being first List <Floor> fakeAndRealFloors = new List <Floor> { floor, fakeFloor }; sortedFloors = fakeAndRealFloors.OrderBy(x => x.displayName).ToList(); } else { sortedFloors = new List <Floor> { floor }; } }
//Special Cases: //Employees in the same department //Manager of the employee public static IClue GenerateRandomClueFromEmployee(Employee employee) { int roll = rnd.Next(1, 101); //Generating random clue type ClueTypes randomClueType = ClueTypes.Useless; switch (employee.rank) { case Person.RankEnum.Employee: randomClueType = PickClueCategory(roll, LowLevelEmployeeClueProbs); break; case Person.RankEnum.Manager: randomClueType = PickClueCategory(roll, ManagerEmployeeClueProbs); break; case Person.RankEnum.Executive: randomClueType = PickClueCategory(roll, ExecEmployeeClueProbs); break; case Person.RankEnum.CEO: randomClueType = PickClueCategory(roll, CEOEmployeeClueProbs); break; default: break; } //if (Employee.currentLocation == Target.currentLocation) //{ // //} IClue generatedClue = null; int clueCategoryRoll = rnd.Next(1, 101); if (clueCategoryRoll <= 70) { var features = Game.S.target.features.getTrueOrnaments(); Feature targetFeature = features.PickRandom(); generatedClue = new ClueFeature(randomClueType, targetFeature); } else if (clueCategoryRoll <= 90) { var floor = Game.S.target.CurrentLocation.floor; generatedClue = new ClueFloor(randomClueType, floor); } else { var room = Game.S.target.CurrentLocation; generatedClue = new ClueRoom(randomClueType, room); } return(generatedClue); }
//Clue needs a ClueTypes //For Useless, we just need a string, we don't need to add to notebook //For Vague, we need a single aspect of a feature //For Unsure, we need an either/or //For perfect, we describe a feature perfectly public ClueFeature(ClueTypes clueType, Feature feature) { this.clueType = clueType; this.feature = feature; if (clueType == ClueTypes.Unsure) { // Find the pool the object shares var samePool = Game.S.GetPoolSharingFeature(feature); List <GameObject> samePoolCopy = new List <GameObject>(); samePoolCopy.AddRange(samePool); //Remove all duplicates from list samePoolCopy.RemoveAll(f => f.GetComponent <Feature>().displayColour + " " + f.GetComponent <Feature>().displayName == feature.displayColour + " " + feature.displayName ); // Pick from non-duplicated list fakeFeature = samePoolCopy.PickRandom().GetComponent <Feature>(); //Sort clues so we don't identify the clue by it being first List <Feature> fakeAndRealFeatures = new List <Feature> { feature, fakeFeature }; sortedFeatures = fakeAndRealFeatures.OrderBy(x => x.displayName).ToList(); } else { sortedFeatures = new List <Feature> { feature }; } }