예제 #1
0
        public void OnLogin()
        {
            int  curExp  = Data.Exp;
            int  NeedExp = RewardHelper.EXPNeeded(Data.Level);
            bool LevelUp = curExp >= NeedExp;

            if (LevelUp)
            {
                Data.Exp = 0;
                int NextLevel = Data.Level + 1;
                if (NextLevel < 100)
                {
                    Data.Level    = NextLevel;
                    LevelUpNotify = true;
                }
            }
            RankinngOBJ Rdata = RankingManager.GetPlayer(this);

            if (Rdata != null)
            {
                Deaths         = Rdata.Deaths;
                Kills          = Rdata.Deaths;
                League         = Rdata.League;
                LeaguePoints   = Rdata.LeaguePoints;
                GameCount      = Rdata.GameCount;
                LeaguePosition = Rdata.RankNo <= 100 ? (byte)Rdata.RankNo : (byte)101;
            }
        }
예제 #2
0
        public void OnGameResultRecieved()
        {
            RankinngOBJ Rdata = RankingManager.GetPlayer(this);

            if (Rdata != null)
            {
                Deaths         = Rdata.Deaths;
                Kills          = Rdata.Deaths;
                League         = Rdata.League;
                LeaguePoints   = Rdata.LeaguePoints;
                LeaguePosition = Rdata.RankNo <= 100 ? (byte)Rdata.RankNo : (byte)101;
            }
        }
예제 #3
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);
        }
예제 #4
0
        static void Main(string[] args)
        {
            float StartTime = JHSTime.Time;

            Console.Title = "LoginServer";
            AppDomain.CurrentDomain.DomainUnload += CleanupBeforeExit;
            AppDomain.CurrentDomain.ProcessExit  += new EventHandler(CurrentDomain_ProcessExit);
            Properties props = new Properties(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs/Config.ini"));

            Settings.AutoCreate   = bool.Parse(props.get("AUTO_CREATE"));
            Settings.BINDPASSWORD = uint.Parse(props.get("BINDPASSWORD"));
            Settings.GAMEVERSION  = int.Parse(props.get("GAMEVERSION"));
            Settings.DEBUG_MODE   = int.Parse(props.get("DEBUG_MODE"));

            Settings.MIN_PLAYERS     = int.Parse(props.get("MIN_PLAYERS"));
            Settings.MAX_PLAYERS     = int.Parse(props.get("MAX_PLAYERS"));
            Settings.CHECK_CAN_START = int.Parse(props.get("CHECK_CAN_START"));
            Settings.MAX_WAIT_TIME   = int.Parse(props.get("MAX_WAIT_TIME"));
            Settings.RANKING_SEASON  = int.Parse(props.get("RANKING_SEASON"));
            Settings.CAN_REQUEST_RANK_UPDATE_TIME       = int.Parse(props.get("CAN_REQUEST_RANK_UPDATE_TIME"));
            Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS = int.Parse(props.get("MIN_GAMES_TO_DECIDE_RANKING_SKILLS"));
            Settings.USE_RANKING_QUEUES    = bool.Parse(props.get("USE_RANKING_QUEUES"));
            Settings.START_WITH_ONE_PLAYER = bool.Parse(props.get("START_WITH_ONE_PLAYER"));
            Settings.DEBUG_GET_PLAYER      = bool.Parse(props.get("ALLOW_NOT_REGISTERED_GET_ROLE_INFO"));
            LOG.Error("Starting LoginServer");
            LOG.Info("Starting LoginServer");
            List <short> skins = new List <short>();

            string[] d = props.get("DEFAULT_SKIKINS").Split(',');
            foreach (string str in d)
            {
                skins.Add(short.Parse(str));
            }
            Settings.randomSkins = skins.ToArray();
            DbService.Instance.Start();
            ConfigManager.LoadConfigs();
            RankingManager.Init();
            NetworkServer.Instance.SetConfig(props);
            NetworkServer.Instance.InitHandlers();
            NetworkServer.Instance.Start();
            LOG.Info("Finished loading Server, time-consuming:" + (JHSTime.Time - StartTime) + " sec.");
WATIREGION:

            string line = Console.ReadLine();

            if (line == "exit")
            {
                goto EXITPROGRAM;
            }
            if (line == "aadd")
            {
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                AccountOBJ obj = DbService.Instance.GetAccountFromDB(2);
                if (obj != null)
                {
                    RankinngOBJ data = RankingManager.GetPlayer(obj);
                    RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 100);
                }
            }
            if (line == "add")
            {
                AccountOBJ obj = DbService.Instance.GetAccountFromDB(1);
                if (obj != null)
                {
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                    RankinngOBJ data = RankingManager.GetPlayer(obj);
                    if (data != null)
                    {
                        RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 100);
                    }
                }
            }
            if (line == "gamec")
            {
                AccountOBJ obj = DbService.Instance.GetAccountFromDB(1);
                if (obj != null)
                {
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                    RankinngOBJ data = RankingManager.GetPlayer(obj);
                    if (data != null)
                    {
                        RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 100, data.GameCount + 1, data.Kills + 1, 0);
                    }
                }
            }
            if (line == "add2")
            {
                AccountOBJ obj = DbService.Instance.GetAccountFromDB(1);
                if (obj != null)
                {
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                    RankinngOBJ data = RankingManager.GetPlayer(obj);
                    RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 1000);
                }
            }
            if (line == "del")
            {
                AccountOBJ obj = DbService.Instance.GetAccountFromDB(1);
                if (obj != null)
                {
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                    RankinngOBJ data = RankingManager.GetPlayer(obj);
                    RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints - 100);
                }
            }

            goto WATIREGION;

EXITPROGRAM:
            Console.WriteLine("Saving Database.");
            if (DbService.Instance.SaveAll())
            {
                Console.WriteLine("Server is now down.");
                Console.ReadKey();
            }
        }