12121
This commit is contained in:
@@ -9,7 +9,7 @@ public static class GameConfig
|
|||||||
public const int SendChatGoodsService = 10002;//金海螺
|
public const int SendChatGoodsService = 10002;//金海螺
|
||||||
public const int UpLevAddWeight = 10;//升级增加负重
|
public const int UpLevAddWeight = 10;//升级增加负重
|
||||||
public const int GameBaseVigour = 50;//初始活力
|
public const int GameBaseVigour = 50;//初始活力
|
||||||
public const int GameRelationEnemyNeedGold = 300;//添加仇人所需金元
|
public const int GameRelationEnemyNeedGold = 100;//添加仇人所需金元
|
||||||
public const int GameUpdateNickNeedGoods = 10018;//更新昵称所需道具
|
public const int GameUpdateNickNeedGoods = 10018;//更新昵称所需道具
|
||||||
public const int GameUpdateSexNeedGoods = 10065;//更新性别所需道具
|
public const int GameUpdateSexNeedGoods = 10065;//更新性别所需道具
|
||||||
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
|
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public interface IUnitUserAttrService
|
|||||||
|
|
||||||
Task<unit_user_exp> GetUserExp(string userId);
|
Task<unit_user_exp> GetUserExp(string userId);
|
||||||
Task<bool> UpdateUserExp(string userId, long exp, int op = 1);
|
Task<bool> UpdateUserExp(string userId, long exp, int op = 1);
|
||||||
|
Task DeductUserExp(string userId, int type, long count);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 士气操作
|
#region 士气操作
|
||||||
|
|||||||
@@ -428,13 +428,27 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
|||||||
string noticeMsg =
|
string noticeMsg =
|
||||||
$"您在{cityInfo.cityName}·{mapInfo.mapName}被[{UbbTool.HomeUbb(winUserInfo.userNo, winUserInfo.nick)}]击杀!";
|
$"您在{cityInfo.cityName}·{mapInfo.mapName}被[{UbbTool.HomeUbb(winUserInfo.userNo, winUserInfo.nick)}]击杀!";
|
||||||
await chatService.SendChat(lowUser, (int)lowUserInfo.areaId, nameof(GameChatEnum.Code.Notice), noticeMsg);
|
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>();
|
var relationService = App.GetService<IUnitUserRelationService>();
|
||||||
if (await relationService.CheckUserEnemy(winUser, lowUser) == false)
|
if (await relationService.CheckUserEnemy(winUser, lowUser) == false)
|
||||||
{
|
{
|
||||||
var accService = App.GetService<IUnitUserAccService>();
|
if (mapInfo.isPk == 1)
|
||||||
await accService.UpdateUserData(winUser, 1, nameof(AccEnum.AccType.enemy), 5, "击杀玩家"); //加罪恶
|
{
|
||||||
|
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
|
#endregion
|
||||||
|
|
||||||
#region 称号加层
|
#region 称号加层
|
||||||
|
|
||||||
var maxNameService = App.GetService<IGameMaxNameService>();
|
var maxNameService = App.GetService<IGameMaxNameService>();
|
||||||
var userMaxName = await maxNameService.GetUserMaxNameData(userId);
|
var userMaxName = await maxNameService.GetUserMaxNameData(userId);
|
||||||
foreach (var maxName in userMaxName)
|
foreach (var maxName in userMaxName)
|
||||||
{
|
{
|
||||||
ExtendAttrData.AddRange(maxName.attr);
|
ExtendAttrData.AddRange(maxName.attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Buff加层
|
#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)
|
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == it.exp - exp)
|
||||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
.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 //增加经验
|
else //增加经验
|
||||||
{
|
{
|
||||||
var MyExp = await db.Queryable<unit_user_exp>().Where(it => it.userId == userId).SingleAsync();
|
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;
|
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 经验操作
|
#endregion 经验操作
|
||||||
|
|
||||||
#region 士气
|
#region 士气
|
||||||
|
|||||||
@@ -362,6 +362,12 @@ public class MapController : ControllerBase
|
|||||||
return PoAction.Message("城市不存在!");
|
return PoAction.Message("城市不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lev = await _attrService.GetUserLev(userId);
|
||||||
|
if (lev < 31)
|
||||||
|
{
|
||||||
|
return PoAction.Message("等级达到31级才可以传送哦!");
|
||||||
|
}
|
||||||
|
|
||||||
var userWeight = await _weightService.GetUserWeightInfo(userId);
|
var userWeight = await _weightService.GetUserWeightInfo(userId);
|
||||||
if (userWeight.shipOnWeight > 0)
|
if (userWeight.shipOnWeight > 0)
|
||||||
{
|
{
|
||||||
@@ -464,7 +470,12 @@ public class MapController : ControllerBase
|
|||||||
{
|
{
|
||||||
return PoAction.Message("城市不存在!");
|
return PoAction.Message("城市不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lev = await _attrService.GetUserLev(userId);
|
||||||
|
if (lev < 31)
|
||||||
|
{
|
||||||
|
return PoAction.Message("等级达到31级才可以出海哦!");
|
||||||
|
}
|
||||||
|
|
||||||
var onMapInfo = await _mapService.GetMapInfo(onMap.mapId);
|
var onMapInfo = await _mapService.GetMapInfo(onMap.mapId);
|
||||||
if (onMapInfo.cityId == cityId)
|
if (onMapInfo.cityId == cityId)
|
||||||
|
|||||||
@@ -15,14 +15,18 @@ public class RelationController : ControllerBase
|
|||||||
private readonly IUnitUserService _userService;
|
private readonly IUnitUserService _userService;
|
||||||
private readonly IMessageService _messageService;
|
private readonly IMessageService _messageService;
|
||||||
private readonly IUnitUserAccService _accService;
|
private readonly IUnitUserAccService _accService;
|
||||||
|
private readonly IUnitUserAttrService _attrService;
|
||||||
|
private readonly IGameChatService _chatService;
|
||||||
|
|
||||||
public RelationController(IUnitUserRelationService relationService, IUnitUserService userService,
|
public RelationController(IUnitUserRelationService relationService, IUnitUserService userService,
|
||||||
IMessageService messageService, IUnitUserAccService accService)
|
IMessageService messageService, IUnitUserAccService accService,IUnitUserAttrService attrService,IGameChatService chatService)
|
||||||
{
|
{
|
||||||
_relationService = relationService;
|
_relationService = relationService;
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_messageService = messageService;
|
_messageService = messageService;
|
||||||
_accService = accService;
|
_accService = accService;
|
||||||
|
_attrService = attrService;
|
||||||
|
_chatService = chatService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -218,17 +222,37 @@ public class RelationController : ControllerBase
|
|||||||
return PoAction.Message("已经是仇人啦,无需重复添加!");
|
return PoAction.Message("已经是仇人啦,无需重复添加!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int needGold = GameConfig.GameRelationEnemyNeedGold;
|
||||||
|
int lev = await _attrService.GetUserLev(userInfo.userId);
|
||||||
|
if (lev <= 30)
|
||||||
|
{
|
||||||
|
return PoAction.Message("对方不大于30级无法添加加为仇人!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lev > 120 && lev <= 220)
|
||||||
|
{
|
||||||
|
needGold = needGold * 3;
|
||||||
|
}
|
||||||
|
else if (lev > 220)
|
||||||
|
{
|
||||||
|
needGold = needGold * 5;
|
||||||
|
}
|
||||||
|
|
||||||
var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold));
|
var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold));
|
||||||
if (myAcc < GameConfig.GameRelationEnemyNeedGold)
|
if (myAcc < needGold)
|
||||||
{
|
{
|
||||||
return PoAction.Message("您的金元不足!");
|
return PoAction.Message("您的金元不足!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await _accService.UpdateUserAcc(userId, 0, nameof(AccEnum.AccType.gold),
|
if (await _accService.UpdateUserAcc(userId, 0, nameof(AccEnum.AccType.gold),
|
||||||
GameConfig.GameRelationEnemyNeedGold, nameof(AccEnum.Name.其他), "添加仇人"))
|
needGold, nameof(AccEnum.Name.其他), "添加仇人"))
|
||||||
{
|
{
|
||||||
if (await _relationService.AddUserEnemy(userId, userInfo.userId))
|
if (await _relationService.AddUserEnemy(userId, userInfo.userId))
|
||||||
{
|
{
|
||||||
|
var myInfo = await _userService.GetUserInfoByUserId(userId);
|
||||||
|
string msg = $"请注意,您已被[{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)}]添加为仇人,被对方击杀将会受到严重惩罚!";
|
||||||
|
await _chatService.SendChat(userInfo.userId, (int)userInfo.areaId, nameof(GameChatEnum.Code.Notice), msg);
|
||||||
|
|
||||||
return PoAction.Ok(true, "仇人添加成功!");
|
return PoAction.Ok(true, "仇人添加成功!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ const FriendHandle = async (): Promise<void> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AddEnemy = async (): Promise<void> => {
|
const AddEnemy = async (): Promise<void> => {
|
||||||
MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要添加Ta为仇人吗?(添加消耗300金元)`, async () => {
|
MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要添加Ta为仇人吗?(添加仇人将会消耗金元:1-120级需要100金元,120-220级需要300金元,220级以上需要500金元)`, async () => {
|
||||||
let no = PageExtend.QueryString("no");
|
let no = PageExtend.QueryString("no");
|
||||||
let result = await RelationService.AddEnemy(no);
|
let result = await RelationService.AddEnemy(no);
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user