Пример #1
0
        public void Add_TheSamePlayerTwice_ShouldFail()
        {
            PlayerManager playerManager = new PlayerManager();
            Player        player        = new Player(Guid.NewGuid().ToString());

            playerManager.Add(player);

            Assert.Throws <ArgumentException>(() => playerManager.Add(player));
        }
Пример #2
0
        static void Main(string[] args)
        {
            PlayerManager playerManager = new PlayerManager();

            IPlayer player1 = new Player();

            player1.Id          = 1;
            player1.FirstName   = "Mert";
            player1.Surname     = "Sevingit";
            player1.TcNo        = "12345678910";
            player1.YearOfBirth = 1994;
            playerManager.Add(player1);


            IPlayer player2 = new Player();

            player2.Id          = 2;
            player2.FirstName   = "Emre";
            player2.Surname     = "Ozturk";
            player2.TcNo        = "12345698710";
            player2.YearOfBirth = 1994;
            playerManager.Add(player2);

            playerManager.List();
            playerManager.Update(2, new Player()
            {
                Id = 2, FirstName = "Efe", Surname = "Onder", TcNo = "12345678911", YearOfBirth = 1994
            });
            playerManager.List();

            GameManager gameManager = new GameManager();
            IGame       game1       = new Game();

            game1.Id        = 1;
            game1.Name      = "Outlast";
            game1.GamePrice = 35;
            gameManager.Add(game1);
            gameManager.Add(new Game()
            {
                Id = 2, Name = "Outlast 2", GamePrice = 80
            });

            gameManager.List();

            CampaignManager campaignManager = new CampaignManager();
            ICampaign       campaign1       = new Campaign();

            campaign1.Id      = 1;
            campaign1.name    = "BlackFriday";
            campaign1.Discont = 50;

            campaignManager.Add(new Campaign());
            campaignManager.ApplyDiscont(game1, campaign1);
            campaignManager.SellGame(player1, game1);
        }
Пример #3
0
        static void Main(string[] args)
        {
            Player player1 = new Player {
                Id = 1, Firstname = "Serhan", Lastname = "Altuğ", BirthDate = new System.DateTime(1977, 06, 04), NationalIdentity = "27706387112"
            };
            Player player2 = new Player {
                Id = 2, Firstname = "Engin", Lastname = "Demiroğ", BirthDate = new System.DateTime(1985, 01, 06), NationalIdentity = "1234567810"
            };
            Player player3 = new Player {
                Id = 3, Firstname = "Zeynep", Lastname = "", BirthDate = new System.DateTime(2012, 05, 08), NationalIdentity = "1234567810"
            };

            IPlayerManager playerManager = new PlayerManager(new MernisServiceAdapter());

            playerManager.Add(player1);
            playerManager.Add(player2);
            playerManager.Add(player3);

            player1.NationalIdentity = "12345678910";
            playerManager.Update(player1);

            playerManager.Delete(player2);

            Console.WriteLine("_____________________________________________________");

            Campaign campaign1 = new Campaign {
                Id = 1, CampaignName = "Campaign 1 - Buy one, get one for free."
            };
            Campaign campaign2 = new Campaign {
                Id = 2, CampaignName = "Campaign 2 - Save %20 in your next order."
            };

            ICampaignManager campaignManager = new CampaignManager();

            campaignManager.Add(campaign1);
            campaignManager.Add(campaign2);

            campaign2.CampaignName = "Campaign 2 (Updated) - Save %25 in your next order.";
            campaignManager.Update(campaign2);

            campaignManager.Delete(campaign1);

            Console.WriteLine("_____________________________________________________");

            ISalesManager salesManager = new SalesManager();

            salesManager.Buy(player1);
            //Kampanya 1 silinmişti ancak listeden kontrol etmediğimiz için bir alt satırda satışa ekleyebiliyoruz.
            salesManager.AddCampaign(campaign1);
            salesManager.AddCampaign(campaign2);
            salesManager.Buy(player2);
        }
Пример #4
0
        public void Remove_OnePlayer_ShouldDecrementNumberOfPlayers()
        {
            PlayerManager playerManager = new PlayerManager();
            Player        player1       = new Player(Guid.NewGuid().ToString());
            Player        player2       = new Player(Guid.NewGuid().ToString());

            playerManager.Add(player1);
            playerManager.Add(player2);
            int countBeforeRemove = playerManager.Count;

            playerManager.Remove(player2.Id);

            Assert.Equal(countBeforeRemove - 1, playerManager.Count);
        }
Пример #5
0
 private static void ProcessKey(IHttpRequest Request, IHttpResponse Response, int usertype)
 {
     using (var a = new MemberShipBussiness())
     {
         using (var b = new PlayerBussiness())
         {
             var name = Request.Uri.QueryString["UserName"].ToSafeString();
             if (name != "" && a.ExistsUsername(name))
             {
                 var type = b.GetUserType(name);
                 if (usertype <= type)
                 {
                     Response.Write("对不起,你的权限不足");
                     return;
                 }
                 var pass = Guid.NewGuid().ToString();
                 PlayerManager.Add(name, pass);
                 string content = "user="******"&key=" + pass;
                 Response.Write(content);
             }
             else
             {
                 Response.Write("错误");
             }
         }
     }
 }
Пример #6
0
        static void Main(string[] args)
        {
            Player player1 = new Player
            {
                Id        = 1,
                FirstName = "Afet",
                LastName  = "Agayeva",
                DateTime  = new DateTime(2003, 1, 6)
            };
            Game game1 = new Game
            {
                Id       = 1,
                GameName = "Pubg",
                Price    = 100
            };
            Campaign campaign1 = new Campaign
            {
                Id           = 1,
                CampaignName = "Discount campaign",
                Percent      = 10
            };
            SellingManager sellingManager = new SellingManager();

            sellingManager.Buy(player1, game1, campaign1);

            PlayerManager playerManager = new PlayerManager();

            playerManager.Add(player1);

            AuthManager authManager = new AuthManager(new CheckManager());

            authManager.Register();
        }
Пример #7
0
        static void Main(string[] args)
        {
            Player player1 = new Player()
            {
                NationaityId = "0000000000", Name = "ANIL", Surname = "ÖZRENK", DateOfBirth = new DateTime(1999, 6, 22)
            };

            Game game1 = new Game()
            {
                Name = "ECorps", Genre = "Cyberpunk Vr Action", BasePrice = 50
            };

            Campaing campaing1 = new Campaing()
            {
                Name = "Patron Cildirdi", SaleAmount = 0.75
            };

            PlayerManager playerManager = new PlayerManager(new PlayerCheckService());

            playerManager.Add(player1);

            GameManager gameManager = new GameManager();

            gameManager.Add(game1);
            CampaingManager campaingManager = new CampaingManager();

            campaingManager.Apply(campaing1, game1);
            SaleManager saleManager = new SaleManager();

            saleManager.Buy(game1, player1);
        }
Пример #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("TheGame Platformuna hoşgeldiniz..\n");

            Console.WriteLine("Oyuncu işlemleri....");
            IPlayer player = new GoldPlayer()
            {
                Id            = 1,
                FirstName     = "Dilek",
                LastName      = "Şen",
                DateOfBirth   = new DateTime(1995, 8, 20),
                NationalityId = "1111111",
                AuthorityId   = 1
            };

            PlayerManager playerManager = new PlayerManager(new EdevletServiceAdapter());

            playerManager.Add(player);
            playerManager.Update(player);
            playerManager.Delete(player);


            Console.WriteLine("\nKampanya işlemleri....");
            Campaign campaign = new Campaign()
            {
                CampaignName = "Yeni Yıl İndirimi", DiscountAmount = 29.99, Id = 1
            };
            CampaignManager campaignManager = new CampaignManager();

            campaignManager.Add(campaign);
            campaignManager.Update(campaign);
            campaignManager.Delete(campaign);


            Console.WriteLine("\n\nKampanyasız satış....");

            Game game = new Game()
            {
                Id        = 1,
                GameName  = "Patlat Kazan",
                GamePoint = 4.9
            };

            ISale sale = new CreditCard()
            {
                Id             = 1,
                SaleMethodName = "Akbank Kredi Kartı",
                CardNumber     = "1111 2222",
                Cvv            = "322",
                SaleAmount     = 100
            };
            SaleManager saleManager = new SaleManager();

            saleManager.Sell(player, sale, game);

            Console.WriteLine("\n\nKampanyalı satış....");
            saleManager.Sell(player, sale, game, campaign);

            Console.WriteLine("\n\nSistemden çıkış yapıldı.");
        }
Пример #9
0
        private static void Main(string[] args)
        {
            Player player = new Player()
            {
                Id = 1, FirstName = "ömer", LastName = "küçük", BirthDate = new DateTime(1995, 10, 17), IdentityNo = "1000000000"
            };

            PlayerManager playerManager = new PlayerManager();

            playerManager.Add(player);

            ISaleService newSale = new SaleManager();

            newSale.Sale(new Player(), new Campaign()
            {
                Duration = new DateTime(2021, 10, 13), Name = "NewCampaign", Price = 10
            }, new Game()
            {
                Id = 1, Name = "NewGame", Price = 100
            });

            ICampaignService campaignService = new CampaignManager();

            campaignService.Add(new Campaign());


            Console.ReadLine();
        }
 public override void OnStartClient()
 {
     //local multiplayer may not have its own client PlayerManager
     if (!isServer)
     {
         Debug.Log("PlayerIdentity OnStartClient");
         PlayerManager.Add(gameObject);
         name = "Player id: " + m_connectionId + "_" + m_controllerId;
     }
 }
Пример #11
0
        public ActionResult UpdatePlayers()
        {
            PlayerManager     playerManager      = new PlayerManager(_context);
            ProjectionManager projectionsManager = new ProjectionManager(_context);

            List <Player> projections = projectionsManager.GetProjections();

            playerManager.DeleteAll();
            playerManager.Add(projections);

            return(RedirectToAction("Index"));
        }
Пример #12
0
        static void Main(string[] args)
        {
            CampaignManager campaignManager = new CampaignManager();
            Campaign        campaign1       = new Campaign();

            campaign1.Id           = 1;
            campaign1.Name         = "YILBAŞI İNDİRİMİ";
            campaign1.DiscountRate = 20;

            Campaign campaign2 = new Campaign();

            campaign2.Id           = 2;
            campaign2.Name         = "SÖMESTR İNDİRİMİ";
            campaign2.DiscountRate = 45;

            List <Campaign> campaigns = new List <Campaign>()
            {
                campaign1, campaign2
            };

            campaignManager.Add(campaign1);
            campaignManager.Delete(campaign2);
            campaignManager.List(campaigns);
            campaignManager.Update(campaign2);

            Player player1 = new Player();

            player1.Id            = 3;
            player1.FirstName     = "Ali";
            player1.LastName      = "YILMAZ";
            player1.NationalityId = "12345678";
            player1.DateOfBirth   = 1995;
            player1.NickName      = "VurucuTim";


            PlayerManager playerManager = new PlayerManager();

            playerManager.Add(player1);



            Game game1 = new Game();

            game1.Id    = 4;
            game1.Name  = "VALORANT";
            game1.Genre = "FPS";
            game1.Price = 55;

            OrderManager orderManager = new OrderManager();

            orderManager.NormalOrder(player1, game1);
            orderManager.OrderWithCampaign(player1, game1, campaign2);
        }
Пример #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            UserManager   UM = new UserManager();
            UserTBx       UT = new UserTBx();
            PlayerManager PM = new PlayerManager();
            PlayerTBx     PL = new PlayerTBx();


            //add User
            UT.status = 1;

            UT.typeuser_id   = Convert.ToInt32(Request["typeuser"]);
            UT.first_name    = Request["firstname"];
            UT.last_name     = Request["lastname"];
            UT.full_name     = Request["fullname"];
            UT.email         = Request["email"];
            UT.password      = UTIL.Encrypt(Request["password"], true);
            UT.token         = UTIL.RemoveSpecial(UTIL.Encrypt(Request["email"] + "***" + Request["password"], true));
            UT.phone         = Request["phone"];
            UT.birthday      = Request["birthday"];
            UT.address       = Request["address"];
            UT.credit        = Convert.ToInt32(Request["credit"]);
            UT.create_day    = DateTime.Now.ToString();
            UT.last_loginday = "";
            UM.Add(UT);


            //add player
            PL.name        = Request["lastname"];
            PL.status      = 1;
            PL.dice        = 0;
            PL.total_step  = "0";
            PL.curent_step = 0;
            PL.user_id     = UM.GetByEmail(Request["email"]).id;
            PM.Add(PL);

            Response.Write(JsonConvert.SerializeObject(new
            {
                success = 1
            }));
        }
        catch (Exception ex)
        {
            Response.Write(JsonConvert.SerializeObject(new
            {
                success = -1,
                error   = ex
            }));
        }
    }
Пример #14
0
        static void Main(string[] args)
        {
            Campaign campaign1 = new Campaign {
                CampaignName = "Şubat sonu %15 indirimi", CampaignType = "İndirim"
            };
            Campaign campaign2 = new Campaign {
                CampaignName = "Sevgililer günü çekilişi", CampaignType = "Çekiliş"
            };

            Console.WriteLine("<<<<<<<<<<Kampanyalar>>>>>>>>>>");
            CampaignManager campaignmanger = new CampaignManager();

            campaignmanger.Add(campaign1);
            campaignmanger.Add(campaign2);
            Console.WriteLine();
            Console.WriteLine("<<<<<<<<<<Oyuncular>>>>>>>>>>");
            PlayerManager player1 = new PlayerManager(new MernisServiceAdapter());

            player1.Add(new Entities.Player {
                DateOfBirth = new DateTime(2001, 4, 1), FirstName = "Mary", LastName = "Blood", NationalityId = "12345678"
            });

            PlayerManager player2 = new PlayerManager(new MernisServiceAdapter());

            player2.Add(new Entities.Player {
                DateOfBirth = new DateTime(1993, 9, 9), FirstName = "Frank", LastName = "Underwood", NationalityId = "12345678"
            });
            Console.WriteLine();
            Console.WriteLine("<<<<<<<<<<Oyunlar>>>>>>>>>");
            GameProduct game1 = new GameProduct()
            {
                GameName = "Total War", GameType = "Strateji", GamePrice = 70
            };
            GameProduct game2 = new GameProduct()
            {
                GameName = "Battlefield 1", GameType = "Savaş", GamePrice = 300
            };
            GameProduct game3 = new GameProduct()
            {
                GameName = "MotoGP", GameType = "Yarış", GamePrice = 100
            };

            GameProduct[] gameProducts = new GameProduct[] { game1, game2, game3 };
            foreach (var product in gameProducts)
            {
                Console.WriteLine("\t Oyunun ismi: " + product.GameName + "---> " + "Oyunun türü: " + product.GameType + "---> " + "Oyunun fiyatı: " + product.GamePrice);
            }
            Console.WriteLine();
            SaleManager sale = new SaleManager();

            sale.SaleOperation(campaign2, game1);
        }
Пример #15
0
        static void Main(string[] args)
        {
            IValidateService eDevletValidation = new ValidationService();
            ILoggerService   loggerService     = new LoggerService();
            PlayerManager    playerManager     = new PlayerManager();
            GameManager      gameManager       = new GameManager();
            CampaignManager  campaignManager   = new CampaignManager();


            Player kutay = new Player()
            {
                Id = 0, FirstName = "Kutay", LastName = "Yıldırım", NationalityId = "00000000000"
            };

            playerManager.Add(kutay);

            Game gta = new Game()
            {
                Id = 0, Name = " Grand Theft Auto", Type = "Action,RPG", Price = 200
            };

            gameManager.Add(gta);

            Game cod4 = new Game()
            {
                Id = 0, Name = " Call of Duty 4", Type = "Action, Shooter", Price = 250
            };

            gameManager.Add(cod4);

            Game formula12020 = new Game()
            {
                Id = 0, Name = " Formula 1 2020", Type = "Racing, Simulator", Price = 150
            };

            gameManager.Add(formula12020);

            Campaign blackFriday = new Campaign()
            {
                Id = 0, Name = "Black Friday", DiscountRate = 20
            };

            campaignManager.Add(blackFriday);

            kutay.Buy(gta, blackFriday, loggerService);
            kutay.Buy(cod4, blackFriday, loggerService);
            kutay.Buy(formula12020, blackFriday, loggerService);

            loggerService.PrintLogs(); // to see all logs
        }
Пример #16
0
        static void Main(string[] args)
        {
            Person player1 = new Person
            {
                Id            = 1,
                NationalityId = "25684908800",
                FirstName     = "Cengiz",
                LastName      = "Kılıç",
                DateOfBirt    = new DateTime(1985, 8, 7)
            };
            BasePlayerManager basePlayerManager = new PlayerManager(new MernisServiceAdapter());

            basePlayerManager.Add(player1);
            Console.ReadLine();
        }
Пример #17
0
        static void Main(string[] args)
        {
            string karsılama = "Oyun sistemine hoşgeldiniz!";

            Console.WriteLine(karsılama);

            IPlayerService playerService = new PlayerManager(new ValidationServiceManager());

            playerService.Add(new Player {
                Id          = 1, FirstName = "Yıldız", LastName = "Yılmaz",
                DateofBirth = new DateTime(1990, 5, 20), TcNo = 12345678910
            });                                                                //ekleme

            Player player = new Player {
                Id          = 2, FirstName = "Şahika", LastName = "Ekinci",
                DateofBirth = new DateTime(1988, 4, 12), TcNo = 54628731084
            };

            playerService.Delete(player); //silme

            playerService.UpDate(new Player
            {
                Id          = 2,
                FirstName   = "Ender",
                LastName    = "Çelebi",
                DateofBirth = new DateTime(1987, 1, 21),
                TcNo        = 165549820135
            }); //güncelleme

            Game game1 = new Game()
            {
                Id = 1, GameName = "Harry Potter", GameCategory = "Simülasyon", Price = 19.40
            };
            Game game2 = new Game()
            {
                Id = 2, GameName = "Mario", GameCategory = "Macera", Price = 25.90
            };

            List <Game> games = new List <Game> {
                game1, game2
            };

            ISellService sellService = new GameManager();

            sellService.ListGame(games);
            sellService.Calculate(games);
        }
Пример #18
0
    private void SpawnPlayer(object sender, MessageReceivedEventArgs e)
    {
        using (Message message = e.GetMessage())
            using (DarkRiftReader reader = message.GetReader())
            {
                if (message.Tag == Tags.SpawnPlayer)
                {
                    if (reader.Length % 17 != 0)
                    {
                        Debug.LogWarning("Received malformed spawn packet.");
                        return;
                    }

                    while (reader.Position < reader.Length)
                    {
                        ushort  id       = reader.ReadUInt16();
                        Vector3 position = new Vector3(reader.ReadSingle(), reader.ReadSingle());
                        float   size     = reader.ReadSingle();
                        Color32 color    = new Color32(
                            reader.ReadByte(),
                            reader.ReadByte(),
                            reader.ReadByte(),
                            255
                            );

                        var obj = default(GameObject);

                        if (id == client.ID)
                        {
                            obj = Instantiate(controllablePrefab, position, Quaternion.identity) as GameObject;
                            obj.GetComponent <Notifier>().Client = client;
                        }
                        else
                        {
                            obj = Instantiate(networkPrefab, position, Quaternion.identity) as GameObject;
                        }

                        var agarObj = obj.GetComponent <Agar>();

                        agarObj.body.Size  = size;
                        agarObj.body.Color = color;

                        manager.Add(id, agarObj);
                    }
                }
            }
    }
Пример #19
0
        static void Main(string[] args)
        {
            IPlayerService playerManager = new PlayerManager(new PlayerValidationManager());
            Player         player        = new Player
            {
                PlayerID          = 1,
                Name              = "Berk",
                Surname           = "Şenel",
                Nickname          = "DeuxBach",
                DateOfBirth       = "09.10.1998",
                CitizenshipNumber = "123456789"
            };

            playerManager.Add(player);
            Console.WriteLine("******");
            IGameService gameManager = new GameManager();

            Game game = new Game();

            game.GameID = 1;
            game.Title  = "Arma 3";
            game.Price  = 100;

            Game game1 = new Game();

            game1.GameID = 2;
            game1.Title  = "XCOM 2";
            game1.Price  = 120;
            gameManager.Add(game);
            gameManager.Add(game1);
            Console.WriteLine("******");
            gameManager.Sell(game, player);
            Console.WriteLine("******");
            Game[] games = new Game[] { game, game1 };

            IDiscountService discountManager = new DiscountManager();
            Discount         discount        = new Discount();

            discount.ID         = 1;
            discount.Percentage = 20;
            discount.Name       = "Winter Sale";
            discountManager.Add(discount);
            Console.WriteLine("******");

            discountManager.Discount(games, discount);
        }
Пример #20
0
        static void Main(string[] args)
        {
            Game game1 = new Game()
            {
                Id = 1, Name = "CoD"
            };
            Player player1 = new Player()
            {
                FirstName = "Akin", Id = 1, IdentityNo = "12345", LastName = "Sibay", FavGame = game1
            };
            PlayerManager playerManager = new PlayerManager(new ArnisCheckManager());

            playerManager.Add(player1);
            playerManager.List();

            Console.ReadLine();
        }
        public async Task <bool> OnHandle(MessageContext context, CRequestLoginMessage message)
        {
            var session = context.GetSession <Session>();
            var logger  = _logger.ForContext(
                ("RemoteEndPoint", session.RemoteEndPoint.ToString()),
                ("Message", message.ToJson()));

            logger.Debug("Login from {RemoteEndPoint}");

            var response = await _messageBus.PublishRequestAsync <RelayLoginRequest, RelayLoginResponse>(new RelayLoginRequest
            {
                AccountId = message.AccountId,
                Nickname  = message.Nickname,
                Address   = session.RemoteEndPoint.Address,
                ServerId  = message.RoomLocation.ServerId,
                ChannelId = message.RoomLocation.ChannelId,
                RoomId    = message.RoomLocation.RoomId
            });

            if (!response.OK)
            {
                session.Send(new SNotifyLoginResultMessage(1));
                return(true);
            }

            if (_playerManager[message.AccountId] != null)
            {
                logger.Information("Already logged in");
                session.Send(new SNotifyLoginResultMessage(2));
                return(true);
            }

            var roomId = (uint)((message.RoomLocation.ChannelId << 8) | message.RoomLocation.RoomId);

            var plr = _serviceProvider.GetRequiredService <Player>();

            plr.Initialize(session, response.Account);
            session.Player = plr;
            _playerManager.Add(plr);

            var room = _roomManager.GetOrCreate(roomId);

            room.Join(plr);
            session.Send(new SNotifyLoginResultMessage(0));
            return(true);
        }
Пример #22
0
        static void Main(string[] args)
        {
            Player player1 = new Player()
            {
                Id            = 1,
                BirthYear     = 1997,
                FirstName     = "Ata Can",
                IdentiyNumber = "1234567890",
                LastName      = "Türk"
            };



            PlayerManager playerManager = new PlayerManager(new InMemoryPlayerDal());

            playerManager.Add(player1);
        }
Пример #23
0
        /// <summary>
        /// 登录功能
        /// </summary>
        /// <param name="request"></param>
        private void HandleUserLoginC2S(BufferEntity request)
        {
            //反序列化 得到客户端 发送的数据

            UserLoginC2S c2sMSG = ProtobufHelper.FromBytes <UserLoginC2S>(request.proto);
            //主要是看反序列化的功能 是否正常
            //Debug.Log("登录:"+ JsonHelper.SerializeObject(c2sMSG));

            //匹配记录:相同的账号 相同的密码
            string sqlCMD = MySqlCMD.Where("Account", c2sMSG.UserInfo.Account) +
                            MySqlCMD.And("Password", c2sMSG.UserInfo.Password);

            UserLoginS2C s2cMSG   = new UserLoginS2C();
            UserInfo     userInfo = DBUserInfo.Instance.Select(sqlCMD);

            if (userInfo != null)
            {
                s2cMSG.UserInfo = userInfo;
                s2cMSG.Result   = 0;//登录成功

                //保存角色信息到服务器本地
                PlayerManager.Add(request.session, s2cMSG.UserInfo.ID, new PlayerEntity()
                {
                    userInfo = s2cMSG.UserInfo,
                    session  = request.session,
                });

                RolesInfo rolesInfo = DBRolesInfo.Instance.Select(MySqlCMD.Where("ID", s2cMSG.UserInfo.ID));

                if (rolesInfo != null)
                {
                    s2cMSG.RolesInfo = rolesInfo;
                    //获取到了角色信息 缓存起来
                    PlayerEntity playerEntity = PlayerManager.GetPlayerEntityFromSession(request.session);
                    playerEntity.rolesInfo = rolesInfo;
                }
            }
            else
            {
                s2cMSG.Result = 2;//帐号和密码不匹配
            }

            //返回结果
            BufferFactory.CreqateAndSendPackage(request, s2cMSG);
        }
Пример #24
0
        public override void OnOperationRequest(OperationRequest request, SendParameters sendParameters, MobaPeer peer)
        {
            MobaServer.LogInfo("处理创建角色的请求");

            string playerName = request.Parameters.ExTryGet((byte)ParameterCode.PlayerName) as string;

            // 无效检测
            if (String.IsNullOrEmpty(playerName))
            {
                return;
            }

            User user = UserManager.GetByUsername(peer.Username);

            DataBase.Model.Player player = new DataBase.Model.Player(playerName, user);
            PlayerManager.Add(peer.Username, player);

            OperationResponse response = new OperationResponse(request.OperationCode);

            peer.SendOperationResponse(response, sendParameters);
        }
Пример #25
0
        static void Main(string[] args)
        {
            //ASAMA 1  player ekleme
            Players players = new Players {
                PlayerFirstName = "Mine", PlayerLastName = "Topcuoglu", PlayerId = 5, PlayerBirthDay = "25.10.1999"
            };

            PlayerManager playerManager = new PlayerManager(new PlayerValidationManager());

            playerManager.Add(players);

            //ASAMA 2 oyun ekleme

            Games games = new Games {
                GamenName = " STAR ", GamePrice = 175, GameId = 1
            };

            GameManager gameManager = new GameManager();

            gameManager.Add(games);

            //ASAMA 3 oyun satın alma

            GameOwnerManager gameOwnerManager = new GameOwnerManager();

            gameOwnerManager.ownGame(games, players);

            //ASAMA 4 oyunu kampanya ile satın alma kısmı

            Campaigns campaigns = new Campaigns
            {
                CampaignName           = " Süper Kasım ",
                Campaigndiscountamount = 20
            };

            CampaignManager campaignManager = new CampaignManager();

            campaignManager.CampaignBuy(campaigns, games, players);
        }
Пример #26
0
        private void _handleCachedPlayers()
        {
            LoginSession session = _loginSessionManager.Session;

            foreach (int id in _playerManager.GetCache())
            {
                if (!WorldObjectService.IsValidObject(id))
                {
                    return;
                }

                WorldObject wo        = WorldObjectService.GetWorldObject(id);
                int         woMonarch = wo.Values(LongValueKey.Monarch);

                bool enemy = session.Monarch != woMonarch;
                bool self  = session.Id == id;
                if (!self)
                {
                    _playerManager.Add(_playerFactory(wo, enemy));
                }
            }

            _playerManager.ClearCache();
        }
Пример #27
0
        /// <summary>
        /// Saving new Team to database
        /// </summary>
        /// <param name="user"></param>
        /// <param name="teamManager"></param>
        /// <param name="stadiumManager"></param>
        /// <param name="playerManager"></param>
        /// <param name="playerSkillManager"></param>
        /// <param name="nationManager"></param>
        /// <param name="coachManager"></param>
        /// <param name="coachSkillManager"></param>
        /// <returns></returns>
        public static Team CreateFinishedTeam(
            User user,
            TeamManager teamManager,
            StadiumManager stadiumManager,
            PlayerManager playerManager,
            PlayerSkillManager playerSkillManager,
            NationManager nationManager
            // CoachManager coachManager,
            //CoachSkillManager coachSkillManager

            )
        {
            Team team = CreateTeam(user);

            // coachSkillManager.Add(team.Coach.CoachSkill);
            //coachSkillManager.Save();
            //  coachManager.Add(team.Coach);
            //coachManager.Save();

            stadiumManager.Add(team.Stadium);
            stadiumManager.Save();
            teamManager.Add(team);
            teamManager.Save();
            team.Players = PlayerMethod.CreatePlayers().ToList();
            foreach (Player player in team.Players)
            {
                nationManager.Add(player.Nation);
                nationManager.Save();
                playerSkillManager.Add(player.PlayerSkill);
                playerSkillManager.Save();
                playerManager.Add(player);
                playerManager.Save();
            }
            teamManager.Save();
            return(team);
        }
Пример #28
0
        static void Main(string[] args)
        {
            IPersonCheckService personCheck    = new PersonCheckManager();
            ILoggerService      databaseLogger = new DatabaseLoggerManager();
            ILoggerService      fileLogger     = new FileLoggerManager();

            List <ILoggerService> loggerServices = new List <ILoggerService>()
            {
                fileLogger
            };

            IPlayerService playerManager = new PlayerManager(personCheck, loggerServices);

            IEntity selim = new Player()
            {
                Name = "Selim", LastName = "Gülce", UserName = "******", Password = "******", DateOfBirth = new DateTime(1999, 11, 20), NationalityId = "11112222333"
            };
            IEntity emre = new Player()
            {
                Name = "Emre", LastName = "Gülce", UserName = "******", Password = "******", DateOfBirth = new DateTime(1999, 11, 20), NationalityId = "11112222333"
            };
            IEntity mehmet = new Player()
            {
                Name = "Mehmet", LastName = "Gülce", UserName = "******", Password = "******", DateOfBirth = new DateTime(2007, 01, 6), NationalityId = "11112222333"
            };

            playerManager.Add(selim);
            playerManager.Add(emre);
            playerManager.Add(mehmet);



            IEntity hitman2 = new Game()
            {
                Name = "Hitman 2", Price = (double)59.90
            };
            IEntity pubg = new Game()
            {
                Name = "PUBG", Price = (double)79.90
            };
            IEntity rocketLeague = new Game()
            {
                Name = "Rocket League", Price = (double)29.90
            };

            IGameService gameManager = new GameManager(loggerServices);

            gameManager.Add(pubg);
            gameManager.Add(hitman2);
            gameManager.Add(rocketLeague);



            ISalesService winterSales = new WinterSalesManager(loggerServices);


            IPlatformService platformManager = new SteamPlatformManager(new List <ISalesService> {
                winterSales
            });

            platformManager.BuyGameFromPlayer(selim, pubg);
            platformManager.BuyGameFromPlayer(emre, hitman2);
            platformManager.BuyGameFromPlayer(mehmet, rocketLeague);
            platformManager.RefundGameFromPlayer(selim, pubg);


            Console.ReadLine();
        }
Пример #29
0
        static void Main(string[] args)
        {
            ILoggerService   fileLogger            = new FileLoggerService();
            ILoggerService   databaseLogger        = new DatabaseLoggerService();
            IValidateService mernisValidateService = new MernisValidateService();

            IEntityService playerManager = new PlayerManager(new List <ILoggerService> {
                databaseLogger, fileLogger
            },
                                                             new List <IValidateService> {
                mernisValidateService
            });
            Person enginHoca = new Player()
            {
                NationalityNumber = "00000000000", Name = "Engin",
                LastName          = "Demiroğ", YearOfBirth = 1985, Balance = 4000
            };
            Person poyraz = new Player()
            {
                NationalityNumber = "11111111111", Name = "Poyraz",
                LastName          = "Aktaş", YearOfBirth = 2000, Balance = 1500
            };
            Person ayaz = new Player()
            {
                NationalityNumber = "22222222222", Name = "A",
                LastName          = "Aktaş", YearOfBirth = 2003, Balance = 99999
            };
            Person mert = new Player()
            {
                NationalityNumber = "33333333333", Name = "Mert",
                LastName          = "Özcan", YearOfBirth = 2000, Balance = 2200
            };

            playerManager.Add(enginHoca);
            playerManager.Add(poyraz);
            playerManager.Add(ayaz);
            playerManager.Add(mert);


            IEntity gta5 = new Game()
            {
                Id = 1, Name = "GTA 5", Publisher = "Rockstar Games", UnitPrice = 140.50
            };
            IEntity wow = new Game()
            {
                Id = 2, Name = "World of Warcraft", Publisher = "Blizzard", UnitPrice = 2000
            };
            IEntity cyberpunk = new Game()
            {
                Id = 3, Name = "Cyberpunk 2077", Publisher = "CD Projekt Red ", UnitPrice = 239.99
            };

            IEntityService gameManager = new GameManager(new List <ILoggerService> {
                databaseLogger
            });

            gameManager.Add(gta5);
            gameManager.Add(wow);
            gameManager.Add(cyberpunk);

            ISalesService yaz_indirimi       = new SummerSalesManager();
            ISalesService karaCuma_indirimi  = new BlackFridaySalesManager();
            ISalesService yilbasi_indirimi   = new NewYearSalesManager();
            ISalesService haftasonu_indirimi = new WeekendSalesManager();

            IPlatformService steam      = new SteamPlatformManager(new List <ISalesService> {
            });
            IPlatformService epic_games =
                new EpicGamesPlatformManager(new List <ISalesService> {
                karaCuma_indirimi, haftasonu_indirimi
            });

            steam.BuyGame(poyraz, gta5);
            epic_games.BuyGame(enginHoca, cyberpunk);
            steam.ToRefund(poyraz, gta5);
            epic_games.BuyGame(poyraz, gta5);
        }
Пример #30
0
        public async Task <bool> OnHandle(MessageContext context, CLoginReqMessage message)
        {
            var session = context.GetSession <Session>();
            var logger  = _logger.ForContext(
                ("RemoteEndPoint", session.RemoteEndPoint.ToString()),
                ("Message", message.ToJson()));

            logger.Debug("Login");

            var allowedVersions = _appOptions.CurrentValue.ClientVersions;

            if (allowedVersions.All(x => message.Version != x))
            {
                logger.Information("Invalid client version={Version} supported versions are {SupportedVersions}",
                                   message.Version.ToString(), string.Join(",", allowedVersions.Select(x => x.ToString())));
                session.Send(new SLoginAckMessage(GameLoginResult.WrongVersion));
                await session.CloseAsync();

                return(true);
            }

            if (_sessionManager.Sessions.Count >= _networkOptions.MaxSessions)
            {
                session.Send(new SLoginAckMessage(GameLoginResult.ServerFull));
                return(true);
            }

            // Validate session
            var sessionId = await _cacheClient.GetAsync <string>(Constants.Cache.SessionKey(message.AccountId));

            if (!sessionId.HasValue || !sessionId.Value.Equals(message.SessionId))
            {
                logger.Information("Invalid session id");
                session.Send(new SLoginAckMessage(GameLoginResult.SessionTimeout));
                return(true);
            }

            AccountEntity accountEntity;

            using (var db = _databaseService.Open <AuthContext>())
            {
                var accountId = (long)message.AccountId;
                accountEntity = await db.Accounts
                                .Include(x => x.Bans)
                                .FirstOrDefaultAsync(x => x.Id == accountId);
            }

            if (accountEntity == null)
            {
                logger.Information("Wrong login");
                session.Send(new SLoginAckMessage(GameLoginResult.SessionTimeout));
                return(true);
            }

            // Check ban status
            var now = DateTimeOffset.Now.ToUnixTimeSeconds();
            var ban = accountEntity.Bans.FirstOrDefault(x => x.Duration == null || x.Date + x.Duration > now);

            if (ban != null)
            {
                var unbanDate = DateTimeOffset.MinValue;
                if (ban.Duration != null)
                {
                    unbanDate = DateTimeOffset.FromUnixTimeSeconds(ban.Date + (ban.Duration ?? 0));
                }

                logger.Information("Account is banned until {UnbanDate}", unbanDate);
                session.Send(new SLoginAckMessage(GameLoginResult.SessionTimeout));
                return(true);
            }

            var account = new Account((ulong)accountEntity.Id, accountEntity.Username, accountEntity.Nickname,
                                      (SecurityLevel)accountEntity.SecurityLevel);

            if (message.KickConnection)
            {
                var oldPlr = _playerManager[account.Id];
                if (oldPlr != null)
                {
                    logger.Information("Kicking old connection hostId={HostId}", oldPlr.Session.HostId);
                    await oldPlr.DisconnectAsync();
                }
            }

            if (_playerManager.Contains(account.Id))
            {
                // TODO Check if logged in on another server

                logger.Information("Account is already logged in");
                session.Send(new SLoginAckMessage(GameLoginResult.TerminateOtherConnection));
                return(true);
            }

            using (var db = _databaseService.Open <GameContext>())
            {
                var plr = await db.Players
                          .Include(x => x.Characters)
                          .Include(x => x.Items)
                          .Include(x => x.Licenses)
                          .FirstOrDefaultAsync(x => x.Id == accountEntity.Id);

                if (plr == null)
                {
                    var levelInfo = _gameDataService.Levels.GetValueOrDefault(_gameOptions.StartLevel);
                    if (levelInfo == null)
                    {
                        logger.Warning("Invalid StartLevel={StartLevel} in config", _gameOptions.StartLevel);
                    }

                    plr = new PlayerEntity
                    {
                        Id              = (int)account.Id,
                        AP              = _gameOptions.StartAP,
                        PEN             = _gameOptions.StartPEN,
                        Coins1          = _gameOptions.StartCoins1,
                        Coins2          = _gameOptions.StartCoins2,
                        TotalExperience = (int)(levelInfo?.TotalExperience ?? 0)
                    };

                    db.Players.Add(plr);
                    await db.SaveChangesAsync();
                }

                session.Player = _serviceProvider.GetRequiredService <Player>();
                session.Player.Initialize(session, account, plr);
                session.SessionId = message.SessionId;
            }

            _playerManager.Add(session.Player);
            logger.Information("Login success");

            var result = string.IsNullOrWhiteSpace(account.Nickname)
                ? GameLoginResult.ChooseNickname
                : GameLoginResult.OK;

            session.Send(new SLoginAckMessage(result, account.Id));

            if (!string.IsNullOrWhiteSpace(account.Nickname))
            {
                await session.Player.SendAccountInformation();
            }
            return(true);
        }