Exemplo n.º 1
0
        public void Execute()
        {
            var roomList          = CacheSet.FoundryRoomCache.FindAll();
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            foreach (var room in roomList)
            {
                room.Progress = 0;
                room.Level    = 0;
                foreach (var player in room.Players)
                {
                    pf.SetUser(player);
                    pf.ResetUser();
                    var target = GameSession.Get(player);
                    if (target != null)
                    {
                        LCResetGearFoundryInfo package = new LCResetGearFoundryInfo();
                        package.NextFoundryTimeInTicks = pf.MyFoundry.NextFoundryTime;
                        package.Progress = new PBGearFoundryProgressInfo()
                        {
                            CurrentLevel = room.Level, CurrentProgress = room.Progress
                        };
                        package.RewardFlags.AddRange(pf.MyFoundry.CanReceiveRewards);
                        byte[] buffer = CustomActionDispatcher.GeneratePackageStream(package.PacketActionId, ProtoBufUtils.Serialize(package));
                        target.SendAsync(buffer, 0, buffer.Length);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override bool TakeAction()
        {
            if (!m_RequestPacket.Accept)
            {
                m_ResponsePacket.Accept          = false;
                m_ResponsePacket.InviterPlayerId = m_RequestPacket.InviterPlayerId;
                m_ResponsePacket.TeamId          = m_RequestPacket.TeamId;
                return(true);
            }
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            if (!pf.JoinRoom(m_RequestPacket.TeamId))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Room is full";
                return(false);
            }
            m_ResponsePacket.Accept          = true;
            m_ResponsePacket.Data            = pf.GetAllFoundryData();
            m_ResponsePacket.InviterPlayerId = m_RequestPacket.InviterPlayerId;
            m_ResponsePacket.TeamId          = m_RequestPacket.TeamId;
            pf.PushRoomPlayerChangedNotify();
            return(true);
        }
Exemplo n.º 3
0
        public override bool TakeAction()
        {
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            if (CacheSet.FoundryRoomCache.FindKey(pf.MyFoundry.CurrentRoomId).Players[0] != m_UserId)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not this permission";
                return(false);
            }
            pf.SetUser(m_RequestPacket.PlayerId);
            pf.QuitRoom();
            pf.SetUser(m_UserId);
            pf.PushRoomPlayerChangedNotify();
            var target = GameSession.Get(m_RequestPacket.PlayerId);

            if (target != null)
            {
                LCKickedFromGearFoundryTeam package = new LCKickedFromGearFoundryTeam();
                byte[] buffer = CustomActionDispatcher.GeneratePackageStream(package.PacketActionId, ProtoBufUtils.Serialize(package));
                target.SendAsync(buffer, 0, buffer.Length);
            }
            return(true);
        }
Exemplo n.º 4
0
        public override bool TakeAction()
        {
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            var playerFoundryInfo = pf.GetPlayerFoundryInfo();

            m_ResponsePacket.Data = pf.GetAllFoundryData();
            return(true);
        }
Exemplo n.º 5
0
        public override bool TakeAction()
        {
            var         allActivities = CacheSet.ActivityTable.GetAllData();
            PlayerLogic p             = new PlayerLogic();

            p.SetUser(m_UserId);
            foreach (var activity in allActivities)
            {
                PBActivityInfo activityInfo = new PBActivityInfo();
                activityInfo.Id     = activity.Id;
                activityInfo.Status = LobbyServerUtils.GetActivityStatus(activity, p.MyPlayer.Level);
                if (activityInfo.Status == (int)ActivityStatusType.Hidden)
                {
                    continue;
                }
                switch ((ActivityType)activity.Id)
                {
                case ActivityType.TurnOverChess:
                    PlayerChessLogic pc = new PlayerChessLogic();
                    pc.SetUser(m_UserId);
                    activityInfo.Progress   = pc.MyChess.Count == 0 ? 0 : 1;
                    activityInfo.CountLimit = 1;
                    break;

                case ActivityType.OfflineArena:
                    PlayerArenaLogic pa = new PlayerArenaLogic();
                    pa.SetUser(m_UserId);
                    activityInfo.Progress   = pa.MyArena.ChallengeCount;
                    activityInfo.CountLimit = GameConsts.Arena.DailyChallengeCount;
                    break;

                case ActivityType.GearFoundry:
                    PlayerFoundryLogic pf = new PlayerFoundryLogic();
                    pf.SetUser(m_UserId);
                    activityInfo.Progress   = pf.GetProgress();
                    activityInfo.CountLimit = 1;
                    break;

                case ActivityType.CosmosCrack:
                    PlayerCosmosCrackLogic pcc = new PlayerCosmosCrackLogic();
                    pcc.SetUser(m_UserId);
                    var cosmosInfo = pcc.GetCosmosCrackInstanceInfo();
                    activityInfo.Progress   = cosmosInfo == null ? 0 : cosmosInfo.PassedRoundCount;
                    activityInfo.CountLimit = cosmosInfo == null ? 0 : GameConfigs.GetInt("Cosmos_Crack_Round_Limit", 10);
                    break;

                default:
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "invalid activity type";
                    return(false);
                }
                m_ResponsePacket.ActivityInfo.Add(activityInfo);
            }
            return(true);
        }
Exemplo n.º 6
0
        public override bool TakeAction()
        {
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            int roomId = pf.MyFoundry.CurrentRoomId;

            pf.QuitRoom();
            pf.PushRoomPlayerChangedNotify(roomId);
            return(true);
        }
Exemplo n.º 7
0
        public override bool TakeAction()
        {
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            if (!pf.CreateRoom())
            {
                ErrorCode = (int)ErrorType.CanNotCreateRoom;
                ErrorInfo = "You must quit your room before you create a room";
                return(false);
            }
            m_ResponsePacket.TeamId = pf.GetPlayerFoundryInfo().CurrentRoomId;
            return(true);
        }
Exemplo n.º 8
0
        public override bool TakeAction()
        {
            GameSession target = GameSession.Get(m_RequestPacket.FriendPlayerId);

            if (target == null)
            {
                ErrorCode = (int)ErrorType.PlayerNotOnline;
                ErrorInfo = "Player is not online";
                return(false);
            }
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            int teamId = pf.GetPlayerFoundryInfo().CurrentRoomId;

            if (teamId < 0)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You are not in a room";
                return(false);
            }
            if (CacheSet.FoundryRoomCache.FindKey(teamId).Players[0] != m_UserId)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not this permission";
                return(false);
            }
            LCInvitedForGearFoundry package = new LCInvitedForGearFoundry();

            package.TeamId        = teamId;
            package.InviterPlayer = new PBPlayerInfo()
            {
                Id           = m_UserId,
                Name         = p.MyPlayer.Name,
                Level        = p.MyPlayer.Level,
                PortraitType = p.MyPlayer.PortraitType
            };
            byte[] buffer = CustomActionDispatcher.GeneratePackageStream(2112, ProtoBufUtils.Serialize(package));
            target.SendAsync(buffer, 0, buffer.Length);
            m_ResponsePacket.FriendPlayerId = m_RequestPacket.FriendPlayerId;
            return(true);
        }
Exemplo n.º 9
0
        public override bool TakeAction()
        {
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            PBGearFoundryInfo roomInfo = pf.MatchRoom(m_RequestPacket.MatchMode);

            if (roomInfo == null)
            {
                return(true);
            }
            else
            {
                m_ResponsePacket.Data = roomInfo;
            }

            pf.PushRoomPlayerChangedNotify(roomInfo.TeamId, false);
            return(true);
        }
Exemplo n.º 10
0
        public override bool TakeAction()
        {
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);

            int[]                      drops    = GameConsts.Foundry.FoundryRewardDropPackageId[m_RequestPacket.Level];
            RandomDropLogic            random   = RandomDropLogic.GetInstance();
            CacheDictionary <int, int> dropDict = new CacheDictionary <int, int>();

            foreach (int dropId in drops)
            {
                DTDrop dataRow = CacheSet.DropTable.GetData(dropId);
                random.GetDropDict(dataRow, dropDict);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(dropDict))
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "package is full";
                return(false);
            }
            if (!pf.GetReward(m_RequestPacket.Level))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You can not get this reward";
                return(false);
            }
            PBReceivedItems receivedItems;

            pp.GetItems(dropDict, ReceiveItemMethodType.GearFoundry, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            m_ResponsePacket.RewardFlags.AddRange(pf.MyFoundry.CanReceiveRewards);
            return(true);
        }
Exemplo n.º 11
0
        public override bool TakeAction()
        {
            PlayerFoundryLogic pf = new PlayerFoundryLogic();

            pf.SetUser(m_UserId);
            if (!pf.Foundry())
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You can not foundry now";
                return(false);
            }
            m_ResponsePacket.NextFoundryTimeInTicks = pf.MyFoundry.NextFoundryTime;
            m_ResponsePacket.PerformerPlayerId      = m_UserId;
            m_ResponsePacket.RewardFlags.AddRange(pf.MyFoundry.CanReceiveRewards);
            var room = CacheSet.FoundryRoomCache.FindKey(pf.MyFoundry.CurrentRoomId);

            m_ResponsePacket.Progress = new PBGearFoundryProgressInfo()
            {
                CurrentLevel    = room.Level,
                CurrentProgress = room.Progress
            };
            pf.PushRoomProgressChangedNotify();
            return(true);
        }