Ejemplo n.º 1
0
 public ClosetItem(ClosetItemRecord record)
 {
     Record = record;
 }
Ejemplo n.º 2
0
        public ErrorEnum CreateCharacter(SimpleClient client, CreateCharacterMessage message, int countCharacters)
        {
            if (countCharacters > 2)
            {
                return(ErrorEnum.ERR_NOCREATE);
            }
            if (!m_nameCheckerRegex.IsMatch(message.name))
            {
                return(ErrorEnum.ERR_NOCREATE);
            }

            if (IsCharacterNameExist(message.name))
            {
                return(ErrorEnum.ERR_PLAYER_EXIST);
            }

            BreedRecord breed = BreedManager.Instance.GetBreedByJobId(message.job);

            if (breed == null)
            {
                return(ErrorEnum.ERR_NOCREATE);
            }

            try
            {
                CharacterRecord record = new CharacterRecord()
                {
                    AccountId     = client.Account.Id,
                    Slot          = countCharacters,
                    Name          = message.name,
                    HD_MD5        = message.hd_md5,
                    SceneId       = breed.StartMap,
                    Sex           = message.sex == 1,
                    X             = breed.StartX,
                    Y             = breed.StartY,
                    Z             = breed.StartZ,
                    Level         = 1,
                    Experience    = 60,
                    Job           = breed.Job,
                    Money         = (uint)breed.StartMoney,
                    HP            = breed.StartHP,
                    DamageTaken   = 0,
                    Strenght      = breed.StartStrenght,
                    Stamina       = breed.StartStamina,
                    Dexterity     = breed.StartDexterity,
                    Intelligence  = breed.StartIntelligence,
                    SPI           = breed.StartSPI,
                    HairMesh      = message.hair_mesh,
                    HairColor     = (uint)message.hair_color,
                    HeadMesh      = message.head_mesh,
                    City_Code     = message.city_code,
                    Constellation = message.constellation,
                    Country       = message.country,
                    SN_Card       = message.sn_card,
                    Card_Type     = message.card_type,
                    HD_SN         = message.hd_sn,
                    Bin_Account   = message.bin_account,
                    BlockTime     = DateTime.MinValue,
                    DeletedDate   = null
                };
                Database.Insert(record);

                ClosetItemRecord[] closets = new ClosetItemRecord[5];
                for (int i = 0; i < message.closets.Count(); i++)
                {
                    closets[i] = new ClosetItemRecord
                    {
                        ClosetItemId = message.closets[i].id,
                        OwnerId      = record.Id,
                        Equipped     = true, Slot = i + 1
                    };
                }

                foreach (var closet in closets)
                {
                    Database.Insert(closet);
                }

                client.Character = new Character(record)
                {
                    Client = client
                };

                client.Account.LoadRecord();

                return(ErrorEnum.ERR_SUCCESS);
            }
            catch (Exception exception)
            {
                ConsoleUtils.WriteMessageDB(exception.Message);
                return(ErrorEnum.ERR_NOCREATE);
            }
        }