This commit is contained in:
Putoo
2026-07-08 19:13:55 +08:00
parent 5d0ebe5077
commit fe2696074b
59 changed files with 1448 additions and 112 deletions

View File

@@ -23,17 +23,6 @@ namespace Application.Domain.Entity
/// </summary>
[SugarColumn(IsNullable = true)]
public long? gold { get; set; }
/// <summary>
/// 师德
/// </summary>
[SugarColumn(IsNullable = true)]
public long? teach { get; set; }
/// <summary>
/// 声望
/// </summary>
[SugarColumn(IsNullable = true)]
public long? renown { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_data
{
/// <summary>
/// userId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string userId { get; set; }
/// <summary>
/// 师德
/// </summary>
[SugarColumn(IsNullable = true)]
public long? teach { get; set; }
/// <summary>
/// 声望
/// </summary>
[SugarColumn(IsNullable = true)]
public long? renown { get; set; }
/// <summary>
/// 罪恶值
/// </summary>
[SugarColumn(IsNullable = true)]
public long? enemy { get; set; }
/// <summary>
/// 魅力
/// </summary>
[SugarColumn(IsNullable = true)]
public long? charm { get; set; }
}
}

View File

@@ -0,0 +1,75 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_temp
{
/// <summary>
/// userId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string userId { get; set; }
/// <summary>
/// areaId
/// </summary>
[SugarColumn(IsNullable = true)]
public int? areaId { get; set; }
/// <summary>
/// lev
/// </summary>
[SugarColumn(IsNullable = true)]
public int? lev { get; set; }
/// <summary>
/// 等级更新时间
/// </summary>
[SugarColumn(IsNullable = true)]
public long? upTime { get; set; }
/// <summary>
/// 人品
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? luck { get; set; }
/// <summary>
/// 评分
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? score { get; set; }
/// <summary>
/// 攻击
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? atk { get; set; }
/// <summary>
/// 防御
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? defense { get; set; }
/// <summary>
/// 敏捷
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? agility { get; set; }
/// <summary>
/// 体力
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? upBlood { get; set; }
/// <summary>
/// 士气
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? upMorale { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Application.Domain.Entity;
public class FightRemoveData
{
public string code { get; set; }
public string par { get; set; }
public int count { get; set; }
}

View File

@@ -6,7 +6,7 @@ public class FightResultModel
public int myHarm { get; set; }
public int otHarm { get; set; }
public List<string> myStateData { get; set; }
public List<dynamic> myRemData { get; set; }
public List<FightRemoveData> myRemData { get; set; }
public List<string> otStateData { get; set; }
public List<dynamic> otRemData { get; set; }
public List<FightRemoveData> otRemData { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace Application.Domain.Entity;
public class GameRankModel
{
public string userId { get; set; }
public UserModel user { get; set; }
public string sign { get; set; }
public string par { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace Application.Domain.Entity;
public class OnHookAwardModel
{
public string userId { get; set; }
public long exp { get; set; }
public long copper { get; set; }
public long useTime { get; set; }
public List<TowerGet> award { get; set; }
}

View File

@@ -17,6 +17,7 @@
public decimal luck { get; set; }//幸运
public int weight { get; set; }//负重
public int lev { get; set; }//等级
public long upTime { get; set; }
public int minAtk { get; set; }//最小攻击
public int maxAtk { get; set; }//最大攻击
public int defense { get; set; }//防御

View File

@@ -10,8 +10,15 @@ namespace Application.Domain
{
public enum BusEventsName
{
HandleOnHook,//处理挂机
PutFightAward,//战斗奖励事件
PutOnHookAward,//发放挂机奖励
HandleOnHook,//处理挂机
HandleUpdateRank,//更新排名
HandleOnlineTime,//处理在线时间
HandleCreateMonster,//处理创建的怪物
HandleFightData,//处理战斗日志数据
HandleExchangeData,//处理兑换数据
}
}
}

View File

@@ -3,22 +3,87 @@
public class BusEventsSubscriber : IEventSubscriber
{
/// <summary>
/// 处理贡献提成
/// 处理战斗结束相关(含奖励发放)
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.PutFightAward, NumRetries = 0)]
public async Task HandleQueueBonus(EventHandlerExecutingContext context)
[EventSubscribe(BusEventsEnum.BusEventsName.PutFightAward, NumRetries = 0,RetryTimeout = 999999999)]
public async Task PutFightAward(EventHandlerExecutingContext context)
{
var data = context.GetPayload<game_fight_data>();
var fightService = App.GetService<IGameFightService>();
await fightService.HandleFight(data);
}
/// <summary>
/// 发放挂机奖励
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.PutOnHookAward, NumRetries = 0,RetryTimeout = 999999999)]
public async Task PutOnHookAward(EventHandlerExecutingContext context)
{
var data = context.GetPayload<OnHookAwardModel>();
var hookService = App.GetService<IOnHookService>();
await hookService.HandleOnHookGoods(data);
}
/// <summary>
/// 处理挂机
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.HandleOnHook, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleOnHook(EventHandlerExecutingContext context)
{
var hookService = App.GetService<IOnHookService>();
await hookService.HandleHook();
}
/// <summary>
/// 处理排行榜
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.HandleUpdateRank, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleUpdateRank(EventHandlerExecutingContext context)
{
var rankService = App.GetService<IRankService>();
await rankService.HandleRank();
}
/// <summary>
/// 处理在线时间
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.HandleOnlineTime, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleOnlineTime(EventHandlerExecutingContext context)
{
var attrService = App.GetService<IUnitUserAttrService>();
await attrService.HandleOnLineTimeData();
}
/// <summary>
/// 处理生成的怪物
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.HandleCreateMonster, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleCreateMonster(EventHandlerExecutingContext context)
{
var monsterService = App.GetService<IGameMonsterService>();
await monsterService.HandleCreateMonster();
}
/// <summary>
/// 处理战斗日志记录
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.HandleFightData, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleFightData(EventHandlerExecutingContext context)
{
var fightService = App.GetService<IGameFightService>();
await fightService.HandleFightData();
}
/// <summary>
/// 处理兑换记录
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.HandleExchangeData, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleExchangeData(EventHandlerExecutingContext context)
{
var exchangeService = App.GetService<IExchangeService>();
await exchangeService.HandleExchangeLogData();
}
}
}

View File

@@ -10,7 +10,7 @@ public static class AccEnum
teach,//师德
renown,//声望
charm,//魅力
evil,//罪恶值
enemy,//罪恶值
}
public enum Name
{

View File

@@ -9,6 +9,7 @@ public static class GameChatEnum
Team,//队伍
Region,//全区
Dress,//全服
System//系统
System,//系统
Notice,//通知
}
}

View File

@@ -10,6 +10,11 @@ public static class GameEnum
public enum JobCode
{
OnHook,//定时任务
UpdateRank,//更新排名
UpdateOnlineTime,//更新在线时间
UpdateCreateMonster,//更新创建得怪物
UpdateFightData,//更新战斗信息
UpdateExchangeData,//更新兑换的记录
}
public enum PropCode//游戏资源编码
{

View File

@@ -20,6 +20,7 @@ public static class GoodsEnum
State,//状态物品
Ship,//船只
Practise,//修炼道具
Durability,//负重道具
}
public enum DrugCls

View File

@@ -7,6 +7,7 @@ public static class MessageEnum
Friend,//交友消息
Marry,//婚姻消息
Trade,//交易通知
Notice,//普通通知
}
public enum BroadcastCode
{

View File

@@ -49,6 +49,10 @@ public class MessageHandle
{
return new MessageHandleResult() { success = true, msg = "消息通知已处理!" };
}
else if (events.code == nameof(MessageEnum.EventCode.Notice))
{
return new MessageHandleResult() { success = true, msg = "消息通知已处理!" };
}
return new MessageHandleResult() { success = false, msg = "暂不支持该操作处理!" };
}

View File

@@ -6,4 +6,5 @@ public interface IExchangeService
Task<game_exchange> GetExchangeInfo(int exId);
Task<int> GetExchangeCount(string userId, int exId);
Task<bool> AddUserExchangeLog(string userId, int exId, int count, long endTime);
Task HandleExchangeLogData();
}

View File

@@ -9,4 +9,5 @@ public interface IOnHookService
Task<bool> StopOnHook(string userId);
Task HandleHook();
Task HandleOnHookGoods(OnHookAwardModel data);
}

View File

@@ -0,0 +1,10 @@
namespace Application.Domain;
public interface IRankService
{
Task<string> GetRankUpdateTime();
Task<List<GameRankModel>> GetGameRank(int type, int area, int page, int limit, RefAsync<int> total);
Task<List<GameRankModel>> GetGameCopperRank(int area, int page, int limit, RefAsync<int> total);
Task<List<GameRankModel>> GetGameTeachAndRenownRank(int type, int area, int page, int limit, RefAsync<int> total);
Task HandleRank();
}

View File

@@ -14,6 +14,7 @@ public interface IGameEquService
Task<List<unit_user_equ>> GetUserEquData(string userId, int type, string equName, int PageIndex, int PageSize,
RefAsync<int> Total, bool isRemOn = false, bool isRemLock = false);
Task<List<unit_user_equ>> GetUserEquData(string userId, string query);
Task<List<unit_user_equ>> GetUserEquData(string userId, int equId);
Task<List<unit_user_equ>> GetUserEquData(string userId, string code, List<string> noUeId);
Task<unit_user_equ> GetUserEquInfo(string ueId);
@@ -62,6 +63,13 @@ public interface IGameEquService
Task<int> GetUserEquWeightSum(string userId);
Task<game_equ_make> GetMakeEquByGoodsId(int goodsId);
Task RemoveUserOnEqu(string userId, string type, int count);
#endregion
#region
Task UpdateUserOnEquDurability(string userId);
#endregion
}

View File

@@ -16,7 +16,7 @@ public interface IGameFightService
string userId, 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 HandleFightData();
#endregion
#region
@@ -28,7 +28,7 @@ public interface IGameFightService
Task<game_map_goods> GetFightGoodsInfo(string mapId, string mgId);
Task RemoveFightGoods(string mapId, string mgId);
Task AutoUseDrug(UserAttrModel user, game_fight_data fight);
Task HandelFightEnd(string userId, List<dynamic> data);
Task HandelFightEnd(string userId, List<FightRemoveData> data);
#endregion
}

View File

@@ -20,6 +20,7 @@ public interface IGameMapService
Task<string> GetUserOnMapId(string userId);
Task<game_city_map> GetUserOnToMapInfo(string userId);
Task<unit_user_online> GetUserOnMap(string userId);
Task UpdateUserOnMap(string userId);
Task UpdateUserOnMap(string userId, string ip, string mapId);
Task<bool> UpdateUserOnMap(unit_user_online data, string mapId);
Task<UserOnMap> GetUserOnMapInfo(string userId);

View File

@@ -14,8 +14,11 @@ public interface IGameMonsterService
int count = 1, int time = 0, string par = "");
Task<unit_user_monster> GetCreateMonsterInfo(string umId);
Task<bool> RemoveCreateMonster(string umId);
Task<bool> RemoveCreateMonster(unit_user_monster data);
Task HandleCreateMonster();
Task<List<MapMonsterModel>> GetMapMonster(string userId, string mapId, string teamId);
#endregion
#region

View File

@@ -16,6 +16,8 @@ public interface IUnitUserAccService
Task<unit_user_copper> GetUserCopperInfo(string userId);
Task<bool> UpdateUserCopper(string userId, int type, long count, string remark = "");
Task<unit_user_data> GetUserDataInfo(string userId);
Task<bool> UpdateUserData(string userId, int type, string accType, long count, string remark = "");
#endregion
}

View File

@@ -44,7 +44,7 @@ public interface IUnitUserAttrService
#region 线
Task<bool> UpdateOnLineTime(string userId, string code, int time);
Task HandleOnLineTimeData();
#endregion
#region

View File

@@ -17,14 +17,12 @@ public class ExchangeService(ISqlSugarClient DbClient, IRedisCache redis) : IExc
public async Task<int> GetExchangeCount(string userId, int exId)
{
int result = 0;
string key = $"{userId}_{exId}";
var db = DbClient.AsTenant().GetConnectionWithAttr<game_exchange_log>();
return await db.Queryable<game_exchange_log>().Where(it => it.userId == userId && it.exId == exId)
.SumAsync(it => (int)it.count);
}
public async Task<bool> AddUserExchangeLog(string userId, int exId, int count,long endTime)
public async Task<bool> AddUserExchangeLog(string userId, int exId, int count, long endTime)
{
game_exchange_log log = new game_exchange_log();
log.ueId = StringAssist.NewGuid;
@@ -38,4 +36,11 @@ public class ExchangeService(ISqlSugarClient DbClient, IRedisCache redis) : IExc
return result;
}
public async Task HandleExchangeLogData()
{
var db = DbClient.AsTenant().GetConnectionWithAttr<game_exchange_log>();
await db.Deleteable<game_exchange_log>().Where(it => it.endTime <= TimeExtend.GetTimeStampSeconds)
.ExecuteCommandAsync();
}
}

View File

@@ -2,7 +2,8 @@
namespace Application.Domain;
public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis,ITimerJobManager jobManager) : IGameAutoJobService, ITransient
public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis, ITimerJobManager jobManager)
: IGameAutoJobService, ITransient
{
public async Task<List<game_job>> GetJobData()
{
@@ -12,11 +13,12 @@ public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis,ITim
public async Task<game_job> GetJobInfo(string jobId)
{
string key = string.Format(BaseCache.BaseCacheKey,"JobData");
string key = string.Format(BaseCache.BaseCacheKey, "JobData");
if (await redis.HExistsHashAsync(key, jobId))
{
return await redis.GetHashAsync<game_job>(key, jobId);
}
var db = DbClient.AsTenant().GetConnectionWithAttr<game_job>();
var data = await db.Queryable<game_job>().Where(it => it.jobId == jobId).SingleAsync();
await redis.AddHashAsync(key, jobId, data);
@@ -53,12 +55,41 @@ public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis,ITim
public async Task HandleJob(game_job data)
{
if (data.code == nameof(GameEnum.JobCode.OnHook))//挂机
if (data.code == nameof(GameEnum.JobCode.OnHook)) //挂机
{
var _eventPublisher = App.GetService<IEventPublisher>();
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleOnHook,
data));
}
else if (data.code == nameof(GameEnum.JobCode.UpdateRank)) //更新排名
{
var _eventPublisher = App.GetService<IEventPublisher>();
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleUpdateRank,
data));
}
else if (data.code == nameof(GameEnum.JobCode.UpdateOnlineTime)) //更新在线时间
{
var _eventPublisher = App.GetService<IEventPublisher>();
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleOnlineTime,
data));
}
else if (data.code == nameof(GameEnum.JobCode.UpdateCreateMonster)) //更新创建得怪物
{
var _eventPublisher = App.GetService<IEventPublisher>();
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleCreateMonster,
data));
}
else if (data.code == nameof(GameEnum.JobCode.UpdateFightData)) //更新战斗记录
{
var _eventPublisher = App.GetService<IEventPublisher>();
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleFightData,
data));
}
else if (data.code == nameof(GameEnum.JobCode.UpdateExchangeData)) //更新兑换类记录
{
var _eventPublisher = App.GetService<IEventPublisher>();
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleExchangeData,
data));
}
}
}

View File

@@ -111,8 +111,9 @@ public class OnHookService(ISqlSugarClient DbClient, IRedisCache redis) : IOnHoo
public async Task HandleHook()
{
long onTime = TimeExtend.GetTimeStampSeconds;
var accService = App.GetService<IUnitUserAccService>();
var attrService = App.GetService<IUnitUserAttrService>();
var _eventPublisher = App.GetService<IEventPublisher>();
var db = DbClient.AsTenant().GetConnectionWithAttr<game_onhook>();
var data = await db.Queryable<game_onhook>().Where(it => it.status == 1).ToListAsync();
foreach (var hook in data)
@@ -147,19 +148,74 @@ public class OnHookService(ISqlSugarClient DbClient, IRedisCache redis) : IOnHoo
if (await UpdateOnHook(hook.userId, exp, copper))
{
if (exp > 0)
OnHookAwardModel push = new OnHookAwardModel()
{
await attrService.UpdateUserExp(hook.userId, exp);
}
userId = hook.userId,
exp = exp,
copper = copper,
useTime = allTime,
award = award
};
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.PutOnHookAward,
push));
}
if (copper > 0)
{
await accService.UpdateUserCopper(hook.userId, 1, copper, "挂机获得");
}
}
}
if (award.Count > 0)
public async Task HandleOnHookGoods(OnHookAwardModel data)
{
var accService = App.GetService<IUnitUserAccService>();
var attrService = App.GetService<IUnitUserAttrService>();
var mapService = App.GetService<IGameMapService>();
var equService = App.GetService<IGameEquService>();
int onlineTime = Convert.ToInt32(data.useTime / 1000 / 60);
if (onlineTime > 0)
{
await attrService.UpdateOnLineTime(data.userId, "OnHook", onlineTime); //更新在线时间
}
await mapService.UpdateUserOnMap(data.userId);//更新在线
await equService.UpdateUserOnEquDurability(data.userId);//更新耐久
if (data.exp > 0)
{
await attrService.UpdateUserExp(data.userId, data.exp);
}
if (data.copper > 0)
{
await accService.UpdateUserCopper(data.userId, 1, data.copper, "挂机获得");
}
if (data.award.Count > 0)
{
var userService = App.GetService<IUnitUserService>();
var userConfig = await userService.GetUserConfigInfo(data.userId);
if (userConfig.autoBag != 0)
{
var weightService = App.GetService<IUnitUserWeight>();
bool auto = true;
foreach (var item in data.award)
{
await GameBus.UpdateBag(hook.userId, 1, award, "挂机获得");
if (auto == false)
{
break;
}
else
{
if (await weightService.CheckUserWeight(data.userId, item))
{
await GameBus.UpdateBag(data.userId, 1, item.code, item.parameter, item.count,
"挂机获得");
}
else
{
auto = false;
}
}
}
}
}

View File

@@ -0,0 +1,193 @@
namespace Application.Domain;
public class RankService(ISqlSugarClient DbClient, IRedisCache redis) : IRankService, ITransient
{
public async Task<string> GetRankUpdateTime()
{
string key = string.Format(BaseCache.BaseCacheKey, "RankTime");
if (await redis.ExistsAsync(key))
{
return await redis.GetAsync<string>(key);
}
return "更新时间:/-/-/ 00:00:00";
}
private async Task SetRankUpdateTime()
{
string key = string.Format(BaseCache.BaseCacheKey, "RankTime");
await redis.SetAsync(key, $"更新时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
public async Task<List<GameRankModel>> GetGameRank(int type, int area, int page, int limit, RefAsync<int> total)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_temp>();
var data = await db.Queryable<unit_user_temp>()
.WhereIF(area != 0, it => it.areaId == area)
.WhereIF(type == 0, it => it.lev > 30)
.WhereIF(type == 1, it => it.atk > 100)
.WhereIF(type == 2, it => it.defense > 100)
.WhereIF(type == 3, it => it.agility > 100)
.WhereIF(type == 4, it => it.upBlood > 100)
.WhereIF(type == 5, it => it.upMorale > 0)
.WhereIF(type == 6, it => it.luck > 0)
.WhereIF(type == 7, it => it.score > 1000)
.OrderByIF(type == 0, it => it.lev, OrderByType.Desc)
.OrderByIF(type == 0, it => it.upTime, OrderByType.Desc)
.OrderByIF(type == 1, it => it.atk, OrderByType.Desc)
.OrderByIF(type == 2, it => it.defense, OrderByType.Desc)
.OrderByIF(type == 3, it => it.agility, OrderByType.Desc)
.OrderByIF(type == 4, it => it.upBlood, OrderByType.Desc)
.OrderByIF(type == 5, it => it.upMorale, OrderByType.Desc)
.OrderByIF(type == 6, it => it.luck, OrderByType.Desc)
.OrderByIF(type == 7, it => it.score, OrderByType.Desc)
.Take(100)
.ToListAsync();
total = data.Count;
data = PageExtend.GetPageList(data, page, limit);
List<GameRankModel> result = new List<GameRankModel>();
foreach (var item in data)
{
GameRankModel temp = new GameRankModel();
temp.userId = item.userId;
temp.user = await UserModelTool.GetUserView(item.userId);
temp.sign = GetRankSign(item, type);
temp.par = "";
result.Add(temp);
}
return result;
}
private string GetRankSign(unit_user_temp data, int type)
{
string result = "0";
switch (type)
{
case 0:
result = $"{Convert.ToString(data.lev)}级";
break;
case 1:
result = Convert.ToString(data.atk);
break;
case 2:
result = Convert.ToString(data.defense);
break;
case 3:
result = Convert.ToString(data.agility);
break;
case 4:
result = Convert.ToString(data.upBlood);
break;
case 5:
result = Convert.ToString(data.upMorale);
break;
case 6:
result = (Convert.ToDecimal(data.luck) * 100).ToString("#0");
break;
case 7:
result = Convert.ToDecimal(data.score).ToString("#0.00");
break;
}
return result;
}
public async Task<List<GameRankModel>> GetGameCopperRank(int area, int page, int limit, RefAsync<int> total)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_copper>();
var data = await db.Queryable<unit_user_copper>().LeftJoin<unit_user>((uc, u) => uc.userId == u.userId)
.WhereIF(area != 0, (uc, u) => u.areaId == area)
.Where((uc, u) => uc.copper > 1000000)
.Select<unit_user_copper>()
.OrderByDescending(uc => uc.copper)
.Take(100)
.ToListAsync();
total = data.Count;
data = PageExtend.GetPageList(data, page, limit);
List<GameRankModel> result = new List<GameRankModel>();
foreach (var item in data)
{
GameRankModel temp = new GameRankModel();
temp.userId = item.userId;
temp.user = await UserModelTool.GetUserView(item.userId);
temp.sign = GameTool.ConvertCopperName((long)item.copper);
temp.par = "";
result.Add(temp);
}
return result;
}
public async Task<List<GameRankModel>> GetGameTeachAndRenownRank(int type, int area, int page, int limit, RefAsync<int> total)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_data>();
var data = await db.Queryable<unit_user_data>().LeftJoin<unit_user>((uc, u) => uc.userId == u.userId)
.WhereIF(area != 0, (uc, u) => u.areaId == area)
.WhereIF(type == 9, (uc, u) => uc.teach > 0)
.WhereIF(type == 10, (uc, u) => uc.renown > 0)
.WhereIF(type == 11, (uc, u) => uc.charm > 0)
.Select<unit_user_data>()
.OrderByIF(type == 9, uc => uc.teach, OrderByType.Desc)
.OrderByIF(type == 10, uc => uc.renown, OrderByType.Desc)
.OrderByIF(type == 11, uc => uc.charm, OrderByType.Desc)
.Take(100)
.ToListAsync();
total = data.Count;
data = PageExtend.GetPageList(data, page, limit);
List<GameRankModel> result = new List<GameRankModel>();
foreach (var item in data)
{
GameRankModel temp = new GameRankModel();
temp.userId = item.userId;
temp.user = await UserModelTool.GetUserView(item.userId);
if (type == 9)
{
temp.sign = item.teach.ToString();
}
else if(type==10)
{
temp.sign = item.renown.ToString();
}
temp.par = "";
result.Add(temp);
}
return result;
}
public async Task HandleRank()
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_temp>();
await db.Deleteable<unit_user_temp>().ExecuteCommandAsync();
long endTime = TimeExtend.GetTimeStampBySeconds(TimeAssist.GetDateTimeYMD(0));
var data = await db.Queryable<unit_user_online>().Where(it => it.upTime > endTime).ToListAsync();
var attrService = App.GetService<IUnitUserAttrService>();
List<unit_user_temp> addData = new List<unit_user_temp>();
foreach (var item in data)
{
var attrInfo = await attrService.GetUserAttrModel(item.userId);
unit_user_temp temp = new unit_user_temp()
{
userId = attrInfo.id,
areaId = attrInfo.area,
lev = attrInfo.lev,
upTime = attrInfo.upTime,
luck = attrInfo.luck,
score = attrInfo.score,
atk = attrInfo.maxAtk,
defense = attrInfo.defense,
agility = attrInfo.agility,
upBlood = attrInfo.upBlood,
upMorale = attrInfo.upMorale
};
addData.Add(temp);
}
if (addData.Count > 0)
{
await db.Insertable(addData).ExecuteCommandAsync();
}
await SetRankUpdateTime();
}
}

View File

@@ -136,6 +136,10 @@ public class GameChatService : IGameChatService, ITransient
case "System":
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6));
break;
case "Notice":
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(1));
chat.code = nameof(GameChatEnum.Code.System);
break;
case "Group":
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6));
break;

View File

@@ -55,6 +55,15 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
.OrderByDescending(it => it.lev)
.OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total);
}
public async Task<List<unit_user_equ>> GetUserEquData(string userId,string query)
{
long onTime = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
return await db.Queryable<unit_user_equ>().Where(it => it.userId == userId)
.WhereIF(!string.IsNullOrEmpty(query),
it => it.equName.Contains(query) || it.unitEquName.Contains(query))
.ToListAsync();
}
public async Task<List<unit_user_equ>> GetUserEquData(string userId, int equId)
{
@@ -93,7 +102,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
.ToList();
return userEqu;
}
public async Task<bool> AddUserEqu(string userId, int equId, int count, string remark)
{
@@ -369,6 +378,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
{
return false;
}
var opData = userEqu.Take(count).ToList();
return await DeductUserEqu(userId, opData, remark);
}
@@ -595,6 +605,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
result.AddRange(attr.AttrItem);
}
}
await redis.SetAsync(key, result, 300);
}
@@ -834,5 +845,90 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
return onMakeEqu;
}
public async Task RemoveUserOnEqu(string userId, string type, int count)
{
var userOnEqu = await GetUserOnEqu(userId);
userOnEqu = userOnEqu.FindAll(it => it.code == type);
if (userOnEqu.Count >= count)
{
var opEqu = userOnEqu.Take(count).ToList();
foreach (var item in opEqu)
{
await EquOnOrDown(item, 0);
}
}
}
#endregion
#region
private async Task<long> GetUserDurabilityTimer(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "Timer", "Durability");
if (await redis.HExistsHashAsync(key, userId))
{
return await redis.GetHashAsync<long>(key, userId);
}
long result = TimeExtend.GetTimeStampSeconds + 5 * 60;
await redis.AddHashAsync(key, userId, result);
return result;
}
private async Task SetUserDurabilityTimer(string userId, long endTime)
{
string key = string.Format(UserCache.BaseCacheKeys, "Timer", "Durability");
await redis.AddHashAsync(key, userId, endTime);
}
public async Task UpdateUserOnEquDurability(string userId)
{
long onTime = TimeExtend.GetTimeStampSeconds;
long endTime = await GetUserDurabilityTimer(userId);
if (onTime > endTime) //进行耐久更新
{
await SetUserDurabilityTimer(userId, onTime + 5 * 60);
var onEquData = await GetUserOnEqu(userId);
List<string> noCode = new List<string>() { "Fashion", "Decorate" };
onEquData = onEquData.FindAll(it => it.durability > 0 && !noCode.Contains(it.code));
if (onEquData.Count > 0)
{
var attrService = App.GetService<IUnitUserAttrService>();
var stockDurability = await attrService.GetUserStock(userId, nameof(GameEnum.GameStockCode.Durability));
if (stockDurability.Count > 0)
{
if (stockDurability.Any(it => it.type == nameof(GameEnum.GameStockType.Time)))
{
return;
}
var onStock = stockDurability.Find(it =>
it.type == nameof(GameEnum.GameStockType.Number) && it.sign >= onEquData.Count);
if (onStock != null)
{
onStock.sign = onStock.sign - onEquData.Count;
if (await attrService.UpdateUserStock(onStock))
{
return;
}
}
}
foreach (var item in onEquData)
{
item.durability = item.durability - 1;
}
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
bool result = await db.Updateable(onEquData).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserOnEqu(userId);
}
}
}
}
#endregion
}

View File

@@ -39,12 +39,6 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result;
}
private async Task RemoveUserFight(string userId)
{
string key = string.Format(FightCache.FightCacheKey, "UserFight");
bool result = await redis.AddHashAsync(key, userId, new List<string>());
}
#endregion
#region
@@ -167,7 +161,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)
public async Task<bool> SetFightWin(game_fight_data fightData, string winUser, bool setDefMap = true)
{
bool result = false;
long okTime = TimeExtend.GetTimeStampMilliseconds;
@@ -215,11 +209,10 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
nameof(UserEnum.AttrCode.Monster), winUser, fightData.userId, okTime);
if (result)
{
await RemoveUserFight(fightData.userId);
if (setDefMap)
{
await UserStateTool.SetUserMapDefault(fightData.userId);
}
}
}
}
}
@@ -230,14 +223,26 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
nameof(UserEnum.AttrCode.Person), winUser, lowUser, okTime);
if (result)
{
await RemoveUserFight(lowUser);
if (setDefMap)
{
await UserStateTool.SetUserMapDefault(lowUser);
}
fightData.state = 1;
fightData.winCode = nameof(UserEnum.AttrCode.Person);
fightData.winUser = winUser;
fightData.okTime = okTime;
//此处调用战斗结束相关
var _eventPublisher = App.GetService<IEventPublisher>();
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.PutFightAward,
fightData));
}
}
//更新耐久
var equService = App.GetService<IGameEquService>();
await equService.UpdateUserOnEquDurability(fightData.userId);
return result;
}
@@ -290,6 +295,49 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result;
}
public async Task HandleFightData()
{
long endTime = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<game_fight_data>();
var data = await db.Queryable<game_fight_data>()
.Where(it => it.state == 0 && it.endTime < endTime)
.ToListAsync();
List<string> dels = data.Select(it => it.fightId).ToList();
bool result = await db.Deleteable<game_fight_data>().Where(it => dels.Contains(it.fightId))
.ExecuteCommandAsync() > 0;
if (result)
{
List<string> fightIdKeys = new List<string>();
List<string> monsterBloodKeys = new List<string>();
List<string> fightHarmKeys = new List<string>();
foreach (var item in data)
{
fightIdKeys.Add(string.Format(FightCache.FightCacheKeys, "FightData:Info", item.fightId));
fightHarmKeys.Add(string.Format(FightCache.FightCacheKeys, "FightData:Harm", item.fightId));
if (item.code == nameof(GameEnum.FightCode.PVE))
{
monsterBloodKeys.Add(string.Format(FightCache.FightCacheKeys, "FightData:Blood", item.keyId));
}
}
if (fightIdKeys.Count > 0)
{
await redis.DelAsync(fightIdKeys.ToArray());
}
if (monsterBloodKeys.Count > 0)
{
await redis.DelAsync(monsterBloodKeys.ToArray());
}
if (fightHarmKeys.Count > 0)
{
await redis.DelAsync(fightHarmKeys.ToArray());
}
}
}
#endregion
#region
@@ -303,7 +351,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
result = await redis.GetHashAsync<int>(key, userId);
}
if (result > 0)
if (result != 0)
{
await redis.AddHashAsync(key, userId, 0);
}
@@ -322,6 +370,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
public async Task HandleFight(game_fight_data fightData)
{
string winUser = fightData.winUser;
string lowUser = fightData.userId == winUser ? fightData.mainId : fightData.userId;
#region
@@ -347,6 +396,40 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
}
#endregion
#region
if (fightData.code == nameof(GameEnum.FightCode.PVP))
{
var mapService = App.GetService<IGameMapService>();
var userService = App.GetService<IUnitUserService>();
var messageService = App.GetService<IMessageService>();
var mapInfo = await mapService.GetMapInfo(fightData.mapId);
var cityInfo = await mapService.GetCityInfo((int)mapInfo.cityId);
var winUserInfo = await userService.GetUserInfoByUserId(winUser);
var lowUserInfo = await userService.GetUserInfoByUserId(lowUser);
//系统广播
string boradMsg =
$"[{UbbTool.HomeUbb(winUserInfo.userNo, winUserInfo.nick)}]在{cityInfo.cityName}·{mapInfo.mapName}击杀了[{UbbTool.HomeUbb(lowUserInfo.userNo, lowUserInfo.nick)}]!";
await messageService.SendBroadcast("0", nameof(MessageEnum.BroadcastCode.Remind), boradMsg);
//个人通知
var chatService = App.GetService<IGameChatService>();
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)
{
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, "击杀玩家"); //加罪恶
}
}
}
#endregion
}
private async Task PutFightAwardGoods(game_fight_data fightData)
@@ -492,7 +575,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
if (config[0] == fight.code || config[0] == "ALL")
{
decimal okLimit = Convert.ToDecimal(config[1]);
if ((Convert.ToDecimal(addBlood) / Convert.ToDecimal(user.upBlood) ) > okLimit)
if ((Convert.ToDecimal(addBlood) / Convert.ToDecimal(user.upBlood)) > okLimit)
{
if (item.type == "Number")
{
@@ -541,7 +624,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
}
//使用普通药品
if (addBlood > 0)
if (addBlood > 0 && (addBlood / user.upMorale / 1.0M) > 0.6M)
{
var unitDrug = myDrug.drug.Find(it => it.code == nameof(GoodsEnum.DrugCls.Blood) && it.count > 0);
if (unitDrug != null)
@@ -563,9 +646,19 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
#endregion
public async Task HandelFightEnd(string userId, List<dynamic> data)
public async Task HandelFightEnd(string userId, List<FightRemoveData> data)
{
await Task.CompletedTask;
var equService = App.GetService<IGameEquService>();
foreach (var item in data)
{
if (item.code == "Equ")
{
await equService.RemoveUserOnEqu(userId, item.par, item.count);
}
}
await Task.CompletedTask;
}
#endregion

View File

@@ -183,7 +183,17 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
isOnline = isOnline
};
}
public async Task UpdateUserOnMap(string userId)
{
unit_user_online onLine = await GetUserOnMap(userId);
onLine.upTime = TimeExtend.GetTimeStampSeconds;
string key = string.Format(UserCache.BaseCacheKey, "UserOnline");
if (await redis.AddHashAsync(key, userId, onLine))
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
await db.Updateable<unit_user_online>(onLine).ExecuteCommandAsync();
}
}
public async Task UpdateUserOnMap(string userId, string ip, string mapId)
{
unit_user_online onLine = new unit_user_online();

View File

@@ -123,6 +123,59 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "CreateMonsterOnMap");
await redis.DelHashAsync(key, mapId);
}
public async Task<bool> RemoveCreateMonster(string umId)
{
bool result = false;
var data = await GetCreateMonsterInfo(umId);
if (data != null)
{
result = await RemoveCreateMonster(data);
}
return result;
}
public async Task<bool> RemoveCreateMonster(unit_user_monster data)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
bool result = await db.Deleteable<unit_user_monster>().Where(it => it.umId == data.umId).ExecuteCommandAsync()>0;
if (result)
{
await ClearCreateMonster(data.mapId);
}
return result;
}
public async Task HandleCreateMonster()
{
var endTime = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
var data = await db.Queryable<unit_user_monster>().Where(it => it.endTime < endTime).ToListAsync();
List<string> delIds = new List<string>();
List<string> mapIds = new List<string>();
foreach (var item in data)
{
delIds.Add(item.umId);
if (mapIds.Any(it => it == item.mapId) == false)
{
mapIds.Add(item.mapId);
}
}
if (delIds.Count > 0)
{
bool result = await db.Deleteable<unit_user_monster>().Where(it => delIds.Contains(it.umId))
.ExecuteCommandAsync() > 0;
if (result)
{
string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "CreateMonsterOnMap");
await redis.DelHashAsync(key, mapIds.ToArray());
}
}
}
public async Task<List<MapMonsterModel>> GetMapMonster(string userId, string mapId, string teamId)
{

View File

@@ -22,14 +22,24 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
}
else if (accType == nameof(AccEnum.AccType.teach))
{
var info = await GetUserAccInfo(userId);
var info = await GetUserDataInfo(userId);
result = (long)info.teach;
}
else if (accType == nameof(AccEnum.AccType.renown))
{
var info = await GetUserAccInfo(userId);
var info = await GetUserDataInfo(userId);
result = (long)info.renown;
}
else if (accType == nameof(AccEnum.AccType.charm))
{
var info = await GetUserDataInfo(userId);
result = (long)info.charm;
}
else if (accType == nameof(AccEnum.AccType.enemy))
{
var info = await GetUserDataInfo(userId);
result = (long)info.enemy;
}
return result;
}
@@ -55,8 +65,6 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
isOk = await db.Updateable<unit_user_acc>()
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.cowry)), it => it.cowry == it.cowry + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.gold)), it => it.gold == it.gold + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.teach)), it => it.teach == it.teach + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.renown)), it => it.renown == it.renown + opCount)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
//生成日志
if (isOk)
@@ -94,10 +102,14 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
{
result = await UpdateUserCopper(userId, type, count, remark);
}
else
else if (accType == nameof(AccEnum.AccType.gold)||accType == nameof(AccEnum.AccType.cowry))
{
result = await UpdateUserAcc(userId, type, accType, count, name, remark);
}
else
{
result = await UpdateUserData(userId, type, accType, count, remark);
}
return result;
}
@@ -138,5 +150,38 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
return isOk;
}
public async Task<unit_user_data> GetUserDataInfo(string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_data>();
return await db.Queryable<unit_user_data>().Where(i => i.userId == userId).SingleAsync();
}
public async Task<bool> UpdateUserData(string userId, int type, string accType, long count, string remark = "")
{
bool isOk = false;
decimal opCount = type == 0 ? (0 - count) : count;
try
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_data>();
await DbClient.AsTenant().BeginTranAsync();
isOk = await db.Updateable<unit_user_data>()
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.teach)), it => it.teach == it.teach + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.renown)), it => it.renown == it.renown + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.charm)), it => it.charm == it.charm + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.enemy)), it => it.enemy == it.enemy + opCount)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
await DbClient.AsTenant().CommitTranAsync();
}
catch
{
isOk = false;
await DbClient.AsTenant().RollbackTranAsync();
}
return isOk;
}
#endregion
}

View File

@@ -18,6 +18,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
result.code = nameof(UserEnum.AttrCode.Person);
var unitAttr = await GetUserAttr(userId);
result.lev = (int)unitAttr.lev;
result.upTime = (long)unitAttr.levUpdate;
result.minAtk = (int)unitAttr.minAtk;
result.maxAtk = (int)unitAttr.maxAtk;
result.defense = (int)unitAttr.defense;
@@ -489,6 +490,16 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
public async Task<bool> UpdateOnLineTime(string userId, string code, int time)
{
if (code == "Default")
{
var hookService = App.GetService<IOnHookService>();
var hookInfo = await hookService.GetUserOnHook(userId);
if (hookInfo.status == 1)
{
return true;
}
}
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online_time>();
bool result = await db.Updateable<unit_user_online_time>()
.SetColumns(it => it.dayTime == it.dayTime + time)
@@ -498,6 +509,15 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
return result;
}
public async Task HandleOnLineTimeData()
{
int day = DateTime.Now.Day;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online_time>();
await db.Updateable<unit_user_online_time>().SetColumns(it => it.dayTime == 0)
.WhereIF(day == 1, it => it.monthTime == 0)
.Where(it => true).ExecuteCommandAsync();
}
#endregion
#region
@@ -657,6 +677,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
{
result.AddRange(item.attr);
}
return GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.AddExp), result, 0);
}
@@ -766,7 +787,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
var result = await db.Updateable(data).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserAttrCache(data.userId);
await ClearUserStockCache(data.userId);
}
return result;
@@ -816,6 +837,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
return result;
}
public async Task AddUserLoadState(string userId, List<string> codes)
{
foreach (var code in codes)
@@ -851,9 +873,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
name = "麻痹";
break;
}
await AddUserLoadState(userId, name, code);
}
}
public async Task<bool> RandomRemoveUserLoadState(string userId, int count)
{
var data = await GetUserLoadState(userId);
@@ -879,7 +903,6 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState");
await redis.DelHashAsync(key, userId);
}
#endregion
}

View File

@@ -185,9 +185,15 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
acc.userId = userId;
acc.cowry = 0;
acc.gold = 0;
acc.teach = 0;
acc.renown = 0;
db.Insertable(acc).AddQueue();
unit_user_data userData = new unit_user_data();
userData.userId = userId;
userData.teach = 0;
userData.renown = 0;
userData.charm = 0;
userData.enemy = 0;
db.Insertable(userData).AddQueue();
//注册游戏货币
unit_user_copper copper = new unit_user_copper();
copper.userId = userId;

View File

@@ -55,13 +55,13 @@ public static class GameBus
else if (goodsType.Equals(nameof(GameEnum.PropCode.renown)))
{
var accService = App.GetService<IUnitUserAccService>();
isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.renown), count,
isok = await accService.UpdateUserAccBath(userId, operate, nameof(AccEnum.AccType.renown), count,
nameof(AccEnum.Name.), remark);
}
else if (goodsType.Equals(nameof(GameEnum.PropCode.teach)))
{
var accService = App.GetService<IUnitUserAccService>();
isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.teach), count,
isok = await accService.UpdateUserAccBath(userId, operate, nameof(AccEnum.AccType.teach), count,
nameof(AccEnum.Name.), remark);
}
else if (goodsType.Equals(nameof(GameEnum.PropCode.map)))

View File

@@ -4,6 +4,31 @@ namespace Application.Domain;
public class GameTool
{
/// <summary>
/// 单位转换
/// </summary>
/// <param name="glod"></param>
/// <returns></returns>
public static string ConvertCopperName(long glod)
{
string result = string.Empty;
string glodStr = glod.ToString();
int yin = 0;
int t = 0;
if (glodStr.Length > 3)
{
yin = Convert.ToInt32(glodStr.Substring(0, glodStr.Length - 3));
t = Convert.ToInt32(glodStr.Substring(glodStr.Length - 3, 3));
}
else
{
t = Convert.ToInt32(glod);
}
result += yin > 0 ? string.Format("{0}银", yin) : "";
result += t > 0 ? string.Format("{0}铜", t) : "";
result = string.IsNullOrEmpty(result) ? "0铜" : result;
return result;
}
/// <summary>
/// 获取等级基础属性
/// </summary>

View File

@@ -14,4 +14,46 @@ public static class UserStateTool
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;
}
}

View File

@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
using Photon.Core.Redis;
namespace Application.Web.Controllers.Login
{
@@ -19,7 +20,7 @@ namespace Application.Web.Controllers.Login
private readonly IUnitUserAttrService _attrService;
public LoginController(IGameAccountService accountService, IAreaService areaService,
IUnitUserService userService,IUnitUserAttrService attrService)
IUnitUserService userService, IUnitUserAttrService attrService)
{
_accountService = accountService;
_areaService = areaService;
@@ -27,6 +28,7 @@ namespace Application.Web.Controllers.Login
_attrService = attrService;
}
/// <summary>
/// 登录接口
/// </summary>
@@ -273,14 +275,14 @@ namespace Application.Web.Controllers.Login
loadData.Add("accId", userInfo.accId);
loadData.Add("areaId", userInfo.areaId);
string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, TokenConfig.TokenTime);
//记录在线时间
await _attrService.UpdateOnLineTime(userInfo.userId, "Default", TokenConfig.TokenTime);
return PoAction.Ok(new
{ token = token, refToken = userInfo.token, userId = userInfo.userId });
}
[HttpPost]
public async Task<IPoAction> RefreshTokenByBook([FromBody] RefreshTokenParms parms)
{
@@ -304,7 +306,7 @@ namespace Application.Web.Controllers.Login
loadData.Add("accId", userInfo.accId);
loadData.Add("areaId", userInfo.areaId);
string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, TokenConfig.TokenTime);
return PoAction.Ok(new
{ token = token, refToken = userInfo.token, userId = userInfo.userId });
}

View File

@@ -296,4 +296,61 @@ public class StoreController : ControllerBase
}
}
}
/// <summary>
/// 批量出售装备
/// </summary>
/// <param name="npcId"></param>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> BathSaleEqu(int npcId, string? query)
{
if (string.IsNullOrEmpty(query))
{
return PoAction.Message("需要筛选搜索后才可以一键出售!");
}
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
var npcInfo = await _mapService.GetNpcInfo(npcId);
if (npcInfo == null)
{
return PoAction.Message("Npc不存在!");
}
if (npcInfo.status != 1)
{
return PoAction.Message("Npc不存在!");
}
if (GameTool.AreaVerify(areaId, npcInfo.areaId) == false)
{
return PoAction.Message("Npc不存在!");
}
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store)))
{
return PoAction.Message("业务不可用!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (npcInfo.mapId != onMap)
{
return PoAction.Message("Npc不存在!");
}
var myEqu = await _equService.GetUserEquData(userId, query);
myEqu = myEqu.FindAll(it => it.isOn == 0 && it.isLock == 0 && it.intensifyLev == 0);
long getCopper = myEqu.Sum(it => (int)it.sysPrice);
if (await _equService.DeductUserEqu(userId, myEqu, "出售装备"))
{
await _accService.UpdateUserCopper(userId, 1, getCopper, "出售装备");
return PoAction.Ok(true, $"共出售{myEqu.Count}件装备,获得{getCopper}铜贝!");
}
else
{
return PoAction.Message("出售失败,请稍后尝试!");
}
}
}

View File

@@ -19,10 +19,12 @@ public class FightController : ControllerBase
private readonly IGameGoodsService _goodsService;
private readonly IUnitUserService _userService;
private readonly IOnHookService _hookService;
private readonly IUnitUserRelationService _relationService;
public FightController(IGameFightService fightService, IGameMonsterService monsterService,
IUnitUserAttrService attrService, IGameMapService mapService, IUnitUserAccService accService,
IGameGoodsService goodsService, IUnitUserService userService,IOnHookService hookService)
IGameGoodsService goodsService, IUnitUserService userService, IOnHookService hookService,
IUnitUserRelationService relationService)
{
_fightService = fightService;
_monsterService = monsterService;
@@ -32,6 +34,7 @@ public class FightController : ControllerBase
_goodsService = goodsService;
_userService = userService;
_hookService = hookService;
_relationService = relationService;
}
/// <summary>
@@ -110,6 +113,77 @@ public class FightController : ControllerBase
}
}
/// <summary>
/// 角色战斗生成
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> FightPerson(string? no)
{
string userId = StateHelper.userId;
var onMapInfo = await _mapService.GetUserOnToMapInfo(userId);
var otUser = await _userService.GetUserInfoByUserNo(no);
if (otUser == null)
{
return PoAction.Message("玩家不存在!");
}
if (onMapInfo.isPk == 0)
{
if (onMapInfo.retMap != onMapInfo.mapId)
{
if (await _relationService.CheckUserEnemy(userId, otUser.userId) == false)
{
return PoAction.Message("该场景不允许PK!");
}
}
else
{
return PoAction.Message("该场景不允许PK!");
}
}
var otUserOnMap = await _mapService.GetUserOnMapInfo(otUser.userId);
if (onMapInfo.mapId != otUserOnMap.mapId)
{
return PoAction.Message("玩家不存在!");
}
if (otUserOnMap.isOnline == 0)
{
return PoAction.Message("玩家已下线!");
}
if (onMapInfo.lookArea == 1)
{
if (otUser.areaId != StateHelper.areaId)
{
return PoAction.Message("该地图不允许跨服战斗!");
}
}
string fightId = StringAssist.NewGuid;
string areaCode = nameof(GameEnum.AreaCode.Own);
string code = nameof(GameEnum.FightCode.PVP);
string keyId = StringAssist.GetSortKey(userId,otUser.userId);
long exp = 0;
long copper = 0;
long petExp = 0;
string award = string.Empty;
string pars = "";
bool result = await _fightService.AddFight(fightId, areaCode, keyId, otUser.userId, code, onMapInfo.code, onMapInfo.mapId, userId, exp,
copper, petExp, award, pars);
if (result)
{
await _hookService.StopOnHook(userId);
return PoAction.Ok(fightId);
}
else
{
return PoAction.Message("战斗生成错误!");
}
}
/// <summary>
/// 战斗接口
/// </summary>
@@ -194,7 +268,6 @@ public class FightController : ControllerBase
//结束战斗都此处直接返回
if (otAttr.blood < 1 || myAttr.blood < 1)
{
await _fightService.RemoveUserFight(userId, fightId);
if (otAttr.blood < 1)
{
await _fightService.SetFightWin(fight, userId);
@@ -343,13 +416,11 @@ public class FightController : ControllerBase
var fight = await _fightService.GetFightInfo(fightId);
if (fight == null)
{
await _fightService.RemoveUserFight(userId, fightId);
return PoAction.Message("战斗不存在!");
}
if (fight.state == 1)
{
await _fightService.RemoveUserFight(userId, fightId);
return PoAction.Message("战斗结束!");
}

View File

@@ -43,7 +43,7 @@ public class GoodsController : ControllerBase
int count = await _goodsService.GetUserGoodsCount(userId, goodsId);
int UseState = 0;
string[] ShowViewNum = ["Pack", "Weight", "State"]; //显示带数量窗口
string[] ShowView = ["Ship","Drug"]; //显示只能使用1个的窗口
string[] ShowView = ["Ship", "Drug", "Durability"]; //显示只能使用1个的窗口
if (ShowViewNum.Any(it => it == goodsInfo.code))
{
UseState = 1;
@@ -113,7 +113,7 @@ public class GoodsController : ControllerBase
return PoAction.Message(ck);
}
}
#endregion
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "使用物品"))
@@ -168,11 +168,24 @@ public class GoodsController : ControllerBase
await _weightService.AddUserShip(userId, name, goodsId, speed, weight, copper, sale, remark);
message = $"使用[{goodsInfo.goodsName}],获得{name}+1";
}
if (goodsInfo.code == nameof(GoodsEnum.Code.Drug))
{
message = "使用成功!";
await _goodsService.UseDrug(userId, goodsId, goodsInfo.content);
}
if (goodsInfo.code == nameof(GoodsEnum.Code.Durability))
{
message = "使用成功!";
dynamic _drugConfig = JsonConvert.DeserializeObject<dynamic>(goodsInfo.content);
await _attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name),
Convert.ToString(_drugConfig.type),
Convert.ToString(_drugConfig.code),
Convert.ToInt64(_drugConfig.num), Convert.ToString(_drugConfig.par),
Convert.ToInt32(_drugConfig.minute));
}
return PoAction.Ok(true, message);
}
else

View File

@@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.Pub;
/// <summary>
/// 排行接口
/// </summary>
[Route("[controller]/[action]")]
[ApiController]
[Authorize]
public class RankController : ControllerBase
{
private readonly IRankService _rankService;
public RankController(IRankService rankService)
{
_rankService = rankService;
}
/// <summary>
/// 获取排名数据
/// </summary>
/// <param name="type"></param>
/// <param name="page"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetRankData(int type, int page)
{
List<GameRankModel> data = new List<GameRankModel>();
RefAsync<int> total = 0;
string upTime = $"更新时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}";
int area = StateHelper.areaId;
if (type is >= 0 and < 8)
{
data = await _rankService.GetGameRank(type, area, page, 10, total);
upTime = await _rankService.GetRankUpdateTime();
}
else if (type == 8)
{
data = await _rankService.GetGameCopperRank(area, page, 10, total);
}
else if (type == 9 || type == 10 || type == 11)
{
data = await _rankService.GetGameTeachAndRenownRank(type, area, page, 10, total);
}
return PoAction.Ok(new { upTime, data, total = total.Value });
}
}

View File

@@ -54,7 +54,8 @@ public class UserController : ControllerBase
object exp = new { expInfo.exp, expInfo.upExp };
var vigourInfo = await _attrService.GetUserVigourInfo(userId);
var accInfo = await _accService.GetUserAccInfo(userId);
object acc = new { accInfo.gold, accInfo.cowry, accInfo.teach, accInfo.renown };
var userDataInfo = await _accService.GetUserDataInfo(userId);
object acc = new { accInfo.gold, accInfo.cowry, userDataInfo.teach, userDataInfo.renown,userDataInfo.enemy };
var buff = await _attrService.GetUserStateData(userId, "ALL");
var stock = await _attrService.GetUserStock(userId);
@@ -165,15 +166,17 @@ public class UserController : ControllerBase
return PoAction.Message("用户本身!", 101);
}
bool isAtArea = true;
if (userInfo.areaId != StateHelper.areaId)
{
isAtArea = false;
return PoAction.Message("玩家不存在!", 102);
}
object user = new { userInfo.userNo, userInfo.nick, userInfo.sex, userInfo.sign };
var attrInfo = await _attrService.GetUserAttrModel(userInfo.userId); //基础属性
var accInfo = await _accService.GetUserAccInfo(userInfo.userId);
object acc = new { accInfo.teach };
var accInfo = await _accService.GetUserDataInfo(userInfo.userId);
object acc = new { accInfo.teach,accInfo.enemy };
var online = await _mapService.GetUserOnMap(userInfo.userId);
int isOnline = online.upTime >
@@ -189,9 +192,11 @@ public class UserController : ControllerBase
var equ = await _equService.GetUserOnEqu(userInfo.userId);
var suit = await _equService.GetUserEquSuit(userInfo.userId);
var isPk = await UserStateTool.CheckPkState(userId, userInfo.userId, isEnemy, isAtArea);
object result = new
{
user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ, suit
user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ, suit,isPk
};
return PoAction.Ok(result);
}

View File

@@ -46,16 +46,15 @@ builder.Services.InjectJwt(builder.Configuration, new OpenApiInfo
}, groups);
#endregion
//自动程序
//定时功能
builder.Services.InjectTimer(services =>
{
services.AddTransient<ITimerJobManager, TimerJobManager>();//注册管理器
services.AddSingleton<AutoJob>();
});
string autoConfig = builder.Configuration["AutoProgram"]!;
if (autoConfig == "1")
{
//定时功能
builder.Services.InjectTimer(services =>
{
services.AddTransient<ITimerJobManager, TimerJobManager>();//注册管理器
services.AddSingleton<AutoJob>();
});
builder.Services.AddHostedService<AppBackgroundService>();
}

View File

@@ -9,7 +9,7 @@
{{ item.nick }}
</Abar>
</span>:
<span v-html="item.msg"></span>
<span v-html="item.msg" @click="HtmlEvent"></span>
</span>
</div>
</div>

View File

@@ -1,10 +1,9 @@
<template>
<span v-if="showUrl == false">
<span v-html="EquTool.ConvertEquName(equData,showLev)"></span>
<span v-html="EquTool.ConvertEquName(equData, showLev)"></span>
</span>
<router-link v-if="showUrl" :to='"/prop/equ?ue=" + equData.ueId'>
<span v-html="EquTool.ConvertEquName(equData,showLev)"></span>
</router-link>
<Abar :href='"/prop/equ?ue=" + equData.ueId' v-if="showUrl"><span
v-html="EquTool.ConvertEquName(equData, showLev)"></span> </Abar>
</template>
<script setup lang="ts">
// 1. 定义接收父组件传来的参数 props

View File

@@ -2,8 +2,8 @@
统一配置中心
*/
export class BaseConfig {
// public static BaseUrl: string = 'https://localhost:7198'
// public static BaseMediaUrl: string = 'https://localhost:7198/'
public static BaseUrl:string="http://kx.iyba.cn:5291";
public static BaseMediaUrl:string="http://kx.iyba.cn:5291";
public static BaseUrl: string = 'https://localhost:7198'
public static BaseMediaUrl: string = 'https://localhost:7198/'
// public static BaseUrl:string="http://kx.iyba.cn:5291";
// public static BaseMediaUrl:string="http://kx.iyba.cn:5291";
}

View File

@@ -1 +1,51 @@
<template></template>
<template>
<div class="content">
排行榜
</div>
<div class="content">
<div class="common">
<Abar href="/rank/info?id=0">等级排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=8">铜贝排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=1">攻击排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=2">防御排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=3">敏捷排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=4">体力排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=5">士气排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=6">幸运排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=9">师德排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=10">声望排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=7">战力排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=11">魅力排行</Abar>
</div>
<div class="common">
<Abar href="/rank/info?id=12">亲密度排行</Abar>
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default
})
</script>

View File

@@ -0,0 +1,97 @@
<template>
<div class="content">
{{ name }}
</div>
<div class="content">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<GameUser :data="item.user"></GameUser>({{ item.sign }})
</div>
<span v-if="data.length == 0">
暂无排行.
</span>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
<div class="content" style="font-size: 14px;margin-top: 15px;">
*{{ timeTips }}
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
const timeTips = ref("");
const name = ref("");
let type = PageExtend.QueryString("id");
onMounted(async () => {
try {
name.value = GetRankName(Number(type));
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await RankService.GetRankData(Number(type), currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
timeTips.value = result.data.upTime;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
const GetRankName = (type: number) => {
let result = '';
switch (type) {
case 0:
result = "等级排行榜"; break;
case 1:
result = "攻击排行榜"; break;
case 2:
result = "防御排行榜"; break;
case 3:
result = "敏捷排行榜"; break;
case 4:
result = "体力排行榜"; break;
case 5:
result = "士气排行榜"; break;
case 6:
result = "幸运排行榜"; break;
case 7:
result = "战力排行榜"; break;
case 8:
result = "铜贝排行榜"; break;
case 9:
result = "师德排行榜"; break;
case 10:
result = "声望排行榜"; break;
case 11:
result = "魅力排行榜"; break;
case 12:
result = "亲密排行榜"; break;
}
return result;
}
</script>

View File

@@ -7,20 +7,20 @@
</div>
<div class="common serch">
搜索内容<input type="text" class="search-ipt" v-model="serch">&nbsp;
<button class="ipt-btn" name="serch" @click="BindData">搜索</button>
<button class="ipt-btn" name="serch" @click="refData">搜索</button>
</div>
<div class="content">
<div class="common" v-if="type == '0'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/prop/goods?ue=" + item.ueId'>{{ item.equName }}({{ item.lev }})</Abar>
<Abar :href='"/prop/equ?ue=" + item.ueId'>{{ item.equName }}({{ item.lev }})</Abar>
[<Abutton @click="SaleView(item)">出售</Abutton>]
</div>
</div>
<div class="common" v-if="type == '1'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{item.count}})</Abar>
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{ item.count }})</Abar>
[<Abutton @click="SaleView(item)">出售</Abutton>]
</div>
</div>
@@ -28,16 +28,19 @@
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<span v-if="item.code == 'Card'">
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{item.count}})</Abar>
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{ item.count }})</Abar>
</span>
<span v-else>
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{item.count}})</Abar>
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{ item.count }})</Abar>
</span>
[<Abutton @click="SaleView(item)">出售</Abutton>]
</div>
</div>
<span v-if="data.length == 0">暂无.</span>
</div>
<div class="content" v-if="type == '0'">
<Abutton @click="bathSale">一键出售装备</Abutton>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
@@ -85,13 +88,18 @@ const BindData = async (): Promise<void> => {
let result = await StoreService.GetNpcSale(Number(npcId), Number(type.value), serch.value, currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
total.value = result.data.total;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const refData = async () => {
currentPage.value = 1;
await BindData();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
@@ -131,11 +139,29 @@ const SaleOk = async (): Promise<void> => {
MessageExtend.LoadingClose();
if (result.code == 0) {
showSale.value = false;
MessageExtend.Notify(result.msg,"success");
MessageExtend.Notify(result.msg, "success");
await BindData();
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const bathSale = async () => {
if (type.value == '0') {
MessageExtend.ShowConfirmDialogAsyc("出售装备", `您确定要出售当前装备吗?`, async () => {
let npcId = LocalStorageHelper.GetOnNpc();
let result = await StoreService.BathSaleEqu(Number(npcId), serch.value);
if (result.code == 0) {
await BindData();
MessageExtend.Notify(result.msg, "success");
}
else {
MessageExtend.Notify(result.msg, "danger");
}
return true;
});
}
}
</script>

View File

@@ -23,7 +23,7 @@
师德:{{ accData.teach }}<br>
声望:{{ accData.renown }}<br>
活力:{{ vitality }}<br>
罪恶值:0<br>
罪恶值:{{ accData.enemy }}<br>
帮派:<br>
<div v-if="buff.length > 0">
---BUFF状态---<br>

View File

@@ -22,7 +22,7 @@
坐骑:<br>
成就:<br>
个性签名:{{ userData.sign }}<br>
罪恶值:0<br>
罪恶值:{{ accData.enemy }}<br>
师德:{{ accData.teach }}<br>
</div>
<div class="content">
@@ -98,6 +98,9 @@
<div class="content" v-if="team.state == 1">
队伍:<Abar :href='"/user/team/info?id=" + team.team.teamId'>{{ team.team.name }}</Abar>
</div>
<div class="content" v-if="isPk">
<Abutton @click="FightAtk">攻击</Abutton>
</div>
</template>
<script setup lang="ts">
@@ -112,6 +115,7 @@ const online = ref(0);
const onMap = ref('');
const isFriend = ref(false);
const isEnemy = ref(false);
const isPk = ref(false);
const team = ref<any>({});
/**装备定义 */
const equ = ref<Array<any>>([]);
@@ -150,7 +154,7 @@ const BindData = async (): Promise<void> => {
isFriend.value = result.data.isFriend;
isEnemy.value = result.data.isEnemy;
team.value = result.data.team;
isPk.value = result.data.isPk;
equ.value = result.data.equ;
suit.value = result.data.suit;
Hold.value = equ.value.filter(it => it.code == 'Hold');
@@ -163,6 +167,7 @@ const BindData = async (): Promise<void> => {
Fashion.value = equ.value.filter(it => it.code == 'Fashion');
Wing.value = equ.value.filter(it => it.code == 'Wing');
Decorate.value = equ.value.filter(it => it.code == 'Decorate');
console.log(result);
}
else if (result.code == 101) {
@@ -210,4 +215,17 @@ const AddEnemy = async (): Promise<void> => {
});
}
const FightAtk = async () => {
let no = PageExtend.QueryString("no");
MessageExtend.LoadingToast("战斗初始化...");
let result = await FightService.FightPerson(no);
MessageExtend.LoadingClose();
if (result.code == 0) {
return PageExtend.Redirect("/fight?f=" + result.data);
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
}
</script>

View File

@@ -10,6 +10,14 @@ export class FightService {
return await ApiService.Request("post", "/Fight/FightMonster", { type, monsterId, sign });
}
/**
* 角色战斗生成
* GET /Fight/FightPerson
*/
static async FightPerson(no: string) {
return await ApiService.Request("get", "/Fight/FightPerson", { no });
}
/**
* 战斗接口
* POST /Fight/Fight

View File

@@ -0,0 +1,9 @@
export class RankService {
/**
* 获取排名数据
* GET /Rank/GetRankData
*/
static async GetRankData(type: number, page: number) {
return await ApiService.Request("get", "/Rank/GetRankData", { type, page });
}
}

View File

@@ -38,4 +38,12 @@ export class StoreService {
static async Sale(npcId: number, count: number, search: string, type: number, id: string) {
return await ApiService.Request("post", "/Map/Store/Sale", { npcId, count, search, type, id });
}
/**
* 批量出售装备
* GET /Map/Store/BathSaleEqu
*/
static async BathSaleEqu(npcId: number, query: string) {
return await ApiService.Request("get", "/Map/Store/BathSaleEqu", { npcId, query });
}
}

View File

@@ -142,7 +142,7 @@ export class FightTool {
if (this.randomTrigger(atkUser.del_Fashion)) {
if (defUser.code == 'Person') {
remData.push({
"code": "equ",
"code": "Equ",
"par": "Fashion",
"count": 1
});