コード例 #1
0
        public bool Execute(JHSNetworkMessage netMsg)
        {
            if (DbManager == null)
            {
                DbManager = AccountManager.Instance;
            }
            if (queueManager == null)
            {
                queueManager = GameServerManager.Instance;
            }
            if (dbService == null)
            {
                dbService = DbService.Instance;
            }
            UpdateMatchResult packet = netMsg.ReadMessage <UpdateMatchResult>();

            if (packet != null)
            {
                uint connectionId = netMsg.conn.connectionId;
                var  server       = queueManager.GetServerByConnectionId(connectionId);
                if (server != null)
                {
                    AccountOBJ user = DbManager.GetOnlineByUserId(packet.UserId);
                    if (user == null)
                    {
                        user = dbService.GetAccountFromDB(packet.UserId);
                    }
                    if (user != null)
                    {
                        lock (user)
                        {
                            foreach (DBPlayerActive active in packet.Actives)
                            {
                                ActivesOBJ obj = user.GetActive((int)active.ActiveId);
                                obj.Value = (int)active.Value;
                                DbService.UpdateEntityIntime(obj);
                            }
                            user.Data.Exp += (int)packet.EXP;

                            RankinngOBJ RankData = RankingManager.GetPlayer(user);
                            if (RankData != null)
                            {
                                RankData.GameCount += 1;
                                RankData.Kills     += (int)packet.KillCount;

                                if (!packet.HasWon)
                                {
                                    RankData.Deaths += 1;
                                }
                            }
                            user.OnGameResultRecieved();
                            DbService.UpdateEntityIntime(user);
                        }
                        LOG.Info(string.Format("SaveResult  ::  Server[{0}] userid[{1}]", connectionId, packet.UserId));
                    }
                    else
                    {
                        LOG.Info(string.Format("SaveResult Error unknown user ::  Server[{0}] userid[{1}]", connectionId, packet.UserId));
                    }
                    netMsg.conn.Send(GameServerOP.PUTROLE, new Empty());
                }
            }
            return(true);
        }
コード例 #2
0
        public bool Execute(JHSNetworkMessage netMsg)
        {
            if (DbManager == null)
            {
                DbManager = AccountManager.Instance;
            }

            CollectActive packet = netMsg.ReadMessage <CollectActive>();

            if (packet != null)
            {
                uint       connectionId = netMsg.conn.connectionId;
                AccountOBJ user         = DbManager.GetOnlineByConnectionId(connectionId);
                if (user != null)
                {
                    lock (user)
                    {
                        ActivesConfig model = ConfigManager.GetActive((int)packet.AciveId);
                        if (model == null)
                        {
                            netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse()
                            {
                                STATUS = ITEM_CONFIG_WRONG
                            });
                            return(true);
                        }

                        ActivesOBJ active = user.GetActive((int)packet.AciveId);
                        if (active == null)
                        {
                            netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse()
                            {
                                STATUS = ACTIVE_NOT_FOUND
                            });
                            return(true);
                        }

                        if (active.Collected)
                        {
                            netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse()
                            {
                                STATUS = ACTIVE_ALREADY_COLLECTED
                            });
                            return(true);
                        }
                        if (model.Conditions != active.Value)
                        {
                            netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse()
                            {
                                STATUS = ACTIVE_NOT_COMPLEATED
                            });
                            return(true);
                        }

                        active.Collected = true;
                        DbService.SubmitUpdate2Queue(active);

                        if (model.GoldReward > 0)
                        {
                            user.Gold += model.GoldReward;
                        }

                        if (model.SilverReward > 0)
                        {
                            user.Silver += model.SilverReward;
                        }

                        user.ResetNotification();
                        DbService.SubmitUpdate2Queue(user);

                        netMsg.conn.Send(NetworkConstants.COLLECT_ACTIVE, new CollectActiveResponse()
                        {
                            STATUS = SUCCESS, AciveId = packet.AciveId, Gold = (uint)user.Gold, Silver = (uint)user.Silver
                        });
                    }
                }
            }
            return(true);
        }
コード例 #3
0
        public bool Execute(JHSNetworkMessage netMsg)
        {
            if (DbManager == null)
            {
                DbManager = AccountManager.Instance;
            }

            ConsoleCMD packet = netMsg.ReadMessage <ConsoleCMD>();

            if (packet != null)
            {
                uint       connectionId = netMsg.conn.connectionId;
                AccountOBJ account      = DbManager.GetOnlineByConnectionId(connectionId);
                if (account != null)
                {
                    if (account.Priviledge > 1)
                    {
                        switch ((GMCOMMAND)packet.Command)
                        {
                        case GMCOMMAND.ADD_GOLD:
                            account.Gold += (int)packet.Value;
                            netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp()
                            {
                                STATUS = 0, SilverValue = (uint)account.Silver, GoldValue = (uint)account.Gold
                            });
                            break;

                        case GMCOMMAND.ADD_SILVER:
                            account.Silver += (int)packet.Value;
                            netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp()
                            {
                                STATUS = 0, SilverValue = (uint)account.Silver, GoldValue = (uint)account.Gold
                            });
                            break;

                        case GMCOMMAND.FINISH_ACTIVES:
                            if (packet.Value == 1)
                            {
                                ActivesConfig[] allConfig = ConfigManager.GetActives();
                                for (int i = 0; i < allConfig.Length; i++)
                                {
                                    ActivesOBJ active = account.GetActive(allConfig[i].ActiveId);
                                    if (active != null)
                                    {
                                        active.Value     = (int)allConfig[i].Conditions;
                                        active.Collected = false;
                                        DbService.SubmitUpdate2Queue(active);
                                    }
                                }
                                netMsg.conn.Send(NetworkConstants.REFRESH_ACTIVES, new RefreshActives()
                                {
                                    actives = account.SerializeActives()
                                });
                            }
                            else
                            {
                                ActivesConfig[] allConfig = ConfigManager.GetActives();
                                for (int i = 0; i < allConfig.Length; i++)
                                {
                                    ActivesOBJ active = account.GetActive(allConfig[i].ActiveId);
                                    if (active != null)
                                    {
                                        active.Value     = 0;
                                        active.Collected = false;
                                        DbService.SubmitUpdate2Queue(active);
                                    }
                                }
                                netMsg.conn.Send(NetworkConstants.REFRESH_ACTIVES, new RefreshActives()
                                {
                                    actives = account.SerializeActives()
                                });
                            }
                            break;
                        }
                    }
                }
            }
            return(true);
        }