ParametersPack.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. using System;
  2. using System.Collections.Generic;
  3. namespace MaidStatus
  4. {
  5. public class ParametersPack
  6. {
  7. public ParametersPack()
  8. {
  9. this.dataPacks = new Dictionary<ParametersPack.StatusType, int>();
  10. }
  11. public ParametersPack(ParametersPack src)
  12. {
  13. this.dataPacks = new Dictionary<ParametersPack.StatusType, int>(src.dataPacks);
  14. }
  15. public static ParametersPack operator +(ParametersPack a, ParametersPack b)
  16. {
  17. ParametersPack parametersPack = new ParametersPack();
  18. foreach (KeyValuePair<ParametersPack.StatusType, int> keyValuePair in a.dataPacks)
  19. {
  20. parametersPack.Add(keyValuePair.Key, keyValuePair.Value);
  21. if (b.dataPacks.ContainsKey(keyValuePair.Key))
  22. {
  23. parametersPack.Add(keyValuePair.Key, b.dataPacks[keyValuePair.Key]);
  24. }
  25. }
  26. foreach (KeyValuePair<ParametersPack.StatusType, int> keyValuePair2 in b.dataPacks)
  27. {
  28. if (!parametersPack.dataPacks.ContainsKey(keyValuePair2.Key))
  29. {
  30. parametersPack.Add(keyValuePair2.Key, keyValuePair2.Value);
  31. }
  32. }
  33. return parametersPack;
  34. }
  35. public static ParametersPack.StatusType NameToStatusType(string statusName)
  36. {
  37. ParametersPack.StatusType result = ParametersPack.StatusType.体力;
  38. try
  39. {
  40. result = (ParametersPack.StatusType)Enum.Parse(typeof(ParametersPack.StatusType), statusName);
  41. }
  42. catch (Exception e)
  43. {
  44. NDebug.AssertParseError("StatusType", e);
  45. }
  46. return result;
  47. }
  48. public Dictionary<ParametersPack.StatusType, int> dataPacks { get; private set; }
  49. public void Parse(string texts, char separator = ',')
  50. {
  51. if (string.IsNullOrEmpty(texts))
  52. {
  53. return;
  54. }
  55. string[] array = texts.Split(new char[]
  56. {
  57. separator
  58. });
  59. foreach (string text in array)
  60. {
  61. string text2 = text.Replace("\u3000", string.Empty).Replace(" ", string.Empty).Replace("+", "+").Replace("ー", "-").Replace("=", "=");
  62. bool flag = text2.IndexOf('=') != -1;
  63. bool flag2 = text2.IndexOf('-') != -1;
  64. string[] array3 = null;
  65. if (flag)
  66. {
  67. array3 = text2.Split(new char[]
  68. {
  69. '='
  70. });
  71. }
  72. else if (flag2)
  73. {
  74. array3 = text2.Split(new char[]
  75. {
  76. '-'
  77. });
  78. }
  79. else
  80. {
  81. array3 = text2.Split(new char[]
  82. {
  83. '+'
  84. });
  85. }
  86. NDebug.Assert(array3.Length == 2, text2 + "\ntoken count error : " + array3.Length);
  87. ParametersPack.StatusType targetStatus = ParametersPack.NameToStatusType(array3[0]);
  88. int num = 0;
  89. try
  90. {
  91. num = int.Parse(array3[1]);
  92. }
  93. catch (Exception)
  94. {
  95. NDebug.Assert("intのパースに失敗しました\n" + array3[1], false);
  96. }
  97. if (flag)
  98. {
  99. this.Set(targetStatus, num);
  100. }
  101. else
  102. {
  103. if (flag2)
  104. {
  105. num *= -1;
  106. }
  107. this.Add(targetStatus, num);
  108. }
  109. }
  110. }
  111. public void Clear()
  112. {
  113. this.dataPacks.Clear();
  114. }
  115. public void Set(ParametersPack.StatusType targetStatus, int setNum)
  116. {
  117. this.dataPacks[targetStatus] = setNum;
  118. }
  119. public void Add(ParametersPack.StatusType targetStatus, int addNum)
  120. {
  121. if (!this.dataPacks.ContainsKey(targetStatus))
  122. {
  123. this.dataPacks.Add(targetStatus, 0);
  124. }
  125. Dictionary<ParametersPack.StatusType, int> dataPacks;
  126. (dataPacks = this.dataPacks)[targetStatus] = dataPacks[targetStatus] + addNum;
  127. if (this.dataPacks[targetStatus] == 0)
  128. {
  129. this.dataPacks.Remove(targetStatus);
  130. }
  131. }
  132. public void ApplyAddBonusStatus(BonusStatus bonusStatus)
  133. {
  134. if (this.dataPacks == null || this.dataPacks.Count <= 0)
  135. {
  136. return;
  137. }
  138. Dictionary<ParametersPack.StatusType, Action<int>> dictionary = new Dictionary<ParametersPack.StatusType, Action<int>>();
  139. dictionary.Add(ParametersPack.StatusType.興奮, delegate(int addNum)
  140. {
  141. bonusStatus.excite += addNum;
  142. });
  143. dictionary.Add(ParametersPack.StatusType.官能, delegate(int addNum)
  144. {
  145. bonusStatus.sensual += addNum;
  146. });
  147. dictionary.Add(ParametersPack.StatusType.理性, delegate(int addNum)
  148. {
  149. bonusStatus.reason += addNum;
  150. });
  151. dictionary.Add(ParametersPack.StatusType.体力, delegate(int addNum)
  152. {
  153. bonusStatus.hp += addNum;
  154. });
  155. dictionary.Add(ParametersPack.StatusType.精神, delegate(int addNum)
  156. {
  157. bonusStatus.mind += addNum;
  158. });
  159. dictionary.Add(ParametersPack.StatusType.接待, delegate(int addNum)
  160. {
  161. bonusStatus.reception += addNum;
  162. });
  163. dictionary.Add(ParametersPack.StatusType.お世話, delegate(int addNum)
  164. {
  165. bonusStatus.care += addNum;
  166. });
  167. dictionary.Add(ParametersPack.StatusType.可憐, delegate(int addNum)
  168. {
  169. bonusStatus.lovely += addNum;
  170. });
  171. dictionary.Add(ParametersPack.StatusType.気品, delegate(int addNum)
  172. {
  173. bonusStatus.elegance += addNum;
  174. });
  175. dictionary.Add(ParametersPack.StatusType.料理, delegate(int addNum)
  176. {
  177. bonusStatus.cooking += addNum;
  178. });
  179. dictionary.Add(ParametersPack.StatusType.ボ\u30FCカル, delegate(int addNum)
  180. {
  181. bonusStatus.vocal += addNum;
  182. });
  183. dictionary.Add(ParametersPack.StatusType.ダンス, delegate(int addNum)
  184. {
  185. bonusStatus.dance += addNum;
  186. });
  187. dictionary.Add(ParametersPack.StatusType.AP, delegate(int addNum)
  188. {
  189. bonusStatus.appealPoint += addNum;
  190. });
  191. dictionary.Add(ParametersPack.StatusType.魅惑, delegate(int addNum)
  192. {
  193. bonusStatus.charm += addNum;
  194. });
  195. dictionary.Add(ParametersPack.StatusType.淫欲, delegate(int addNum)
  196. {
  197. bonusStatus.inyoku += addNum;
  198. });
  199. dictionary.Add(ParametersPack.StatusType.M性, delegate(int addNum)
  200. {
  201. bonusStatus.mvalue += addNum;
  202. });
  203. dictionary.Add(ParametersPack.StatusType.変態, delegate(int addNum)
  204. {
  205. bonusStatus.hentai += addNum;
  206. });
  207. dictionary.Add(ParametersPack.StatusType.奉仕, delegate(int addNum)
  208. {
  209. bonusStatus.housi += addNum;
  210. });
  211. dictionary.Add(ParametersPack.StatusType.指導, delegate(int addNum)
  212. {
  213. bonusStatus.teachRate += addNum;
  214. });
  215. foreach (KeyValuePair<ParametersPack.StatusType, int> keyValuePair in this.dataPacks)
  216. {
  217. if (dictionary.ContainsKey(keyValuePair.Key))
  218. {
  219. dictionary[keyValuePair.Key](keyValuePair.Value);
  220. }
  221. else
  222. {
  223. NDebug.Assert("ボーナスステータスの適用に[" + keyValuePair.Key.ToString() + "]が指定されていますが未対応です", false);
  224. }
  225. }
  226. }
  227. public bool GreaterThanOrEqualToStatus(Status status)
  228. {
  229. if (this.dataPacks == null || this.dataPacks.Count <= 0)
  230. {
  231. return true;
  232. }
  233. Dictionary<ParametersPack.StatusType, int> dictionary = this.CreateCurrentStatusDic(status);
  234. foreach (KeyValuePair<ParametersPack.StatusType, int> keyValuePair in this.dataPacks)
  235. {
  236. NDebug.Assert(dictionary.ContainsKey(keyValuePair.Key), "ParametersPack:" + keyValuePair.Key.ToString() + "はステータスに存在しません");
  237. if (keyValuePair.Value > dictionary[keyValuePair.Key])
  238. {
  239. return false;
  240. }
  241. }
  242. return true;
  243. }
  244. public List<KeyValuePair<string[], bool>> CreateConditionTextAndStaturResults(Status status)
  245. {
  246. List<KeyValuePair<string[], bool>> list = new List<KeyValuePair<string[], bool>>();
  247. Dictionary<ParametersPack.StatusType, int> dictionary = this.CreateCurrentStatusDic(status);
  248. foreach (KeyValuePair<ParametersPack.StatusType, int> keyValuePair in this.dataPacks)
  249. {
  250. string text = "MaidStatus/条件文/" + keyValuePair.Key.ToString() + " {0}";
  251. bool value = keyValuePair.Value <= dictionary[keyValuePair.Key];
  252. list.Add(new KeyValuePair<string[], bool>(new string[]
  253. {
  254. text,
  255. keyValuePair.Value.ToString()
  256. }, value));
  257. }
  258. return list;
  259. }
  260. private Dictionary<ParametersPack.StatusType, int> CreateCurrentStatusDic(Status status)
  261. {
  262. return new Dictionary<ParametersPack.StatusType, int>
  263. {
  264. {
  265. ParametersPack.StatusType.興奮,
  266. status.currentExcite
  267. },
  268. {
  269. ParametersPack.StatusType.官能,
  270. status.currentSensual
  271. },
  272. {
  273. ParametersPack.StatusType.理性,
  274. status.maxReason
  275. },
  276. {
  277. ParametersPack.StatusType.体力,
  278. status.maxHp
  279. },
  280. {
  281. ParametersPack.StatusType.精神,
  282. status.maxMind
  283. },
  284. {
  285. ParametersPack.StatusType.接待,
  286. status.reception
  287. },
  288. {
  289. ParametersPack.StatusType.お世話,
  290. status.care
  291. },
  292. {
  293. ParametersPack.StatusType.可憐,
  294. status.lovely
  295. },
  296. {
  297. ParametersPack.StatusType.気品,
  298. status.elegance
  299. },
  300. {
  301. ParametersPack.StatusType.魅惑,
  302. status.charm
  303. },
  304. {
  305. ParametersPack.StatusType.料理,
  306. status.cooking
  307. },
  308. {
  309. ParametersPack.StatusType.ボ\u30FCカル,
  310. status.vocal
  311. },
  312. {
  313. ParametersPack.StatusType.ダンス,
  314. status.dance
  315. },
  316. {
  317. ParametersPack.StatusType.AP,
  318. status.appealPoint
  319. },
  320. {
  321. ParametersPack.StatusType.淫欲,
  322. status.inyoku
  323. },
  324. {
  325. ParametersPack.StatusType.M性,
  326. status.mvalue
  327. },
  328. {
  329. ParametersPack.StatusType.変態,
  330. status.hentai
  331. },
  332. {
  333. ParametersPack.StatusType.奉仕,
  334. status.housi
  335. },
  336. {
  337. ParametersPack.StatusType.指導,
  338. status.teachRate
  339. },
  340. {
  341. ParametersPack.StatusType.経験人数,
  342. status.sexPlayNumberOfPeople
  343. }
  344. };
  345. }
  346. public enum StatusType
  347. {
  348. 興奮,
  349. 官能,
  350. 理性,
  351. 体力,
  352. 精神,
  353. 接待,
  354. お世話,
  355. 可憐,
  356. 気品,
  357. 魅惑,
  358. 料理,
  359. ボ\u30FCカル,
  360. ダンス,
  361. AP,
  362. 淫欲,
  363. M性,
  364. 変態,
  365. 奉仕,
  366. 指導,
  367. 経験人数
  368. }
  369. }
  370. }