Influence.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.Json.Serialization;
  4. namespace SOTF_Struct.Generic {
  5. public class Influence {
  6. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  7. public string TypeId { get; set; }
  8. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  9. public double Sentiment { get; set; }
  10. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  11. public double Anger { get; set; }
  12. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  13. public double Fear { get; set; }
  14. public static Influence operator +(Influence a, Influence b) => new Influence() {
  15. TypeId = a.TypeId,
  16. Anger = a.Anger + b.Anger,
  17. Fear = a.Fear + b.Fear,
  18. Sentiment = a.Sentiment + b.Sentiment
  19. };
  20. public static Influence operator +(Influence a, double b) => new Influence() {
  21. TypeId = a.TypeId,
  22. Anger = a.Anger + b,
  23. Fear = a.Fear + b,
  24. Sentiment = a.Sentiment + b
  25. };
  26. public static Influence operator +(Influence a, int b) => new Influence() {
  27. TypeId = a.TypeId,
  28. Anger = a.Anger + b,
  29. Fear = a.Fear + b,
  30. Sentiment = a.Sentiment + b
  31. };
  32. public static Influence operator -(Influence a, Influence b) => new Influence() {
  33. TypeId = a.TypeId,
  34. Anger = a.Anger - b.Anger,
  35. Fear = a.Fear - b.Fear,
  36. Sentiment = a.Sentiment - b.Sentiment
  37. };
  38. public static Influence operator -(Influence a, double b) => new Influence() {
  39. TypeId = a.TypeId,
  40. Anger = a.Anger - b,
  41. Fear = a.Fear - b,
  42. Sentiment = a.Sentiment - b
  43. };
  44. public static Influence operator -(Influence a, int b) => new Influence() {
  45. TypeId = a.TypeId,
  46. Anger = a.Anger - b,
  47. Fear = a.Fear - b,
  48. Sentiment = a.Sentiment - b
  49. };
  50. public static Influence operator *(Influence a, Influence b) => new Influence() {
  51. TypeId = a.TypeId,
  52. Anger = a.Anger * b.Anger,
  53. Fear = a.Fear * b.Fear,
  54. Sentiment = a.Sentiment * b.Sentiment
  55. };
  56. public static Influence operator *(Influence a, double b) => new Influence() {
  57. TypeId = a.TypeId,
  58. Anger = a.Anger * b,
  59. Fear = a.Fear * b,
  60. Sentiment = a.Sentiment * b
  61. };
  62. public static Influence operator *(Influence a, int b) => new Influence() {
  63. TypeId = a.TypeId,
  64. Anger = a.Anger * b,
  65. Fear = a.Fear * b,
  66. Sentiment = a.Sentiment * b
  67. };
  68. public static Influence operator /(Influence a, Influence b) => new Influence() {
  69. TypeId = a.TypeId,
  70. Anger = a.Anger / b.Anger,
  71. Fear = a.Fear / b.Fear,
  72. Sentiment = a.Sentiment / b.Sentiment
  73. };
  74. public static Influence operator /(Influence a, double b) => new Influence() {
  75. TypeId = a.TypeId,
  76. Anger = a.Anger / b,
  77. Fear = a.Fear / b,
  78. Sentiment = a.Sentiment / b
  79. };
  80. public static Influence operator /(Influence a, int b) => new Influence() {
  81. TypeId = a.TypeId,
  82. Anger = a.Anger / b,
  83. Fear = a.Fear / b,
  84. Sentiment = a.Sentiment / b
  85. };
  86. }
  87. }