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); }
void SendClassMessage(int classType) { var classMessage = new ClassMessage(); classMessage.classType = classType; client.Send(NetworkMessages.Class, classMessage); }
static void Main(string[] args) { Console.Write("Введите своё имя: "); string name = Console.ReadLine(); Console.WriteLine(ClassMessage.MethodGreeting(name)); Console.ReadKey(); }
public void RemoveNotExistingClassFromHero_ThrowsException_Test() { // Arrange var removeClassMessage = ClassMessage.CreateRemove(_sequence.Next, _playerId, new[] { _warriorClass }); // Act & Assert Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, removeClassMessage)); }
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)); }
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)); }
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); }
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); }
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)); } }
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)); } }
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()); }
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); }
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); }
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)); } }
public static ClassMessageTO toTO(this ClassMessage classMessage) { return(new ClassMessageTO()); }
public void SelectClass(int choice) { classMessage = new ClassMessage(); classMessage.chosenClass = choice; classSelected = true; }