123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- // <copyright file="PlayerStats.cs" company="Google Inc.">
- // Copyright (C) 2015 Google Inc.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- // </copyright>
- #if UNITY_ANDROID
- namespace GooglePlayGames.BasicApi
- {
- using System;
- /// <summary>
- /// Player stats. See https://developers.google.com/games/services/android/stats
- /// </summary>
- public class PlayerStats
- {
- private static float UNSET_VALUE = -1.0f;
- public PlayerStats(
- int numberOfPurchases,
- float avgSessionLength,
- int daysSinceLastPlayed,
- int numberOfSessions,
- float sessPercentile,
- float spendPercentile,
- float spendProbability,
- float churnProbability,
- float highSpenderProbability,
- float totalSpendNext28Days)
- {
- mValid = true;
- mNumberOfPurchases = numberOfPurchases;
- mAvgSessionLength = avgSessionLength;
- mDaysSinceLastPlayed = daysSinceLastPlayed;
- mNumberOfSessions = numberOfSessions;
- mSessPercentile = sessPercentile;
- mSpendPercentile = spendPercentile;
- mSpendProbability = spendProbability;
- mChurnProbability = churnProbability;
- mHighSpenderProbability = highSpenderProbability;
- mTotalSpendNext28Days = totalSpendNext28Days;
- }
- public PlayerStats()
- {
- mValid = false;
- }
- private bool mValid;
- private int mNumberOfPurchases;
- private float mAvgSessionLength;
- private int mDaysSinceLastPlayed;
- private int mNumberOfSessions;
- private float mSessPercentile;
- private float mSpendPercentile;
- private float mSpendProbability;
- private float mChurnProbability;
- private float mHighSpenderProbability;
- private float mTotalSpendNext28Days;
- /// <summary>
- /// If this PlayerStats object is valid (i.e. successfully retrieved from games services).
- /// </summary>
- /// <remarks>
- /// Note that a PlayerStats with all stats unset may still be valid.
- /// </remarks>
- public bool Valid
- {
- get { return mValid; }
- }
- /// <summary>
- /// The number of in-app purchases.
- /// </summary>
- public int NumberOfPurchases
- {
- get { return mNumberOfPurchases; }
- }
- /// <summary>
- /// The length of the avg session in minutes.
- /// </summary>
- public float AvgSessionLength
- {
- get { return mAvgSessionLength; }
- }
- /// <summary>
- /// The days since last played.
- /// </summary>
- public int DaysSinceLastPlayed
- {
- get { return mDaysSinceLastPlayed; }
- }
- /// <summary>
- /// The number of sessions based on sign-ins.
- /// </summary>
- public int NumberOfSessions
- {
- get { return mNumberOfSessions; }
- }
- /// <summary>
- /// The approximation of sessions percentile for the player.
- /// </summary>
- /// <remarks>
- /// This value is given as a decimal value between 0 and 1 (inclusive).
- /// It indicates how many sessions the current player has
- /// played in comparison to the rest of this game's player base.
- /// Higher numbers indicate that this player has played more sessions.
- /// A return value less than zero indicates this value is not available.
- /// </remarks>
- public float SessPercentile
- {
- get { return mSessPercentile; }
- }
- /// <summary>
- /// The approximate spend percentile of the player.
- /// </summary>
- /// <remarks>
- /// This value is given as a decimal value between 0 and 1 (inclusive).
- /// It indicates how much the current player has spent in
- /// comparison to the rest of this game's player base. Higher
- /// numbers indicate that this player has spent more.
- /// A return value less than zero indicates this value is not available.
- /// </remarks>
- public float SpendPercentile
- {
- get { return mSpendPercentile; }
- }
- /// <summary>
- /// The approximate probability of the player choosing to spend in this game.
- /// </summary>
- /// <remarks>
- /// This value is given as a decimal value between 0 and 1 (inclusive).
- /// Higher values indicate that a player is more likely to spend.
- /// A return value less than zero indicates this value is not available.
- /// </remarks>
- public float SpendProbability
- {
- get { return mSpendProbability; }
- }
- /// <summary>
- /// The approximate probability of the player not returning to play the game.
- /// </summary>
- /// <remarks>
- /// Higher values indicate that a player is less likely to return.
- /// A return value less than zero indicates this value is not available.
- /// </remarks>
- public float ChurnProbability
- {
- get { return mChurnProbability; }
- }
- /// <summary>
- /// The high spender probability of this player.
- /// </summary>
- public float HighSpenderProbability
- {
- get { return mHighSpenderProbability; }
- }
- /// <summary>
- /// The predicted total spend of this player over the next 28 days.
- /// </summary>
- public float TotalSpendNext28Days
- {
- get { return mTotalSpendNext28Days; }
- }
- /// <summary>
- /// Determines whether this instance has NumberOfPurchases.
- /// </summary>
- /// <returns><c>true</c> if this instance has NumberOfPurchases; otherwise, <c>false</c>.</returns>
- public bool HasNumberOfPurchases()
- {
- return NumberOfPurchases != (int) UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has AvgSessionLength.
- /// </summary>
- /// <returns><c>true</c> if this instance has AvgSessionLength; otherwise, <c>false</c>.</returns>
- public bool HasAvgSessionLength()
- {
- return AvgSessionLength != UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has DaysSinceLastPlayed.
- /// </summary>
- /// <returns><c>true</c> if this instance has DaysSinceLastPlayed; otherwise, <c>false</c>.</returns>
- public bool HasDaysSinceLastPlayed()
- {
- return DaysSinceLastPlayed != (int) UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has NumberOfSessions.
- /// </summary>
- /// <returns><c>true</c> if this instance has NumberOfSessions; otherwise, <c>false</c>.</returns>
- public bool HasNumberOfSessions()
- {
- return NumberOfSessions != (int) UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has SessPercentile.
- /// </summary>
- /// <returns><c>true</c> if this instance has SessPercentile; otherwise, <c>false</c>.</returns>
- public bool HasSessPercentile()
- {
- return SessPercentile != UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has SpendPercentile.
- /// </summary>
- /// <returns><c>true</c> if this instance has SpendPercentile; otherwise, <c>false</c>.</returns>
- public bool HasSpendPercentile()
- {
- return SpendPercentile != UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has ChurnProbability.
- /// </summary>
- /// <returns><c>true</c> if this instance has ChurnProbability; otherwise, <c>false</c>.</returns>
- public bool HasChurnProbability()
- {
- return ChurnProbability != UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has HighSpenderProbability.
- /// </summary>
- /// <returns><c>true</c> if this instance has HighSpenderProbability; otherwise, <c>false</c>.</returns>
- public bool HasHighSpenderProbability()
- {
- return HighSpenderProbability != UNSET_VALUE;
- }
- /// <summary>
- /// Determines whether this instance has TotalSpendNext28Days.
- /// </summary>
- /// <returns><c>true</c> if this instance has TotalSpendNext28Days; otherwise, <c>false</c>.</returns>
- public bool HasTotalSpendNext28Days()
- {
- return TotalSpendNext28Days != UNSET_VALUE;
- }
- }
- }
- #endif
|