示例#1
0
        // Controlador
        public static void Controller(Client client, P_20F rcv)
        {
            if (!Regex.IsMatch(rcv.Name, @"^[A-Za-z0-9-]{4,12}$"))
            {
                client.Send(P_101.New("Somente letras e números no nome. 4 a 12 caracteres."));
            }
            else if (rcv.Slot < 0 || rcv.Slot > 3)
            {
                client.Close( );
            }
            else if (rcv.ClassInfo < 0 || rcv.ClassInfo > 3)
            {
                client.Close( );
            }
            else
            {
                // Retorna character da conta
                ref Character character = ref client.Account.Characters [rcv.Slot];

                // Verifica se não está vaziu
                if (character != null)
                {
                    client.Close( );
                }
                else
                {
                    // Inicializa novo character
                    character = new Character( );

                    // Referencia o MOB do character
                    ref SMob mob = ref character.Mob;

                    // Inicializa a classe selecionada no MOB
                    switch (rcv.ClassInfo)
                    {
                    case 1: mob = SMob.FM(rcv.Name); break;

                    case 2: mob = SMob.BM(rcv.Name); break;

                    case 3: mob = SMob.HT(rcv.Name); break;

                    default: mob = SMob.TK(rcv.Name); break;
                    }

                    // Atualiza os status do MOB
                    Functions.GetCurrentScore(character, true);

                    // Envia os pacotes de criação de personagem
                    client.Send(P_110.New(client));
                    client.Send(P_101.New($"Personagem [{rcv.Name}] criado! Bom jogo!"));
                }
示例#2
0
        public static Character CreateOrUpdateChar(Character character)
        {
            lock (m_Locker)
            {
                DeleteCharFile(character);
                SMob userMob = SMob.New();
                switch (character.Mob.ClassInfo)
                {
                case ClassInfo.TK:
                    userMob = SMob.TK(character.Mob.Name);
                    break;

                case ClassInfo.FM:
                    userMob = SMob.FM(character.Mob.Name);
                    break;

                case ClassInfo.BM:
                    userMob = SMob.BM(character.Mob.Name);
                    break;

                case ClassInfo.HT:
                    userMob = SMob.HT(character.Mob.Name);
                    break;
                }

                using (XmlWriter xw = XmlWriter.Create(GetPath(character.Mob.Name), m_WriterSettings))
                    m_Serializator.Serialize(xw, character);

                if (Exists(character.Mob.Name))
                {
                    return(new Character(userMob));
                }

                return(null);
            }
        }