Example #1
0
        public void Should_throw_exception_if_game_mode_invalid(int mode)
        {
            var cmd = new ChangeGameMode {
                MembershipId = "abcde", GameMode = mode
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("Game mode selection is invalid"));
        }
Example #2
0
        public void Should_throw_exception_if_membership_null()
        {
            var cmd = new ChangeGameMode {
                MembershipId = null, GameMode = (int)GameModeStatics.GameModes.Protection
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("MembershipID is required!"));
        }
Example #3
0
        public void Should_throw_exception_if_player_not_found()
        {
            var cmd = new ChangeGameMode {
                MembershipId = "fake", GameMode = (int)GameModeStatics.GameModes.Protection
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message
                        .EqualTo("Player with MembershipID 'fake' could not be found"));
        }
Example #4
0
        public void Should_throw_exception_if_choosing_same_game_mode()
        {
            new PlayerBuilder()
            .With(u => u.User, new UserBuilder().With(u => u.Id, "abcde").BuildAndSave())
            .With(p => p.GameMode, (int)GameModeStatics.GameModes.Superprotection)
            .BuildAndSave();

            var cmd = new ChangeGameMode {
                MembershipId = null, GameMode = (int)GameModeStatics.GameModes.Superprotection
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("MembershipID is required!"));
        }
Example #5
0
        public void should_not_change_not_PvP_to_PvP_in_not_chaos(int mode)
        {
            var player = new PlayerBuilder()
                         .With(u => u.User, new UserBuilder().With(u => u.Id, "abcde").BuildAndSave())
                         .With(p => p.GameMode, mode)
                         .BuildAndSave();

            var cmd = new ChangeGameMode {
                MembershipId = player.User.Id, GameMode = (int)GameModeStatics.GameModes.PvP, Force = false
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message
                        .EqualTo("You cannot switch into that mode during regular gameplay."));
        }
Example #6
0
        public void should_not_change_PvP_to_SP_in_not_chaos_with_recent_combat()
        {
            var player = new PlayerBuilder()
                         .With(u => u.User, new UserBuilder().With(u => u.Id, "abcde").BuildAndSave())
                         .With(p => p.GameMode, (int)GameModeStatics.GameModes.PvP)
                         .With(p => p.LastCombatTimestamp, DateTime.UtcNow.AddMinutes(-28))
                         .BuildAndSave();

            var cmd = new ChangeGameMode {
                MembershipId = player.User.Id, GameMode = (int)GameModeStatics.GameModes.Superprotection, Force = false
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message
                        .EqualTo("You cannot leave PvP mode until you have been out of combat for thirty (30) minutes."));
        }
Example #7
0
        public void should_not_change_not_from_PvP_when_in_dungeon(int mode)
        {
            var player = new PlayerBuilder()
                         .With(p => p.User, new UserBuilder().With(u => u.Id, "abcde").BuildAndSave())
                         .With(p => p.GameMode, (int)GameModeStatics.GameModes.PvP)
                         .With(p => p.Location, "dungeon_location")
                         .BuildAndSave();

            var cmd = new ChangeGameMode {
                MembershipId = player.User.Id, GameMode = mode, Force = true
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message
                        .EqualTo("You cannot switch out of PvP mode while you are in the dungeon."));
        }
Example #8
0
        public void should_change_PvP_to_SP_in_not_chaos_no_recent_combat()
        {
            var player = new PlayerBuilder()
                         .With(u => u.User, new UserBuilder().With(u => u.Id, "abcde").BuildAndSave())
                         .With(p => p.GameMode, (int)GameModeStatics.GameModes.PvP)
                         .With(p => p.PvPScore, 123)
                         .With(p => p.LastCombatTimestamp, DateTime.UtcNow.AddMinutes(-31))
                         .BuildAndSave();

            var cmd = new ChangeGameMode {
                MembershipId = player.User.Id, GameMode = (int)GameModeStatics.GameModes.Superprotection, Force = false
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.Nothing);

            var foundPlayer = DataContext.AsQueryable <Player>().First(p => p.User.Id == "abcde");

            Assert.That(foundPlayer.GameMode, Is.EqualTo((int)GameModeStatics.GameModes.Superprotection));
            Assert.That(foundPlayer.PvPScore, Is.EqualTo(0));
        }
 void Start()
 {
     screenManager = FindObjectOfType <ScreenManager> ();
     gameMode      = FindObjectOfType <ChangeGameMode>();
     cup           = FindObjectOfType <ChangeCup>();
 }