public async Task <bool> OnHandle(MessageContext context, CBeginRoundReqMessage message) { var session = context.GetSession <Session>(); var plr = session.Player; var room = plr.Room; if (!_equipValidator.IsValid(plr.CharacterManager.CurrentCharacter)) { session.Send(new SServerResultInfoAckMessage(ServerResult.WearingUnusableItem)); return(true); } if (!room.GameRule.StateMachine.StartGame()) { session.Send(new SEventMessageAckMessage(GameEventMessage.CantStartGame, 0, 0, 0, "")); } return(true); }
public async Task <bool> OnHandle(MessageContext context, CSelectCharacterReqMessage message) { var session = context.GetSession <Session>(); var plr = session.Player; // Prevents player from changing characters while playing if (plr.Room != null && plr.State != PlayerState.Lobby && plr.Room.GameRule.StateMachine.TimeState != GameTimeState.HalfTime) { session.Send(new SServerResultInfoAckMessage(ServerResult.SelectCharacterFailed)); return(true); } // Cant switch characters when ready if (plr.Room != null && plr.IsReady) { session.Send(new SServerResultInfoAckMessage(ServerResult.SelectCharacterFailed)); return(true); } // Validate equip if (plr.Room != null && plr.State != PlayerState.Lobby && plr.Room.GameRule.StateMachine.TimeState == GameTimeState.HalfTime) { var character = plr.CharacterManager[message.Slot]; if (character != null && !_equipValidator.IsValid(character)) { session.Send(new SServerResultInfoAckMessage(ServerResult.WearingUnusableItem)); return(true); } } if (!plr.CharacterManager.Select(message.Slot)) { session.Send(new SServerResultInfoAckMessage(ServerResult.SelectCharacterFailed)); } return(true); }