Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions Packages/com.trytalo.talo/Runtime/Entities/Player.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using UnityEngine;
using System.Linq;
using System;
using System.Threading.Tasks;

using System.Threading.Tasks;
namespace TaloGameServices
{
[Serializable]
Expand All @@ -19,8 +19,8 @@ public override string ToString()

public string GetProp(string key, string fallback = null)
{
Prop prop = props.First((prop) => prop.key == key);
return prop?.key ?? fallback;
Prop prop = props.FirstOrDefault((prop) => prop.key == key);
return prop?.value ?? fallback;
}

public async Task SetProp(string key, string value)
Expand All @@ -45,17 +45,22 @@ public async Task SetProp(string key, string value)

public async Task DeleteProp(string key)
{
Prop prop = props.First((prop) => prop.key == key);
Prop prop = props.FirstOrDefault((prop) => prop.key == key);
if (prop == null) throw new Exception($"Prop with key {key} does not exist");

prop.value = null;

await Talo.Players.Update();
}

public bool IsInGroup(string groupId)
{
return groups.Any((group) => group.id == groupId);
}

public bool IsInGroupID(string groupId)
{
return groups.Any((group) => group.id == groupId);
}

public bool IsInGroupName(string groupName)
{
return groups.Any((group) => group.name == groupName);
}
}
}