using System.Collections.Generic;
using System.Linq;
namespace ET.Server
{
///
/// Proto工具类
///
public static class ProtoHelper
{
///
/// 玩家信息转proto
///
///
///
public static PlayerInfo PlayerToProto(Player player)
{
return new PlayerInfo()
{
id = player.Id,
name = player.Name,
sex = player.Sex,
exp = player.Exp,
level = player.Level,
vip = 0
};
}
///
/// 房间信息转proto
///
///
///
public static RoomInfo RoomToProto(Room room)
{
RoomInfo info = new RoomInfo();
info.RoomId = room.RoomId;
info.Type = room.Type;
info.OwnerId = room.OwnerId;
info.PlayerList = new List();
foreach (Player p in room.Players.Where(p => p != null))
{
info.PlayerList.Add(ProtoHelper.PlayerToProto(p));
}
return info;
}
}
}