PlayerStats.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // <copyright file="PlayerStats.cs" company="Google Inc.">
  2. // Copyright (C) 2015 Google Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. #if (UNITY_ANDROID || (UNITY_IPHONE && !NO_GPGS))
  17. namespace GooglePlayGames.BasicApi
  18. {
  19. using System;
  20. /// <summary>
  21. /// Player stats. See https://developers.google.com/games/services/android/stats
  22. /// </summary>
  23. public class PlayerStats
  24. {
  25. private static float UNSET_VALUE = -1.0f;
  26. /// <summary>
  27. /// If this PlayerStats object is valid (i.e. successfully retrieved from games services).
  28. /// </summary>
  29. /// <remarks>
  30. /// Note that a PlayerStats with all stats unset may still be valid.
  31. /// </remarks>
  32. public bool Valid
  33. {
  34. get;
  35. set;
  36. }
  37. /// <summary>
  38. /// The number of in-app purchases.
  39. /// </summary>
  40. public int NumberOfPurchases
  41. {
  42. get;
  43. set;
  44. }
  45. /// <summary>
  46. /// The length of the avg sesson in minutes.
  47. /// </summary>
  48. public float AvgSessonLength
  49. {
  50. get;
  51. set;
  52. }
  53. /// <summary>
  54. /// The days since last played.
  55. /// </summary>
  56. public int DaysSinceLastPlayed
  57. {
  58. get;
  59. set;
  60. }
  61. /// <summary>
  62. /// The number of sessions based on sign-ins.
  63. /// </summary>
  64. public int NumberOfSessions
  65. {
  66. get;
  67. set;
  68. }
  69. /// <summary>
  70. /// The approximation of sessions percentile for the player.
  71. /// </summary>
  72. /// <remarks>
  73. /// This value is given as a decimal value between 0 and 1 (inclusive).
  74. /// It indicates how many sessions the current player has
  75. /// played in comparison to the rest of this game's player base.
  76. /// Higher numbers indicate that this player has played more sessions.
  77. /// A return value less than zero indicates this value is not available.
  78. /// </remarks>
  79. public float SessPercentile
  80. {
  81. get;
  82. set;
  83. }
  84. /// <summary>
  85. /// The approximate spend percentile of the player.
  86. /// </summary>
  87. /// <remarks>
  88. /// This value is given as a decimal value between 0 and 1 (inclusive).
  89. /// It indicates how much the current player has spent in
  90. /// comparison to the rest of this game's player base. Higher
  91. /// numbers indicate that this player has spent more.
  92. /// A return value less than zero indicates this value is not available.
  93. /// </remarks>
  94. public float SpendPercentile
  95. {
  96. get;
  97. set;
  98. }
  99. /// <summary>
  100. /// The approximate probability of the player choosing to spend in this game.
  101. /// </summary>
  102. /// <remarks>
  103. /// This value is given as a decimal value between 0 and 1 (inclusive).
  104. /// Higher values indicate that a player is more likely to spend.
  105. /// A return value less than zero indicates this value is not available.
  106. /// </remarks>
  107. public float SpendProbability
  108. {
  109. get;
  110. set;
  111. }
  112. /// <summary>
  113. /// The approximate probability of the player not returning to play the game.
  114. /// </summary>
  115. /// <remarks>
  116. /// Higher values indicate that a player is less likely to return.
  117. /// A return value less than zero indicates this value is not available.
  118. /// </remarks>
  119. public float ChurnProbability
  120. {
  121. get;
  122. set;
  123. }
  124. /// <summary>
  125. /// The high spender probability of this player.
  126. /// </summary>
  127. public float HighSpenderProbability
  128. {
  129. get;
  130. set;
  131. }
  132. /// <summary>
  133. /// The predicted total spend of this player over the next 28 days.
  134. /// </summary>
  135. public float TotalSpendNext28Days
  136. {
  137. get;
  138. set;
  139. }
  140. /// <summary>
  141. /// Initializes a new instance of the <see cref="GooglePlayGames.BasicApi.PlayerStats"/> class.
  142. /// Sets all values to -1.
  143. /// </summary>
  144. public PlayerStats() {
  145. Valid = false;
  146. }
  147. /// <summary>
  148. /// Determines whether this instance has NumberOfPurchases.
  149. /// </summary>
  150. /// <returns><c>true</c> if this instance has NumberOfPurchases; otherwise, <c>false</c>.</returns>
  151. public bool HasNumberOfPurchases()
  152. {
  153. return NumberOfPurchases != (int)UNSET_VALUE;
  154. }
  155. /// <summary>
  156. /// Determines whether this instance has AvgSessonLength.
  157. /// </summary>
  158. /// <returns><c>true</c> if this instance has AvgSessonLength; otherwise, <c>false</c>.</returns>
  159. public bool HasAvgSessonLength()
  160. {
  161. return AvgSessonLength != UNSET_VALUE;
  162. }
  163. /// <summary>
  164. /// Determines whether this instance has DaysSinceLastPlayed.
  165. /// </summary>
  166. /// <returns><c>true</c> if this instance has DaysSinceLastPlayed; otherwise, <c>false</c>.</returns>
  167. public bool HasDaysSinceLastPlayed()
  168. {
  169. return DaysSinceLastPlayed != (int)UNSET_VALUE;
  170. }
  171. /// <summary>
  172. /// Determines whether this instance has NumberOfSessions.
  173. /// </summary>
  174. /// <returns><c>true</c> if this instance has NumberOfSessions; otherwise, <c>false</c>.</returns>
  175. public bool HasNumberOfSessions()
  176. {
  177. return NumberOfSessions != (int)UNSET_VALUE;
  178. }
  179. /// <summary>
  180. /// Determines whether this instance has SessPercentile.
  181. /// </summary>
  182. /// <returns><c>true</c> if this instance has SessPercentile; otherwise, <c>false</c>.</returns>
  183. public bool HasSessPercentile()
  184. {
  185. return SessPercentile != UNSET_VALUE;
  186. }
  187. /// <summary>
  188. /// Determines whether this instance has SpendPercentile.
  189. /// </summary>
  190. /// <returns><c>true</c> if this instance has SpendPercentile; otherwise, <c>false</c>.</returns>
  191. public bool HasSpendPercentile()
  192. {
  193. return SpendPercentile != UNSET_VALUE;
  194. }
  195. /// <summary>
  196. /// Determines whether this instance has ChurnProbability.
  197. /// </summary>
  198. /// <returns><c>true</c> if this instance has ChurnProbability; otherwise, <c>false</c>.</returns>
  199. public bool HasChurnProbability()
  200. {
  201. return ChurnProbability != UNSET_VALUE;
  202. }
  203. /// <summary>
  204. /// Determines whether this instance has HighSpenderProbability.
  205. /// </summary>
  206. /// <returns><c>true</c> if this instance has HighSpenderProbability; otherwise, <c>false</c>.</returns>
  207. public bool HasHighSpenderProbability()
  208. {
  209. return HighSpenderProbability != UNSET_VALUE;
  210. }
  211. /// <summary>
  212. /// Determines whether this instance has TotalSpendNext28Days.
  213. /// </summary>
  214. /// <returns><c>true</c> if this instance has TotalSpendNext28Days; otherwise, <c>false</c>.</returns>
  215. public bool HasTotalSpendNext28Days()
  216. {
  217. return TotalSpendNext28Days != UNSET_VALUE;
  218. }
  219. }
  220. }
  221. #endif