59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
namespace Application.Domain;
|
|
|
|
public static class UserStateTool
|
|
{
|
|
public static async Task<bool> CheckUserFight(string userId)
|
|
{
|
|
var fightService = App.GetService<IGameFightService>();
|
|
var myFight = await fightService.GetUserFight(userId);
|
|
return myFight.Count > 0;
|
|
}
|
|
|
|
public static async Task SetUserMapDefault(string userId)
|
|
{
|
|
var mapService = App.GetService<IGameMapService>();
|
|
await mapService.SetUserMapDefault(userId);
|
|
}
|
|
|
|
public static async Task<bool> CheckPkState(string userId, string otId, bool isEnemy, bool isAtArea)
|
|
{
|
|
bool result = true;
|
|
var _mapService = App.GetService<IGameMapService>();
|
|
var onMapInfo = await _mapService.GetUserOnToMapInfo(userId);
|
|
if (onMapInfo.isPk == 0)
|
|
{
|
|
if (onMapInfo.retMap != onMapInfo.mapId)
|
|
{
|
|
if (isEnemy == false)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
var otUserOnMap = await _mapService.GetUserOnMapInfo(otId);
|
|
if (onMapInfo.mapId != otUserOnMap.mapId)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (otUserOnMap.isOnline == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (onMapInfo.lookArea == 1)
|
|
{
|
|
if (isAtArea == false)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
} |