Rename folder from Shogi.Sockets to Shogi.Api

This commit is contained in:
2022-11-09 09:11:25 -06:00
parent 3257b420e9
commit a1f996e508
41 changed files with 6 additions and 6 deletions

42
Shogi.Api/Models/User.cs Normal file
View File

@@ -0,0 +1,42 @@
using System.Collections.ObjectModel;
namespace Shogi.Api.Models;
public class User
{
public static readonly ReadOnlyCollection<string> Adjectives = new(new[] {
"Fortuitous", "Retractable", "Happy", "Habbitable", "Creative", "Fluffy", "Impervious", "Kingly"
});
public static readonly ReadOnlyCollection<string> Subjects = new(new[] {
"Hippo", "Basil", "Mouse", "Walnut", "Prince", "Lima Bean", "Coala", "Potato", "Penguin"
});
public static User CreateMsalUser(string id) => new(id, id, WhichLoginPlatform.Microsoft);
public static User CreateGuestUser(string id)
{
var random = new Random();
// Adjective
var index = (int)Math.Floor(random.NextDouble() * Adjectives.Count);
var adj = Adjectives[index];
// Subject
index = (int)Math.Floor(random.NextDouble() * Subjects.Count);
var subj = Subjects[index];
return new User(id, $"{adj} {subj}", WhichLoginPlatform.Guest);
}
public string Id { get; }
public string DisplayName { get; }
public WhichLoginPlatform LoginPlatform { get; }
public bool IsGuest => LoginPlatform == WhichLoginPlatform.Guest;
public bool IsAdmin => LoginPlatform == WhichLoginPlatform.Microsoft && Id == "Hauth@live.com";
public User(string id, string displayName, WhichLoginPlatform platform)
{
Id = id;
DisplayName = displayName;
LoginPlatform = platform;
}
}