forked from SoDOff-Project/sodoff
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:
parent
1600938902
commit
838f15fed8
@ -83,12 +83,15 @@ public class ProfileController : Controller {
|
|||||||
private UserProfileData GetProfileDataFromViking(Viking viking, [FromForm] string apiKey) {
|
private UserProfileData GetProfileDataFromViking(Viking viking, [FromForm] string apiKey) {
|
||||||
// Get the avatar data
|
// Get the avatar data
|
||||||
AvatarData avatarData = null;
|
AvatarData avatarData = null;
|
||||||
Gender gender = Gender.Male;
|
Gender? gender = null;
|
||||||
if (viking.AvatarSerialized is not null) {
|
if (viking.AvatarSerialized is not null) {
|
||||||
avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
||||||
avatarData.Id = viking.Id;
|
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 != 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) {
|
if (avatarData.Part.FirstOrDefault(e => e.PartType == "Sword") is null) {
|
||||||
@ -118,9 +121,10 @@ public class ProfileController : Controller {
|
|||||||
GenderID = gender,
|
GenderID = gender,
|
||||||
OpenChatEnabled = true,
|
OpenChatEnabled = true,
|
||||||
IsApproved = true,
|
IsApproved = true,
|
||||||
RegistrationDate = new DateTime(DateTime.Now.Ticks), // placeholder
|
RegistrationDate = viking.CreationDate,
|
||||||
CreationDate = new DateTime(DateTime.Now.Ticks), // placeholder
|
CreationDate = viking.CreationDate,
|
||||||
FacebookUserID = 0
|
FacebookUserID = 0,
|
||||||
|
BirthDate = viking.BirthDate
|
||||||
},
|
},
|
||||||
UserSubscriptionInfo = new UserSubscriptionInfo {
|
UserSubscriptionInfo = new UserSubscriptionInfo {
|
||||||
UserID = viking.UserId.ToString(),
|
UserID = viking.UserId.ToString(),
|
||||||
|
@ -71,7 +71,7 @@ public class RegistrationController : Controller {
|
|||||||
}
|
}
|
||||||
if (ctx.Users.Count(e => e.Username== u.Username) > 0) {
|
if (ctx.Users.Count(e => e.Username== u.Username) > 0) {
|
||||||
return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateUserName });
|
return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateUserName });
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Users.Add(u);
|
ctx.Users.Add(u);
|
||||||
|
|
||||||
@ -82,7 +82,9 @@ public class RegistrationController : Controller {
|
|||||||
User = u,
|
User = u,
|
||||||
InventoryItems = new List<InventoryItem>(),
|
InventoryItems = new List<InventoryItem>(),
|
||||||
AchievementPoints = new List<AchievementPoints>(),
|
AchievementPoints = new List<AchievementPoints>(),
|
||||||
Rooms = new List<Room>()
|
Rooms = new List<Room>(),
|
||||||
|
CreationDate = DateTime.UtcNow,
|
||||||
|
BirthDate = data.ChildList[0].BirthDate
|
||||||
};
|
};
|
||||||
ctx.Vikings.Add(v);
|
ctx.Vikings.Add(v);
|
||||||
}
|
}
|
||||||
@ -142,12 +144,17 @@ public class RegistrationController : Controller {
|
|||||||
User = user,
|
User = user,
|
||||||
InventoryItems = items,
|
InventoryItems = items,
|
||||||
AchievementPoints = new List<AchievementPoints>(),
|
AchievementPoints = new List<AchievementPoints>(),
|
||||||
Rooms = new List<Room>()
|
Rooms = new List<Room>(),
|
||||||
|
CreationDate = DateTime.Now,
|
||||||
|
BirthDate = data.BirthDate
|
||||||
};
|
};
|
||||||
|
|
||||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
||||||
missionService.SetUpMissions(v, gameVersion);
|
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.Vikings.Add(v);
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using sodoff.Schema;
|
||||||
|
|
||||||
namespace sodoff.Model;
|
namespace sodoff.Model;
|
||||||
|
|
||||||
@ -37,4 +38,8 @@ public class Viking {
|
|||||||
public virtual ICollection<SavedData> SavedData { get; set; } = null!;
|
public virtual ICollection<SavedData> SavedData { get; set; } = null!;
|
||||||
public virtual ICollection<Party> Parties { get; set; } = null!;
|
public virtual ICollection<Party> Parties { get; set; } = null!;
|
||||||
public virtual Dragon? SelectedDragon { get; set; }
|
public virtual Dragon? SelectedDragon { get; set; }
|
||||||
|
|
||||||
|
public DateTime? CreationDate { get; set; }
|
||||||
|
public DateTime? BirthDate { get; set; }
|
||||||
|
public Gender? Gender { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user