コード例 #1
0
        public void LevelUpHeroThenKillHim_ResultsInClassesAndRacesUnchanged_Test()
        {
            // Arrange
            var dwarf  = "Dwarf";
            var priest = "Priest";
            var quest  = QuestFactory.CreateStartedWithMaleHero(
                out var gameStore,
                out var gameId,
                out var playerId,
                out var sequence);

            var raceMessage  = RaceMessage.CreateAdd(sequence.Next, playerId, new[] { dwarf });
            var classMessage = ClassMessage.CreateAdd(sequence.Next, playerId, new[] { priest });
            var deathMsg     = DeathMessage.Create(sequence.Next, playerId);

            // Act
            quest.AddMessage(gameId, raceMessage);
            quest.AddMessage(gameId, classMessage);
            var game = quest.AddMessage(gameId, deathMsg);

            // Assert
            var hero = game.GetHero(playerId);

            Assert.Single(hero.Races);
            Assert.Single(hero.Classes);
        }
コード例 #2
0
ファイル: Client.cs プロジェクト: mserier/vrar
    void SendClassMessage(int classType)
    {
        var classMessage = new ClassMessage();

        classMessage.classType = classType;
        client.Send(NetworkMessages.Class, classMessage);
    }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.Write("Введите своё имя: ");
            string name = Console.ReadLine();

            Console.WriteLine(ClassMessage.MethodGreeting(name));
            Console.ReadKey();
        }
コード例 #4
0
        public void RemoveNotExistingClassFromHero_ThrowsException_Test()
        {
            // Arrange
            var removeClassMessage = ClassMessage.CreateRemove(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act & Assert
            Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, removeClassMessage));
        }
コード例 #5
0
        public void RemoveClassFromUnknownHero_ThrowsException_Test()
        {
            // Arrange
            var removeClassMessage = ClassMessage.CreateRemove(_sequence.Next, Guid.NewGuid(), new[] { _warriorClass });

            // Act & Assert
            Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, removeClassMessage));
        }
コード例 #6
0
        public void AddClassToHeroTwice_ThrowsException_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });
            var addAnotherClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act & Assert
            _quest.AddMessage(_gameId, addClassMessage);
            Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, addAnotherClassMessage));
        }
コード例 #7
0
        public void AddClassToHero_ResultsInAddedClass_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act
            var game = _quest.AddMessage(_gameId, addClassMessage);

            // Assert
            Assert.Single(game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
            Assert.Contains(_warriorClass, game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
        }
コード例 #8
0
        public void AddClassToHero_ThenUndoIt_ResultsInNoChange_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act
            _quest.AddMessage(_gameId, addClassMessage);
            var game = _quest.Undo(_gameId);

            // Assert
            Assert.Empty(game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
        }
コード例 #9
0
        public async Task <ActionResult> Post([FromBody] ClassMessage value)
        {
            try
            {
                await db.ClassMessage.AddAsync(value);

                await db.SaveChangesAsync();

                return(Ok("添加成功"));
            }
            catch (Exception e) {
                return(BadRequest("添加失败,请求出错:" + e.InnerException.Message));
            }
        }
コード例 #10
0
        public async Task <ActionResult> Delete([FromBody] ClassMessage value)
        {
            try
            {
                db.ClassMessage.Remove(value);
                await db.SaveChangesAsync();

                return(Ok("删除成功"));
            }
            catch (Exception e)
            {
                return(BadRequest("删除失败,请求出错:" + e.Message));
            }
        }
コード例 #11
0
        public void AddClassToHero_ThenSwitchClasses_ResultsInSwitchedClass_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });
            var switchClassMessage = ClassMessage.Create(_sequence.Next, _playerId, new[] { _thiefClass }, new[] { _warriorClass });

            // Act
            _quest.AddMessage(_gameId, addClassMessage);
            var game = _quest.AddMessage(_gameId, switchClassMessage);

            // Assert
            Assert.Single(game.Score.Heroes.First().Classes);
            Assert.Equal(_thiefClass, game.Score.Heroes.First().Classes.First());
        }
コード例 #12
0
ファイル: Server.cs プロジェクト: mserier/vrar
    void OnServerGotClass(NetworkMessage netMsg)
    {
        var msg = netMsg.ReadMessage <ClassMessage>();

        players[netMsg.conn.connectionId].classType = (ClassType)msg.classType;

        dWin.Text(GetPlayerStats());

        // broadcast
        var classMessage = new ClassMessage();

        classMessage.id        = netMsg.conn.connectionId;
        classMessage.classType = msg.classType;
        NetworkServer.SendToAll(NetworkMessages.Class, classMessage);
    }
コード例 #13
0
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader)
    {
        ClassMessage message       = extraMessageReader.ReadMessage <ClassMessage>();
        GameObject   selectedClass = classes[message.chosenClass];

        Transform startPos = GetStartPosition();

        Vector3 pos = startPos != null ? startPos.position : Vector3.zero;

        GameObject player = Instantiate(selectedClass, pos, Quaternion.identity) as GameObject;

        player.GetComponent <UnitActions>().chosenClass = message.chosenClass;

        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
    }
コード例 #14
0
        public async Task <ActionResult> PutReply([FromBody] ClassMessage value)
        {
            try
            {
                var result = await db.ClassMessage.Where(s => s.ClassId == value.ClassId && s.MessageId == value.MessageId).FirstOrDefaultAsync();

                result.ReplyMessage = value.ReplyMessage;
                result.HasReply     = 1;
                await db.SaveChangesAsync();

                return(Ok("回复成功"));
            }
            catch (Exception e)
            {
                return(BadRequest("修改失败,请求出错:" + e.Message));
            }
        }
コード例 #15
0
 public static ClassMessageTO toTO(this ClassMessage classMessage)
 {
     return(new ClassMessageTO());
 }
コード例 #16
0
 public void SelectClass(int choice)
 {
     classMessage             = new ClassMessage();
     classMessage.chosenClass = choice;
     classSelected            = true;
 }