Advertisement
Guest User

Soup

a guest
Oct 12th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1. long cycleTest = 1;
  2. long totalLimit = 0;
  3. while (cookingTime > 0)
  4. {
  5. cookingTime -= cycleTest;
  6. totalLimit += (long)(cycleTest * temperature);
  7. foreach (Food f in ingredients)
  8. {
  9. if (totalLimit > f.limit * 12000)
  10. {//this ingredient is burning
  11. Console.Write("burning!");
  12. f.quality -= f.quality / 100f * cycleTest;
  13. f.deliciousness -= f.deliciousness / 100f * cycleTest;
  14. for (int i = 0; i < f.nutrients.Length; i++)
  15. {
  16. f.nutrients[i] -= (f.nutrients[i] / 100f) * cycleTest;
  17. }
  18. }
  19. else
  20. {
  21. f.idealTemp = (short)((f.idealTemp * 0.25f) + (93 * 0.75f));//moving ingredient idealTemp close to 93ºC
  22. short highLimit = (short)(f.idealTemp + (25 * f.resilience));
  23. short lowerLimit = (short)(f.idealTemp - (50 * f.resilience));
  24. if (temperature > highLimit)
  25. {
  26. f.rawValue += ((1 - f.rawValue) * (temperature / highLimit) / 100f) * cycleTest;
  27. f.quality -= (f.quality * (1 - (highLimit / temperature)) / 100f) * cycleTest;
  28. for (int i = 0; i < f.nutrients.Length; i++)
  29. {
  30. f.nutrients[i] -= (f.nutrients[i] * (1 - (f.idealTemp / temperature)) / 100f) * cycleTest;
  31. }
  32. }
  33. else if (temperature < lowerLimit)
  34. {
  35. f.quality -= (f.quality * (1 - (temperature / lowerLimit)) / 100f) * cycleTest;
  36. f.deliciousness -= (f.deliciousness * (1 - (temperature / f.idealTemp)) / 100f) * cycleTest;
  37. }
  38. else if (temperature > f.idealTemp)
  39. {
  40. f.quality += ((1 - f.quality) * (f.idealTemp / temperature) / 100f) * cycleTest;
  41. f.rawValue += ((1 - f.rawValue) * (temperature / highLimit) / 100f) * cycleTest;
  42. f.deliciousness += ((1 - f.deliciousness) * (temperature / f.idealTemp) / 100f) * cycleTest;
  43. for (int i = 0; i < f.nutrients.Length; i++)
  44. {
  45. f.nutrients[i] -= (f.nutrients[i] * (1 - (f.idealTemp / temperature)) / 100f) * cycleTest;
  46. }
  47. }
  48. else if (temperature < f.idealTemp)
  49. {
  50. f.quality += ((1 - f.quality) * (temperature / f.idealTemp) / 100f) * cycleTest;
  51. f.rawValue += ((1 - f.rawValue) * (temperature / highLimit) / 100f) * cycleTest;
  52. f.deliciousness -= (f.deliciousness * (1 - (temperature / f.idealTemp)) / 100f) * cycleTest;
  53. for (int i = 0; i < f.nutrients.Length; i++)
  54. {
  55. f.nutrients[i] += ((1 - f.nutrients[i]) * (temperature / f.idealTemp) / 100f) * cycleTest;
  56. }
  57. }
  58. else
  59. {//perfect temperature
  60. f.quality += (1 - f.quality) / 100f * cycleTest;
  61. f.rawValue += (1 - f.rawValue) / 100f * cycleTest;
  62. f.deliciousness += (1 - f.deliciousness) / 100f * cycleTest;
  63. for (int i = 0; i < f.nutrients.Length; i++)
  64. {
  65. f.nutrients[i] += ((1 - f.nutrients[i]) / 100f) * cycleTest;
  66. }
  67. }
  68. }
  69. if (totalLimit >= f.cookPoint * 6000)
  70. {
  71. f.rawValue = 1;
  72. }
  73. }
  74. }
  75.  
  76. string name = "";
  77. FoodType type = FoodType.soup;
  78. short calories = 0;
  79. short unitsOfMass = (short)totalMass;
  80. short idealTemp = 93;
  81. float water = 0;
  82. float fat = 0;
  83. float resilience = 0;
  84. long cookPoint = 0;
  85. long limit = 0;
  86. float rawValue = 0;
  87. float deliciousness = 0;
  88. float quality = 0;
  89. bool leaveningAgent = false;
  90. float[] tastes = new float[7];
  91. float[] nutrients = new float[5];
  92. List<Food> mainIngredients = new List<Food>();
  93. float largestAmount = 0;
  94. long shelfTime = 48;
  95. float freshness = 1;
  96.  
  97. foreach (Food f in ingredients){
  98. if (largestAmount < f.unitsOfMass){
  99. if ((f.rawValue >= 1 && !f.liquidCooked) || (f.rawValue < 1 && !f.liquidRaw)){
  100. largestAmount = f.unitsOfMass;
  101. }
  102. }
  103. float percent = (f.unitsOfMass / totalMass);
  104. calories += (short)(f.calories * percent);
  105. water += (f.water * percent);
  106. fat += (f.fat * percent);
  107. resilience += (f.resilience * percent);
  108. limit += (long)(f.limit * percent);
  109. rawValue += (f.rawValue * percent);
  110. deliciousness += (f.deliciousness * percent * f.rawValue);
  111. float q = f.quality * (1 + (f.freshness * 0.3f));
  112. quality += percent * (q < 1 ? q : 1);
  113. for (int i = 0; i < tastes.Length; i++){
  114. tastes[i] += (f.tastes[i] * percent);
  115. }
  116. for (int i = 0; i < nutrients.Length; i++){
  117. nutrients[i] += (f.nutrients[i] * percent * f.rawValue);
  118. }
  119. }
  120.  
  121. foreach (Food f in ingredients){
  122. if (f.unitsOfMass >= 0.95 * largestAmount)
  123. {//if it is at least 95% of the largest ingredient it counts as a main ingredient
  124. mainIngredients.Add(f);
  125. }
  126. }
  127.  
  128. string mainingnames = mainIngredients[0].name;
  129.  
  130. for (int i = 1; i < mainIngredients.Count - 1; i++){
  131. mainingnames += ", " + mainIngredients[i];
  132. }
  133.  
  134. if (mainIngredients.Count > 1){
  135. mainingnames += "and " + mainIngredients[mainIngredients.Count];
  136. }
  137.  
  138. bool liquidRaw = liquid;
  139. bool liquidCooked = liquid;
  140.  
  141. name = dishName.Replace("?", mainingnames);
  142. return new Dish(0, name, type, water, fat, deliciousness, resilience, freshness, quality, cookPoint, limit, shelfTime, rawValue, unitsOfMass, idealTemp, calories, nutrients, tastes, leaveningAgent, ingredients, liquidRaw, liquidCooked);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement