12121
This commit is contained in:
@@ -9,7 +9,7 @@ public static class GameConfig
|
||||
public const int SendChatGoodsService = 10002;//金海螺
|
||||
public const int UpLevAddWeight = 10;//升级增加负重
|
||||
public const int GameBaseVigour = 50;//初始活力
|
||||
public const int GameRelationEnemyNeedGold = 300;//添加仇人所需金元
|
||||
public const int GameRelationEnemyNeedGold = 100;//添加仇人所需金元
|
||||
public const int GameUpdateNickNeedGoods = 10018;//更新昵称所需道具
|
||||
public const int GameUpdateSexNeedGoods = 10065;//更新性别所需道具
|
||||
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface IUnitUserAttrService
|
||||
|
||||
Task<unit_user_exp> GetUserExp(string userId);
|
||||
Task<bool> UpdateUserExp(string userId, long exp, int op = 1);
|
||||
|
||||
Task DeductUserExp(string userId, int type, long count);
|
||||
#endregion
|
||||
|
||||
#region 士气操作
|
||||
|
||||
@@ -428,13 +428,27 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
string noticeMsg =
|
||||
$"您在{cityInfo.cityName}·{mapInfo.mapName}被[{UbbTool.HomeUbb(winUserInfo.userNo, winUserInfo.nick)}]击杀!";
|
||||
await chatService.SendChat(lowUser, (int)lowUserInfo.areaId, nameof(GameChatEnum.Code.Notice), noticeMsg);
|
||||
if (mapInfo.isPk == 1 && fightData.userId == winUser && fightData.scene == nameof(MapEnum.MapCode.DEF_MAP))
|
||||
|
||||
if (fightData.userId == winUser && fightData.scene == nameof(MapEnum.MapCode.DEF_MAP))
|
||||
{
|
||||
var relationService = App.GetService<IUnitUserRelationService>();
|
||||
if (await relationService.CheckUserEnemy(winUser, lowUser) == false)
|
||||
{
|
||||
var accService = App.GetService<IUnitUserAccService>();
|
||||
await accService.UpdateUserData(winUser, 1, nameof(AccEnum.AccType.enemy), 5, "击杀玩家"); //加罪恶
|
||||
if (mapInfo.isPk == 1)
|
||||
{
|
||||
var accService = App.GetService<IUnitUserAccService>();
|
||||
await accService.UpdateUserData(winUser, 1, nameof(AccEnum.AccType.enemy), 5,
|
||||
"击杀玩家"); //加罪恶
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//执行扣除经验
|
||||
var attrService = App.GetService<IUnitUserAttrService>();
|
||||
await attrService.DeductUserExp(lowUser, 1, 1); //扣除1级
|
||||
//设置回威尼斯
|
||||
await mapService.UpdateUserOnMap(lowUser, "15_27");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,15 +83,16 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
|
||||
#endregion
|
||||
|
||||
#region 称号加层
|
||||
#region 称号加层
|
||||
|
||||
var maxNameService = App.GetService<IGameMaxNameService>();
|
||||
var userMaxName = await maxNameService.GetUserMaxNameData(userId);
|
||||
foreach (var maxName in userMaxName)
|
||||
{
|
||||
ExtendAttrData.AddRange(maxName.attr);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Buff加层
|
||||
@@ -294,6 +295,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == it.exp - exp)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
else if (op == 2) //固定经验
|
||||
{
|
||||
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == exp)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
else //增加经验
|
||||
{
|
||||
var MyExp = await db.Queryable<unit_user_exp>().Where(it => it.userId == userId).SingleAsync();
|
||||
@@ -354,6 +360,82 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task DeductUserExp(string userId, int type, long count)
|
||||
{
|
||||
bool result = false;
|
||||
var userAttr = await GetUserAttr(userId);
|
||||
int OnLev = (int)userAttr.lev;
|
||||
if (OnLev <= 30)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var userExp = await GetUserExp(userId);
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_exp>();
|
||||
if (type == 0) //扣除经验
|
||||
{
|
||||
long sumExp = (long)userExp.exp;
|
||||
while (count > 0 && OnLev > 30)
|
||||
{
|
||||
if (sumExp >= count)
|
||||
{
|
||||
count = 0;
|
||||
sumExp = sumExp - count;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnLev -= 1;
|
||||
sumExp += GameTool.GetUserUpExp(OnLev);
|
||||
}
|
||||
}
|
||||
|
||||
if (OnLev == 30)
|
||||
{
|
||||
sumExp = 0;
|
||||
}
|
||||
var data = GameTool.GetAttrData(OnLev);
|
||||
result = await db.Updateable<unit_user_attr>(data).Where(i => i.userId == userId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await UpdateUserExp(userId, sumExp, 2);
|
||||
await ClearUserAttrCache(userId);
|
||||
}
|
||||
|
||||
}
|
||||
else if(type==1) //扣除等级
|
||||
{
|
||||
OnLev -= Convert.ToInt32(count);
|
||||
var data = GameTool.GetAttrData(OnLev);
|
||||
result = await db.Updateable<unit_user_attr>(data).Where(i => i.userId == userId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
if (userExp.exp > 0)
|
||||
{
|
||||
await UpdateUserExp(userId, 0, 2);
|
||||
}
|
||||
|
||||
await ClearUserAttrCache(userId);
|
||||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
//下装备
|
||||
var equService = App.GetService<IGameEquService>();
|
||||
var onEqu = await equService.GetUserOnEqu(userId);
|
||||
onEqu = onEqu.FindAll(it => it.lev > OnLev);
|
||||
if (onEqu.Count > 0)
|
||||
{
|
||||
foreach (var item in onEqu)
|
||||
{
|
||||
await equService.EquOnOrDown(item, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 经验操作
|
||||
|
||||
#region 士气
|
||||
|
||||
Reference in New Issue
Block a user