示例#1
0
        public async Task CreateCharacterListEntryForPlayer(PlayerCreateData info, IPlayer plr)
        {
            if (State.CharacterList == null)
            {
                State.CharacterList = new List <PlayerCharacterListEntry>();
            }

            var chars = GetCharacters(info.RealmID);


            PlayerCharacterListEntry entry = new PlayerCharacterListEntry();

            entry.Player = await plr.GetGUID();

            entry.RealmID = info.RealmID;

            foreach (var c in chars)
            {
                entry.CharacterSlot = c.CharacterSlot + 1;
            }

            State.CharacterList.Add(entry);

            Save();
        }
示例#2
0
        public async Task <Tuple <LoginErrorCode, IPlayer> > CreatePlayer(PlayerCreateData info)
        {
            LoginErrorCode err  = LoginErrorCode.CHAR_CREATE_SUCCESS;
            var            guid = await GeneratePlayerGUID();

            var plr = GrainFactory.GetGrain <IPlayer>(guid.ToInt64());

            err = await plr.Create(info);

            var ret = new Tuple <LoginErrorCode, IPlayer>(err, err == LoginErrorCode.CHAR_CREATE_SUCCESS ? plr : null);

            return(ret);
        }
示例#3
0
        public async Task CreatePlayer(CMSG_CHAR_CREATE create)
        {
            IDataStoreManager datastore = GrainFactory.GetGrain <IDataStoreManager>(0);

            var createinfo = await datastore.GetPlayerCreateInfo(create.Class, create.Race);

            if (createinfo == null)
            {
                await SendCharCreateReply(LoginErrorCode.CHAR_CREATE_ERROR);

                return;
            }

            var plrnameindex  = GrainFactory.GetGrain <IPlayerByNameIndex>(create.Name);
            var guidnameindex = await plrnameindex.GetPlayerGUID();

            if (guidnameindex != 0)
            {
                await SendCharCreateReply(LoginErrorCode.CHAR_CREATE_NAME_IN_USE);

                return;
            }

            var chrclass = await datastore.GetChrClasses(create.Class);

            var chrrace = await datastore.GetChrRaces(create.Race);

            if (chrclass == null || chrrace == null)
            {
                await SendCharCreateReply(LoginErrorCode.CHAR_CREATE_ERROR);

                return;
            }

            var chars = GetCharacters(RealmSessionRealmID);

            if (chars != null && chars.Length >= 10) //todo: add max
            {
                await SendCharCreateReply(LoginErrorCode.CHAR_CREATE_SERVER_LIMIT);

                return;
            }

            var creator = GrainFactory.GetGrain <ICreator>(0);

            //OK LETS CREATE
            PlayerCreateData info = new PlayerCreateData();

            info.CreateData  = create;
            info.RealmID     = RealmSessionRealmID;
            info.AccountName = this.GetPrimaryKeyString();

            var create_response = await creator.CreatePlayer(info);

            if (create_response.Item1 != LoginErrorCode.CHAR_CREATE_SUCCESS)
            {
                await SendCharCreateReply(create_response.Item1);

                return;
            }
            await plrnameindex.SetPlayer(create_response.Item2);

            await SendCharCreateReply(LoginErrorCode.CHAR_CREATE_SUCCESS);

            await CreateCharacterListEntryForPlayer(info, create_response.Item2);
        }
 public static void OnPlayerCreateData(PlayerCreateDataEventArgs args)
 {
     PlayerCreateData?.Invoke(args);
 }
示例#5
0
        public async Task <LoginErrorCode> Create(PlayerCreateData info)
        {
            await Create();

            State.Name    = info.CreateData.Name;
            State.Account = info.AccountName;
            _Account      = GrainFactory.GetGrain <IAccount>(State.Account);
            State.Race    = info.CreateData.Race;
            State.Class   = info.CreateData.Class;
            State.Gender  = info.CreateData.Gender;
            State.RealmID = (UInt32)info.RealmID;
            await SetGender(info.CreateData.Gender);
            await SetRace(info.CreateData.Race);
            await SetClass(info.CreateData.Class);
            await SetSkin(info.CreateData.Skin);
            await SetFace(info.CreateData.Face);
            await SetHairStyle(info.CreateData.HairStyle);
            await SetHairColor(info.CreateData.HairColor);
            await SetFacialHair(info.CreateData.FacialHair);

            var datastore = GrainFactory.GetGrain <IDataStoreManager>(0);
            var chrclass  = await datastore.GetChrClasses(info.CreateData.Class);

            var chrrace = await datastore.GetChrRaces(info.CreateData.Race);

            var creationinfo = await datastore.GetPlayerCreateInfo(info.CreateData.Class, info.CreateData.Race);

            if (chrclass == null || chrrace == null || creationinfo == null)
            {
                return(LoginErrorCode.CHAR_CREATE_ERROR);
            }

            await SetFaction((int)chrrace.Faction);
            await SetPowerType((byte)chrclass.powerType);

            if (_GetGender() == 0) //male
            {
                await SetDisplayID((int)chrrace.ModelMale);
                await SetNativeDisplayID((int)chrrace.ModelMale);
            }
            else
            {
                await SetDisplayID((int)chrrace.ModelFemale);
                await SetNativeDisplayID((int)chrrace.ModelFemale);
            }

            State.PositionX   = creationinfo.position_x;
            State.PositionY   = creationinfo.position_y;
            State.PositionZ   = creationinfo.position_z;
            State.Orientation = creationinfo.orientation;
            State.MapID       = creationinfo.map;

            State.BindX    = State.PositionX;
            State.BindY    = State.PositionY;
            State.BindZ    = State.PositionZ;
            State.BindMap  = State.MapID;
            State.BindArea = 0;

            State.Exists = true;                                        //WE EXIST, YAY

            await SetUInt32((int)EUnitFields.UNIT_FIELD_FLAGS_2, 2048); //regen power
            await SetUInt32((int)EUnitFields.PLAYER_FIELD_WATCHED_FACTION_INDEX, 0xFFFFFFFF);
            await SetUInt32((int)EUnitFields.UNIT_FIELD_LEVEL, 1);
            await SetUInt32((int)EUnitFields.PLAYER_FIELD_COINAGE, 1);
            await SetUInt32((int)EUnitFields.UNIT_FIELD_HEALTH, 100);
            await SetUInt32((int)EUnitFields.UNIT_FIELD_MAXHEALTH, 100);

            await OnConstruct();
            await Save();

            return(LoginErrorCode.CHAR_CREATE_SUCCESS);
        }