Exemplo n.º 1
0
        public async Task CanPrivateMinilandAsync()
        {
            var mleditPacket = new MLEditPacket()
            {
                Parameter = MinilandState.Private,
                Type      = 2
            };
            await _mlEditPacketHandler !.ExecuteAsync(mleditPacket, _session !).ConfigureAwait(false);
            var   lastpacket = (MsgiPacket?)_session !.LastPackets.FirstOrDefault(s => s is MsgiPacket);

            Assert.AreEqual(lastpacket?.Message, Game18NConstString.MinilandPrivate);
            var miniland = _minilandProvider.GetMiniland(_session.Character.CharacterId);

            Assert.AreEqual(MinilandState.Private, miniland.State);
        }
Exemplo n.º 2
0
        public async Task CanChangeMinilandMessageWithSpaceAsync()
        {
            var mleditPacket = new MLEditPacket()
            {
                MinilandInfo = "Test Test",
                Type         = 1
            };
            await _mlEditPacketHandler !.ExecuteAsync(mleditPacket, _session !).ConfigureAwait(false);
            var   lastpacket = (InfoiPacket?)_session !.LastPackets.FirstOrDefault(s => s is InfoiPacket);

            Assert.AreEqual(Game18NConstString.MinilandChanged, lastpacket !.Message);
            var miniland = _minilandProvider.GetMiniland(_session.Character.CharacterId);

            Assert.AreEqual("Test Test", miniland.MinilandMessage);
            var lastpacket2 = (MlintroPacket?)_session !.LastPackets.FirstOrDefault(s => s is MlintroPacket);

            Assert.AreEqual("Test^Test", lastpacket2?.Intro);
        }
Exemplo n.º 3
0
        public async Task PrivateKickEveryoneButFriendAsync()
        {
            var mleditPacket = new MLEditPacket()
            {
                Parameter = MinilandState.Private,
                Type      = 2
            };
            await _mlEditPacketHandler !.ExecuteAsync(mleditPacket, _session !).ConfigureAwait(false);

            var miniland = _minilandProvider.GetMiniland(_session !.Character.CharacterId);

            Assert.AreEqual(MinilandState.Private, miniland.State);

            Assert.IsFalse(Broadcaster.Instance.GetCharacters()
                           .Where(s => s.MapInstanceId == miniland.MapInstanceId)
                           .Any(s => s.VisualId != _session.Character.CharacterId && s.VisualId != _session2.Character.VisualId));
            Assert.AreEqual(2, Broadcaster.Instance
                            .GetCharacters().Count(s => s.MapInstanceId == miniland.MapInstanceId));
        }
Exemplo n.º 4
0
        /// <summary>
        /// mledit packet
        /// </summary>
        /// <param name="mlEditPacket"></param>
        public void MinilandEdit(MLEditPacket mlEditPacket)
        {
            switch (mlEditPacket.Type)
            {
            case 1:
                Session.SendPacket($"mlintro {mlEditPacket.Parameters.Replace(' ', '^')}");
                Session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("MINILAND_INFO_CHANGED")));
                break;

            case 2:
                MinilandState state;
                Enum.TryParse(mlEditPacket.Parameters, out state);

                switch (state)
                {
                case MinilandState.PRIVATE:
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MINILAND_PRIVATE"), 0));

                    //Need to be review to permit one friend limit on the miniland
                    Session.Character.Miniland.Sessions.Where(s => s.Character != Session.Character).ToList().ForEach(s => ServerManager.Instance.ChangeMap(s.Character.CharacterId, s.Character.MapId, s.Character.MapX, s.Character.MapY));
                    break;

                case MinilandState.LOCK:
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MINILAND_LOCK"), 0));
                    Session.Character.Miniland.Sessions.Where(s => s.Character != Session.Character).ToList().ForEach(s => ServerManager.Instance.ChangeMap(s.Character.CharacterId, s.Character.MapId, s.Character.MapX, s.Character.MapY));
                    break;

                case MinilandState.OPEN:
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MINILAND_PUBLIC"), 0));
                    break;
                }

                Session.Character.MinilandState = state;
                break;
            }
        }