private void CreateDefaultRoles(DataModels.Clan clan) { gameData.Add(new DataModels.ClanRole { ClanId = clan.Id, Id = Guid.NewGuid(), Level = 3, Name = "Officer", Cape = 0, }); gameData.Add(new DataModels.ClanRole { ClanId = clan.Id, Id = Guid.NewGuid(), Level = 2, Name = "Member", Cape = 0, }); gameData.Add(new DataModels.ClanRole { ClanId = clan.Id, Id = Guid.NewGuid(), Level = 1, Name = "Recruit", Cape = 0, }); gameData.Add(new DataModels.ClanRole { ClanId = clan.Id, Id = Guid.NewGuid(), Level = 0, Name = "Inactive", Cape = 0, }); }
public Clan CreateClan(Guid ownerUserId, string name, string logoImageFile) { if (string.IsNullOrWhiteSpace(name)) { return(null); } name = name.Trim(); // already have a clan var clan = gameData.GetClanByUser(ownerUserId); if (clan != null) { return(null); } // no such user var user = gameData.GetUser(ownerUserId); if (user == null) { return(null); } var clans = gameData.GetClans(); if (clans.FirstOrDefault(x => x.Name?.Trim().Equals(name.Trim(), StringComparison.OrdinalIgnoreCase) ?? false) != null) { return(null); } clan = new DataModels.Clan() { Id = Guid.NewGuid(), CanChangeName = true, Logo = logoImageFile, Level = 1, Name = name, UserId = ownerUserId, Created = DateTime.UtcNow }; gameData.Add(clan); CreateDefaultRoles(clan); return(ModelMapper.Map(gameData, clan)); }
public static Models.Clan Map(IGameData gameData, DataModels.Clan data) { if (data == null) { return(null); } var user = gameData.GetUser(data.UserId); return(new Models.Clan() { Id = data.Id, Logo = data.Logo, Name = data.Name, Owner = user.UserId }); }
public static Models.Clan Map(IGameData gameData, DataModels.Clan data) { if (data == null) { return(null); } var user = gameData.GetUser(data.UserId); if (user == null) { return(null); } var s = gameData.GetClanSkills(data.Id); var skills = new Models.ClanSkill[s.Count]; for (var i = 0; i < s.Count; ++i) { var s0 = s[i]; var s1 = gameData.GetSkill(s0.SkillId); skills[i] = new Models.ClanSkill { Id = s0.Id, Experience = s0.Experience, Level = s0.Level, MaxLevel = s1.MaxLevel, Name = s1.Name }; } return(new Models.Clan() { Id = data.Id, Logo = data.Logo, Name = data.Name, Owner = user.UserId, Experience = data.Experience, Level = data.Level, ClanSkills = skills }); }