12121
This commit is contained in:
@@ -13,9 +13,9 @@ public interface IGameFightService
|
||||
Task RemoveFightHarm(string fightId, string userId);
|
||||
Task<bool> AddFight(string fightId, string areaCode, string keyId, string mainId, string code,
|
||||
string scene, string mapId,
|
||||
string userId, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = "");
|
||||
string userId,long dueTime, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = "");
|
||||
|
||||
Task<bool> SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true);
|
||||
Task<bool> SetFightWin(game_fight_data fightData, string winUser, bool setDefMap=true);
|
||||
Task HandleFightData();
|
||||
|
||||
#endregion
|
||||
@@ -29,6 +29,7 @@ public interface IGameFightService
|
||||
Task RemoveFightGoods(string mapId, string mgId);
|
||||
Task AutoUseDrug(UserAttrModel user, game_fight_data fight);
|
||||
Task HandelFightEnd(string userId, List<FightRemoveData> data);
|
||||
Task<bool> ValidFight(game_fight_data fight, bool isBlack = true);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public interface IUnitUserService
|
||||
Task<bool> UpdateUserNick(string userId, string nick);
|
||||
Task<bool> UpdateUserSex(string userId, string sex);
|
||||
Task<bool> UpdateUserSign(string userId, string sign);
|
||||
Task<bool> BlackUser(string userId);
|
||||
#endregion
|
||||
|
||||
#region 用户注册
|
||||
|
||||
@@ -94,7 +94,8 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
|
||||
public async Task<bool> AddFight(string fightId, string areaCode, string keyId, string mainId, string code,
|
||||
string scene, string mapId,
|
||||
string userId, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = "")
|
||||
string userId, long dueTime, long exp = 0, long copper = 0, long petExp = 0, string award = "",
|
||||
string pars = "")
|
||||
{
|
||||
long addTime = TimeExtend.GetTimeStampMilliseconds;
|
||||
long endTime = TimeExtend.GetTimeStampSeconds + 24 * 60 * 60;
|
||||
@@ -118,6 +119,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
petExp = petExp,
|
||||
award = award,
|
||||
pars = pars,
|
||||
dueTime = dueTime,
|
||||
addTime = addTime,
|
||||
okTime = 0,
|
||||
endTime = endTime
|
||||
@@ -161,6 +163,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> SetFightWin(game_fight_data fightData, string winUser, bool setDefMap = true)
|
||||
{
|
||||
bool result = false;
|
||||
@@ -379,6 +382,11 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
|
||||
public async Task HandleFight(game_fight_data fightData)
|
||||
{
|
||||
if (await ValidFight(fightData) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string winUser = fightData.winUser;
|
||||
string lowUser = fightData.userId == winUser ? fightData.mainId : fightData.userId;
|
||||
|
||||
@@ -448,7 +456,6 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
await attrService.DeductUserExp(lowUser, 1, 1); //扣除1级
|
||||
//设置回威尼斯
|
||||
await mapService.UpdateUserOnMap(lowUser, "15_27");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,5 +702,26 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<bool> ValidFight(game_fight_data fight, bool isBlack = true)
|
||||
{
|
||||
bool result = true;
|
||||
if (fight.dueTime > 0)
|
||||
{
|
||||
int diffTime = Convert.ToInt32(fight.okTime - fight.addTime);
|
||||
if (diffTime < 3000)
|
||||
{
|
||||
result = diffTime >= fight.dueTime;
|
||||
if (result == false && isBlack) //异常处理
|
||||
{
|
||||
//封禁账号
|
||||
var userService = App.GetService<IUnitUserService>();
|
||||
await userService.BlackUser(fight.userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace Application.Domain;
|
||||
|
||||
public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserService, ITransient
|
||||
{
|
||||
|
||||
#region 用户信息
|
||||
|
||||
public async Task<List<unit_user>> GetUserDataByAccId(string accId)
|
||||
@@ -101,6 +100,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserSex(string userId, string sex)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
|
||||
@@ -113,6 +113,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserSign(string userId, string sign)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
|
||||
@@ -126,6 +127,21 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> BlackUser(string userId)
|
||||
{
|
||||
string newToken = await GetToken();
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
|
||||
bool result = await db.Updateable<unit_user>().SetColumns(it => it.status == 0)
|
||||
.SetColumns(it => it.token == newToken)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserInfo(0, userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 用户注册
|
||||
@@ -186,7 +202,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
acc.cowry = 0;
|
||||
acc.gold = 0;
|
||||
db.Insertable(acc).AddQueue();
|
||||
|
||||
|
||||
unit_user_data userData = new unit_user_data();
|
||||
userData.userId = userId;
|
||||
userData.teach = 0;
|
||||
@@ -204,7 +220,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
unit_user_attr userAttr = GameTool.GetAttrData(1);
|
||||
userAttr.userId = userId;
|
||||
db.Insertable(userAttr).AddQueue();
|
||||
|
||||
|
||||
//注册配置
|
||||
unit_user_config config = new unit_user_config();
|
||||
config.userId = userId;
|
||||
@@ -261,7 +277,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
onlineTime.monthTime = 0;
|
||||
onlineTime.totalTime = 0;
|
||||
db.Insertable(onlineTime).AddQueue();
|
||||
|
||||
|
||||
//注册队伍
|
||||
unit_user_team team = new unit_user_team();
|
||||
team.userId = userId;
|
||||
@@ -271,9 +287,8 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
await db.SaveQueuesAsync(false);
|
||||
}
|
||||
|
||||
if (result)//注册各项后处理
|
||||
if (result) //注册各项后处理
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -330,7 +345,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
|
||||
#endregion
|
||||
|
||||
#region 权限配置
|
||||
#region 权限配置
|
||||
|
||||
public async Task<unit_user_config> GetUserConfigInfo(string userId)
|
||||
{
|
||||
@@ -370,8 +385,8 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
case "MsgRole":
|
||||
result = (int)config.msgRole;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -400,6 +415,5 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user