This commit is contained in:
Putoo
2026-07-06 14:44:15 +08:00
parent a1dbce8a96
commit 63d56b245e
21 changed files with 483 additions and 36 deletions

View File

@@ -0,0 +1,40 @@
namespace Application.Domain.Entity
{
public class game_map_goods
{
/// <summary>
/// mgId
/// </summary>
public string mgId { get; set; }
/// <summary>
/// userId
/// </summary>
public string? userId { get; set; }
/// <summary>
/// mapId
/// </summary>
public string? mapId { get; set; }
/// <summary>
/// name
/// </summary>
public string? name { get; set; }
/// <summary>
/// code
/// </summary>
public string? code { get; set; }
/// <summary>
/// par
/// </summary>
public string? par { get; set; }
/// <summary>
/// count
/// </summary>
public long count { get; set; }
}
}

View File

@@ -13,7 +13,7 @@ public class RandomModel
/// </summary> /// </summary>
public string code { get; set; } public string code { get; set; }
public string name { get; set; } public string name { get; set; }
public int empty { get; set; } public double empty { get; set; }
public List<RandomData> data { get; set; } public List<RandomData> data { get; set; }
} }

View File

@@ -15,7 +15,7 @@ public interface IGameFightService
string scene, string mapId, string scene, string mapId,
string userId, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = ""); string userId, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = "");
Task<bool> SetFightWin(game_fight_data fightData, string winUser); Task<bool> SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true);
#endregion #endregion
@@ -24,6 +24,10 @@ public interface IGameFightService
Task<int> GetUserFightHarm(string userId); Task<int> GetUserFightHarm(string userId);
Task SetUserFightHarm(string userId, int harm); Task SetUserFightHarm(string userId, int harm);
Task HandleFight(game_fight_data eventData); Task HandleFight(game_fight_data eventData);
Task<List<game_map_goods>> GetMapFightGoods(string mapId);
Task<game_map_goods> GetFightGoodsInfo(string mapId, string mgId);
Task RemoveFightGoods(string mapId, string mgId);
Task AutoUseDrug(UserAttrModel user, game_fight_data fight);
#endregion #endregion
} }

View File

@@ -32,8 +32,9 @@ public interface IGameGoodsService
#region #region
Task<string> CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = ""); Task<string> CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = "");
Task<string> CheckUseDrug(string userId, int goodsId, string scene = "");
Task<bool> UseDrug(string userId, int goodsId, string drugConfig, string scene = ""); Task<bool> UseDrug(string userId, int goodsId, string drugConfig, string scene = "");
Task<bool> UseDrug(string userId, int goodsId, string scene = "");
#endregion #endregion
} }

View File

@@ -23,7 +23,7 @@ public interface IGameMapService
Task UpdateUserOnMap(string userId, string ip, string mapId); Task UpdateUserOnMap(string userId, string ip, string mapId);
Task<bool> UpdateUserOnMap(unit_user_online data, string mapId); Task<bool> UpdateUserOnMap(unit_user_online data, string mapId);
Task<UserOnMap> GetUserOnMapInfo(string userId); Task<UserOnMap> GetUserOnMapInfo(string userId);
Task SetUserMapDefult(string userId); Task SetUserMapDefault(string userId);
Task<game_city_map> GetToMapInfo(string userId, string toMap, bool isUpUserMap = true, bool isChangeCity = false); Task<game_city_map> GetToMapInfo(string userId, string toMap, bool isUpUserMap = true, bool isChangeCity = false);
Task<List<unit_user_map>> GetUserCityMapData(string userId); Task<List<unit_user_map>> GetUserCityMapData(string userId);
Task<bool> AddUserCityMap(string userId, int cityId); Task<bool> AddUserCityMap(string userId, int cityId);

View File

@@ -51,7 +51,7 @@ public interface IUnitUserAttrService
Task<unit_user_drug> GetUserDrug(string userId); Task<unit_user_drug> GetUserDrug(string userId);
Task<bool> UpdateUserDrug(unit_user_drug data); Task<bool> UpdateUserDrug(unit_user_drug data);
Task<bool> UpdateUserDrug(string userId, string drugId, int op, int count);
#endregion #endregion
#region BUFF状态 #region BUFF状态

View File

@@ -11,7 +11,8 @@ public interface IUnitUserWeight
Task<List<unit_user_weight_log>> GetUserWeightLog(string userId); Task<List<unit_user_weight_log>> GetUserWeightLog(string userId);
Task<bool> CheckUserWeight(string userId, int useWeight); Task<bool> CheckUserWeight(string userId, int useWeight);
Task<bool> CheckUserWeight(string userId, TowerGet data);
Task<bool> CheckUserWeight(string userId, string code, string par, long count);
#region #region
Task<unit_user_ship> GetUserShipInfo(string usId); Task<unit_user_ship> GetUserShipInfo(string usId);
Task<List<unit_user_ship>> GetUserShip(string userId); Task<List<unit_user_ship>> GetUserShip(string userId);

View File

@@ -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 public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGameFightService, ITransient
{ {
@@ -164,7 +167,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result; return result;
} }
public async Task<bool> SetFightWin(game_fight_data fightData, string winUser) public async Task<bool> SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true)
{ {
bool result = false; bool result = false;
long okTime = TimeExtend.GetTimeStampSeconds; long okTime = TimeExtend.GetTimeStampSeconds;
@@ -213,6 +216,10 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
if (result) if (result)
{ {
await RemoveUserFight(fightData.userId); 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) if (result)
{ {
await RemoveUserFight(lowUser); 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); await redis.AddHashAsync(key, userId, harm);
} }
#region
public async Task HandleFight(game_fight_data fightData) public async Task HandleFight(game_fight_data fightData)
{ {
string winUser = fightData.winUser; 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 #endregion
} }
private async Task PutFightAwardGoods(game_fight_data fightData)
{
var fightAward = JsonConvert.DeserializeObject<FightAwardModel>(fightData.award);
if (fightAward.code == "Default")
{
var userService = App.GetService<IUnitUserService>();
var userConfig = await userService.GetUserConfigInfo(fightData.winUser);
List<TowerGet> AddMapGoods = new List<TowerGet>();
var opGoods = JsonConvert.DeserializeObject<List<TowerGet>>(fightAward.award.ToString());
string addGoodsUser = fightData.areaCode == nameof(GameEnum.AreaCode.Public) ? "0" : fightData.winUser;
if (userConfig.autoBag == 1)
{
var weightService = App.GetService<IUnitUserWeight>();
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<List<game_map_goods>> GetMapFightGoods(string mapId)
{
List<game_map_goods> result = new List<game_map_goods>();
string key = string.Format(FightCache.FightCacheKeys, "MapGoods", mapId);
if (await redis.ExistsAsync(key))
{
result = await redis.GetAsync<List<game_map_goods>>(key);
}
return result;
}
public async Task<game_map_goods> 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<TowerGet> goods)
{
var data = await GetMapFightGoods(mapId);
List<game_map_goods> addData = new List<game_map_goods>();
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<IUnitUserService>();
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<IUnitUserAttrService>();
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<IGameGoodsService>();
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<IUnitUserAttrService>();
var goodsService = App.GetService<IGameGoodsService>();
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 #endregion
} }

View File

@@ -283,6 +283,16 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result; return result;
} }
public async Task<string> 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<bool> UseDrug(string userId, int goodsId, string drugConfig, string scene = "") public async Task<bool> UseDrug(string userId, int goodsId, string drugConfig, string scene = "")
{ {
@@ -323,6 +333,17 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result; return result;
} }
public async Task<bool> 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 #endregion
} }

View File

@@ -213,7 +213,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
return true; return true;
} }
public async Task SetUserMapDefult(string userId) public async Task SetUserMapDefault(string userId)
{ {
var userMap = await GetUserOnMap(userId); var userMap = await GetUserOnMap(userId);
var MapInfo = await GetMapInfo(userMap.mapId); var MapInfo = await GetMapInfo(userMap.mapId);
@@ -762,7 +762,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
if (await StopUserRun(userId)) if (await StopUserRun(userId))
{ {
var mapService = App.GetService<IGameMapService>(); var mapService = App.GetService<IGameMapService>();
await mapService.SetUserMapDefult(userId); await mapService.SetUserMapDefault(userId);
} }
} }
} }

View File

@@ -256,10 +256,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
if (mustUp) if (mustUp)
{ {
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_blood>(); var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_blood>();
result = await db.Updateable<unit_user_blood>() result = await db.Updateable<unit_user_blood>().SetColumns(it => it.blood == data.blood)
.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)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0; .Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
} }
@@ -539,6 +536,30 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
return result; return result;
} }
public async Task<bool> 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) private async Task ClearUserDrug(string userId)
{ {
string key = string.Format(UserCache.BaseCacheKeys, "UserTool", "DrugColumn"); string key = string.Format(UserCache.BaseCacheKeys, "UserTool", "DrugColumn");

View File

@@ -122,6 +122,46 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit
return result; return result;
} }
public async Task<bool> CheckUserWeight(string userId, TowerGet data)
{
bool result = await CheckUserWeight(userId, data.code, data.parameter, data.count);
return result;
}
public async Task<bool> CheckUserWeight(string userId, string code, string par, long count)
{
bool result = true;
if (code == nameof(GameEnum.PropCode.Goods))
{
var goodsService = App.GetService<IGameGoodsService>();
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<IGameEquService>();
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 #region
public async Task<unit_user_ship> GetUserShipInfo(string usId) public async Task<unit_user_ship> GetUserShipInfo(string usId)

View File

@@ -423,8 +423,8 @@ public static class GameBus
{ {
var _randomInstance = new Random(); var _randomInstance = new Random();
List<RandomData> result = new List<RandomData>(); List<RandomData> result = new List<RandomData>();
int empty = random.empty - Convert.ToInt32(luck * 100); double empty = random.empty * (1.0 + (double)luck) / 100;
if (_randomInstance.Next(0, 100) < empty) if (_randomInstance.NextDouble() > empty)
{ {
return result; return result;
} }
@@ -454,8 +454,8 @@ public static class GameBus
{ {
var _randomInstance = new Random(); var _randomInstance = new Random();
List<RandomData> result = new List<RandomData>(); List<RandomData> result = new List<RandomData>();
int empty = random.empty; double empty = (random.empty / 100);
if (_randomInstance.Next(0, 100) < empty) if (_randomInstance.NextDouble() > empty)
{ {
return result; return result;
} }

View File

@@ -8,4 +8,10 @@ public static class UserStateTool
var myFight = await fightService.GetUserFight(userId); var myFight = await fightService.GetUserFight(userId);
return myFight.Count > 0; return myFight.Count > 0;
} }
public static async Task SetUserMapDefault(string userId)
{
var mapService = App.GetService<IGameMapService>();
await mapService.SetUserMapDefault(userId);
}
} }

View File

@@ -70,7 +70,7 @@ public class MapController : ControllerBase
#region #region
bool isSelfMap = false; bool isSelfMap = string.IsNullOrEmpty(map);
if (!isSelfMap) if (!isSelfMap)
{ {
//血量为0得时候地图点为本身 //血量为0得时候地图点为本身
@@ -78,7 +78,7 @@ public class MapController : ControllerBase
if (myBlood.blood < 1) if (myBlood.blood < 1)
{ {
//设置默认地图点 //设置默认地图点
await _mapService.SetUserMapDefult(userId); await _mapService.SetUserMapDefault(userId);
isSelfMap = true; isSelfMap = true;
gameTips = "➢当前体力为0,恢复一下吧!"; gameTips = "➢当前体力为0,恢复一下吧!";
} }
@@ -147,6 +147,8 @@ public class MapController : ControllerBase
var userFight = await _fightService.GetUserFight(userId); var userFight = await _fightService.GetUserFight(userId);
string fightId = userFight.Count > 0 ? userFight[0] : ""; 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 object ret = new
{ {
@@ -159,6 +161,7 @@ public class MapController : ControllerBase
noReadMsg = noReadMsg[3], noReadMsg = noReadMsg[3],
business, business,
mapRes, mapRes,
mapGoods,
broadcast, broadcast,
monster = monsterData, monster = monsterData,
fightId, fightId,
@@ -733,4 +736,42 @@ public class MapController : ControllerBase
} }
#endregion #endregion
#region
/// <summary>
/// 拾取地图物品
/// </summary>
/// <param name="mgId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> 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
} }

View File

@@ -180,6 +180,7 @@ public class FightController : ControllerBase
await _fightService.SetUserFightHarm(fight.mainId, fightResult.otHarm); await _fightService.SetUserFightHarm(fight.mainId, fightResult.otHarm);
await _attrService.UpdateUserBlood(fight.mainId, 1, fightResult.otHarm); await _attrService.UpdateUserBlood(fight.mainId, 1, fightResult.otHarm);
} }
otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene); otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene);
} }
@@ -195,14 +196,21 @@ public class FightController : ControllerBase
{ {
await _fightService.SetFightWin(fight, fight.mainId); await _fightService.SetFightWin(fight, fight.mainId);
} }
await _fightService.RemoveUserFight(userId, fightId); await _fightService.RemoveUserFight(userId, fightId);
return PoAction.Message("战斗结束", 100); return PoAction.Message("战斗结束", 100);
} }
else 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 diff = myAttr.agility - otAttr.agility;
decimal bl = diff / 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; cool = cool > 1000 ? 1000 : cool;
} }
@@ -227,10 +236,7 @@ public class FightController : ControllerBase
cool = Convert.ToInt32(cool * (1 + atkCoolData.count * 0.1M)); cool = Convert.ToInt32(cool * (1 + atkCoolData.count * 0.1M));
} }
//更新伤害提示 int exitCopper = otAttr.lev * 5; //退出战斗需要的铜贝
int exitCopper = otAttr.lev * 5;
var result = new var result = new
{ {
myHarm, myHarm,
@@ -294,7 +300,7 @@ public class FightController : ControllerBase
{ {
if (await _fightService.RemoveUserFight(userId, fightId)) if (await _fightService.RemoveUserFight(userId, fightId))
{ {
await _fightService.SetFightWin(fight, fight.mainId); await _fightService.SetFightWin(fight, fight.mainId,false);
await _fightService.RemoveFightHarm(fightId, userId); //移除伤害 await _fightService.RemoveFightHarm(fightId, userId); //移除伤害
var nextFight = myFight.FindAll(it => it != fightId); var nextFight = myFight.FindAll(it => it != fightId);
string nextId = nextFight.Count > 0 ? nextFight[0] : ""; string nextId = nextFight.Count > 0 ? nextFight[0] : "";
@@ -411,7 +417,7 @@ public class FightController : ControllerBase
{ {
isWin = 0; isWin = 0;
} }
else if(fight.winUser==userId) else if (fight.winUser == userId)
{ {
isWin = 1; isWin = 1;
} }

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace Application.Web.Controllers.User; namespace Application.Web.Controllers.User;
@@ -398,11 +399,13 @@ public class UserController : ControllerBase
{ {
if (isAdd) if (isAdd)
{ {
string drugConfig = await _goodsService.GetGoodsContent(goodsId);
dynamic _drugConfig = JsonConvert.DeserializeObject<dynamic>(drugConfig);
UserDrugModel temp = new UserDrugModel(); UserDrugModel temp = new UserDrugModel();
temp.id = StringAssist.NewGuid; temp.id = StringAssist.NewGuid;
temp.goodsId = goodsId; temp.goodsId = goodsId;
temp.name = myGoods.goodsName; temp.name = myGoods.goodsName;
temp.code = "Blood"; temp.code =Convert.ToString(_drugConfig.cls);
temp.count = count; temp.count = count;
myDrug.drug.Add(temp); myDrug.drug.Add(temp);
} }

View File

@@ -39,6 +39,12 @@
<Abutton @click="showResProp(item)">{{ item.resName }}({{ item.lev }})</Abutton> <Abutton @click="showResProp(item)">{{ item.resName }}({{ item.lev }})</Abutton>
</div> </div>
</div> </div>
<div class="content" v-if="mapGoods.length > 0">
物品:<br>
<div class="item" v-for="item in mapGoods">
<Abutton @click="GetMapGoods(item.mgId)">{{ item.name }}×{{ item.count }}</Abutton>
</div>
</div>
<div class="content"> <div class="content">
请选择出口:<br /> 请选择出口:<br />
@@ -130,6 +136,7 @@ const monster = ref<Array<any>>([]);
const messageCount = ref(0); const messageCount = ref(0);
const broadcast = ref<Array<any>>([]); const broadcast = ref<Array<any>>([]);
const gameTips = ref(''); const gameTips = ref('');
const mapGoods = ref<Array<any>>([]);
// 城内地图显示 // 城内地图显示
const showCity = ref(false); const showCity = ref(false);
@@ -163,7 +170,8 @@ const BindData = async (map: string): Promise<void> => {
MapVent(result.data.mapInfo.near); MapVent(result.data.mapInfo.near);
onMap.value = mapInfo.value.mapId; onMap.value = mapInfo.value.mapId;
gameTips.value = result.data.gameTips; gameTips.value = result.data.gameTips;
console.log(result) mapGoods.value = result.data.mapGoods;
// console.log(result)
} }
else if (result.code == 103) { else if (result.code == 103) {
PageExtend.Redirect("/map/runing"); 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");
}
}
</script> </script>

View File

@@ -68,7 +68,7 @@ const BindData = async (): Promise<void> => {
const awardTipsStr = (data: any) => { const awardTipsStr = (data: any) => {
let result = ''; let result = '';
if (data.type == 'Default') { if (data.type == 'Default') {
result += "<strong style='font-size: 14px;'>怪物掉落几率:" + (100 - data.award.empty) + "%</strong><br>" result += "<strong style='font-size: 14px;'>怪物掉落几率:" + data.award.empty + "%</strong><br>"
let awData: Array<any> = data.award.data; let awData: Array<any> = data.award.data;
awData.forEach(it => { awData.forEach(it => {
result += "▸" + it.name + "(" + (data.award.code == 'Chance' ? "概率:" : "权重:") + it.chance + (data.award.code == 'Chance' ? "%" : "") + ")<br>"; result += "▸" + it.name + "(" + (data.award.code == 'Chance' ? "概率:" : "权重:") + it.chance + (data.award.code == 'Chance' ? "%" : "") + ")<br>";

View File

@@ -94,4 +94,12 @@ export class MapService {
static async CollectMapRes(resId: string) { static async CollectMapRes(resId: string) {
return await ApiService.Request("get", "/Map/Map/CollectMapRes", { resId }); 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 });
}
} }