3 using System.Collections.Generic;
9 public enum PlayerProfileOperationType : byte
21 public delegate
void StylesUpdateHandler (
string avatarType,
string slotType);
22 public event StylesUpdateHandler StylesUpdated = delegate { };
29 DailyStatistics.TryGetValue(
"*", out stats);
34 public string PlayerID;
38 public UJeli Inventory;
40 public Dictionary<string, PlayerCharacterProfile> Characters =
new Dictionary<string, PlayerCharacterProfile>();
41 public Dictionary<string, PlayerDailyStatistics> DailyStatistics =
new Dictionary<string, PlayerDailyStatistics>();
50 Inventory = jeli[
"Inventory"];
51 Styles = jeli[
"Styles"];
53 UJeli charactersJeli = jeli[
"Characters"];
55 if (charactersJeli != null)
57 foreach (var charJeli
in charactersJeli.Children)
64 UJeli dailyStatsJeli = jeli[
"DailyStatistics"];
66 if (dailyStatsJeli != null)
68 foreach (var dailyMapStatsJeli
in dailyStatsJeli.Children)
76 public override string ToString()
80 jeli.AddChild(Basic.ToJeli());
81 jeli.AddChild(Styles);
83 return jeli.ToString();
89 Characters.TryGetValue(avatarId, out character);
93 internal void ProcessIncomingOperation (
GameMessage op)
95 var opType = (PlayerProfileOperationType)op.ReadByte();
97 if (opType == PlayerProfileOperationType.InventoryUpdate)
99 string path = op.ReadString();
100 string value = op.ReadString();
101 string property = SetJeliProperty(Inventory, path, value);
103 if (property ==
"libi")
107 else if (opType == PlayerProfileOperationType.StylesUpdate)
109 string avatarType = op.ReadString();
110 string slotType = op.ReadString();
111 string value = op.ReadString();
113 if (!Styles[avatarType].HasChild(slotType))
114 Styles[avatarType].AddChild(slotType);
116 Styles[avatarType][slotType].Value = value;
119 StylesUpdated(avatarType, slotType.ToString().ToLower());
123 private string SetJeliProperty (
UJeli jeli,
string path,
string value)
125 List<string> pathTokens = path.Split(
'/').ToList();
127 while (pathTokens.Count != 0)
129 string childName = pathTokens[0];
131 if (jeli.HasChild(childName))
132 jeli = jeli.GetChild(childName);
134 jeli = jeli.AddChild(childName);
136 pathTokens.RemoveAt(0);
146 public string Nickname;
147 public bool IsMonitor;
151 try { Nickname = jeli[
"Nickname"].Value; }
catch { }
153 if (
string.IsNullOrEmpty(Nickname))
154 Nickname =
System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(
id);
156 try { IsMonitor = jeli[
"IsMonitor"].BoolValue; }
catch { }
159 public UJeli ToJeli ()
163 jeli.AddChild(
"Nickname", Nickname);
164 jeli.AddChild(
"IsMonitor", IsMonitor);
169 public override string ToString ()
171 return ToJeli().ToString();
177 public string LastZoneMapID;
178 public string LastCheckpointID;
182 try { LastZoneMapID = jeli[
"LastZone"].Value; }
catch { }
183 try { LastCheckpointID = jeli[
"LastCheckpoint"].Value; }
catch { }
189 public Dictionary<string, int> TraitPoints =
new Dictionary<string, int>();
190 public string LastActivePersonaID;
194 UJeli traitsJeli = jeli[
"Traits"];
196 if (traitsJeli != null)
197 TraitPoints = traitsJeli.GetChildDictionaryStringNames<
int>(
int.Parse);
199 UJeli lastActivePersonaJeli = jeli[
"LastActivePersona"];
201 if (lastActivePersonaJeli != null)
202 LastActivePersonaID = lastActivePersonaJeli.Value;
205 public int GetTraitPoints (
string traitId)
208 TraitPoints.TryGetValue(traitId, out traitPoints);
215 public float HeartRateReserve
217 get {
return MaxHeartRate - RestingHeartRate; }
220 public float TargetHeartRate
222 get {
return Mathf.Ceil(RestingHeartRate + HeartRateReserve * TargetHeartRateRatio); }
225 public float VigorousHeartRate
227 get {
return Mathf.Ceil(RestingHeartRate + HeartRateReserve * VigorousHeartRateRatio); }
230 public float ExtremeHeartRate
232 get {
return Mathf.Ceil(RestingHeartRate + HeartRateReserve * ExtremeHeartRateRatio); }
235 public float RestingHeartRate = 70;
236 public float MaxHeartRate = 190;
237 public float TargetHeartRateRatio = .6f;
238 public float VigorousHeartRateRatio = .8f;
239 public float ExtremeHeartRateRatio = 1f;
240 public float EffortBalanceCadenceCap = 60;
241 public float GenericBalanceCadenceCap = 60;
242 public float MaxDailyTimePlayed =
float.PositiveInfinity;
243 public float MaxDailyTimePedaled =
float.PositiveInfinity;
244 public float MaxDailyTimeAboveTarget = 3600;
245 public float MaxDailyTimeAboveVigorous = 600;
246 public float VigorousWarningRaiseTime = 30;
247 public float VigorousWarningDropTime = 30;
248 public float WarmupDuration = 180;
249 public float CooldownDuration = 180;
250 public bool NoRestrictions =
false;
254 try { RestingHeartRate = jeli[
"RestingHeartRate"].FloatValue; }
catch { }
255 try { MaxHeartRate = jeli[
"MaxHeartRate"].FloatValue; }
catch { }
256 try { TargetHeartRateRatio = jeli[
"TargetHeartRateRatio"].FloatValue; }
catch { }
257 try { VigorousHeartRateRatio = jeli[
"VigorousHeartRateRatio"].FloatValue; }
catch { }
258 try { ExtremeHeartRateRatio = jeli[
"ExtremeHeartRateRatio"].FloatValue; }
catch { }
259 try { EffortBalanceCadenceCap = jeli[
"EffortBalanceCadenceCap"].FloatValue; }
catch { }
260 try { GenericBalanceCadenceCap = jeli[
"GenericBalanceCadenceCap"].FloatValue; }
catch { }
261 try { MaxDailyTimePlayed = jeli[
"MaxDailyTimePlayed"].FloatValue; }
catch { }
262 try { MaxDailyTimePedaled = jeli[
"MaxDailyTimePedaled"].FloatValue; }
catch { }
263 try { MaxDailyTimeAboveTarget = jeli[
"MaxDailyTimeAboveTarget"].FloatValue; }
catch { }
264 try { MaxDailyTimeAboveVigorous = jeli[
"MaxDailyTimeAboveVigorous"].FloatValue; }
catch { }
265 try { VigorousWarningRaiseTime = jeli[
"VigorousWarningRaiseTime"].FloatValue; }
catch { }
266 try { VigorousWarningDropTime = jeli[
"VigorousWarningDropTime"].FloatValue; }
catch { }
267 try { WarmupDuration = jeli[
"WarmupDuration"].FloatValue; }
catch { }
268 try { CooldownDuration = jeli[
"CooldownDuration"].FloatValue; }
catch { }
269 try { NoRestrictions = jeli[
"NoRestrictions"].BoolValue; }
catch { }
272 public HeartTier GetHeartTier (
float heartRate)
274 if (heartRate >= ExtremeHeartRate)
275 return HeartTier.Extreme;
276 else if (heartRate >= VigorousHeartRate)
277 return HeartTier.Vigorous;
278 else if (heartRate >= TargetHeartRate)
279 return HeartTier.Target;
280 else return HeartTier.Normal;
283 public float CadenceCap
289 if (balanceAlgorithm == BalanceCondition.GenericBalance)
290 return Mathf.Max(1, GenericBalanceCadenceCap);
291 else if (balanceAlgorithm == BalanceCondition.EffortBalance)
292 return Mathf.Max(1, EffortBalanceCadenceCap);
301 public DateTime LastTimePlayed = DateTime.Parse(
"2001/01/01");
302 public float TimePlayed = 0f;
303 public float TimePedaled = 0f;
304 public float TimeAboveTarget = 0f;
305 public float TimeAboveVigorous = 0f;
309 try { LastTimePlayed = jeli[
"LastTimePlayed"].TimeValue; }
catch { }
310 try { TimePlayed = jeli[
"TimePlayed"].FloatValue; }
catch { }
311 try { TimePedaled = jeli[
"TimePedaled"].FloatValue; }
catch { }
312 try { TimeAboveTarget = jeli[
"TimeAboveTarget"].FloatValue; }
catch { }
313 try { TimeAboveVigorous = jeli[
"TimeAboveVigorous"].FloatValue; }
catch { }
316 public void Reset (DateTime now)
318 LastTimePlayed = now;
321 TimeAboveTarget = 0f;
322 TimeAboveVigorous = 0f;
327 if (healthProfile.NoRestrictions)
330 return TimePedaled >= healthProfile.MaxDailyTimePedaled ||
331 TimeAboveTarget >= healthProfile.MaxDailyTimeAboveTarget ||
332 TimeAboveVigorous >= healthProfile.MaxDailyTimeAboveVigorous;
ClientConfig Config
Gets the configuration for this client.
static GameClient Instance
Gets the sole instance of the game client.
Stores data related to the player profile. Loads from a World Data file and provides runtime operatio...
A visual representation of the player's libi count. PlayerProfile uses the Text property to update th...
A class for serializing game data into a stream for propagation between objects and peers...
Unity version of Jeli markup class.