add BirthDate, CreationDate and Gender

-Set Gender For Player
-Put CreationDate and BirthDate into Viking model
-Birthday Events Now Work
This commit is contained in:
Alan Moon 2023-12-13 16:10:25 -08:00 committed by Robert Paciorek
parent 1600938902
commit 838f15fed8
3 changed files with 24 additions and 8 deletions

View File

@ -83,12 +83,15 @@ public class ProfileController : Controller {
private UserProfileData GetProfileDataFromViking(Viking viking, [FromForm] string apiKey) {
// Get the avatar data
AvatarData avatarData = null;
Gender gender = Gender.Male;
Gender? gender = null;
if (viking.AvatarSerialized is not null) {
avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
avatarData.Id = viking.Id;
gender = avatarData.GenderType;
if (gender is null)
gender = avatarData.GenderType;
}
if (gender is null)
gender = Gender.Unknown;
if (avatarData != null && ClientVersion.GetVersion(apiKey) == 0xa3a12a0a) { // TODO adjust version number: we don't know for which versions it is required (for 3.12 it is, for 3.19 and 3.0 it's not)
if (avatarData.Part.FirstOrDefault(e => e.PartType == "Sword") is null) {
@ -118,9 +121,10 @@ public class ProfileController : Controller {
GenderID = gender,
OpenChatEnabled = true,
IsApproved = true,
RegistrationDate = new DateTime(DateTime.Now.Ticks), // placeholder
CreationDate = new DateTime(DateTime.Now.Ticks), // placeholder
FacebookUserID = 0
RegistrationDate = viking.CreationDate,
CreationDate = viking.CreationDate,
FacebookUserID = 0,
BirthDate = viking.BirthDate
},
UserSubscriptionInfo = new UserSubscriptionInfo {
UserID = viking.UserId.ToString(),

View File

@ -71,7 +71,7 @@ public class RegistrationController : Controller {
}
if (ctx.Users.Count(e => e.Username== u.Username) > 0) {
return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateUserName });
}
}
ctx.Users.Add(u);
@ -82,7 +82,9 @@ public class RegistrationController : Controller {
User = u,
InventoryItems = new List<InventoryItem>(),
AchievementPoints = new List<AchievementPoints>(),
Rooms = new List<Room>()
Rooms = new List<Room>(),
CreationDate = DateTime.UtcNow,
BirthDate = data.ChildList[0].BirthDate
};
ctx.Vikings.Add(v);
}
@ -142,12 +144,17 @@ public class RegistrationController : Controller {
User = user,
InventoryItems = items,
AchievementPoints = new List<AchievementPoints>(),
Rooms = new List<Room>()
Rooms = new List<Room>(),
CreationDate = DateTime.Now,
BirthDate = data.BirthDate
};
uint gameVersion = ClientVersion.GetVersion(apiKey);
missionService.SetUpMissions(v, gameVersion);
if (data.Gender == "Boy") v.Gender = Gender.Male;
else if (data.Gender == "Girl") v.Gender = Gender.Female;
ctx.Vikings.Add(v);
ctx.SaveChanges();

View File

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using sodoff.Schema;
namespace sodoff.Model;
@ -37,4 +38,8 @@ public class Viking {
public virtual ICollection<SavedData> SavedData { get; set; } = null!;
public virtual ICollection<Party> Parties { get; set; } = null!;
public virtual Dragon? SelectedDragon { get; set; }
public DateTime? CreationDate { get; set; }
public DateTime? BirthDate { get; set; }
public Gender? Gender { get; set; }
}