private CharacterSkillDTO Insert(CharacterSkillDTO characterSkill, OpenNosContext context) { CharacterSkill entity = _mapper.Map <CharacterSkill>(characterSkill); context.CharacterSkill.Add(entity); context.SaveChanges(); return(_mapper.Map <CharacterSkillDTO>(entity)); }
public CharacterSkill(CharacterSkillDTO characterSkill) { CharacterId = characterSkill.CharacterId; Id = characterSkill.Id; SkillVNum = characterSkill.SkillVNum; LastUse = DateTime.Now.AddHours(-1); Hit = 0; }
public CharacterSkill(CharacterSkillDTO dto) { CharacterId = dto.CharacterId; Id = dto.Id; SkillVNum = dto.SkillVNum; LastUse = DateTime.Now.AddHours(-1); Hit = 0; }
public CharacterSkill(CharacterSkillDTO input) : this() { CharacterId = input.CharacterId; Id = input.Id; SkillVNum = input.SkillVNum; IsTattoo = input.IsTattoo; TattooUpgrade = input.TattooUpgrade; IsPartnerSkill = input.IsPartnerSkill; }
public CharacterSkill(CharacterSkillDTO dto) { this.CharacterId = dto.CharacterId; this.CharacterSkillId = dto.CharacterSkillId; this.SkillVNum = dto.SkillVNum; this.NpcMonsterVNum = dto.NpcMonsterVNum; LastUse = DateTime.Now.AddHours(-1); Used = false; Hit = 0; }
private CharacterSkillDTO Update(CharacterSkill entity, CharacterSkillDTO characterSkill, OpenNosContext context) { if (entity != null) { _mapper.Map(characterSkill, entity); context.SaveChanges(); } return(_mapper.Map <CharacterSkillDTO>(characterSkill)); }
public static bool ToCharacterSkillDTO(CharacterSkill input, CharacterSkillDTO output) { if (input == null) { return(false); } output.CharacterId = input.CharacterId; output.Id = input.Id; output.SkillVNum = input.SkillVNum; return(true); }
public bool ToCharacterSkill(CharacterSkillDTO input, CharacterSkill output) { if (input == null) { output = null; return(false); } output.CharacterId = input.CharacterId; output.Id = input.Id; output.SkillVNum = input.SkillVNum; return(true); }
public CharacterSkillDTO LoadById(Guid id) { using (OpenNosContext context = DataAccessHelper.CreateContext()) { CharacterSkillDTO characterSkillDTO = new CharacterSkillDTO(); if (Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkillDTO(context.CharacterSkill.FirstOrDefault(i => i.Id.Equals(id)), characterSkillDTO)) { return(characterSkillDTO); } return(null); } }
protected CharacterSkillDTO InsertOrUpdate(OpenNosContext context, CharacterSkillDTO dto) { Guid primaryKey = dto.Id; CharacterSkill entity = context.Set <CharacterSkill>().FirstOrDefault(c => c.Id == primaryKey); if (entity == null) { return(Insert(dto, context)); } else { return(Update(entity, dto, context)); } }
public IEnumerable <CharacterSkillDTO> LoadByCharacterId(long characterId) { using (OpenNosContext context = DataAccessHelper.CreateContext()) { List <CharacterSkillDTO> result = new List <CharacterSkillDTO>(); foreach (CharacterSkill entity in context.CharacterSkill.Where(i => i.CharacterId == characterId)) { CharacterSkillDTO output = new CharacterSkillDTO(); Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkillDTO(entity, output); result.Add(output); } return(result); } }
protected CharacterSkillDTO Update(CharacterSkill entity, CharacterSkillDTO inventory, OpenNosContext context) { if (entity != null) { Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkill(inventory, entity); context.SaveChanges(); } if (Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkillDTO(entity, inventory)) { return(inventory); } return(null); }
protected CharacterSkillDTO Insert(CharacterSkillDTO dto, OpenNosContext context) { CharacterSkill entity = new CharacterSkill(); Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkill(dto, entity); context.Set <CharacterSkill>().Add(entity); context.SaveChanges(); if (Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkillDTO(entity, dto)) { return(dto); } return(null); }
public CharacterSkillDTO InsertOrUpdate(CharacterSkillDTO dto) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { return(InsertOrUpdate(context, dto)); } } catch (Exception e) { Logger.Error($"Message: {e.Message}", e); return(null); } }
public SaveResult InsertOrUpdate(ref CharacterSkillDTO characterSkill) { try { using (var context = DataAccessHelper.CreateContext()) { return(InsertOrUpdate(ref characterSkill, context)); } } catch (Exception e) { Logger.Log.Error(String.Format(Language.Instance.GetMessageFromKey("UPDATE_ERROR"), e.Message), e); return(SaveResult.Error); } }
public static bool ToCharacterSkill(CharacterSkillDTO input, CharacterSkill output) { if (input == null) { return(false); } output.CharacterId = input.CharacterId; output.Id = input.Id; output.SkillVNum = input.SkillVNum; output.IsTattoo = input.IsTattoo; output.TattooUpgrade = input.TattooUpgrade; output.IsPartnerSkill = input.IsPartnerSkill; return(true); }
private SaveResult InsertOrUpdate(ref CharacterSkillDTO characterSkill, OpenNosContext context) { long characterSkillId = characterSkill.CharacterSkillId; CharacterSkill entity = context.CharacterSkill.FirstOrDefault(i => i.CharacterSkillId == characterSkillId); if (entity == null) //new entity { characterSkill = Insert(characterSkill, context); return(SaveResult.Inserted); } else //existing entity { characterSkill = Update(entity, characterSkill, context); return(SaveResult.Updated); } }
public async Task <ServiceResponse <CharacterDTO> > AddCharacterSkill(CharacterSkillDTO characterSkillDTO) { ServiceResponse <CharacterDTO> ServiceResponse = new ServiceResponse <CharacterDTO>(); try { CharacterSkill characterSkill = await _dataContext.CharacterSkills.FirstOrDefaultAsync(x => x.CharacterId == characterSkillDTO.characterId && x.SkillId == characterSkillDTO.skillId); if (characterSkill != null) { ServiceResponse.Success = false; ServiceResponse.Message = "Character alread has skill."; return(ServiceResponse); } CharacterSkill characterSkillEntity = _iMapper.Map <CharacterSkill>(characterSkillDTO); await _dataContext.CharacterSkills.AddAsync(characterSkillEntity); await _dataContext.SaveChangesAsync(); Character character = await _dataContext.Characters .Include(x => x.weapon) .Include(x => x.User) .Include(x => x.skills) .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == characterSkillDTO.characterId && x.User.Id == GetUserId()); CharacterDTO characterDTO = _iMapper.Map <CharacterDTO>(character); ServiceResponse.Data = characterDTO; } catch (Exception ex) { ServiceResponse.Success = false; ServiceResponse.Message = ex.Message; } return(ServiceResponse); }
public IEnumerable <CharacterSkillDTO> InsertOrUpdate(IEnumerable <CharacterSkillDTO> characterSkills) { try { List <CharacterSkillDTO> returnSkills = new List <CharacterSkillDTO>(); using (var context = DataAccessHelper.CreateContext()) { foreach (CharacterSkillDTO skill in characterSkills) { CharacterSkillDTO returnSkill = skill; SaveResult result = InsertOrUpdate(ref returnSkill, context); returnSkills.Add(returnSkill); } } return(returnSkills); } catch (Exception e) { Logger.Log.Error(String.Format(Language.Instance.GetMessageFromKey("UPDATE_ERROR"), e.Message), e); return(Enumerable.Empty <CharacterSkillDTO>()); } }
public async Task <IActionResult> AddCharacterSkill(CharacterSkillDTO characterSkillDTO) { return(Ok(await _iCharacterSkillService.AddCharacterSkill(characterSkillDTO))); }
public void CreateCharacter(string packet) { Logger.Debug(packet, Session.SessionId); if (Session.HasCurrentMap) { return; } // TODO: Hold Account Information in Authorized object long accountId = Session.Account.AccountId; string[] packetsplit = packet.Split(' '); byte slot = Convert.ToByte(packetsplit[3]); string characterName = packetsplit[2]; Random random = new Random(); if (slot <= 2 && DAOFactory.CharacterDAO.LoadBySlot(accountId, slot) == null) { if (characterName.Length > 3 && characterName.Length < 15) { System.Text.RegularExpressions.Regex rg = new System.Text.RegularExpressions.Regex(@"^[\u0021-\u007E\u00A1-\u00AC\u00AE-\u00FF\u4E00-\u9FA5\u0E01-\u0E3A\u0E3F-\u0E5B]*$"); int isIllegalCharacter = rg.Matches(characterName).Count; if (isIllegalCharacter == 1) { if (DAOFactory.CharacterDAO.LoadByName(characterName) == null) { if (Convert.ToByte(packetsplit[3]) > 2) { return; } CharacterDTO newCharacter = new CharacterDTO() { Class = (byte)ClassType.Adventurer, Gender = (GenderType)Enum.Parse(typeof(GenderType), packetsplit[4]), HairColor = (HairColorType)Enum.Parse(typeof(HairColorType), packetsplit[6]), HairStyle = (HairStyleType)Enum.Parse(typeof(HairStyleType), packetsplit[5]), Hp = 221, JobLevel = 1, Level = 1, MapId = 1, MapX = (short)ServerManager.RandomNumber(78, 81), MapY = (short)ServerManager.RandomNumber(114, 118), Mp = 221, SpPoint = 10000, SpAdditionPoint = 0, Name = characterName, Slot = slot, AccountId = accountId, State = CharacterState.Active, }; SaveResult insertResult = DAOFactory.CharacterDAO.InsertOrUpdate(ref newCharacter); CharacterSkillDTO sk1 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 200 }; CharacterSkillDTO sk2 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 201 }; CharacterSkillDTO sk3 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 209 }; QuicklistEntryDTO qlst1 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Type = 1, Slot = 1, Pos = 1 }; QuicklistEntryDTO qlst2 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 1, Slot = 2, }; QuicklistEntryDTO qlst3 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 8, Type = 1, Slot = 1, Pos = 16 }; QuicklistEntryDTO qlst4 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 9, Type = 1, Slot = 3, Pos = 1 }; DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst1); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst2); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst3); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst4); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk1); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk2); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk3); IList <ItemInstanceDTO> startupInventory = new List <ItemInstanceDTO>(); ItemInstance inventory = new WearableInstance // first weapon { CharacterId = newCharacter.CharacterId, Slot = (byte)EquipmentType.MainWeapon, Type = InventoryType.Wear, Amount = 1, ItemVNum = 1, }; startupInventory.Add(inventory); inventory = new WearableInstance() // second weapon { CharacterId = newCharacter.CharacterId, Slot = (byte)EquipmentType.SecondaryWeapon, Type = InventoryType.Wear, Amount = 1, ItemVNum = 8 }; startupInventory.Add(inventory); inventory = new WearableInstance() // armor { CharacterId = newCharacter.CharacterId, Slot = (byte)EquipmentType.Armor, Type = InventoryType.Wear, Amount = 1, ItemVNum = 12 }; startupInventory.Add(inventory); inventory = new ItemInstance() // snack { CharacterId = newCharacter.CharacterId, Type = InventoryType.Etc, Amount = 10, ItemVNum = 2024 }; startupInventory.Add(inventory); inventory = new ItemInstance() // ammo { CharacterId = newCharacter.CharacterId, Slot = 1, Type = InventoryType.Etc, Amount = 1, ItemVNum = 2081 }; startupInventory.Add(inventory); DAOFactory.IteminstanceDao.InsertOrUpdate(startupInventory); LoadCharacters(packet); } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("ALREADY_TAKEN")}"); } } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("INVALID_CHARNAME")}"); } } } }
public void CreateCharacter(string packet) { Logger.Debug(packet, Session.SessionId); if (Session.CurrentMap != null) { return; } // TODO: Hold Account Information in Authorized object long accountId = Session.Account.AccountId; string[] packetsplit = packet.Split(' '); byte slot = Convert.ToByte(packetsplit[3]); string characterName = packetsplit[2]; Random random = new Random(); if (slot <= 2 && DAOFactory.CharacterDAO.LoadBySlot(accountId, slot) == null) { if (characterName.Length > 3 && characterName.Length < 15) { bool isIllegalCharacter = false; System.Text.RegularExpressions.Regex rg = new System.Text.RegularExpressions.Regex(@"^[\u4E00-\u9FA5a-zA-Z0-9ąáàâäãåçćéèêëęíìîïłńñóòôöõúùûüśźżýÿæœĄÁÀÂÄÃÅĆÇĘÉÈÊËÍÌÎÏŁŃÑÓÒÔÖÕÚÙÛÜŚŹŻÝŸÆŒ.¤*-|#²§µß™€=$^<>£!()&~{}@]*$`~"); isIllegalCharacter = rg.IsMatch(characterName); if (!isIllegalCharacter) { if (DAOFactory.CharacterDAO.LoadByName(characterName) == null) { if (Convert.ToByte(packetsplit[3]) > 2) { return; } CharacterDTO newCharacter = new CharacterDTO() { Class = (byte)ClassType.Adventurer, Gender = (Convert.ToByte(packetsplit[4]) >= 0 && Convert.ToByte(packetsplit[4]) <= 1 ? Convert.ToByte(packetsplit[4]) : Convert.ToByte(0)), Gold = 0, HairColor = Enum.IsDefined(typeof(HairColorType), Convert.ToByte(packetsplit[6])) ? Convert.ToByte(packetsplit[6]) : Convert.ToByte(0), HairStyle = Enum.IsDefined(typeof(HairStyleType), Convert.ToByte(packetsplit[5])) ? Convert.ToByte(packetsplit[5]) : Convert.ToByte(0), Hp = 221, JobLevel = 1, JobLevelXp = 0, Level = 1, LevelXp = 0, MapId = 1, FamilyId = -1, FamilyInfo = "-", FamilyLevel = 1, FamilyName = "-", FamilyPosition = "-", MapX = (short)(random.Next(78, 81)), MapY = (short)(random.Next(114, 118)), Mp = 221, Name = characterName, Slot = slot, AccountId = accountId, StateEnum = CharacterState.Active, WhisperBlocked = false, FamilyRequestBlocked = false, ExchangeBlocked = false, BuffBlocked = false, EmoticonsBlocked = false, FriendRequestBlocked = false, GroupRequestBlocked = false, MinilandInviteBlocked = false, HeroChatBlocked = false, QuickGetUp = false, MouseAimLock = false, HpBlocked = false, }; SaveResult insertResult = DAOFactory.CharacterDAO.InsertOrUpdate(ref newCharacter); CharacterSkillDTO sk1 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 200 }; CharacterSkillDTO sk2 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 201 }; CharacterSkillDTO sk3 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 209 }; QuicklistEntryDTO qlst1 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q1 = 0, Q2 = 0, Type = 1, Slot = 1, Pos = 1 }; QuicklistEntryDTO qlst2 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q1 = 0, Q2 = 1, Type = 0, Slot = 2, Pos = 0 }; QuicklistEntryDTO qlst3 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q1 = 0, Q2 = 8, Type = 1, Slot = 1, Pos = 16 }; QuicklistEntryDTO qlst4 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q1 = 0, Q2 = 9, Type = 1, Slot = 3, Pos = 1 }; qlst1 = DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst1); qlst2 = DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst2); qlst3 = DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst3); qlst4 = DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst4); sk1 = DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk1); sk2 = DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk2); sk3 = DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk3); IList <InventoryDTO> startupInventory = new List <InventoryDTO>(); InventoryDTO inventory = new InventoryDTO() // first weapon { CharacterId = newCharacter.CharacterId, Slot = (short)EquipmentType.MainWeapon, Type = InventoryType.Equipment }; inventory.ItemInstance = new WearableInstance() { Amount = 1, ItemVNum = 1, Id = inventory.Id }; startupInventory.Add(inventory); inventory = new InventoryDTO() // second weapon { CharacterId = newCharacter.CharacterId, Slot = (short)EquipmentType.SecondaryWeapon, Type = InventoryType.Equipment }; inventory.ItemInstance = new WearableInstance() { Amount = 1, ItemVNum = 8, Id = inventory.Id }; startupInventory.Add(inventory); inventory = new InventoryDTO() // armor { CharacterId = newCharacter.CharacterId, Slot = (short)EquipmentType.Armor, Type = InventoryType.Equipment }; inventory.ItemInstance = new WearableInstance() { Amount = 1, ItemVNum = 12, Id = inventory.Id }; startupInventory.Add(inventory); inventory = new InventoryDTO() // snack { CharacterId = newCharacter.CharacterId, Slot = 0, Type = InventoryType.Etc }; inventory.ItemInstance = new ItemInstance() { Amount = 10, ItemVNum = 2024, Id = inventory.Id }; startupInventory.Add(inventory); inventory = new InventoryDTO() // ammo { CharacterId = newCharacter.CharacterId, Slot = 1, Type = InventoryType.Etc }; inventory.ItemInstance = new ItemInstance() { Amount = 1, ItemVNum = 2081, Id = inventory.Id }; startupInventory.Add(inventory); DAOFactory.InventoryDAO.InsertOrUpdate(startupInventory); LoadCharacters(packet); } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("ALREADY_TAKEN")}"); } } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("INVALID_CHARNAME")}"); } } } }
public void CreateCharacter(string packet) { Logger.Debug(Session.GenerateIdentity(), packet); if (Session.HasCurrentMapInstance) { return; } // TODO: Hold Account Information in Authorized object long accountId = Session.Account.AccountId; string[] packetsplit = packet.Split(' '); if (packetsplit.Length != 7) { return; } byte slot; string characterName = packetsplit[2]; if (byte.TryParse(packetsplit[3], out slot) && slot <= 2 && DAOFactory.CharacterDAO.LoadBySlot(accountId, slot) == null) { if (characterName.Length > 3 && characterName.Length < 15) { Regex rg = new Regex(@"^[\u0021-\u007E\u00A1-\u00AC\u00AE-\u00FF\u4E00-\u9FA5\u0E01-\u0E3A\u0E3F-\u0E5B\u002E]*$"); int isIllegalCharacter = rg.Matches(characterName).Count; if (isIllegalCharacter == 1) { if (DAOFactory.CharacterDAO.LoadByName(characterName) == null) { if (Convert.ToByte(packetsplit[3]) > 2) { return; } CharacterDTO newCharacter = new CharacterDTO { Class = (byte)ClassType.Adventurer, Gender = (GenderType)Enum.Parse(typeof(GenderType), packetsplit[4]), HairColor = (HairColorType)Enum.Parse(typeof(HairColorType), packetsplit[6]), HairStyle = (HairStyleType)Enum.Parse(typeof(HairStyleType), packetsplit[5]), Hp = 221, JobLevel = 1, Level = 1, MapId = 1, MapX = (short)ServerManager.Instance.RandomNumber(78, 81), MapY = (short)ServerManager.Instance.RandomNumber(114, 118), Mp = 221, MaxMateCount = 10, SpPoint = 10000, SpAdditionPoint = 0, Name = characterName, Slot = slot, AccountId = accountId, MinilandMessage = "Welcome", State = CharacterState.Active }; SaveResult insertResult = DAOFactory.CharacterDAO.InsertOrUpdate(ref newCharacter); CharacterSkillDTO sk1 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 200 }; CharacterSkillDTO sk2 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 201 }; CharacterSkillDTO sk3 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 209 }; QuicklistEntryDTO qlst1 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Type = 1, Slot = 1, Pos = 1 }; QuicklistEntryDTO qlst2 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 1, Slot = 2 }; QuicklistEntryDTO qlst3 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 8, Type = 1, Slot = 1, Pos = 16 }; QuicklistEntryDTO qlst4 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 9, Type = 1, Slot = 3, Pos = 1 }; DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst1); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst2); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst3); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst4); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk1); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk2); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk3); Inventory startupInventory = new Inventory((Character)newCharacter); startupInventory.AddNewToInventory(1, 1, InventoryType.Wear); startupInventory.AddNewToInventory(8, 1, InventoryType.Wear); startupInventory.AddNewToInventory(12, 1, InventoryType.Wear); startupInventory.AddNewToInventory(2024, 10, InventoryType.Etc); startupInventory.AddNewToInventory(2081, 1, InventoryType.Etc); startupInventory.GetAllItems().ForEach(i => DAOFactory.IteminstanceDAO.InsertOrUpdate(i)); LoadCharacters(packet); } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("ALREADY_TAKEN")}"); } } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("INVALID_CHARNAME")}"); } } } }
/// <summary> /// Char_NEW character creation character /// </summary> /// <param name="characterCreatePacket"></param> public void CreateCharacter(CharacterCreatePacket characterCreatePacket) { if (Session.HasCurrentMapInstance) { return; } // TODO: Hold Account Information in Authorized object long accountId = Session.Account.AccountId; byte slot = characterCreatePacket.Slot; string characterName = characterCreatePacket.Name; if (slot > 2 || DaoFactory.CharacterDao.LoadBySlot(accountId, slot) != null) { return; } if (characterName.Length <= 3 || characterName.Length >= 15) { return; } Regex rg = new Regex(@"^[\u0021-\u007E\u00A1-\u00AC\u00AE-\u00FF\u4E00-\u9FA5\u0E01-\u0E3A\u0E3F-\u0E5B\u002E]*$"); if (rg.Matches(characterName).Count == 1) { CharacterDTO character = DaoFactory.CharacterDao.LoadByName(characterName); if (character == null || character.State == CharacterState.Inactive) { if (characterCreatePacket.Slot > 2) { return; } CharacterDTO newCharacter = new CharacterDTO { Class = (byte)ClassType.Adventurer, Gender = characterCreatePacket.Gender, HairColor = characterCreatePacket.HairColor, HairStyle = characterCreatePacket.HairStyle, Hp = 221, JobLevel = 20, Level = 15, MapId = 1, MapX = (short)ServerManager.Instance.RandomNumber(78, 81), MapY = (short)ServerManager.Instance.RandomNumber(109, 112), Mp = 221, MaxMateCount = 10, Gold = 15000, SpPoint = 10000, SpAdditionPoint = 0, Name = characterName, Slot = slot, AccountId = accountId, MinilandMessage = "Welcome", State = CharacterState.Active }; SaveResult insertResult = DaoFactory.CharacterDao.InsertOrUpdate(ref newCharacter); CharacterQuestDTO firstQuest = new CharacterQuestDTO { CharacterId = newCharacter.CharacterId, QuestId = 1997, IsMainQuest = true }; CharacterSkillDTO sk1 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 200 }; CharacterSkillDTO sk2 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 201 }; CharacterSkillDTO sk3 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 209 }; QuicklistEntryDTO qlst1 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Type = 1, Slot = 1, Pos = 1 }; QuicklistEntryDTO qlst2 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 1, Slot = 2 }; QuicklistEntryDTO qlst3 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 8, Type = 1, Slot = 1, Pos = 16 }; QuicklistEntryDTO qlst4 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 9, Type = 1, Slot = 3, Pos = 1 }; DaoFactory.CharacterQuestDao.InsertOrUpdate(firstQuest); DaoFactory.QuicklistEntryDao.InsertOrUpdate(qlst1); DaoFactory.QuicklistEntryDao.InsertOrUpdate(qlst2); DaoFactory.QuicklistEntryDao.InsertOrUpdate(qlst3); DaoFactory.QuicklistEntryDao.InsertOrUpdate(qlst4); DaoFactory.CharacterSkillDao.InsertOrUpdate(sk1); DaoFactory.CharacterSkillDao.InsertOrUpdate(sk2); DaoFactory.CharacterSkillDao.InsertOrUpdate(sk3); Inventory startupInventory = new Inventory((Character)newCharacter); startupInventory.AddNewToInventory(2024, 10, InventoryType.Etc); startupInventory.AddNewToInventory(2081, 1, InventoryType.Etc); startupInventory.AddNewToInventory(1907, 1, InventoryType.Main); startupInventory.Select(s => s.Value).ToList().ForEach(i => DaoFactory.IteminstanceDao.InsertOrUpdate(i)); LoadCharacters(characterCreatePacket.OriginalContent); } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("ALREADY_TAKEN")}"); } } else { Session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("INVALID_CHARNAME")}"); } }
private void ExecuteHandler(ClientSession session, string packet) { if (session.HasCurrentMapInstance) { return; } long accountId = session.Account.AccountId; if (Slot <= 2 && DAOFactory.CharacterDAO.LoadBySlot(accountId, Slot) == null && Name.Length > 3 && Name.Length < 15) { Regex rg = new Regex(@"^[A-Za-z0-9_äÄöÖüÜß~*<>°+-.!_-Й¤£±†‡×ßø^\S]+$"); if (rg.Matches(Name).Count == 1) { if (DAOFactory.CharacterDAO.LoadByName(Name) == null) { GameLogger.Instance.LogCharacterCreation(ServerManager.Instance.ChannelId, session.Account.Name, session.Account.AccountId, Name, Slot, Gender, HairStyle, HairColor); CharacterDTO newCharacter = new CharacterDTO { Class = (byte)ClassType.Adventurer, Gender = Gender, HairColor = HairColor, HairStyle = HairStyle, Hp = 221, JobLevel = 1, Level = 1, MapId = 1, MapX = (short)ServerManager.RandomNumber(78, 81), MapY = (short)ServerManager.RandomNumber(114, 118), Mp = 221, MaxMateCount = 10, SpPoint = 10000, SpAdditionPoint = 0, Name = Name, Slot = Slot, AccountId = accountId, MaxPartnerCount = 3, MinilandMessage = "Welcome on Xarion", State = CharacterState.Active, MinilandPoint = 2000 }; DAOFactory.CharacterDAO.InsertOrUpdate(ref newCharacter); CharacterSkillDTO sk1 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 200 }; CharacterSkillDTO sk2 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 201 }; CharacterSkillDTO sk3 = new CharacterSkillDTO { CharacterId = newCharacter.CharacterId, SkillVNum = 209 }; QuicklistEntryDTO qlst1 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Type = 1, Slot = 1, Pos = 1 }; QuicklistEntryDTO qlst2 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 1, Slot = 2 }; QuicklistEntryDTO qlst3 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 8, Type = 1, Slot = 1, Pos = 16 }; QuicklistEntryDTO qlst4 = new QuicklistEntryDTO { CharacterId = newCharacter.CharacterId, Q2 = 9, Type = 1, Slot = 3, Pos = 1 }; DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst1); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst2); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst3); DAOFactory.QuicklistEntryDAO.InsertOrUpdate(qlst4); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk1); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk2); DAOFactory.CharacterSkillDAO.InsertOrUpdate(sk3); using (Inventory startupInventory = new Inventory(new Character(newCharacter))) { startupInventory.AddNewToInventory(901, 1, InventoryType.Equipment); startupInventory.AddNewToInventory(903, 1, InventoryType.Equipment); startupInventory.AddNewToInventory(905, 1, InventoryType.Equipment); startupInventory.AddNewToInventory(884, 1, InventoryType.Equipment); startupInventory.AddNewToInventory(885, 1, InventoryType.Equipment); startupInventory.AddNewToInventory(886, 1, InventoryType.Equipment); startupInventory.AddNewToInventory(887, 1, InventoryType.Equipment); startupInventory.AddNewToInventory(5228, 1, InventoryType.Main); startupInventory.AddNewToInventory(1, 1, InventoryType.Wear, 7, 8); startupInventory.AddNewToInventory(8, 1, InventoryType.Wear, 7, 8); startupInventory.AddNewToInventory(12, 1, InventoryType.Wear, 7, 8); startupInventory.AddNewToInventory(2081, 255, InventoryType.Etc); startupInventory.ForEach(i => DAOFactory.ItemInstanceDAO.InsertOrUpdate(i)); EntryPointPacket.HandlePacket(session, packet); } } else { session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("ALREADY_TAKEN")}"); } } else { session.SendPacketFormat($"info {Language.Instance.GetMessageFromKey("INVALID_CHARNAME")}"); } } }
public CharacterSkillDTO InsertOrUpdate(CharacterSkillDTO dto) { throw new NotImplementedException(); }
public CharacterSkill(CharacterSkillDTO input) : this() { CharacterId = input.CharacterId; Id = input.Id; SkillVNum = input.SkillVNum; }