diff --git a/Service/Application.Domain.Entity/logdb/ot/game_broadcast.cs b/Service/Application.Domain.Entity/logdb/ot/game_broadcast.cs new file mode 100644 index 0000000..0ac16cb --- /dev/null +++ b/Service/Application.Domain.Entity/logdb/ot/game_broadcast.cs @@ -0,0 +1,13 @@ +namespace Application.Domain.Entity; + +public class game_broadcast +{ + public string Id { get; set; } + public int area { get; set; } + public string code { get; set; } + public string userId { get; set; } + public string userNo { get; set; } + public string nick { get; set; } + public string msg { get; set; } + public long endTime { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/CheckTowerNeeds.cs b/Service/Application.Domain.Entity/model/CheckTowerNeeds.cs new file mode 100644 index 0000000..98f08a2 --- /dev/null +++ b/Service/Application.Domain.Entity/model/CheckTowerNeeds.cs @@ -0,0 +1,30 @@ +namespace Application.Domain.Entity; + +public class CheckTowerNeeds +{ + 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/EquAwaken.cs b/Service/Application.Domain.Entity/model/EquAwaken.cs index f21bf14..352ba9b 100644 --- a/Service/Application.Domain.Entity/model/EquAwaken.cs +++ b/Service/Application.Domain.Entity/model/EquAwaken.cs @@ -31,7 +31,6 @@ public class EquAwaken /// /// /// - [SqlSugar.SugarColumn(ColumnDataType = "varchar(max)", IsJson = true)] public List awaken { get { return this._awaken; } set { this._awaken = value; } } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/EquAwakenData.cs b/Service/Application.Domain.Entity/model/EquAwakenData.cs new file mode 100644 index 0000000..f9312fa --- /dev/null +++ b/Service/Application.Domain.Entity/model/EquAwakenData.cs @@ -0,0 +1,36 @@ +namespace Application.Domain.Entity; + +public class EquAwakenData +{ + private System.Int32 _lev; + + /// + /// + /// + public System.Int32 lev + { get { return this._lev; } set { this._lev = value; } } + + private System.Int32 _success; + + /// + /// + /// + public System.Int32 success + { get { return this._success; } set { this._success = value; } } + + private List _need; + + /// + /// + /// + public List need + { get { return this._need; } set { this._need = value; } } + + private List _attr; + + /// + /// + /// + public List attr + { get { return this._attr; } set { this._attr = value; } } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/TowerNeed.cs b/Service/Application.Domain.Entity/model/TowerNeed.cs index 373d076..f27a720 100644 --- a/Service/Application.Domain.Entity/model/TowerNeed.cs +++ b/Service/Application.Domain.Entity/model/TowerNeed.cs @@ -26,20 +26,20 @@ public class TowerNeed public System.String parameter { get { return this._parameter; } set { this._parameter = value; } } - private System.Int32 _count; + private long _count; /// /// /// - public System.Int32 count + public long count { get { return this._count; } set { this._count = value; } } - private System.Int32 _retCount; + private long _retCount; /// /// /// - public System.Int32 retCount + public long retCount { get { return this._retCount; } set { this._retCount = value; } } private System.Int32 _isOp; @@ -57,4 +57,12 @@ public class TowerNeed /// public System.Int32 isAsk { get { return this._isAsk; } set { this._isAsk = value; } } + + private long _onCount; + + /// + /// + /// + public long onCount + { get { return this._onCount; } set { this._onCount = value; } } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/TowerNeeds.cs b/Service/Application.Domain.Entity/model/TowerNeeds.cs new file mode 100644 index 0000000..050df10 --- /dev/null +++ b/Service/Application.Domain.Entity/model/TowerNeeds.cs @@ -0,0 +1,111 @@ +namespace Application.Domain.Entity; + +public class TowerNeeds +{ + private System.Int32 _Id; + + /// + /// + /// + public System.Int32 Id + { + get { return this._Id; } + set { this._Id = value; } + } + + 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 long _count; + + /// + /// + /// + public long count + { + get { return this._count; } + set { this._count = value; } + } + + private long _retCount; + + /// + /// + /// + public long 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; } + } + + private long _onCount; + + /// + /// + /// + public long onCount + { + get { return this._onCount; } + set { this._onCount = value; } + } + + private List _NeedItem; + + public List NeedItem + { + get { return this._NeedItem; } + set { this._NeedItem = value; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_dic.cs b/Service/Application.Domain.Entity/resource/game/game_dic.cs new file mode 100644 index 0000000..d4013fb --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_dic.cs @@ -0,0 +1,27 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_dic + { + /// + /// code + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// sign + /// + [SugarColumn(IsNullable = true)] + public string? sign { get; set; } + + /// + /// remark + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_awaken.cs b/Service/Application.Domain.Entity/resource/game/game_equ_awaken.cs new file mode 100644 index 0000000..e7b62ff --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_awaken.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_awaken + { + /// + /// 特性表 + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string atId { get; set; } + + /// + /// 特性名称 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// levAttr + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List levAttr { get; set; } + + /// + /// 权重 + /// + [SugarColumn(IsNullable = true)] + public int? random { get; set; } + + /// + /// 可觉醒装备 + /// + [SugarColumn(IsNullable = true)] + public string? position { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_up.cs b/Service/Application.Domain.Entity/resource/game/game_equ_up.cs new file mode 100644 index 0000000..c84fcdc --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_up.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_up + { + /// + /// euId + /// + [SugarColumn(IsPrimaryKey = true)] + public int euId { get; set; } + + /// + /// onLev + /// + [SugarColumn(IsNullable = true)] + public int? onLev { get; set; } + + /// + /// maxLev + /// + [SugarColumn(IsNullable = true)] + public int? maxLev { get; set; } + + /// + /// okChance + /// + [SugarColumn(IsNullable = true)] + public int? okChance { get; set; } + + /// + /// needData + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List needData { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GameEnum.cs b/Service/Application.Domain/Enum/GameEnum.cs index 56434e5..b99b983 100644 --- a/Service/Application.Domain/Enum/GameEnum.cs +++ b/Service/Application.Domain/Enum/GameEnum.cs @@ -57,4 +57,9 @@ public static class GameEnum RetVigour, MapTo, } + + public enum DicCode + { + Awaken,//觉醒配置 + } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/MessageEnum.cs b/Service/Application.Domain/Enum/MessageEnum.cs index c3a18ac..2fd9480 100644 --- a/Service/Application.Domain/Enum/MessageEnum.cs +++ b/Service/Application.Domain/Enum/MessageEnum.cs @@ -8,4 +8,12 @@ public static class MessageEnum Marry,//婚姻消息 Trade,//交易通知 } + public enum BroadcastCode + { + Gift, + System, + Award, + Remind, + Promote + } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs index 3d6876b..937c5c4 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -6,7 +6,9 @@ public interface IGameEquService Task GetEquInfo(int equId); Task GetEuqSuitInfo(string suitCode); + #endregion + #region 用户装备 Task> GetUserEquData(string userId, int type, string equName, int PageIndex, int PageSize, @@ -21,6 +23,7 @@ public interface IGameEquService Task UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "", string remark = ""); + Task DeductUserEqu(string userId, List equData, string remark); Task DeductUserEqu(string userId, int equId, int count, string remark); @@ -30,12 +33,25 @@ public interface IGameEquService Task> GetUserOnEqu(string userId); Task EquOnOrDown(unit_user_equ data, int state); Task> GetUserEquSuit(string userId); + #endregion - #region 辅助 + #region 觉醒相关 + + Task GetEquAwakenInfo(string atId); + Task GetRandomOneAwakenByCode(string code); + Task GetEquAwakenInfoByLev(string atId, int lev); + + #endregion + + #region 强化相关 + + Task GetUserEquUpData(int lev); + #endregion + + #region 辅助 Task GetUserEquWeightSum(string userId); - #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Pub/IGameDicService.cs b/Service/Application.Domain/Services/Interface/Pub/IGameDicService.cs new file mode 100644 index 0000000..f7f34d3 --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Pub/IGameDicService.cs @@ -0,0 +1,6 @@ +namespace Application.Domain; + +public interface IGameDicService +{ + Task GetDicInfo(string code); +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs index bf1ca05..07044cc 100644 --- a/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs +++ b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs @@ -43,4 +43,11 @@ public interface IMessageService List btns = null, int days = 10); #endregion + + #region 广播消息 + + Task> GetBroadcastData(int area); + Task SendBroadcast(string userId, string code, string msg); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index 343ffcd..5e2e576 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -191,6 +191,11 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame { await AddEquLog(equData, code, remark); } + + if (equData.isOn == 1) + { + await ClearUserOnEqu(equData.userId); + } } return result; @@ -429,6 +434,98 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return result; } + #endregion + + #region 觉醒 + + public async Task GetEquAwakenInfo(string atId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "AwakenData"); + var data = await redis.GetHashAsync(key, atId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(i => i.atId == atId).SingleAsync(); + if (data != null) + { + await redis.AddHashAsync(key, atId, data); + } + } + + return data; + } + + public async Task GetRandomOneAwakenByCode(string code) + { + game_equ_awaken attr = new game_equ_awaken(); + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var list = await db.Queryable().Where(i => i.position.Contains(code)).ToListAsync(); + if (list.Count == 0) + { + return null; + } + + List data = new List(); + List weights = new List(); + List result = new List(); + Random rand = new Random(); + + foreach (var item in list) + { + data.Add(item); + weights.Add(ushort.Parse(item.random.ToString())); + } + + RandomAssist random = new RandomAssist(1); + + result = random.ControllerRandomExtract(rand, data, weights); + if (result.Count > 0) + { + attr = result[0] as game_equ_awaken; + return attr; + } + else + { + return null; + } + } + + public async Task GetEquAwakenInfoByLev(string atId, int lev) + { + var awakenInfo = await GetEquAwakenInfo(atId); + EquAwakenData awaken = new EquAwakenData(); + foreach (var item in awakenInfo.levAttr) + { + if (item.lev == lev) + { + return item; + } + } + + return null; + } + + #endregion + + #region 强化相关 + + public async Task GetUserEquUpData(int lev) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquUpData"); + var data = await redis.GetHashAsync(key, lev.ToString()); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(i => i.onLev <= lev && i.maxLev >= lev).FirstAsync(); + if (data != null) + { + await redis.AddHashAsync(key, lev.ToString(), data); + } + } + return data; + } + + #endregion #region 辅助方法 diff --git a/Service/Application.Domain/Services/Service/Map/GameMapService.cs b/Service/Application.Domain/Services/Service/Map/GameMapService.cs index ed31d1e..5b25721 100644 --- a/Service/Application.Domain/Services/Service/Map/GameMapService.cs +++ b/Service/Application.Domain/Services/Service/Map/GameMapService.cs @@ -832,7 +832,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame if (!string.IsNullOrEmpty(offSet)) { var offsetData = JsonConvert.DeserializeObject(offSet); - var chekResult = await GameBus.CheakNeed(userId, offsetData, ""); + var chekResult = await GameBus.CheckNeed(userId, offsetData); if (chekResult.result) { if (offsetData.isOp == 0) @@ -858,7 +858,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame public async Task> GetMapBus(string BusCode, int v, int l) { - string key = string.Format(BaseCache.BaseCacheKeys, "CITY_MAP_BUS", BusCode); + string key = string.Format(BaseCache.BaseCacheKeys, "CityMapBus", BusCode); var data = await redis.GetAsync>(key); if (data == null) { @@ -877,7 +877,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame public async Task GetMapBusInfo(int busId) { - string key = string.Format(BaseCache.BaseCacheKeys, "CITY_MAP_BUS", "BUS_INFO"); + string key = string.Format(BaseCache.BaseCacheKeys, "CityMapBus", "BUS_INFO"); if (await redis.HExistsHashAsync(key, busId.ToString())) { return await redis.GetHashAsync(key, busId.ToString()); @@ -925,6 +925,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame #endregion #region 地图资源 + public async Task GetMapResInfo(string resId) { string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "MapResInfo"); @@ -938,6 +939,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return data; } + public async Task> GetMapRes(string mapId) { string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "MapRes"); diff --git a/Service/Application.Domain/Services/Service/Pub/GameDicService.cs b/Service/Application.Domain/Services/Service/Pub/GameDicService.cs new file mode 100644 index 0000000..91d74a5 --- /dev/null +++ b/Service/Application.Domain/Services/Service/Pub/GameDicService.cs @@ -0,0 +1,19 @@ +namespace Application.Domain; + +public class GameDicService(ISqlSugarClient DbClient, IRedisCache redis) : IGameDicService, ITransient +{ + public async Task GetDicInfo(string code) + { + string key = string.Format(BaseCache.BaseCacheKey, "DicData"); + if (await redis.HExistsHashAsync(key, code)) + { + return await redis.GetHashAsync(key, code); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.code == code).SingleAsync(); + await redis.AddHashAsync(key, code, data); + return data; + } + +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/MessageService.cs b/Service/Application.Domain/Services/Service/Pub/MessageService.cs index 214af37..9d0a658 100644 --- a/Service/Application.Domain/Services/Service/Pub/MessageService.cs +++ b/Service/Application.Domain/Services/Service/Pub/MessageService.cs @@ -311,8 +311,9 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess return await db.Queryable().Where(it => it.state == 0 && it.token == token).AnyAsync(); } - public async Task SendEventMsg(string userId, string code, string name, string sign, string pars,string token, - List btns=null, int days = 10) + public async Task SendEventMsg(string userId, string code, string name, string sign, string pars, + string token, + List btns = null, int days = 10) { unit_user_message_event data = new unit_user_message_event(); data.eventId = StringAssist.NewGuid; @@ -331,8 +332,9 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess } else { - data.btns = btns; + data.btns = btns; } + data.addTime = DateTime.Now; data.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(days)); data.token = token; @@ -347,4 +349,54 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess } #endregion + + #region 广播消息 + + public async Task> GetBroadcastData(int area) + { + List data = new List(); + string key = string.Format(BaseCache.BaseCacheKey, "GameBroadcast"); + var result = await redis.GetHashAllAsync(key); + if (result.Count > 0) + { + data = result.Values.ToList(); + } + + long time = TimeExtend.GetTimeStampSeconds; + data = data.FindAll(it => (it.area == area || it.area == 0) && it.endTime > time); + data = data.OrderByDescending(it => it.endTime).Take(2).ToList(); + return data; + } + + public async Task SendBroadcast(string userId, string code, string msg) + { + game_broadcast add = new game_broadcast(); + add.Id = StringAssist.NewGuid; + add.userId = userId; + add.code = code; + add.msg = msg; + int area = 0; + if (add.userId == "0") + { + add.area = 0; + add.userNo = "0"; + add.nick = "海精灵"; + } + else + { + var userService = App.GetService(); + var userInfo = await userService.GetUserInfoByUserId(userId); + add.area = (int)userInfo.areaId; + add.userNo = userInfo.userNo; + add.nick = userInfo.nick; + area = add.area; + } + + add.endTime = TimeExtend.GetTimeStampSeconds + 300; + string key = string.Format(BaseCache.BaseCacheKey, "GameBroadcast"); + bool result = await redis.AddHashAsync(key, add.Id, add); + return result; + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Tool/Base/GameBus.cs b/Service/Application.Domain/Tool/Base/GameBus.cs index c1e295a..027528a 100644 --- a/Service/Application.Domain/Tool/Base/GameBus.cs +++ b/Service/Application.Domain/Tool/Base/GameBus.cs @@ -1,6 +1,6 @@ namespace Application.Domain; -public class GameBus +public static class GameBus { #region 物品资源操作 @@ -96,20 +96,24 @@ public class GameBus #region 验证 - public static async Task CheakNeed(string userId, TowerNeed item, string sid, int count = 1) + public static async Task CheckNeed(string userId, TowerNeed item, int count = 1) { CheckTowerNeed result = new CheckTowerNeed(); + result.Needs = new List(); bool isok = true; int isDeal = 1; int isGive = 1; - + item.isAsk = 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) + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; + if (MyCount < needCount) { + item.isAsk = 0; isok = false; } } @@ -132,29 +136,38 @@ public class GameBus } } - int needCount = item.count * count; + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; if (MyCount < needCount) { isok = false; + item.isAsk = 0; } } 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; + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; if (MyAcc < needAcc) { isok = false; + item.isAsk = 0; } } 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; + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; if (MyAcc < needAcc) { + item.isAsk = 0; isok = false; } } @@ -162,9 +175,12 @@ public class GameBus { var attrService = App.GetService(); var MyAcc = await attrService.GetUserVigourInfo(userId); - decimal neecAcc = item.count * count; - if (MyAcc.vitality < neecAcc) + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = (long)MyAcc.vitality; + if (MyAcc.vitality < needAcc) { + item.isAsk = 0; isok = false; } } @@ -172,6 +188,8 @@ public class GameBus { var attrService = App.GetService(); var MyLev = await attrService.GetUserLev(userId); + item.count = item.count; + item.onCount = MyLev; if (MyLev < item.count) { isok = false; @@ -181,18 +199,20 @@ public class GameBus result.result = isok; result.isDeal = isDeal; result.isGive = isGive; + result.Needs.Add(item); return result; } - public static async Task CheakNeed(string userId, List needs, string sid, int count = 1) + public static async Task CheckNeed(string userId, List needs, int count = 1) { CheckTowerNeed result = new CheckTowerNeed(); + result.Needs = new List(); bool isok = true; int isDeal = 1; int isGive = 1; foreach (var item in needs) { - var cheakResult = await CheakNeed(userId, item, sid, count); + var cheakResult = await CheckNeed(userId, item, count); if (isok) { isok = cheakResult.result; @@ -208,7 +228,116 @@ public class GameBus isGive = 0; } - item.isAsk = cheakResult.result ? 1 : 0; + result.Needs.AddRange(cheakResult.Needs); + } + + result.result = isok; + result.isDeal = isDeal; + result.isGive = isGive; + return result; + } + + public static async Task CheckNeeds(string userId, List needs, int count = 1) + { + CheckTowerNeeds result = new CheckTowerNeeds(); + bool isok = true; + int isDeal = 1; + int isGive = 1; + result.Needs = new List(); + foreach (var item in needs) + { + item.isAsk = 1; + if (item.code == nameof(GameEnum.PropCode.Equ)) + { + var equService = App.GetService(); + int MyCount = await equService.GetUserEquByEquIdCount(userId, Convert.ToInt32(item.parameter)); + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; + if (MyCount < needCount) + { + item.isAsk = 0; + 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; + } + } + + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; + if (MyCount < needCount) + { + isok = false; + item.isAsk = 0; + } + } + else if (item.code == nameof(GameEnum.PropCode.copper)) + { + var accService = App.GetService(); + var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; + if (MyAcc < needAcc) + { + isok = false; + item.isAsk = 0; + } + } + else if (item.code == nameof(GameEnum.PropCode.gold)) + { + var accService = App.GetService(); + var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold)); + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; + if (MyAcc < needAcc) + { + item.isAsk = 0; + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.vigour)) //活力 + { + var attrService = App.GetService(); + var MyAcc = await attrService.GetUserVigourInfo(userId); + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = (long)MyAcc.vitality; + if (MyAcc.vitality < needAcc) + { + item.isAsk = 0; + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.lev)) + { + var attrService = App.GetService(); + var MyLev = await attrService.GetUserLev(userId); + item.count = item.count; + item.onCount = MyLev; + if (MyLev < item.count) + { + isok = false; + } + } result.Needs.Add(item); } @@ -240,7 +369,7 @@ public class GameBus foreach (var item in timeAward) { var onAward = result.FindIndex(it => it.code == item.code && it.parameter == item.par); - if(onAward>-1) + if (onAward > -1) { result[onAward].count += item.count; } @@ -256,7 +385,6 @@ public class GameBus result.Add(add); } } - } return result; @@ -271,10 +399,12 @@ public class GameBus { return result; } + if (random.data.Count == 0) { return result; } + double totalWeight = random.data.Sum(it => it.chance); int rnd = _randomInstance.Next(Convert.ToInt32(totalWeight) + 1); double current = 0; @@ -290,6 +420,7 @@ public class GameBus return result; } + private static List RandomHandleByChance(RandomModel random, int luck = 0) { var _randomInstance = new Random(); @@ -299,11 +430,12 @@ public class GameBus { return result; } + if (random.data.Count == 0) { return result; } - + foreach (var item in random.data) { double rnd = _randomInstance.NextDouble(); @@ -313,6 +445,7 @@ public class GameBus result.Add(item); } } + return result; } diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 62b717e..53667f0 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -132,6 +132,7 @@ public class MapController : ControllerBase #endregion + var broadcast = await _messageService.GetBroadcastData(area); object ret = new { @@ -143,7 +144,8 @@ public class MapController : ControllerBase nearUser, noReadMsg = noReadMsg[3], business, - mapRes + mapRes, + broadcast }; return PoAction.Ok(ret); diff --git a/Service/Application.Web/Controllers/Pub/EquController.cs b/Service/Application.Web/Controllers/Pub/EquController.cs index 11b416b..5baff62 100644 --- a/Service/Application.Web/Controllers/Pub/EquController.cs +++ b/Service/Application.Web/Controllers/Pub/EquController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; namespace Application.Web.Controllers.Pub; @@ -13,12 +14,17 @@ public class EquController : ControllerBase private readonly IGameEquService _equService; private readonly IUnitUserAttrService _attrService; private readonly IUnitUserService _userService; + private readonly IGameDicService _dicService; + private readonly IMessageService _messageService; - public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService) + public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService, + IGameDicService dicService, IMessageService messageService) { _equService = equService; _attrService = attrService; _userService = userService; + _dicService = dicService; + _messageService = messageService; } /// @@ -109,12 +115,6 @@ public class EquController : ControllerBase return PoAction.Message("装备不存在!"); } - if (equInfo.isAppr == 0) - { - return PoAction.Message("装备未鉴定!"); - } - - equInfo.isLock = equInfo.isLock == 0 ? 1 : 0; bool result = await _equService.UpdateUserEquInfo(equInfo); @@ -341,4 +341,393 @@ public class EquController : ControllerBase return PoAction.Ok(new { data, suit }); } + + /// + /// 获取装备觉醒所需 + /// + /// + /// + [HttpGet] + public async Task GetEquAwakenInfo(string ue) + { + string userId = StateHelper.userId; + var equData = await _equService.GetUserEquInfo(ue); + if (equData == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + if (equData.useEndTime < TimeExtend.GetTimeStampSeconds) + { + return PoAction.Message("装备已过期!"); + } + + CheckTowerNeed result = new CheckTowerNeed(); + if (equData.EquAwaken.Count == 0) + { + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + result = await GameBus.CheckNeed(userId, need); + } + else + { + var upAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, equData.EquAwaken[0].lev + 1); + if (upAwaken == null) + { + return PoAction.Message("觉醒已达到上限!"); + } + + result = await GameBus.CheckNeed(userId, upAwaken.need); + } + + return PoAction.Ok(result); + } + + /// + /// 觉醒装备 + /// + /// + /// 0重置,1正常觉醒 + /// + [HttpGet] + public async Task HandleEquAwaken(string ue, int type) + { + string userId = StateHelper.userId; + var equData = await _equService.GetUserEquInfo(ue); + if (equData == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + if (equData.useEndTime < TimeExtend.GetTimeStampSeconds) + { + return PoAction.Message("装备已过期!"); + } + + EquAwakenData onAwaken = new EquAwakenData(); + game_equ_awaken newAwaken = new game_equ_awaken(); + CheckTowerNeed result = new CheckTowerNeed(); + if (type == 0) //重置 + { + newAwaken = await _equService.GetRandomOneAwakenByCode(equData.code); + if (newAwaken == null) + { + return PoAction.Message("该部件装备不可觉醒!"); + } + + onAwaken = newAwaken.levAttr.Find(it => it.lev == 1); + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + result = await GameBus.CheckNeed(userId, need); + } + else + { + if (equData.EquAwaken.Count == 0) + { + newAwaken = await _equService.GetRandomOneAwakenByCode(equData.code); + if (newAwaken == null) + { + return PoAction.Message("该部件装备不可觉醒!"); + } + + onAwaken = newAwaken.levAttr.Find(it => it.lev == 1); + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + result = await GameBus.CheckNeed(userId, need); + } + else + { + var upAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, equData.EquAwaken[0].lev + 1); + if (upAwaken == null) + { + return PoAction.Message("觉醒已达到上限!"); + } + + newAwaken = await _equService.GetEquAwakenInfo(equData.EquAwaken[0].atId); + onAwaken = upAwaken; + result = await GameBus.CheckNeed(userId, upAwaken.need); + } + } + + if (result.result == false) + { + return PoAction.Message("不满足觉醒条件!"); + } + + if (await GameBus.UpdateBag(userId, 0, result.Needs, "觉醒装备")) + { + if (RandomAssist.CheakRandom(onAwaken.success)) + { + EquAwaken awaken = new EquAwaken(); + awaken.atId = newAwaken.atId; + awaken.name = newAwaken.name; + awaken.lev = onAwaken.lev; + awaken.awaken = onAwaken.attr; + equData.EquAwaken = [awaken]; + if (await _equService.UpdateUserEquInfo(equData, true, "觉醒", "装备觉醒")) + { + string msg = $"[{equData.equName}]装备的特性【{awaken.name}】升至{awaken.lev}级!"; + await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg); + //此处为觉醒成功,返回相关数据 + var nextAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, + equData.EquAwaken[0].lev + 1); + var nextResult = new CheckTowerNeed() + { + result = false, + Needs = new List() + }; + if (nextAwaken != null) + { + nextResult = await GameBus.CheckNeed(userId, nextAwaken.need); + } + + return PoAction.Ok(new { state = 1, awaken = equData.EquAwaken, result = nextResult }, "觉醒成功!"); + } + else + { + return PoAction.Message("觉醒异常,请稍后尝试!"); + } + } + else + { + //此处为觉醒成功,返回相关数据 + var nextAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, + equData.EquAwaken[0].lev + 1); + var nextResult = new CheckTowerNeed() + { + result = false, + Needs = new List() + }; + if (nextAwaken != null) + { + nextResult = await GameBus.CheckNeed(userId, nextAwaken.need); + } + + return PoAction.Ok(new { state = 0, awaken = equData.EquAwaken, result = nextResult }, "觉醒失败!"); + } + } + else + { + return PoAction.Message("觉醒异常,请稍后尝试!"); + } + + return PoAction.Ok(result); + } + + /// + /// 获取强化信息 + /// + /// + /// + [HttpGet] + public async Task GetEquUpInfo(string ueId) + { + string userId = StateHelper.userId; + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + long time = TimeExtend.GetTimeStampSeconds; + if (equInfo.useEndTime < time) + { + return PoAction.Message("装备已过期!"); + } + + if (equInfo.isIntensify == 0) + { + return PoAction.Message("装备不可强化!"); + } + + bool isMax = false; + int upLev = (int)equInfo.intensifyLev + 1; + var needs = await _equService.GetUserEquUpData(upLev); + if (needs == null) + { + isMax = true; + } + + CheckTowerNeeds result = new CheckTowerNeeds(); + result.result = false; + result.Needs = new List(); + if (!isMax) + { + result = await GameBus.CheckNeeds(userId, needs.needData); + } + + return PoAction.Ok(new + { + equData = equInfo, + isMax, + result + }); + } + + /// + /// 强化装备 + /// + /// + /// + [HttpPost] + public async Task HandleEquUp([FromBody] EquUpParms parms) + { + string ueId = parms.ueId; + string userId = StateHelper.userId; + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + long time = TimeExtend.GetTimeStampSeconds; + if (equInfo.useEndTime < time) + { + return PoAction.Message("装备已过期!"); + } + + if (equInfo.isIntensify == 0) + { + return PoAction.Message("装备不可强化!"); + } + + int upLev = (int)equInfo.intensifyLev + 1; + var needs = await _equService.GetUserEquUpData(upLev); + if (needs == null) + { + return PoAction.Message("已达到最大强化等级!"); + } + + List reqNeeds = JsonConvert.DeserializeObject>(parms.needs); + //验证材料 + foreach (var item in needs.needData) + { + var onNeed = reqNeeds.Find(it => it.Id == item.Id); + if (item.NeedItem.Any(it => it.code == onNeed.code && it.parameter == onNeed.parameter) == false && + item.code != onNeed.code && item.parameter != onNeed.parameter) + { + return PoAction.Message("材料错误!"); + } + } + + var result = await GameBus.CheckNeeds(userId, reqNeeds); + if (result.result == false) + { + return PoAction.Message("材料不足!"); + } + + if (await GameBus.UpdateBag(userId, 0, reqNeeds, $"强化装备:{ueId}")) + { + CheckTowerNeeds nexResult = new CheckTowerNeeds(); + nexResult.result = false; + nexResult.Needs = new List(); + bool isMax = false; + int state = 0; + int okNum = (int)needs.okChance; + if (RandomAssist.CheakRandom(okNum)) + { + state = 1; + equInfo.intensifyLev = upLev; + equInfo.isDeal = result.isDeal; + equInfo.isGive = result.isGive; + if (await _equService.UpdateUserEquInfo(equInfo, true, "强化", "强化装备") == false) + { + return PoAction.Message("强化异常,请联系客服!"); + } + + var nextNeeds = await _equService.GetUserEquUpData((int)equInfo.intensifyLev + 1); + if (needs == null) + { + isMax = true; + } + else + { + var nexts = nextNeeds.euId == needs.euId ? reqNeeds : nextNeeds.needData; + nexResult = await GameBus.CheckNeeds(userId, nexts); + } + } + else //执行材料返还 + { + List retProp = new List(); + foreach (var item in reqNeeds) + { + if (item.retCount > 0 && item.isOp == 1) + { + TowerGet temp = new TowerGet() + { + code = item.code, + name = item.name, + parameter = item.parameter, + count = item.count + }; + retProp.Add(temp); + } + } + + if (retProp.Count > 0) + { + await GameBus.UpdateBag(userId, 1, retProp, "强化失败,返还"); + } + + nexResult = await GameBus.CheckNeeds(userId, reqNeeds); + } + + + return PoAction.Ok(new + { + state, + equData = equInfo, + isMax, + result = nexResult + }); + } + else + { + return PoAction.Message("强化错误,请稍后尝试!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/BagController.cs b/Service/Application.Web/Controllers/User/BagController.cs index 1b5fdf0..2fe4a17 100644 --- a/Service/Application.Web/Controllers/User/BagController.cs +++ b/Service/Application.Web/Controllers/User/BagController.cs @@ -126,4 +126,18 @@ public class BagController : ControllerBase return PoAction.Ok(new { data = new List(), total = total.Value }); } } + + /// + /// 验证用户道具 + /// + /// + /// + [HttpPost] + public async Task CheckUserProp([FromBody] CheckUserPropParms parms) + { + string userId = StateHelper.userId; + List needs = JsonConvert.DeserializeObject>(parms.needs); + var result = await GameBus.CheckNeeds(userId, needs, 1); + return PoAction.Ok(result); + } } \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/Equ/EquUpParms.cs b/Service/Application.Web/Model/RequestParms/Equ/EquUpParms.cs new file mode 100644 index 0000000..e20f461 --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/Equ/EquUpParms.cs @@ -0,0 +1,7 @@ +namespace Application.Web; + +public class EquUpParms +{ + public string ueId { get; set; } + public string needs { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs b/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs new file mode 100644 index 0000000..0a33a6f --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs @@ -0,0 +1,6 @@ +namespace Application.Web; + +public class CheckUserPropParms +{ + public string needs { get; set; } +} \ No newline at end of file diff --git a/Web/public/images/broad/award.gif b/Web/public/images/broad/award.gif new file mode 100644 index 0000000..c1c151b Binary files /dev/null and b/Web/public/images/broad/award.gif differ diff --git a/Web/public/images/broad/gift.gif b/Web/public/images/broad/gift.gif new file mode 100644 index 0000000..8e75525 Binary files /dev/null and b/Web/public/images/broad/gift.gif differ diff --git a/Web/public/images/broad/hot1.gif b/Web/public/images/broad/hot1.gif new file mode 100644 index 0000000..5d6d015 Binary files /dev/null and b/Web/public/images/broad/hot1.gif differ diff --git a/Web/public/images/broad/promote.gif b/Web/public/images/broad/promote.gif new file mode 100644 index 0000000..f86aca1 Binary files /dev/null and b/Web/public/images/broad/promote.gif differ diff --git a/Web/public/images/broad/remind.gif b/Web/public/images/broad/remind.gif new file mode 100644 index 0000000..b667ccd Binary files /dev/null and b/Web/public/images/broad/remind.gif differ diff --git a/Web/public/images/broad/system.gif b/Web/public/images/broad/system.gif new file mode 100644 index 0000000..aeff515 Binary files /dev/null and b/Web/public/images/broad/system.gif differ diff --git a/Web/src/components/Base/Aimage.vue b/Web/src/components/Base/Aimage.vue index 087fa08..c5a224d 100644 --- a/Web/src/components/Base/Aimage.vue +++ b/Web/src/components/Base/Aimage.vue @@ -1,5 +1,7 @@ \ No newline at end of file diff --git a/Web/src/components/Business/GameBroadcast.vue b/Web/src/components/Business/GameBroadcast.vue new file mode 100644 index 0000000..aa5778f --- /dev/null +++ b/Web/src/components/Business/GameBroadcast.vue @@ -0,0 +1,408 @@ + + + \ No newline at end of file diff --git a/Web/src/components/Business/GamePropVerify.vue b/Web/src/components/Business/GamePropVerify.vue new file mode 100644 index 0000000..02255c2 --- /dev/null +++ b/Web/src/components/Business/GamePropVerify.vue @@ -0,0 +1,18 @@ + + \ No newline at end of file diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue index aa44778..2153825 100644 --- a/Web/src/pages/map/index.vue +++ b/Web/src/pages/map/index.vue @@ -1,7 +1,8 @@ \ No newline at end of file diff --git a/Web/src/pages/user/bag/index.vue b/Web/src/pages/user/bag/index.vue index c32a241..411e82f 100644 --- a/Web/src/pages/user/bag/index.vue +++ b/Web/src/pages/user/bag/index.vue @@ -54,7 +54,7 @@ (未鉴定) (过期) (损坏) - (锁) + (绑)
diff --git a/Web/src/pages/user/equ/awaken.vue b/Web/src/pages/user/equ/awaken.vue new file mode 100644 index 0000000..8f13f8e --- /dev/null +++ b/Web/src/pages/user/equ/awaken.vue @@ -0,0 +1,48 @@ + + \ No newline at end of file diff --git a/Web/src/pages/user/equ/up.vue b/Web/src/pages/user/equ/up.vue new file mode 100644 index 0000000..f828b88 --- /dev/null +++ b/Web/src/pages/user/equ/up.vue @@ -0,0 +1,147 @@ + + \ No newline at end of file diff --git a/Web/src/services/Index/EquService.ts b/Web/src/services/Index/EquService.ts index 38a5195..ccc6a8c 100644 --- a/Web/src/services/Index/EquService.ts +++ b/Web/src/services/Index/EquService.ts @@ -54,4 +54,39 @@ export class EquService { static async GetUserOnSuitInfo(suitCode: string) { return await ApiService.Request("get", "/Equ/GetUserOnSuitInfo", { suitCode }); } + + /** + * 获取装备觉醒所需 + * GET /Equ/GetEquAwakenInfo + */ + static async GetEquAwakenInfo(ue: string) { + return await ApiService.Request("get", "/Equ/GetEquAwakenInfo", { ue }); + } + + /** + * 觉醒装备 + * GET /Equ/HandleEquAwaken + * @param type 0重置,1正常觉醒 + */ + static async HandleEquAwaken(ue: string, type: number) { + return await ApiService.Request("get", "/Equ/HandleEquAwaken", { ue, type }); + } + + /** + * 获取强化信息 + * GET /Equ/GetEquUpInfo + */ + static async GetEquUpInfo(ueId: string) { + return await ApiService.Request("get", "/Equ/GetEquUpInfo", { ueId }); + } + + /** + * 强化装备 + * POST /Equ/HandleEquUp + * @param ueId body + * @param needs body + */ + static async HandleEquUp(ueId: string, needs: string) { + return await ApiService.Request("post", "/Equ/HandleEquUp", { ueId, needs }); + } } \ No newline at end of file diff --git a/Web/src/services/user/BagService.ts b/Web/src/services/user/BagService.ts index bd83acc..0892817 100644 --- a/Web/src/services/user/BagService.ts +++ b/Web/src/services/user/BagService.ts @@ -8,10 +8,19 @@ export class BagService { } /** - * GetUserBagProp + * 获取用户道具数据 * GET /User/Bag/GetUserBagProp */ static async GetUserBagProp(type: number, ch: number, query: string, page: number) { return await ApiService.Request("get", "/User/Bag/GetUserBagProp", { type, ch, query, page }); } + + /** + * 验证用户道具 + * POST /User/Bag/CheckUserProp + * @param needs body + */ + static async CheckUserProp(needs: string) { + return await ApiService.Request("post", "/User/Bag/CheckUserProp", { needs }); + } } \ No newline at end of file