From 1a1f12abf59fc5cde820f8cd6f65da3ce0feb37a Mon Sep 17 00:00:00 2001 From: Putoo <290555932@qq.com> Date: Thu, 4 Jun 2026 18:25:31 +0800 Subject: [PATCH] 1212 --- .../game/user/unit_user_online_time.cs | 33 +++ .../model/CheckTowerNeed.cs | 30 ++ .../model/MapEventData.cs | 9 + .../model/TowerNeed.cs | 60 ++++ .../resource/game/game_city_map_bus.cs | 69 +++++ .../resource/game/game_city_map_event.cs | 33 +++ Service/Application.Domain/Enum/MapEnum.cs | 13 + .../Interface/Goods/IGameGoodsService.cs | 2 +- .../Services/Interface/Map/IGameMapService.cs | 15 + .../Interface/User/IUnitUserAttrService.cs | 7 + .../Service/Goods/GameGoodsService.cs | 11 +- .../Services/Service/Map/GameMapService.cs | 270 +++++++++++++++++- .../Service/User/UnitUserAttrService.cs | 16 ++ .../Services/Service/User/UnitUserService.cs | 7 + .../Application.Domain/Tool/Base/GameBus.cs | 125 ++++++++ .../Controllers/Login/LoginController.cs | 8 +- .../Controllers/Map/MapController.cs | 45 ++- Web/src/pages/map/business.vue | 1 + Web/src/pages/map/index.vue | 15 + Web/src/pages/map/runing.vue | 21 +- 20 files changed, 772 insertions(+), 18 deletions(-) create mode 100644 Service/Application.Domain.Entity/game/user/unit_user_online_time.cs create mode 100644 Service/Application.Domain.Entity/model/CheckTowerNeed.cs create mode 100644 Service/Application.Domain.Entity/model/MapEventData.cs create mode 100644 Service/Application.Domain.Entity/model/TowerNeed.cs create mode 100644 Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs create mode 100644 Service/Application.Domain.Entity/resource/game/game_city_map_event.cs create mode 100644 Service/Application.Domain/Enum/MapEnum.cs create mode 100644 Web/src/pages/map/business.vue diff --git a/Service/Application.Domain.Entity/game/user/unit_user_online_time.cs b/Service/Application.Domain.Entity/game/user/unit_user_online_time.cs new file mode 100644 index 0000000..485e02e --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_online_time.cs @@ -0,0 +1,33 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_online_time + { + /// + /// userId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string userId { get; set; } + + /// + /// dayTime + /// + [SugarColumn(IsNullable = true)] + public long? dayTime { get; set; } + + /// + /// monthTime + /// + [SugarColumn(IsNullable = true)] + public long? monthTime { get; set; } + + /// + /// totalTime + /// + [SugarColumn(IsNullable = true)] + public long? totalTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/CheckTowerNeed.cs b/Service/Application.Domain.Entity/model/CheckTowerNeed.cs new file mode 100644 index 0000000..f82706b --- /dev/null +++ b/Service/Application.Domain.Entity/model/CheckTowerNeed.cs @@ -0,0 +1,30 @@ +namespace Application.Domain.Entity; + +public class CheckTowerNeed +{ + private bool _result; + + public bool result + { get { return this._result; } set { this._result = value; } } + + private System.Int32 _isDeal; + + /// + /// 0不可交易1可交易 + /// + public System.Int32 isDeal + { get { return this._isDeal; } set { this._isDeal = value; } } + + private System.Int32 _isGive; + + /// + /// 0不可交易1可交易 + /// + public System.Int32 isGive + { get { return this._isGive; } set { this._isGive = value; } } + + private List _Needs; + + public List Needs + { get { return this._Needs; } set { this._Needs = value; } } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/MapEventData.cs b/Service/Application.Domain.Entity/model/MapEventData.cs new file mode 100644 index 0000000..c8b04b8 --- /dev/null +++ b/Service/Application.Domain.Entity/model/MapEventData.cs @@ -0,0 +1,9 @@ +namespace Application.Domain.Entity; + +public class MapEventData +{ + public int minCount { get; set; } + public int maxCount { get; set;} + public string tips { get; set; } + public string offSetTips { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/TowerNeed.cs b/Service/Application.Domain.Entity/model/TowerNeed.cs new file mode 100644 index 0000000..373d076 --- /dev/null +++ b/Service/Application.Domain.Entity/model/TowerNeed.cs @@ -0,0 +1,60 @@ +namespace Application.Domain.Entity; + +public class TowerNeed +{ + private System.String _code; + + /// + /// + /// + public System.String code + { get { return this._code; } set { this._code = value; } } + + private System.String _name; + + /// + /// + /// + public System.String name + { get { return this._name; } set { this._name = value; } } + + private System.String _parameter; + + /// + /// + /// + public System.String parameter + { get { return this._parameter; } set { this._parameter = value; } } + + private System.Int32 _count; + + /// + /// + /// + public System.Int32 count + { get { return this._count; } set { this._count = value; } } + + private System.Int32 _retCount; + + /// + /// + /// + public System.Int32 retCount + { get { return this._retCount; } set { this._retCount = value; } } + + private System.Int32 _isOp; + + /// + /// + /// + public System.Int32 isOp + { get { return this._isOp; } set { this._isOp = value; } } + + private System.Int32 _isAsk; + + /// + /// + /// + public System.Int32 isAsk + { get { return this._isAsk; } set { this._isAsk = value; } } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs b/Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs new file mode 100644 index 0000000..8fe186f --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs @@ -0,0 +1,69 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_city_map_bus + { + /// + /// busId + /// + [SugarColumn(IsPrimaryKey = true)] + public int busId { get; set; } + + /// + /// busCode + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? busCode { get; set; } + + /// + /// busName + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? busName { get; set; } + + /// + /// busType + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? busType { get; set; } + + /// + /// bus_s + /// + [SugarColumn(IsNullable = true)] + public int? bus_s { get; set; } + + /// + /// bus_e + /// + [SugarColumn(IsNullable = true)] + public int? bus_e { get; set; } + + /// + /// bus_l + /// + [SugarColumn(IsNullable = true)] + public int? bus_l { get; set; } + + /// + /// busTips + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? busTips { get; set; } + + /// + /// busNeed + /// + [SugarColumn(IsNullable = true)] + public string? busNeed { get; set; } + + /// + /// busContent + /// + [SugarColumn(IsNullable = true)] + public string? busContent { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_city_map_event.cs b/Service/Application.Domain.Entity/resource/game/game_city_map_event.cs new file mode 100644 index 0000000..063633e --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_city_map_event.cs @@ -0,0 +1,33 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_city_map_event + { + /// + /// evId + /// + [SugarColumn(IsPrimaryKey = true)] + public int evId { get; set; } + + /// + /// evType + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? evType { get; set; } + + /// + /// eventData + /// + [SugarColumn(IsNullable = true)] + public string? eventData { get; set; } + + /// + /// offsetData + /// + [SugarColumn(IsNullable = true)] + public string? offsetData { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/MapEnum.cs b/Service/Application.Domain/Enum/MapEnum.cs new file mode 100644 index 0000000..01faa29 --- /dev/null +++ b/Service/Application.Domain/Enum/MapEnum.cs @@ -0,0 +1,13 @@ +namespace Application.Domain; + +public class MapEnum +{ + public enum RunEvent + { + reduce_goods, + reduce_blood, + reduce_vigour, + add_blood, + add_copper, + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs index 0fb307e..fe0d91c 100644 --- a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs +++ b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs @@ -18,8 +18,8 @@ public interface IGameGoodsService Task> GetUserGoodsData(string userId, List code, List noCode, string search, int page, int limit, RefAsync total); + Task> GetUserGoodsData(string userId, string code); Task UpdateUserGoods(string userId, int op, int goodsId, int count, string remark = ""); - #endregion #region 辅助 diff --git a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs index ced31fa..7acdb86 100644 --- a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs +++ b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs @@ -26,6 +26,7 @@ public interface IGameMapService Task GetToMapInfo(string userId, string toMap, bool isUpUserMap = true, bool isChangeCity = false); Task> GetUserCityMapData(string userId); Task AddUserCityMap(string userId, int cityId); + Task GetUserRunEvent(string userId); #endregion #region 其他相关 @@ -53,4 +54,18 @@ public interface IGameMapService Task UpdateUserRunInfo(unit_user_run data); #endregion + + #region 地图业务 + + Task> GetMapBus(string BusCode, int v, int l); + Task GetMapBusInfo(int busId); + Task CheckBusPower(game_city_map_bus bus, string userId); + + #endregion + + #region 地图资源 + + Task> GetMapRes(string mapId); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs index d509cdf..09aebd7 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -37,5 +37,12 @@ public interface IUnitUserAttrService Task UpdateUserVigour(string userId, int op, long count, string UpTime = ""); Task UpdateUserUpVigour(string userId, decimal count); + #endregion + + #region 在线时间 + + Task UpdateOnLineTime(string userId, string code, int time); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs index b7e6d00..a73d7e4 100644 --- a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs +++ b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs @@ -68,7 +68,14 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa .OrderBy(it => it.count, OrderByType.Desc) .ToPageListAsync(page, limit, total); } - + public async Task> GetUserGoodsData(string userId, string code) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.userId == userId && it.count > 0 && it.code == code) + .OrderBy(it => it.lev, OrderByType.Desc) + .OrderBy(it => it.count, OrderByType.Desc) + .ToListAsync(); + } public async Task UpdateUserGoods(string userId, int op, int goodsId, int count, string remark = "") { @@ -156,6 +163,8 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return await db.Insertable(bagLog).SplitTable().ExecuteCommandAsync() > 0; } + + #endregion #region 辅助 diff --git a/Service/Application.Domain/Services/Service/Map/GameMapService.cs b/Service/Application.Domain/Services/Service/Map/GameMapService.cs index 232bd1a..716f752 100644 --- a/Service/Application.Domain/Services/Service/Map/GameMapService.cs +++ b/Service/Application.Domain/Services/Service/Map/GameMapService.cs @@ -1,4 +1,6 @@ -namespace Application.Domain; +using Newtonsoft.Json; + +namespace Application.Domain; public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMapService, ITransient { @@ -17,6 +19,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return data; } + public async Task GetCityInfoByMapId(string mapId) { var data = await GetMapInfo(mapId); @@ -100,7 +103,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return 0; } } - + public async Task> GetMapNpc(string mapId) { @@ -594,7 +597,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame var data = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); if (data == null) { - data = await ResetUserRun(userId,false); + data = await ResetUserRun(userId, false); } await redis.AddHashAsync(key, userId, data); @@ -664,6 +667,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return result; } + public async Task UpdateUserRunInfo(unit_user_run data) { string key = string.Format(UserCache.BaseCacheKey, "UserMapRun"); @@ -676,5 +680,265 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return result; } + + private async Task GetRandomOneMapRunEvent() + { + string key = string.Format(BaseCache.BaseCacheKey, "CityRunEvent"); + var data = await redis.GetAsync>(key); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().ToListAsync(); + await redis.SetAsync(key, data); + } + + int index = RandomAssist.UnitRandomNum(0, data.Count); + return data[index]; + } + + public async Task GetUserRunEvent(string userId) + { + string result = string.Empty; + if (RandomAssist.CheakRandom(30)) + { + var data = await GetRandomOneMapRunEvent(); + if (data != null) + { + if (string.IsNullOrEmpty(data.eventData)) + { + return result; + } + + var eventData = JsonConvert.DeserializeObject(data.eventData); + if (data.evType == nameof(MapEnum.RunEvent.reduce_goods)) + { + var goodsService = App.GetService(); + var cagioData = await goodsService.GetUserGoodsData(userId, nameof(GoodsEnum.Code.Cargo)); + if (cagioData.Count > 0) + { + bool isOp = await CheckOpEvent(userId, data.offsetData); + if (isOp) + { + int index = RandomAssist.UnitRandomNum(0, cagioData.Count); + int count = RandomAssist.UnitRandomNum((int)eventData.minCount, + (int)eventData.maxCount + 1); + var onGoods = cagioData[index]; + + if (onGoods.count >= count) + { + if (await goodsService.UpdateUserGoods(userId, 0, (int)onGoods.goodsId, count, + "航海事件触发")) + { + result = String.Format(eventData.tips, onGoods.goodsName, count); + } + } + } + else + { + result = eventData.offSetTips; + } + } + } + else if (data.evType == nameof(MapEnum.RunEvent.reduce_blood)) + { + bool isOp = await CheckOpEvent(userId, data.offsetData); + if (isOp) + { + int count = RandomAssist.UnitRandomNum((int)eventData.minCount, (int)eventData.maxCount + 1); + var attrService = App.GetService(); + var myAttr = await attrService.GetUserAttrModel(userId); + myAttr.blood = myAttr.blood - count; + myAttr.blood = myAttr.blood < 1 ? 0 : myAttr.blood; + if (await attrService.UpdateUserBlood(userId, 2, myAttr.blood)) + { + if (myAttr.blood == 0) + { + if (await StopUserRun(userId)) + { + var mapService = App.GetService(); + await mapService.SetUserMapDefult(userId); + } + } + } + + result = String.Format(eventData.tips, count); + } + else + { + result = eventData.offSetTips; + } + } + else if (data.evType == nameof(MapEnum.RunEvent.add_blood)) + { + bool isOp = await CheckOpEvent(userId, data.offsetData); + if (isOp) + { + int count = RandomAssist.UnitRandomNum((int)eventData.minCount, (int)eventData.maxCount + 1); + var attrService = App.GetService(); + var myAttr = await attrService.GetUserAttrModel(userId); + myAttr.blood = myAttr.blood + count; + myAttr.blood = myAttr.blood > myAttr.upBlood ? myAttr.upBlood : myAttr.blood; + + await attrService.UpdateUserBlood(userId, 2, myAttr.blood); + result = String.Format(eventData.tips, count); + } + else + { + result = eventData.offSetTips; + } + } + else if (data.evType == nameof(MapEnum.RunEvent.reduce_vigour)) + { + bool isOp = await CheckOpEvent(userId, data.offsetData); + if (isOp) + { + int count = RandomAssist.UnitRandomNum((int)eventData.minCount, (int)eventData.maxCount + 1); + var attrService = App.GetService(); + var myVigour = await attrService.GetUserVigourInfo(userId); + myVigour.vitality = myVigour.vitality - count; + myVigour.vitality = myVigour.vitality < 1 ? 0 : myVigour.vitality; + await attrService.UpdateUserVigour(userId, 2, (long)myVigour.vitality); + result = String.Format(eventData.tips, count); + } + else + { + result = eventData.offSetTips; + } + } + else if (data.evType == nameof(MapEnum.RunEvent.add_copper)) + { + bool isOp = await CheckOpEvent(userId, data.offsetData); + if (isOp) + { + int count = RandomAssist.UnitRandomNum((int)eventData.minCount, (int)eventData.maxCount + 1); + var accService = App.GetService(); + await accService.UpdateUserCopper(userId, 1, count, "航海事件"); + result = String.Format(eventData.tips, count); + } + else + { + result = eventData.offSetTips; + } + } + } + } + + return result; + } + + private async Task CheckOpEvent(string userId, string offSet) + { + bool isOp = true; + if (!string.IsNullOrEmpty(offSet)) + { + var offsetData = JsonConvert.DeserializeObject(offSet); + var chekResult = await GameBus.CheakNeed(userId, offsetData, ""); + if (chekResult.result) + { + if (offsetData.isOp == 0) + { + isOp = false; + } + else + { + var result = await GameBus.UpdateBag(userId, 0, offsetData.code, offsetData.parameter, + offsetData.count, + "航海事件"); + isOp = !result; + } + } + } + + return isOp; + } + + #endregion + + #region 地图业务 + + public async Task> GetMapBus(string BusCode, int v, int l) + { + string key = string.Format(BaseCache.BaseCacheKeys, "CITY_MAP_BUS", BusCode); + var data = await redis.GetAsync>(key); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.busCode == BusCode).ToListAsync(); + await redis.SetAsync(key, data); + } + + if (data != null) + { + data = data.FindAll(it => it.bus_s <= v && it.bus_e >= v && it.bus_l == l); + } + + return data; + } + + public async Task GetMapBusInfo(int busId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "CITY_MAP_BUS","BUS_INFO"); + if (await redis.HExistsHashAsync(key, busId.ToString())) + { + return await redis.GetHashAsync(key, busId.ToString()); + } + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.busId == busId).SingleAsync(); + await redis.AddHashAsync(key,busId.ToString(), data); + return data; + } + + public async Task CheckBusPower(game_city_map_bus bus, string userId) + { + bool result = false; + var onMap = await GetUserOnMapId(userId); + var runInfo = await GetUserRun(userId); + if (onMap == bus.busCode) + { + if (runInfo == null) + { + result = true; + } + else if (runInfo.status == 0) + { + result = true; + } + } + + if (result == false) + { + if (runInfo != null) + { + if (bus.busCode == String.Format("{0}_{1}", runInfo.onMap, runInfo.toMap) && + runInfo.position >= bus.bus_s && runInfo.position <= bus.bus_e && bus.bus_l == runInfo.depth && + runInfo.status == 1) + { + result = true; + } + } + } + + return result; + } + + #endregion + + #region 地图资源 + + public async Task> GetMapRes(string mapId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "MapRes"); + var data = await redis.GetHashAsync>(key, mapId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.mapId == mapId).ToListAsync(); + await redis.AddHashAsync(key, mapId,data); + } + + return data; + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index ecd01a1..4ab8a72 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -336,4 +336,20 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : } #endregion 活力 + + #region 在线时间 + + public async Task UpdateOnLineTime(string userId, string code, int time) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Updateable() + .SetColumns(it => it.dayTime == it.dayTime + time) + .SetColumns(it => it.monthTime == it.monthTime + time) + .SetColumns(it => it.totalTime == it.totalTime + time) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + return result; + } + + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserService.cs b/Service/Application.Domain/Services/Service/User/UnitUserService.cs index 4d70dd7..4673c37 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserService.cs @@ -250,6 +250,13 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni online.upTime = TimeAssist.GetTimeStampNum; db.Insertable(online).AddQueue(); + unit_user_online_time onlineTime = new unit_user_online_time(); + onlineTime.userId = userId; + onlineTime.dayTime = 0; + onlineTime.monthTime = 0; + onlineTime.totalTime = 0; + db.Insertable(onlineTime).AddQueue(); + await db.SaveQueuesAsync(false); } diff --git a/Service/Application.Domain/Tool/Base/GameBus.cs b/Service/Application.Domain/Tool/Base/GameBus.cs index e8c00fb..34d745a 100644 --- a/Service/Application.Domain/Tool/Base/GameBus.cs +++ b/Service/Application.Domain/Tool/Base/GameBus.cs @@ -93,4 +93,129 @@ public class GameBus } #endregion + + #region 验证 + + public static async Task CheakNeed(string userId, TowerNeed item, string sid, int count = 1) + { + CheckTowerNeed result = new CheckTowerNeed(); + bool isok = true; + int isDeal = 1; + int isGive = 1; + + if (item.code == nameof(GameEnum.PropCode.Equ)) + { + var equService = App.GetService(); + int MyCount = await equService.GetUserEquByEquIdCount(userId, Convert.ToInt32(item.parameter)); + int neecCount = item.count * count; + if (MyCount < neecCount) + { + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.Goods)) + { + int MyCount = 0; + var goodsService = App.GetService(); + var goodsInfo = await goodsService.GetUserGoodsInfo(userId, Convert.ToInt32(item.parameter)); + if (goodsInfo != null) + { + MyCount = (int)goodsInfo.count; + if (goodsInfo.isDeal == 0) + { + isDeal = 0; + } + + if (goodsInfo.isGive == 0) + { + isGive = 0; + } + } + + int needCount = item.count * count; + if (MyCount < needCount) + { + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.copper)) + { + var accService = App.GetService(); + var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + decimal needAcc = item.count * count; + if (MyAcc < needAcc) + { + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.gold)) + { + var accService = App.GetService(); + var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold)); + decimal needAcc = item.count * count; + if (MyAcc < needAcc) + { + isok = false; + } + } + else if (item.code ==nameof( GameEnum.PropCode.vigour)) //活力 + { + var attrService = App.GetService(); + var MyAcc = await attrService.GetUserVigourInfo(userId); + decimal neecAcc = item.count * count; + if (MyAcc.vitality < neecAcc) + { + isok = false; + } + } + else if (item.code ==nameof( GameEnum.PropCode.lev)) + { + var attrService = App.GetService(); + var MyLev = await attrService.GetUserLev(userId); + if (MyLev < item.count) + { + isok = false; + } + } + result.result = isok; + result.isDeal = isDeal; + result.isGive = isGive; + return result; + } + + public static async Task CheakNeed(string userId, List needs, string sid, int count = 1) + { + CheckTowerNeed result = new CheckTowerNeed(); + bool isok = true; + int isDeal = 1; + int isGive = 1; + foreach (var item in needs) + { + var cheakResult = await CheakNeed(userId, item, sid, count); + if (isok) + { + isok = cheakResult.result; + } + + if (cheakResult.isDeal == 0) + { + isDeal = 0; + } + + if (cheakResult.isGive == 0) + { + isGive = 0; + } + + item.isAsk = cheakResult.result ? 1 : 0; + result.Needs.Add(item); + } + + result.result = isok; + result.isDeal = isDeal; + result.isGive = isGive; + return result; + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Login/LoginController.cs b/Service/Application.Web/Controllers/Login/LoginController.cs index 5273dde..9d53e6e 100644 --- a/Service/Application.Web/Controllers/Login/LoginController.cs +++ b/Service/Application.Web/Controllers/Login/LoginController.cs @@ -16,13 +16,15 @@ namespace Application.Web.Controllers.Login private readonly IGameAccountService _accountService; private readonly IAreaService _areaService; private readonly IUnitUserService _userService; + private readonly IUnitUserAttrService _attrService; public LoginController(IGameAccountService accountService, IAreaService areaService, - IUnitUserService userService) + IUnitUserService userService,IUnitUserAttrService attrService) { _accountService = accountService; _areaService = areaService; _userService = userService; + _attrService = attrService; } /// @@ -271,6 +273,10 @@ 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 }); } diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index e2b33a5..ffbd2dd 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -46,15 +46,16 @@ public class MapController : ControllerBase int area = StateHelper.areaId; game_city_map mapInfo = new game_city_map(); - #region 前置条件处理 + #region 前置条件处理 + var userRunInfo = await _mapService.GetUserRun(userId); if (userRunInfo.status != 0) { return PoAction.Message("正在航行状态", 103); } - + #endregion - + #region 地图导向处理 bool isSelfMap = false; @@ -104,10 +105,26 @@ public class MapController : ControllerBase string ip = ComHelper.GetClientUserIp(HttpContext); await _mapService.UpdateUserOnMap(userId, ip, mapInfo.mapId); + //地图业务 + IEnumerable business = new List(); + if (mapInfo.isBus == 1) + { + var busData = await _mapService.GetMapBus(mapInfo.mapId, 0, 0); + business = busData.Select(it => new + { + busId = it.busId, + busName = it.busName + }); + } + //地图资源 + List mapRes = new List(); + if (mapInfo.isRes==1) + { + mapRes = await _mapService.GetMapRes(mapInfo.mapId); + } #endregion - object ret = new { mapInfo, @@ -116,7 +133,9 @@ public class MapController : ControllerBase chatData, cityShow, nearUser, - noReadMsg = noReadMsg[3] + noReadMsg = noReadMsg[3], + business, + mapRes }; return PoAction.Ok(ret); @@ -495,7 +514,14 @@ public class MapController : ControllerBase var toCity = await _mapService.GetCityInfoByMapId(runInfo.toMap); int isShip = 0; int safety = 0; - + string busCode = $"{runInfo.onMap}_{runInfo.toMap}"; + var busData = await _mapService.GetMapBus(busCode, (int)runInfo.position, (int)runInfo.depth); + var business = busData.Select(it => new + { + busId = it.busId, + busName = it.busName + }); + return PoAction.Ok(new { onCity = onCity.cityName, @@ -503,7 +529,8 @@ public class MapController : ControllerBase distance = runInfo.distance, position = runInfo.position, isShip = isShip, - safety = safety + safety = safety, + business }); } @@ -540,6 +567,7 @@ public class MapController : ControllerBase { return PoAction.Message("不在航行状态", 100); } + var userShip = await _weightService.GetUserShip(userId); if (userShip.Count == 0) { @@ -560,7 +588,8 @@ public class MapController : ControllerBase runInfo.upTime = TimeExtend.GetTimeStampSeconds; if (await _mapService.UpdateUserRunInfo(runInfo)) { - return PoAction.Ok(true); + string msg = await _mapService.GetUserRunEvent(userId); + return PoAction.Ok(true, msg); } else { diff --git a/Web/src/pages/map/business.vue b/Web/src/pages/map/business.vue new file mode 100644 index 0000000..41a40c8 --- /dev/null +++ b/Web/src/pages/map/business.vue @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue index c7d27c7..5582d9d 100644 --- a/Web/src/pages/map/index.vue +++ b/Web/src/pages/map/index.vue @@ -23,6 +23,17 @@ {{ item.npcName }}{{ item.tips }} +
+
+ {{ item.busName }} +
+
+
+ 特产:
+
+ {{item.resName}} +
+
请选择出口:
@@ -91,6 +102,8 @@ const npcData = ref>([]); const chatData = ref>([]); const cityShow = ref>([]); const mapUser = ref>([]); +const business = ref>([]); +const mapRes = ref>([]); const messageCount = ref(0); // 城内地图显示 const showCity = ref(false); @@ -115,6 +128,8 @@ const BindData = async (map: string): Promise => { cityShow.value = result.data.cityShow; mapUser.value = result.data.nearUser; messageCount.value = result.data.noReadMsg; + business.value = result.data.business; + mapRes.value = result.data.mapRes; MapVent(result.data.mapInfo.near); onMap.value = mapInfo.value.mapId; console.log(result.data); diff --git a/Web/src/pages/map/runing.vue b/Web/src/pages/map/runing.vue index 83cb20f..5fbc555 100644 --- a/Web/src/pages/map/runing.vue +++ b/Web/src/pages/map/runing.vue @@ -14,6 +14,11 @@
您看到:
+
+ + {{ item.busName }} + +