public async Task <bool> RemovePlayer(ulong target) { AccountDto account; using (var db = AuthDatabase.Open()) { account = (await DbUtil.FindAsync <AccountDto>(db, statement => statement .Include <BanDto>(join => join.LeftOuterJoin()) .Where($"{nameof(AccountDto.Id):C} = @Id") .WithParameters(new { Id = target })) ).FirstOrDefault(); if (account == null) { return(false); } } using (var db = GameDatabase.Open()) { var clubPlrDto = new ClubPlayerDto { PlayerId = account.Id, ClubId = Id }; DbUtil.Delete(db, clubPlrDto); } var player = GameServer.Instance.PlayerManager[target]; Players.Remove(target, out _); if (player != null) { LogOff(player); player.Club = null; await player.Session.SendAsync(new ClubMyInfoAckMessage(player.Map <Player, ClubMyInfoDto>())); } CheckMaster(); return(true); }
public bool Remove(ulong friendId, Player plr) { var friend = _friends[friendId]; if (friend == null) { return(false); } _friends.Remove(friendId); if (plr != null) { plr.FriendManager._friends.Remove(Player.Account.Id); } using (var db = GameDatabase.Open()) { var dbFriend = DbUtil.Find <PlayerFriendDto>(db, statement => statement .Where( $"{nameof(PlayerFriendDto.PlayerId):C} = @PlayerId AND {nameof(PlayerFriendDto.FriendId):C} = @FriendId") .WithParameters(new { PlayerId = Player.Account.Id, FriendId = friendId })).FirstOrDefault(); if (dbFriend == null) { dbFriend = DbUtil.Find <PlayerFriendDto>(db, statement => statement .Where( $"{nameof(PlayerFriendDto.PlayerId):C} = @PlayerId AND {nameof(PlayerFriendDto.FriendId):C} = @FriendId") .WithParameters(new { PlayerId = friendId, FriendId = Player.Account.Id })).FirstOrDefault(); } if (dbFriend == null) { throw new Exception("db and server are de-synced!"); } DbUtil.Delete(db, dbFriend); } return(true); }