1212
This commit is contained in:
40
Service/Application.Domain.Entity/db/game_map_goods.cs
Normal file
40
Service/Application.Domain.Entity/db/game_map_goods.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class RandomModel
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
public string name { get; set; }
|
||||
public int empty { get; set; }
|
||||
public double empty { get; set; }
|
||||
public List<RandomData> data { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -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<bool> SetFightWin(game_fight_data fightData, string winUser);
|
||||
Task<bool> SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true);
|
||||
|
||||
|
||||
#endregion
|
||||
@@ -24,6 +24,10 @@ public interface IGameFightService
|
||||
Task<int> GetUserFightHarm(string userId);
|
||||
Task SetUserFightHarm(string userId, int harm);
|
||||
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
|
||||
}
|
||||
@@ -32,8 +32,9 @@ public interface IGameGoodsService
|
||||
#region 药品
|
||||
|
||||
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 scene = "");
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public interface IGameMapService
|
||||
Task UpdateUserOnMap(string userId, string ip, string mapId);
|
||||
Task<bool> UpdateUserOnMap(unit_user_online data, string mapId);
|
||||
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<List<unit_user_map>> GetUserCityMapData(string userId);
|
||||
Task<bool> AddUserCityMap(string userId, int cityId);
|
||||
|
||||
@@ -51,7 +51,7 @@ public interface IUnitUserAttrService
|
||||
|
||||
Task<unit_user_drug> GetUserDrug(string userId);
|
||||
Task<bool> UpdateUserDrug(unit_user_drug data);
|
||||
|
||||
Task<bool> UpdateUserDrug(string userId, string drugId, int op, int count);
|
||||
#endregion
|
||||
|
||||
#region BUFF状态
|
||||
|
||||
@@ -11,7 +11,8 @@ public interface IUnitUserWeight
|
||||
|
||||
Task<List<unit_user_weight_log>> GetUserWeightLog(string userId);
|
||||
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 船只相关
|
||||
Task<unit_user_ship> GetUserShipInfo(string usId);
|
||||
Task<List<unit_user_ship>> GetUserShip(string userId);
|
||||
|
||||
@@ -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<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;
|
||||
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<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
|
||||
}
|
||||
@@ -283,6 +283,16 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
|
||||
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 = "")
|
||||
{
|
||||
@@ -323,6 +333,17 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
|
||||
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
|
||||
}
|
||||
@@ -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<IGameMapService>();
|
||||
await mapService.SetUserMapDefult(userId);
|
||||
await mapService.SetUserMapDefault(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,10 +256,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
if (mustUp)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_blood>();
|
||||
result = await db.Updateable<unit_user_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)
|
||||
result = await db.Updateable<unit_user_blood>().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<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)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "UserTool", "DrugColumn");
|
||||
|
||||
@@ -122,6 +122,46 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit
|
||||
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 船只相关
|
||||
|
||||
public async Task<unit_user_ship> GetUserShipInfo(string usId)
|
||||
|
||||
@@ -423,8 +423,8 @@ public static class GameBus
|
||||
{
|
||||
var _randomInstance = new Random();
|
||||
List<RandomData> result = new List<RandomData>();
|
||||
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<RandomData> result = new List<RandomData>();
|
||||
int empty = random.empty;
|
||||
if (_randomInstance.Next(0, 100) < empty)
|
||||
double empty = (random.empty / 100);
|
||||
if (_randomInstance.NextDouble() > empty)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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<IGameMapService>();
|
||||
await mapService.SetUserMapDefault(userId);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ const BindData = async (data: string): Promise<void> => {
|
||||
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);
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
<Abutton @click="showResProp(item)">{{ item.resName }}({{ item.lev }}级)</Abutton>
|
||||
</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">
|
||||
请选择出口:<br />
|
||||
@@ -130,6 +136,7 @@ const monster = ref<Array<any>>([]);
|
||||
const messageCount = ref(0);
|
||||
const broadcast = ref<Array<any>>([]);
|
||||
const gameTips = ref('');
|
||||
const mapGoods = ref<Array<any>>([]);
|
||||
// 城内地图显示
|
||||
const showCity = ref(false);
|
||||
|
||||
@@ -163,7 +170,8 @@ const BindData = async (map: string): Promise<void> => {
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -68,7 +68,7 @@ const BindData = async (): Promise<void> => {
|
||||
const awardTipsStr = (data: any) => {
|
||||
let result = '';
|
||||
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;
|
||||
awData.forEach(it => {
|
||||
result += "▸" + it.name + "(" + (data.award.code == 'Chance' ? "概率:" : "权重:") + it.chance + (data.award.code == 'Chance' ? "%" : "") + ")<br>";
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user