/// <summary> /// Subtract the cost of a review from the current balance /// and add the review to the list of reviews for this level /// </summary> /// <param name="levelID"></param> /// <param name="review"></param> public void ConfirmReviwedResourceRequest(LevelID levelID, ReviewedResourceRequest review) { ReviewedResourceRequestList list = GetEntryWithLatestAttempt(levelID).reviews; // Check if the game manager exists and the review was not denied if (GameManager.Instance && review.CurrentStatus != ReviewedResourceRequest.Status.Denied) { // Add the item to the resource manager and subtract the total cost Item itemObjectGranted = GameManager.Instance.LevelData.GetItemWithID(review.Request.ItemRequested).itemObject; GameManager.Instance.m_resourceManager.AddItem(itemObjectGranted.ItemName, review.QuantityGranted); GameManager.Instance.SubtractFromBalance(review.TotalCost); } list.Reviews.Add(review); }
private void GenerateQuizInstance() { // Get the list of reviews for the current attempt of this level ReviewedResourceRequestList reviewsList = GameManager .Instance .NotebookUI .Data .Concepts .GetEntryWithLatestAttempt(LevelID.Current()) .reviews; // If there are reviewed requests then create a quiz with additional questions if (reviewsList.Reviews.Count > 0) { // Filter only reviews that were granted, // and combine reviews that addressed and requested the same item ReviewedResourceRequest[] filteredReviews = reviewsList .Reviews .Where(ResourceRequestGeneratesQuestion) .Distinct(new ReviewedResourceRequest.ItemComparer()) .ToArray(); // Check to make sure there are some reviews to quiz on if (filteredReviews.Length > 0) { // Create an array with all the quiz questions QuizQuestion[] requestQuestions = new QuizQuestion[filteredReviews.Length]; // Fill in the info for each question for (int i = 0; i < requestQuestions.Length; i++) { ResourceRequest request = filteredReviews[i].Request; // Set the category to the item addressed by the request QuizCategory category = new QuizCategory(request.ItemAddressed, request.NeedAddressed); // Generate the quiz options QuizOption[] options = GenerateQuizOptions(request, category); // Setup the format for the question string question = $"Was the requested {request.ItemRequested.Data.Name.Get(ItemName.Type.Colloquial)} " + $"useful for improving the {request.ItemAddressed.Data.Name.Get(ItemName.Type.Colloquial)}" + $" {request.NeedAddressed} need?"; // Create the question requestQuestions[i] = new QuizQuestion(question, category, options); } // Set the current quiz with additional request questions currentQuiz = new QuizInstance(template, requestQuestions); } else { currentQuiz = new QuizInstance(template); } } // If there are no reviwed requests // then create a quiz without additional questions else { currentQuiz = new QuizInstance(template); } }