Esempio n. 1
0
        public void Create_World_And_Hexes()
        {
            var race = new Race { Name = "Default Race" };
            var nation = new Nation { Name = "Default Nation", Race = race };
            var user = new User { Email = "*****@*****.**", FirstName = "Jamie", LastName = "Fraser", OpenId = "http://jamief00.myopenid.com/" };
            var world = new World { Height = 100, Width = 100, Name = "Default World" };
            var game = new Game { Name = "Default Game", Started = DateTime.Now, GameWorld = world};
            var gameSession = new GameSession { EnteredGame = DateTime.Now, Nation = nation, Game = game, User = user };

            using (var tran = _dataContext.WorldRepository.Session.BeginTransaction())
            {
                _dataContext.RaceRepository.Save(race);
                _dataContext.NationRepository.Save(nation);
                _dataContext.UserRepository.Save(user);
                _dataContext.GameRepository.Save(game);
                _dataContext.WorldRepository.Save(world);
                _dataContext.GameSessionRepository.Save(gameSession);

                for (var y = 1; y <= world.Width; y++)
                {
                    for (var x = 1; x <= world.Height; x++)
                    {
                        var hex = new Hex { World = world, HexType = HexType.Grass, X = x, Y = y };

                        _dataContext.HexRepository.Save(hex);
                    }
                }

                tran.Commit();
            }
        }
Esempio n. 2
0
        public ActionResult CreateUser(string firstName, string lastName, string email, string userName)
        {
            var user = new User();
            using (var tran = DataContext.UserRepository.Session.BeginTransaction())
            {
                user.FirstName = firstName;
                user.LastName = lastName;
                user.Email = email;
                user.OpenId = userName;

                DataContext.UserRepository.Save(user);

                tran.Commit();
            }

            return RedirectToAction("ViewUser");
        }
Esempio n. 3
0
        public void Setup_Tests()
        {
            _dataContext = IoC.Resolve<IDataContext>();
            _createdUsers = new List<Guid>();
            var user = new User
            {
                Email = TestDataHelper.EMAIL,
                FirstName = TestDataHelper.FIRST_NAME,
                LastName = TestDataHelper.LAST_NAME,
                OpenId = TestDataHelper.OPEN_ID
            };

            using (var tran = _dataContext.UserRepository.Session.BeginTransaction())
            {
                _dataContext.UserRepository.Save(user);
                tran.Commit();
            }
            _createdUsers.Add(user.Id);
        }
Esempio n. 4
0
        public static GameSession CreateSession(User user, Race race)
        {
            var nation = new Nation { Name = "Default Nation", Race = race };
            var world = new World { Height = 100, Width = 100, Name = "Default World" };
            var game = new Game { Name = "Default Game", Started = DateTime.Now, GameWorld = world };
            var gameSession = new GameSession { EnteredGame = DateTime.Now, Nation = nation, Game = game, User = user };

            for (var y = 1; y <= world.Width; y++)
            {
                for (var x = 1; x <= world.Height; x++)
                {
                    world.AddHex(new Hex { World = world, HexType = HexType.Grass, X = x, Y = y });
                }
            }

            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());

            return gameSession;
        }
Esempio n. 5
0
        public static GameSession CreateGameSession()
        {
            var race = new Race { Name = "Default Race", Description = "Test Race not used in the actual game."};
            var nation = new Nation { Name = "Default Nation", Race = race };
            var user = new User { Email = "*****@*****.**", FirstName = "Jamie", LastName = "Fraser", OpenId = "http://jamief00.mytestopenid.com/" };
            var world = new World { Height = 100, Width = 100, Name = "Default World" };
            var game = new Game { Name = "Default Game", Started = DateTime.Now, GameWorld = world};
            var gameSession = new GameSession { EnteredGame = DateTime.Now, Nation = nation, Game = game, User = user };

            for (var y = 1; y <= world.Width; y++)
            {
                for (var x = 1; x <= world.Height; x++)
                {
                    world.AddHex(new Hex { World = world, HexType = HexType.Grass, X = x, Y = y });
                }
            }

            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());

            return gameSession;
        }