diff --git a/Service/Application.Domain.Entity/db/game_map_goods.cs b/Service/Application.Domain.Entity/db/game_map_goods.cs new file mode 100644 index 0000000..73e08d3 --- /dev/null +++ b/Service/Application.Domain.Entity/db/game_map_goods.cs @@ -0,0 +1,40 @@ +namespace Application.Domain.Entity +{ + public class game_map_goods + { + /// + /// mgId + /// + public string mgId { get; set; } + + /// + /// userId + /// + public string? userId { get; set; } + + /// + /// mapId + /// + public string? mapId { get; set; } + + /// + /// name + /// + public string? name { get; set; } + + /// + /// code + /// + public string? code { get; set; } + + /// + /// par + /// + public string? par { get; set; } + + /// + /// count + /// + public long count { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/RandomModel.cs b/Service/Application.Domain.Entity/model/RandomModel.cs index 8c3983f..46eab1e 100644 --- a/Service/Application.Domain.Entity/model/RandomModel.cs +++ b/Service/Application.Domain.Entity/model/RandomModel.cs @@ -13,7 +13,7 @@ public class RandomModel /// public string code { get; set; } public string name { get; set; } - public int empty { get; set; } + public double empty { get; set; } public List data { get; set; } } diff --git a/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs index db5c875..cf5eb18 100644 --- a/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs +++ b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs @@ -15,7 +15,7 @@ public interface IGameFightService string scene, string mapId, string userId, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = ""); - Task SetFightWin(game_fight_data fightData, string winUser); + Task SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true); #endregion @@ -24,6 +24,10 @@ public interface IGameFightService Task GetUserFightHarm(string userId); Task SetUserFightHarm(string userId, int harm); Task HandleFight(game_fight_data eventData); + Task> GetMapFightGoods(string mapId); + Task GetFightGoodsInfo(string mapId, string mgId); + Task RemoveFightGoods(string mapId, string mgId); + Task AutoUseDrug(UserAttrModel user, game_fight_data fight); #endregion } \ 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 05814d6..fd37e06 100644 --- a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs +++ b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs @@ -32,8 +32,9 @@ public interface IGameGoodsService #region 药品 Task CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = ""); + Task CheckUseDrug(string userId, int goodsId, string scene = ""); Task UseDrug(string userId, int goodsId, string drugConfig, string scene = ""); - + Task UseDrug(string userId, int goodsId, string scene = ""); #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs index 34fc0c7..236e147 100644 --- a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs +++ b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs @@ -23,7 +23,7 @@ public interface IGameMapService Task UpdateUserOnMap(string userId, string ip, string mapId); Task UpdateUserOnMap(unit_user_online data, string mapId); Task GetUserOnMapInfo(string userId); - Task SetUserMapDefult(string userId); + Task SetUserMapDefault(string userId); Task GetToMapInfo(string userId, string toMap, bool isUpUserMap = true, bool isChangeCity = false); Task> GetUserCityMapData(string userId); Task AddUserCityMap(string userId, int cityId); diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs index c9d10ba..2de3433 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -51,7 +51,7 @@ public interface IUnitUserAttrService Task GetUserDrug(string userId); Task UpdateUserDrug(unit_user_drug data); - + Task UpdateUserDrug(string userId, string drugId, int op, int count); #endregion #region BUFF状态 diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs index 673911f..433291e 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs @@ -11,7 +11,8 @@ public interface IUnitUserWeight Task> GetUserWeightLog(string userId); Task CheckUserWeight(string userId, int useWeight); - + Task CheckUserWeight(string userId, TowerGet data); + Task CheckUserWeight(string userId, string code, string par, long count); #region 船只相关 Task GetUserShipInfo(string usId); Task> GetUserShip(string userId); diff --git a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs index ad91fee..cc4ad15 100644 --- a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs +++ b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs @@ -1,4 +1,7 @@ -namespace Application.Domain; +using Dm.util; +using Newtonsoft.Json; + +namespace Application.Domain; public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGameFightService, ITransient { @@ -164,7 +167,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return result; } - public async Task SetFightWin(game_fight_data fightData, string winUser) + public async Task SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true) { bool result = false; long okTime = TimeExtend.GetTimeStampSeconds; @@ -213,6 +216,10 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa if (result) { await RemoveUserFight(fightData.userId); + if (setDefMap) + { + await UserStateTool.SetUserMapDefault(fightData.userId); + } } } } @@ -224,6 +231,10 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa if (result) { await RemoveUserFight(lowUser); + if (setDefMap) + { + await UserStateTool.SetUserMapDefault(lowUser); + } } } @@ -306,6 +317,8 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa await redis.AddHashAsync(key, userId, harm); } + #region 战斗地图掉落 + public async Task HandleFight(game_fight_data fightData) { string winUser = fightData.winUser; @@ -328,8 +341,227 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa { } + if (!string.IsNullOrEmpty(fightData.award)) //发放物品奖励 + { + await PutFightAwardGoods(fightData); + } + #endregion } + private async Task PutFightAwardGoods(game_fight_data fightData) + { + var fightAward = JsonConvert.DeserializeObject(fightData.award); + if (fightAward.code == "Default") + { + var userService = App.GetService(); + var userConfig = await userService.GetUserConfigInfo(fightData.winUser); + List AddMapGoods = new List(); + var opGoods = JsonConvert.DeserializeObject>(fightAward.award.ToString()); + string addGoodsUser = fightData.areaCode == nameof(GameEnum.AreaCode.Public) ? "0" : fightData.winUser; + if (userConfig.autoBag == 1) + { + var weightService = App.GetService(); + bool auto = true; + foreach (var item in opGoods) + { + if (auto == false) + { + AddMapGoods.Add(item); + } + else + { + if (await weightService.CheckUserWeight(fightData.winUser, item)) + { + await GameBus.UpdateBag(fightData.winUser, 1, item.code, item.parameter, item.count, + "战斗获得"); + } + else + { + auto = false; + AddMapGoods.add(item); + } + } + } + } + else + { + AddMapGoods = opGoods; + } + + if (AddMapGoods.Count > 0) + { + await AddMapFightGoods(addGoodsUser, fightData.mapId, AddMapGoods); + } + } + } + + public async Task> GetMapFightGoods(string mapId) + { + List result = new List(); + string key = string.Format(FightCache.FightCacheKeys, "MapGoods", mapId); + if (await redis.ExistsAsync(key)) + { + result = await redis.GetAsync>(key); + } + + return result; + } + + public async Task GetFightGoodsInfo(string mapId, string mgId) + { + var data = await GetMapFightGoods(mapId); + var result = data.Find(it => it.mgId == mgId); + return result; + } + + private async Task AddMapFightGoods(string userId, string mapId, List goods) + { + var data = await GetMapFightGoods(mapId); + List addData = new List(); + foreach (var item in goods) + { + game_map_goods temp = new game_map_goods() + { + mgId = StringAssist.NewGuid, + userId = userId, + mapId = mapId, + name = item.name, + code = item.code, + par = item.parameter, + count = item.count + }; + addData.Add(temp); + } + + data.AddRange(addData); + string key = string.Format(FightCache.FightCacheKeys, "MapGoods", mapId); + await redis.SetAsync(key, data, 600); + } + + public async Task RemoveFightGoods(string mapId, string mgId) + { + var data = await GetMapFightGoods(mapId); + data = data.FindAll(it => it.mgId != mgId); + string key = string.Format(FightCache.FightCacheKeys, "MapGoods", mapId); + await redis.SetAsync(key, data, 600); + } + + #endregion + + #region 自动使用药品 + + public async Task AutoUseDrug(UserAttrModel user, game_fight_data fight) + { + var userService = App.GetService(); + var userConfig = await userService.GetUserConfigInfo(user.id); + await UseBloodDrug(user, fight, userConfig.autoDrug == 1, user.upBlood - user.blood); + if (userConfig.autoDrug == 1) + { + var attrService = App.GetService(); + var myDrug = await attrService.GetUserDrug(user.id); + var loadDrug = myDrug.drug.Find(it => it.code == nameof(GoodsEnum.DrugCls.LoadBuff) && it.count > 0); + if (loadDrug != null) + { + var goodsService = App.GetService(); + var _drugConfig = await goodsService.GetGoodsContent(loadDrug.goodsId); + string check = await goodsService.CheckUseDrug(user.id, loadDrug.goodsId, _drugConfig, fight.fightId); + if (string.IsNullOrEmpty(check)) + { + if (await attrService.UpdateUserDrug(user.id, loadDrug.id, 0, 1)) + { + await goodsService.UseDrug(user.id, loadDrug.goodsId, _drugConfig, fight.fightId); + } + } + } + } + } + + private async Task UseBloodDrug(UserAttrModel user, game_fight_data fight, bool isAuto, int addBlood) + { + //先判断储存状态 + var attrService = App.GetService(); + var goodsService = App.GetService(); + var bloodStock = await attrService.GetUserStock(user.id, "Blood"); + var myDrug = await attrService.GetUserDrug(user.id); + if (bloodStock.Count > 0) + { + foreach (var item in bloodStock) + { + string[] config = item.par.split("|"); + if (config[0] == fight.code || config[0] == "ALL") + { + decimal okLimit = Convert.ToDecimal(config[1]); + if ((Convert.ToDecimal(addBlood) / Convert.ToDecimal(user.upBlood) ) > okLimit) + { + if (item.type == "Number") + { + int opCount = item.sign > addBlood ? addBlood : Convert.ToInt32(item.sign); + item.sign = item.sign - opCount; + if (await attrService.UpdateUserStock(item)) + { + addBlood -= opCount; + await attrService.UpdateUserBlood(user.id, 1, opCount); + if (addBlood < 1) + { + break; + } + } + } + else if (item.type == "Time") + { + await attrService.UpdateUserBlood(user.id, 1, addBlood); + addBlood = 0; + break; + } + } + } + } + } + + if (isAuto && addBlood > 0) + { + //优先开放储存 + var stockDrug = myDrug.drug.Find(it => it.code == nameof(GoodsEnum.DrugCls.BloodStock) && it.count > 0); + if (stockDrug != null) + { + var _drugConfig = await goodsService.GetGoodsContent(stockDrug.goodsId); + string check = await goodsService.CheckUseDrug(user.id, stockDrug.goodsId, _drugConfig, fight.fightId); + if (string.IsNullOrEmpty(check)) + { + if (await attrService.UpdateUserDrug(user.id, stockDrug.id, 0, 1)) + { + if (await goodsService.UseDrug(user.id, stockDrug.goodsId, _drugConfig, fight.fightId)) + { + await UseBloodDrug(user, fight, isAuto, addBlood); + return; + } + } + } + } + + //使用普通药品 + if (addBlood > 0) + { + var unitDrug = myDrug.drug.Find(it => it.code == nameof(GoodsEnum.DrugCls.Blood) && it.count > 0); + if (unitDrug != null) + { + var _drugConfig = await goodsService.GetGoodsContent(unitDrug.goodsId); + string check = + await goodsService.CheckUseDrug(user.id, unitDrug.goodsId, _drugConfig, fight.fightId); + if (string.IsNullOrEmpty(check)) + { + if (await attrService.UpdateUserDrug(user.id, unitDrug.id, 0, 1)) + { + await goodsService.UseDrug(user.id, unitDrug.goodsId, _drugConfig, fight.fightId); + } + } + } + } + } + } + + #endregion + #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 1f34601..7ff6e8c 100644 --- a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs +++ b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs @@ -283,6 +283,16 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return result; } + public async Task CheckUseDrug(string userId, int goodsId,string scene = "") + { + string result = string.Empty; + var goodsInfo = await GetGoodsContent(goodsId); + if (!string.IsNullOrEmpty(goodsInfo)) + { + result = await CheckUseDrug(userId,goodsId, goodsInfo, scene); + } + return result; + } public async Task UseDrug(string userId, int goodsId, string drugConfig, string scene = "") { @@ -323,6 +333,17 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return result; } + public async Task UseDrug(string userId, int goodsId, string scene = "") + { + bool result = false; + var goodsInfo = await GetGoodsContent(goodsId); + if (!string.IsNullOrEmpty(goodsInfo)) + { + result = await UseDrug(userId,goodsId, goodsInfo, scene); + } + + return result; + } #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Map/GameMapService.cs b/Service/Application.Domain/Services/Service/Map/GameMapService.cs index a93d16a..19ed8f8 100644 --- a/Service/Application.Domain/Services/Service/Map/GameMapService.cs +++ b/Service/Application.Domain/Services/Service/Map/GameMapService.cs @@ -213,7 +213,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return true; } - public async Task SetUserMapDefult(string userId) + public async Task SetUserMapDefault(string userId) { var userMap = await GetUserOnMap(userId); var MapInfo = await GetMapInfo(userMap.mapId); @@ -762,7 +762,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame if (await StopUserRun(userId)) { var mapService = App.GetService(); - await mapService.SetUserMapDefult(userId); + await mapService.SetUserMapDefault(userId); } } } diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index 4be5b9a..b9f0698 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -256,10 +256,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : if (mustUp) { var db = DbClient.AsTenant().GetConnectionWithAttr(); - result = await db.Updateable() - .SetColumnsIF(op == 0, it => it.blood == it.blood - count) - .SetColumnsIF(op == 1, it => it.blood == it.blood + count) - .SetColumnsIF(op == 2, it => it.blood == count) + result = await db.Updateable().SetColumns(it => it.blood == data.blood) .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; } @@ -539,6 +536,30 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } + public async Task UpdateUserDrug(string userId, string drugId, int op, int count) + { + var data = await GetUserDrug(userId); + foreach (var item in data.drug) + { + if (item.id == drugId) + { + if (op == 0) + { + item.count = item.count - count; + } + else + { + item.count = item.count + count; + } + + break; + } + } + + bool result = await UpdateUserDrug(data); + return result; + } + private async Task ClearUserDrug(string userId) { string key = string.Format(UserCache.BaseCacheKeys, "UserTool", "DrugColumn"); diff --git a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs index 14dd995..467a278 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs @@ -122,6 +122,46 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return result; } + public async Task CheckUserWeight(string userId, TowerGet data) + { + bool result = await CheckUserWeight(userId, data.code, data.parameter, data.count); + return result; + } + + public async Task CheckUserWeight(string userId, string code, string par, long count) + { + bool result = true; + if (code == nameof(GameEnum.PropCode.Goods)) + { + var goodsService = App.GetService(); + var goodsInfo = await goodsService.GetGoodsInfo(Convert.ToInt32(par)); + if (goodsInfo != null) + { + int needCount = (int)goodsInfo.weight * Convert.ToInt32(count) ; + if (goodsInfo.code == nameof(GoodsEnum.Code.Cargo)) + { + result =await CheakUserShipWeight(userId, needCount); + } + else + { + result = await CheckUserWeight(userId, needCount); + } + } + } + else if (code == nameof(GameEnum.PropCode.Equ)) + { + var equService = App.GetService(); + var equInfo = await equService.GetEquInfo(Convert.ToInt32(par)); + if (equInfo != null) + { + int needCount = (int)equInfo.weight * Convert.ToInt32(count) ; + result = await CheckUserWeight(userId, needCount); + } + } + + return result; + } + #region 船只相关 public async Task GetUserShipInfo(string usId) diff --git a/Service/Application.Domain/Tool/Base/GameBus.cs b/Service/Application.Domain/Tool/Base/GameBus.cs index eff9b30..d91f501 100644 --- a/Service/Application.Domain/Tool/Base/GameBus.cs +++ b/Service/Application.Domain/Tool/Base/GameBus.cs @@ -423,8 +423,8 @@ public static class GameBus { var _randomInstance = new Random(); List result = new List(); - int empty = random.empty - Convert.ToInt32(luck * 100); - if (_randomInstance.Next(0, 100) < empty) + double empty = random.empty * (1.0 + (double)luck) / 100; + if (_randomInstance.NextDouble() > empty) { return result; } @@ -454,8 +454,8 @@ public static class GameBus { var _randomInstance = new Random(); List result = new List(); - int empty = random.empty; - if (_randomInstance.Next(0, 100) < empty) + double empty = (random.empty / 100); + if (_randomInstance.NextDouble() > empty) { return result; } diff --git a/Service/Application.Domain/Tool/Base/UserStateTool.cs b/Service/Application.Domain/Tool/Base/UserStateTool.cs index 6703557..5c89b1e 100644 --- a/Service/Application.Domain/Tool/Base/UserStateTool.cs +++ b/Service/Application.Domain/Tool/Base/UserStateTool.cs @@ -8,4 +8,10 @@ public static class UserStateTool var myFight = await fightService.GetUserFight(userId); return myFight.Count > 0; } + + public static async Task SetUserMapDefault(string userId) + { + var mapService = App.GetService(); + await mapService.SetUserMapDefault(userId); + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 8cfbb0a..3b35e4e 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -70,7 +70,7 @@ public class MapController : ControllerBase #region 地图导向处理 - bool isSelfMap = false; + bool isSelfMap = string.IsNullOrEmpty(map); if (!isSelfMap) { //血量为0得时候地图点为本身 @@ -78,7 +78,7 @@ public class MapController : ControllerBase if (myBlood.blood < 1) { //设置默认地图点 - await _mapService.SetUserMapDefult(userId); + await _mapService.SetUserMapDefault(userId); isSelfMap = true; gameTips = "➢当前体力为0,恢复一下吧!"; } @@ -147,6 +147,8 @@ public class MapController : ControllerBase var userFight = await _fightService.GetUserFight(userId); string fightId = userFight.Count > 0 ? userFight[0] : ""; + var mapGoods = await _fightService.GetMapFightGoods(mapInfo.mapId); + mapGoods = mapGoods.FindAll(it => it.userId == "0" || it.userId == userId).Take(3).ToList(); object ret = new { @@ -159,6 +161,7 @@ public class MapController : ControllerBase noReadMsg = noReadMsg[3], business, mapRes, + mapGoods, broadcast, monster = monsterData, fightId, @@ -733,4 +736,42 @@ public class MapController : ControllerBase } #endregion + + #region 地图物品 + + /// + /// 拾取地图物品 + /// + /// + /// + [HttpGet] + public async Task GetMapGoods(string mgId) + { + string userId = StateHelper.userId; + var onMap = await _mapService.GetUserOnMapId(userId); + var goods = await _fightService.GetFightGoodsInfo(onMap, mgId); + if (goods == null) + { + return PoAction.Message("物品已被拾取!"); + } + + if (await _weightService.CheckUserWeight(userId, goods.code, goods.par, goods.count)) + { + await _fightService.RemoveFightGoods(onMap, mgId); + if (await GameBus.UpdateBag(userId, 1, goods.code, goods.par, goods.count, "城市地图拾取")) + { + return PoAction.Ok(true, $"成功拾取:{goods.name}×{goods.count}!"); + } + else + { + return PoAction.Message("拾取失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("背包暂无空间!"); + } + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/FightController.cs b/Service/Application.Web/Controllers/Pub/FightController.cs index 745b0e8..574fe11 100644 --- a/Service/Application.Web/Controllers/Pub/FightController.cs +++ b/Service/Application.Web/Controllers/Pub/FightController.cs @@ -180,6 +180,7 @@ public class FightController : ControllerBase await _fightService.SetUserFightHarm(fight.mainId, fightResult.otHarm); await _attrService.UpdateUserBlood(fight.mainId, 1, fightResult.otHarm); } + otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene); } @@ -195,14 +196,21 @@ public class FightController : ControllerBase { await _fightService.SetFightWin(fight, fight.mainId); } + await _fightService.RemoveUserFight(userId, fightId); return PoAction.Message("战斗结束", 100); } else { - //自动使用药品 - - + if (fightResult.result == 0) + { + //自动使用药品 + await _fightService.AutoUseDrug(myAttr, fight); + if (otAttr.code == nameof(UserEnum.AttrCode.Person)) + { + await _fightService.AutoUseDrug(otAttr, fight); + } + } } //获取个人药品栏 @@ -216,7 +224,8 @@ public class FightController : ControllerBase { decimal diff = myAttr.agility - otAttr.agility; decimal bl = diff / otAttr.agility; - cool = Convert.ToInt32(bl * 1000.0m); + cool = Convert.ToInt32((1-bl) * 1000.0m); + cool = cool < 10 ? 10 : cool; cool = cool > 1000 ? 1000 : cool; } @@ -227,10 +236,7 @@ public class FightController : ControllerBase cool = Convert.ToInt32(cool * (1 + atkCoolData.count * 0.1M)); } - //更新伤害提示 - - - int exitCopper = otAttr.lev * 5; + int exitCopper = otAttr.lev * 5; //退出战斗需要的铜贝 var result = new { myHarm, @@ -294,7 +300,7 @@ public class FightController : ControllerBase { if (await _fightService.RemoveUserFight(userId, fightId)) { - await _fightService.SetFightWin(fight, fight.mainId); + await _fightService.SetFightWin(fight, fight.mainId,false); await _fightService.RemoveFightHarm(fightId, userId); //移除伤害 var nextFight = myFight.FindAll(it => it != fightId); string nextId = nextFight.Count > 0 ? nextFight[0] : ""; @@ -389,7 +395,7 @@ public class FightController : ControllerBase { string userId = StateHelper.userId; var myFight = await _fightService.GetUserFight(userId); - + var fight = await _fightService.GetFightInfo(fightId); if (fight == null) { @@ -411,7 +417,7 @@ public class FightController : ControllerBase { isWin = 0; } - else if(fight.winUser==userId) + else if (fight.winUser == userId) { isWin = 1; } @@ -460,7 +466,7 @@ public class FightController : ControllerBase otName = monsterInfo.name; } } - + var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene); diff --git a/Service/Application.Web/Controllers/User/UserController.cs b/Service/Application.Web/Controllers/User/UserController.cs index 9ab4b4d..e1874d0 100644 --- a/Service/Application.Web/Controllers/User/UserController.cs +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; namespace Application.Web.Controllers.User; @@ -398,11 +399,13 @@ public class UserController : ControllerBase { if (isAdd) { + string drugConfig = await _goodsService.GetGoodsContent(goodsId); + dynamic _drugConfig = JsonConvert.DeserializeObject(drugConfig); UserDrugModel temp = new UserDrugModel(); temp.id = StringAssist.NewGuid; temp.goodsId = goodsId; temp.name = myGoods.goodsName; - temp.code = "Blood"; + temp.code =Convert.ToString(_drugConfig.cls); temp.count = count; myDrug.drug.Add(temp); } diff --git a/Web/src/pages/fight/index.vue b/Web/src/pages/fight/index.vue index b2e2d98..c85c79a 100644 --- a/Web/src/pages/fight/index.vue +++ b/Web/src/pages/fight/index.vue @@ -100,7 +100,7 @@ const BindData = async (data: string): Promise => { coolTime.value = result.data.cool; dataLock = false; myHarm.value = result.data.myHarm; - otHarm.value = result.data.otHarm; + otHarm.value = result.data.otHarm; } else if (result.code == 100) { PageExtend.RedirectTo("/fight/result?f=" + fightId); diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue index 409537d..73c551b 100644 --- a/Web/src/pages/map/index.vue +++ b/Web/src/pages/map/index.vue @@ -39,6 +39,12 @@ {{ item.resName }}({{ item.lev }}级) +
+ 物品:
+
+ {{ item.name }}×{{ item.count }} +
+
请选择出口:
@@ -130,6 +136,7 @@ const monster = ref>([]); const messageCount = ref(0); const broadcast = ref>([]); const gameTips = ref(''); +const mapGoods = ref>([]); // 城内地图显示 const showCity = ref(false); @@ -163,7 +170,8 @@ const BindData = async (map: string): Promise => { MapVent(result.data.mapInfo.near); onMap.value = mapInfo.value.mapId; gameTips.value = result.data.gameTips; - console.log(result) + mapGoods.value = result.data.mapGoods; + // console.log(result) } else if (result.code == 103) { PageExtend.Redirect("/map/runing"); @@ -322,4 +330,19 @@ const AddFight = async (type: number, monsterId: string, sign: string) => { } } +/**拾取物品 */ +const GetMapGoods = async (mgId: string) => { +MessageExtend.LoadingToast("拾取中..."); + let result = await MapService.GetMapGoods(mgId); + MessageExtend.LoadingClose(); + if (result.code == 0) { + await BindData(""); + MessageExtend.Notify(result.msg,"success"); + } + else { + MessageExtend.Notify(result.msg,"danger"); + } + +} + diff --git a/Web/src/pages/prop/monster.vue b/Web/src/pages/prop/monster.vue index 806b15a..450b3ce 100644 --- a/Web/src/pages/prop/monster.vue +++ b/Web/src/pages/prop/monster.vue @@ -68,7 +68,7 @@ const BindData = async (): Promise => { const awardTipsStr = (data: any) => { let result = ''; if (data.type == 'Default') { - result += "怪物掉落几率:" + (100 - data.award.empty) + "%
" + result += "怪物掉落几率:" + data.award.empty + "%
" let awData: Array = data.award.data; awData.forEach(it => { result += "▸" + it.name + "(" + (data.award.code == 'Chance' ? "概率:" : "权重:") + it.chance + (data.award.code == 'Chance' ? "%" : "") + ")
"; diff --git a/Web/src/services/map/MapService.ts b/Web/src/services/map/MapService.ts index 7c0e660..359d090 100644 --- a/Web/src/services/map/MapService.ts +++ b/Web/src/services/map/MapService.ts @@ -94,4 +94,12 @@ export class MapService { static async CollectMapRes(resId: string) { return await ApiService.Request("get", "/Map/Map/CollectMapRes", { resId }); } + + /** + * 拾取地图物品 + * GET /Map/Map/GetMapGoods + */ + static async GetMapGoods(mgId: string) { + return await ApiService.Request("get", "/Map/Map/GetMapGoods", { mgId }); + } } \ No newline at end of file