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

@@ -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
/// <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 _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);

View File

@@ -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<dynamic>(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);
}