ParametersPack.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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 str = keyValuePair.Key.ToString();
  251. bool value = keyValuePair.Value <= dictionary[keyValuePair.Key];
  252. list.Add(new KeyValuePair<string, bool>(str + " " + keyValuePair.Value.ToString(), value));
  253. }
  254. return list;
  255. }
  256. private Dictionary<ParametersPack.StatusType, int> CreateCurrentStatusDic(Status status)
  257. {
  258. return new Dictionary<ParametersPack.StatusType, int>
  259. {
  260. {
  261. ParametersPack.StatusType.興奮,
  262. status.currentExcite
  263. },
  264. {
  265. ParametersPack.StatusType.官能,
  266. status.currentSensual
  267. },
  268. {
  269. ParametersPack.StatusType.理性,
  270. status.maxReason
  271. },
  272. {
  273. ParametersPack.StatusType.体力,
  274. status.maxHp
  275. },
  276. {
  277. ParametersPack.StatusType.精神,
  278. status.maxMind
  279. },
  280. {
  281. ParametersPack.StatusType.接待,
  282. status.reception
  283. },
  284. {
  285. ParametersPack.StatusType.お世話,
  286. status.care
  287. },
  288. {
  289. ParametersPack.StatusType.可憐,
  290. status.lovely
  291. },
  292. {
  293. ParametersPack.StatusType.気品,
  294. status.elegance
  295. },
  296. {
  297. ParametersPack.StatusType.魅惑,
  298. status.charm
  299. },
  300. {
  301. ParametersPack.StatusType.料理,
  302. status.cooking
  303. },
  304. {
  305. ParametersPack.StatusType.ボ\u30FCカル,
  306. status.vocal
  307. },
  308. {
  309. ParametersPack.StatusType.ダンス,
  310. status.dance
  311. },
  312. {
  313. ParametersPack.StatusType.AP,
  314. status.appealPoint
  315. },
  316. {
  317. ParametersPack.StatusType.淫欲,
  318. status.inyoku
  319. },
  320. {
  321. ParametersPack.StatusType.M性,
  322. status.mvalue
  323. },
  324. {
  325. ParametersPack.StatusType.変態,
  326. status.hentai
  327. },
  328. {
  329. ParametersPack.StatusType.奉仕,
  330. status.housi
  331. },
  332. {
  333. ParametersPack.StatusType.指導,
  334. status.teachRate
  335. },
  336. {
  337. ParametersPack.StatusType.経験人数,
  338. status.sexPlayNumberOfPeople
  339. }
  340. };
  341. }
  342. public enum StatusType
  343. {
  344. 興奮,
  345. 官能,
  346. 理性,
  347. 体力,
  348. 精神,
  349. 接待,
  350. お世話,
  351. 可憐,
  352. 気品,
  353. 魅惑,
  354. 料理,
  355. ボ\u30FCカル,
  356. ダンス,
  357. AP,
  358. 淫欲,
  359. M性,
  360. 変態,
  361. 奉仕,
  362. 指導,
  363. 経験人数
  364. }
  365. }
  366. }