diff --git a/Kx.SeaTime.sln.DotSettings.user b/Kx.SeaTime.sln.DotSettings.user index f7d6c25..ce45a72 100644 --- a/Kx.SeaTime.sln.DotSettings.user +++ b/Kx.SeaTime.sln.DotSettings.user @@ -13,5 +13,6 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/FightResultModel.cs b/Service/Application.Domain.Entity/model/FightResultModel.cs new file mode 100644 index 0000000..35966c1 --- /dev/null +++ b/Service/Application.Domain.Entity/model/FightResultModel.cs @@ -0,0 +1,12 @@ +namespace Application.Domain.Entity; + +public class FightResultModel +{ + public int result { get; set; } + public int myHarm { get; set; } + public int otHarm { get; set; } + public List myStateData { get; set; } + public List myRemData { get; set; } + public List otStateData { get; set; } + public List otRemData { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/UserEnum.cs b/Service/Application.Domain/Enum/UserEnum.cs index cedb51a..5e76e22 100644 --- a/Service/Application.Domain/Enum/UserEnum.cs +++ b/Service/Application.Domain/Enum/UserEnum.cs @@ -4,7 +4,8 @@ public static class UserEnum { public enum AttrCode { - Person + Person, + Monster } public enum ConfigCode diff --git a/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs index 725f65f..11bb29a 100644 --- a/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs +++ b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs @@ -9,9 +9,8 @@ public interface IGameFightService #endregion #region 战斗信息 Task GetFightInfo(string fightId); - Task GetFightBlood(string keyId, long maxBlood); - Task SetFightBlood(string keyId, long blood); Task AddFightHarm(string fightId, string userId, long harm); + Task RemoveFightHarm(string fightId, string userId); Task AddFight(string fightId, string areaCode, string keyId, string mainId, string code, string scene, string mapId, string userId, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = ""); diff --git a/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs b/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs index 1ba4ca9..b9d3c10 100644 --- a/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs +++ b/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs @@ -16,5 +16,13 @@ public interface IGameMonsterService Task GetCreateMonsterInfo(string umId); Task> GetMapMonster(string userId, string mapId, string teamId); + #endregion + + #region 怪物模型 + + Task GetMonsterAttrModel(string keyId, string monsterId); + Task SetMonsterBlood(string keyId, int blood); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs index ea9c375..2bd724a 100644 --- a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs +++ b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs @@ -54,28 +54,6 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return data; } - public async Task GetFightBlood(string keyId, long maxBlood) - { - long blood = maxBlood; - string key = string.Format(FightCache.FightCacheKeys, "FightData:Blood", keyId); - if (await redis.ExistsAsync(key)) - { - blood = await redis.GetAsync(key); - blood = blood > maxBlood ? maxBlood : blood; - } - else - { - await SetFightBlood(keyId, blood); - } - - return blood; - } - - public async Task SetFightBlood(string keyId, long blood) - { - string key = string.Format(FightCache.FightCacheKeys, "FightData:Blood", keyId); - await redis.SetAsync(key, blood, 43200); - } public async Task AddFightHarm(string fightId,string userId, long harm) { @@ -91,6 +69,12 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa await redis.AddHashAsync(key, userId, harm); } } + + public async Task RemoveFightHarm(string fightId,string userId) + { + string key = string.Format(FightCache.FightCacheKeys, "FightData:Harm", fightId); + await redis.DelHashAsync(key, userId); + } private async Task ClearFightInfoCache(string fightId, string keyId) diff --git a/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs b/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs index d9ede28..83f2378 100644 --- a/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs +++ b/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs @@ -204,4 +204,66 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I } #endregion + + #region 怪物模型 + + public async Task GetMonsterAttrModel(string keyId,string monsterId) + { + UserAttrModel temp = new UserAttrModel(); + var monsterInfo = await GetMonsterInfo(monsterId); + if (monsterInfo != null) + { + temp.id = keyId; + temp.viceId = monsterId; + temp.name = monsterInfo.name; + temp.IsSystem = 1; + temp.isCopy = (int)monsterInfo.isCopy; + temp.sex = "Default"; + temp.code = nameof(UserEnum.AttrCode.Monster); + temp.lev = (int)monsterInfo.lev; + temp.minAtk = (int)monsterInfo.minAtk; + temp.maxAtk = (int)monsterInfo.maxAtk; + temp.defense = (int)monsterInfo.defense; + temp.agility = (int)monsterInfo.agility; + temp.upBlood = (int)monsterInfo.blood; + temp.upMorale = 1; + temp.morale = 0; + temp = GameAttrTool.GetRoleAttrTempMerge(temp, monsterInfo.attr); + temp.score = 0; + + //处理负面 + var attrService = App.GetService(); + var loadState = await attrService.GetUserLoadState(keyId); + temp = await GameAttrTool.CheckRoleLoadBuff(temp, loadState); + temp.blood = await GetMonsterBlood(keyId, temp.upBlood); + } + + return temp; + } + private async Task GetMonsterBlood(string keyId, int maxBlood) + { + int blood = maxBlood; + blood = blood < 0 ? 0 : blood; + string key = string.Format(FightCache.FightCacheKeys, "FightData:Blood", keyId); + if (await redis.ExistsAsync(key)) + { + blood = await redis.GetAsync(key); + blood = blood > maxBlood ? maxBlood : blood; + blood = blood < 0 ? 0 : blood; + } + else + { + await SetMonsterBlood(keyId, blood); + } + + return blood; + } + + public async Task SetMonsterBlood(string keyId, int blood) + { + string key = string.Format(FightCache.FightCacheKeys, "FightData:Blood", keyId); + await redis.SetAsync(key, blood, 43200); + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index 117b9eb..4be5b9a 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -778,6 +778,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { data.Remove(onData); onData.count += 1; + onData.count = onData.count > 10 ? 10 : onData.count; result = await redis.AddHashAsync(key, userId, data); } diff --git a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs index 278a23b..14dd995 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs @@ -21,9 +21,9 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit { int result = 100 + (int)data.maxWeight; var attrService = App.GetService(); - int myLev = await attrService.GetUserLev(data.userId); - result += myLev * GameConfig.UpLevAddWeight; - //其他属性加层 + var userAttr = await attrService.GetUserAttrModel(data.userId); + result += userAttr.lev * GameConfig.UpLevAddWeight; + result += userAttr.weight; return result; } diff --git a/Service/Application.Domain/Tool/Base/GameAttrTool.cs b/Service/Application.Domain/Tool/Base/GameAttrTool.cs index 69f1a10..8c8dd98 100644 --- a/Service/Application.Domain/Tool/Base/GameAttrTool.cs +++ b/Service/Application.Domain/Tool/Base/GameAttrTool.cs @@ -227,11 +227,6 @@ public class GameAttrTool decimal radio = item.count * 0.04M; temp.defense = Convert.ToInt32(temp.defense * (1.0M - radio)); } - else if (item.code == nameof(GameEnum.AttrCode.PalsyAtk)) - { - decimal radio = item.count * 0.1M; - temp.Atk_Next -= radio; - } } return temp; diff --git a/Service/Application.Domain/Tool/Base/UserStateTool.cs b/Service/Application.Domain/Tool/Base/UserStateTool.cs new file mode 100644 index 0000000..6703557 --- /dev/null +++ b/Service/Application.Domain/Tool/Base/UserStateTool.cs @@ -0,0 +1,11 @@ +namespace Application.Domain; + +public static class UserStateTool +{ + public static async Task CheckUserFight(string userId) + { + var fightService = App.GetService(); + var myFight = await fightService.GetUserFight(userId); + return myFight.Count > 0; + } +} \ No newline at end of file diff --git a/Service/Application.Service.Pub/Class1.cs b/Service/Application.Service.Pub/Class1.cs deleted file mode 100644 index 00188bd..0000000 --- a/Service/Application.Service.Pub/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Application.Service.Pub -{ - public class Class1 - { - - } -} diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 6d47836..8cfbb0a 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -27,7 +27,7 @@ public class MapController : ControllerBase public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService, IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService, IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService, - IGameTeamService teamService, IGameMonsterService monsterService,IGameFightService fightService) + IGameTeamService teamService, IGameMonsterService monsterService, IGameFightService fightService) { _userService = userService; _mapService = mapService; @@ -55,6 +55,7 @@ public class MapController : ControllerBase { string userId = StateHelper.userId; int area = StateHelper.areaId; + string gameTips = string.Empty; game_city_map mapInfo = new game_city_map(); #region 前置条件处理 @@ -79,6 +80,7 @@ public class MapController : ControllerBase //设置默认地图点 await _mapService.SetUserMapDefult(userId); isSelfMap = true; + gameTips = "➢当前体力为0,恢复一下吧!"; } } @@ -145,7 +147,7 @@ public class MapController : ControllerBase var userFight = await _fightService.GetUserFight(userId); string fightId = userFight.Count > 0 ? userFight[0] : ""; - + object ret = new { mapInfo, @@ -159,7 +161,8 @@ public class MapController : ControllerBase mapRes, broadcast, monster = monsterData, - fightId + fightId, + gameTips }; return PoAction.Ok(ret); diff --git a/Service/Application.Web/Controllers/Pub/FightController.cs b/Service/Application.Web/Controllers/Pub/FightController.cs index 1398cda..36c454f 100644 --- a/Service/Application.Web/Controllers/Pub/FightController.cs +++ b/Service/Application.Web/Controllers/Pub/FightController.cs @@ -15,14 +15,19 @@ public class FightController : ControllerBase private readonly IGameMonsterService _monsterService; private readonly IUnitUserAttrService _attrService; private readonly IGameMapService _mapService; + private readonly IUnitUserAccService _accService; + private readonly IGameGoodsService _goodsService; public FightController(IGameFightService fightService, IGameMonsterService monsterService, - IUnitUserAttrService attrService, IGameMapService mapService) + IUnitUserAttrService attrService, IGameMapService mapService, IUnitUserAccService accService, + IGameGoodsService goodsService) { _fightService = fightService; _monsterService = monsterService; _attrService = attrService; _mapService = mapService; + _accService = accService; + _goodsService = goodsService; } /// @@ -68,20 +73,21 @@ public class FightController : ControllerBase areaCode = monster.areaCode; pars = JsonConvert.SerializeObject(new { type = "Create", code = monster.code, par = monster.par }); } + var monsterInfo = await _monsterService.GetMonsterInfo(mainId); if (monsterInfo != null) { var userAttr = await _attrService.GetUserAttrModel(userId, scene); //处理奖励和资源 - exp = Convert.ToInt64(monsterInfo.exp * (1.0m + userAttr.addExp)) ; + exp = Convert.ToInt64(monsterInfo.exp * (1.0m + userAttr.addExp)); copper = Convert.ToInt64(monsterInfo.copper * (1.0m + userAttr.addGold)); petExp = (long)monsterInfo.petExp; - if (!string.IsNullOrEmpty(monsterInfo.award))//生成奖励 + if (!string.IsNullOrEmpty(monsterInfo.award)) //生成奖励 { var awardModel = JsonConvert.DeserializeObject(monsterInfo.award); if (awardModel.type == nameof(MonsterEnum.AwardCode.Default)) { - var getAward = GameBus.GetRandomGoods(awardModel.award, 1,userAttr.burst); + var getAward = GameBus.GetRandomGoods(awardModel.award, 1, userAttr.burst); award = JsonConvert.SerializeObject(new FightAwardModel() { code = "Default", award = getAward }); } } @@ -99,9 +105,257 @@ public class FightController : ControllerBase } } + /// + /// 战斗接口 + /// + /// + /// [HttpPost] public async Task Fight([FromBody] FightParms parms) { - return PoAction.Ok(true); + string userId = StateHelper.userId; + string fightId = parms.fightId; + int myHarm = 0; + int otHarm = 0; + var myFight = await _fightService.GetUserFight(userId); + if (myFight.Any(it => it == fightId) == false) + { + return PoAction.Message("战斗不存在!"); + } + + var fight = await _fightService.GetFightInfo(fightId); + if (fight == null) + { + await _fightService.RemoveUserFight(userId, fightId); + return PoAction.Message("战斗不存在!"); + } + + if (fight.state == 1) + { + await _fightService.RemoveUserFight(userId, fightId); + return PoAction.Message("战斗结束", 100); + } + + #region 此处处理战斗 + + FightResultModel fightResult = new FightResultModel() + { + result = -1 + }; + if (!string.IsNullOrEmpty(parms.data)) + { + fightResult = JsonConvert.DeserializeObject(parms.data); + } + + + #endregion + + //更新攻击 + if (fightResult.result == 0) + { + myHarm = fightResult.myHarm; + otHarm = fightResult.otHarm; + await _attrService.UpdateUserBlood(userId, 1, fightResult.myHarm); + } + var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene); + UserAttrModel otAttr = new UserAttrModel(); + if (fight.code == nameof(GameEnum.FightCode.PVE)) + { + otAttr = await _monsterService.GetMonsterAttrModel(fight.keyId, fight.mainId); + if (fightResult.result == 0) + { + otAttr.blood = otAttr.blood + fightResult.otHarm; + otAttr.blood = otAttr.blood < 0 ? 0 : otAttr.blood; + otAttr.blood = otAttr.blood > otAttr.upBlood ? otAttr.upBlood : otAttr.blood; + await _monsterService.SetMonsterBlood(fight.keyId, otAttr.blood); + } + } + else + { + otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene); + if (fightResult.result == 0) + { + await _attrService.UpdateUserBlood(fight.mainId, 1, fightResult.otHarm); + } + } + + //结束战斗都此处直接返回 + if (otAttr.blood < 1||myAttr.blood<1) + { + await _fightService.RemoveUserFight(userId, fightId); + return PoAction.Message("战斗结束", 100); + } + //获取个人药品栏 + var myDrug = await _attrService.GetUserDrug(userId); + //获取个人负面 + var myLoad = await _attrService.GetUserLoadState(userId); + + //冷却时间 + int cool = 1000; + if (myAttr.agility > otAttr.agility&&otAttr.agility>0) + { + decimal diff = myAttr.agility - otAttr.agility; + decimal bl = diff / otAttr.agility; + cool = Convert.ToInt32(bl * 1000.0m); + cool = cool > 1000 ? 1000 : cool; + } + + //麻痹状态增加冷却时间 + var atkCoolData = myLoad.Find(it => it.code == nameof(GameEnum.AttrCode.PalsyAtk)); + if (atkCoolData != null) + { + cool = Convert.ToInt32(cool * (1 + atkCoolData.count * 0.1M)); + } + + //更新伤害提示 + + + int exitCopper = otAttr.lev * 5; + var result = new + { + myHarm, + otHarm, + myAttr = myAttr, + otAttr = otAttr, + myDrug = myDrug.drug, + myLoad = myLoad, + exitCopper, + cool, + }; + return PoAction.Ok(result); + } + + /// + /// 退出战斗 + /// + /// + /// + [HttpGet] + public async Task Exit(string fightId) + { + string userId = StateHelper.userId; + var myFight = await _fightService.GetUserFight(userId); + if (myFight.Any(it => it == fightId) == false) + { + return PoAction.Message("战斗不存在!"); + } + + var fight = await _fightService.GetFightInfo(fightId); + if (fight == null) + { + await _fightService.RemoveUserFight(userId, fightId); + return PoAction.Message("战斗不存在!"); + } + + if (fight.state == 1) + { + await _fightService.RemoveUserFight(userId, fightId); + return PoAction.Message("战斗结束", 100); + } + + UserAttrModel otAttr = new UserAttrModel(); + if (fight.code == nameof(GameEnum.FightCode.PVE)) + { + otAttr = await _monsterService.GetMonsterAttrModel(fight.keyId, fight.mainId); + } + else + { + otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene); + } + + int needCopper = otAttr.lev * 5; + var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + if (myAcc < needCopper) + { + return PoAction.Message("铜贝不足!", 101); + } + + if (await _accService.UpdateUserCopper(userId, 0, needCopper, "退出战斗")) + { + if (await _fightService.RemoveUserFight(userId, fightId)) + { + await _fightService.RemoveFightHarm(fightId, userId); //移除伤害 + var nextFight = myFight.FindAll(it => it != fightId); + string nextId = nextFight.Count > 0 ? nextFight[0] : ""; + return PoAction.Ok(nextId); + } + else + { + return PoAction.Message("退出失败,请稍后尝试!", 101); + } + } + else + { + return PoAction.Message("退出失败,请稍后尝试!", 101); + } + } + + /// + /// 使用药品 + /// + /// + /// + /// + [HttpGet] + public async Task UseFightDrug(string fightId, string drugId) + { + string userId = StateHelper.userId; + var myFight = await _fightService.GetUserFight(userId); + if (myFight.Any(it => it == fightId) == false) + { + return PoAction.Message("战斗不存在!"); + } + var fight = await _fightService.GetFightInfo(fightId); + if (fight == null) + { + await _fightService.RemoveUserFight(userId, fightId); + return PoAction.Message("战斗不存在!"); + } + + if (fight.state == 1) + { + await _fightService.RemoveUserFight(userId, fightId); + return PoAction.Message("战斗结束!"); + } + + var myDrug = await _attrService.GetUserDrug(userId); + var onDrug = myDrug.drug.Find(it => it.id == drugId); + if (onDrug == null) + { + return PoAction.Message("药品不存在!"); + } + + if (onDrug.count < 1) + { + return PoAction.Message("药品不足!"); + } + + var drugConfig = await _goodsService.GetGoodsContent(onDrug.goodsId); + string check = await _goodsService.CheckUseDrug(userId, onDrug.goodsId, drugConfig, fightId); + if (!string.IsNullOrEmpty(check)) + { + return PoAction.Message(check); + } + + foreach (var item in myDrug.drug) + { + if (item.id == drugId) + { + item.count = item.count - 1; + break; + } + } + + if (await _attrService.UpdateUserDrug(myDrug)) + { + await _goodsService.UseDrug(userId, onDrug.goodsId, drugConfig, fightId); + return PoAction.Ok("药品使用成功!"); + } + else + { + return PoAction.Message("药品使用失败!"); + } + + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/GoodsController.cs b/Service/Application.Web/Controllers/Pub/GoodsController.cs index 0221cab..86033d6 100644 --- a/Service/Application.Web/Controllers/Pub/GoodsController.cs +++ b/Service/Application.Web/Controllers/Pub/GoodsController.cs @@ -102,6 +102,11 @@ public class GoodsController : ControllerBase if (goodsInfo.code == nameof(GoodsEnum.Code.Drug)) { + if (await UserStateTool.CheckUserFight(userId)) + { + return PoAction.Message($"战斗状态下无法使用!"); + } + var ck = await _goodsService.CheckUseDrug(userId, goodsId, goodsInfo.content); if (!string.IsNullOrEmpty(ck)) { diff --git a/Service/Application.Web/Controllers/Pub/PubController.cs b/Service/Application.Web/Controllers/Pub/PubController.cs index c16b58d..a760885 100644 --- a/Service/Application.Web/Controllers/Pub/PubController.cs +++ b/Service/Application.Web/Controllers/Pub/PubController.cs @@ -14,13 +14,15 @@ namespace Application.Web.Controllers.Pub private readonly INoticeService _noticeService; private readonly IGameAccountService _accountService; private readonly IUnitUserService _userService; + private readonly IGameMonsterService _monsterService; - public PubController(IAreaService areaService, INoticeService noticeService, IGameAccountService accountService,IUnitUserService userService) + public PubController(IAreaService areaService, INoticeService noticeService, IGameAccountService accountService,IUnitUserService userService,IGameMonsterService monsterService) { _areaService = areaService; _noticeService = noticeService; _accountService = accountService; _userService = userService; + _monsterService = monsterService; } /// @@ -134,5 +136,21 @@ namespace Application.Web.Controllers.Pub return PoAction.Ok(areaInfo); } + /// + /// 怪物信息 + /// + /// + /// + [HttpGet] + public async Task GetMonsterInfo(string monsterId) + { + var monster = await _monsterService.GetMonsterInfo(monsterId); + if (monster == null) + { + return PoAction.Message("怪物不存在!"); + } + + return PoAction.Ok(monster); + } } } \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/Fight/FightParms.cs b/Service/Application.Web/Model/RequestParms/Fight/FightParms.cs index 394459c..c28e5f2 100644 --- a/Service/Application.Web/Model/RequestParms/Fight/FightParms.cs +++ b/Service/Application.Web/Model/RequestParms/Fight/FightParms.cs @@ -3,4 +3,5 @@ public class FightParms { public string fightId { get; set; } + public string data { get; set; } } \ No newline at end of file diff --git a/Web/src/model/common/FightData b/Web/src/model/common/FightData new file mode 100644 index 0000000..74a4dc1 --- /dev/null +++ b/Web/src/model/common/FightData @@ -0,0 +1,9 @@ +export interface IFightData { +result:number, +myHarm:number, +otHarm:number +myStateData:Array, +myRemData:Array, +otStateData:Array, +otRemData:Array +} \ No newline at end of file diff --git a/Web/src/model/common/UserAttr.ts b/Web/src/model/common/UserAttr.ts new file mode 100644 index 0000000..c9b69aa --- /dev/null +++ b/Web/src/model/common/UserAttr.ts @@ -0,0 +1,48 @@ +export interface IUserAttr { + id:string, + area:number, + isSystem:number, + isCopy:number, + viceId:string, + name:string, + sex:string, + code:string, + tips:string, + lev:number, + minAtk:number, + maxAtk:number, + defense:number, + agility:number, + blood:number, + upBlood:number, + morale:number, + upMorale:number, + score:number, + inBlood:number, + crit:number, + noHarm:number, + dodge:number, + rebound:number, + reboundLess:number, + punish:number, + slow:number, + slowLess:number, + poison:number, + poisonLess:number, + curse:number, + curseLess:number, + weaken:number, + weakenLess:number, + deadly:number, + deadlyLess:number, + depressed:number, + depressedLess:number, + breach:number, + breachLess:number, + del_Fashion:number, + atk_Next:number, + harm_Add:number, + palsyAtk:number, + palsyAtkLess:number, + +} \ No newline at end of file diff --git a/Web/src/pages/fight/index.vue b/Web/src/pages/fight/index.vue new file mode 100644 index 0000000..b2fbb8b --- /dev/null +++ b/Web/src/pages/fight/index.vue @@ -0,0 +1,165 @@ + + \ No newline at end of file diff --git a/Web/src/pages/fight/result.vue b/Web/src/pages/fight/result.vue new file mode 100644 index 0000000..41a40c8 --- /dev/null +++ b/Web/src/pages/fight/result.vue @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue index 97ade96..409537d 100644 --- a/Web/src/pages/map/index.vue +++ b/Web/src/pages/map/index.vue @@ -6,7 +6,9 @@ 任务 消息{{ messageCount > 0 ? "(" + messageCount + ")" : "" }} - +
+ {{ gameTips }} +
@@ -127,6 +129,7 @@ const mapRes = ref>([]); const monster = ref>([]); const messageCount = ref(0); const broadcast = ref>([]); +const gameTips = ref(''); // 城内地图显示 const showCity = ref(false); @@ -159,6 +162,7 @@ const BindData = async (map: string): Promise => { broadcast.value = result.data.broadcast; MapVent(result.data.mapInfo.near); onMap.value = mapInfo.value.mapId; + gameTips.value = result.data.gameTips; console.log(result) } else if (result.code == 103) { diff --git a/Web/src/pages/prop/monster.vue b/Web/src/pages/prop/monster.vue new file mode 100644 index 0000000..41a40c8 --- /dev/null +++ b/Web/src/pages/prop/monster.vue @@ -0,0 +1 @@ + \ 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 5fafd37..1887b6c 100644 --- a/Web/src/pages/user/bag/index.vue +++ b/Web/src/pages/user/bag/index.vue @@ -12,11 +12,16 @@
【 - 装备| - 药品| - 物品| - 坐骑| - 九宫| + 装备 +  |  + 药品 +  |  + 物品 +  |  + 坐骑 +  |  + 九宫 +  |  十方
@@ -29,22 +34,34 @@
- 全部.穿戴.过期.未鉴定 + 全部 +  .  + 穿戴 +  .  + 过期 +  .  + 未鉴定
- 全部.宝石.九宫.圣痕.礼包.材料.图纸.卡片.货物.其他 + 全部 +  .  + 宝石 +  .  + 九宫 +  .  + 圣痕 +  .  + 礼包 +  .  + 材料 +  .  + 图纸 +  .  + 卡片 +  .  + 货物 +  .  + 其他
diff --git a/Web/src/services/Index/FightService.ts b/Web/src/services/Index/FightService.ts new file mode 100644 index 0000000..a5b7560 --- /dev/null +++ b/Web/src/services/Index/FightService.ts @@ -0,0 +1,38 @@ +export class FightService { + /** + * 添加怪物战斗 + * POST /Fight/FightMonster + * @param type body + * @param monsterId body + * @param sign body + */ + static async FightMonster(type: number, monsterId: string, sign: string) { + return await ApiService.Request("post", "/Fight/FightMonster", { type, monsterId, sign }); + } + + /** + * 战斗接口 + * POST /Fight/Fight + * @param fightId body + * @param data body + */ + static async Fight(fightId: string, data: string) { + return await ApiService.Request("post", "/Fight/Fight", { fightId, data }); + } + + /** + * 退出战斗 + * GET /Fight/Exit + */ + static async Exit(fightId: string) { + return await ApiService.Request("get", "/Fight/Exit", { fightId }); + } + + /** + * 使用药品 + * GET /Fight/UseFightDrug + */ + static async UseFightDrug(fightId: string, drugId: string) { + return await ApiService.Request("get", "/Fight/UseFightDrug", { fightId, drugId }); + } +} \ No newline at end of file diff --git a/Web/src/utility‌/FightTool.ts b/Web/src/utility‌/FightTool.ts new file mode 100644 index 0000000..4d623dd --- /dev/null +++ b/Web/src/utility‌/FightTool.ts @@ -0,0 +1,171 @@ +interface IUnitFight { + atkHarm: number, + defHarm: number, + stateData: Array, + remData: Array, +} +export class FightTool { + public static FightHandle(atkUser: IUserAttr, defUser: IUserAttr): IFightData { + let result = 0; + let myHarm = 0; + let otHarm = 0; + let myStateData: Array = []; + let myRemData: Array = []; + let otStateData: Array = []; + let otRemData: Array = []; + + var atkHandle = this.UnitFight(atkUser, defUser); + myHarm += atkHandle.atkHarm; + otHarm += atkHandle.defHarm; + otStateData.push(...atkHandle.stateData); + otRemData.push(...atkHandle.remData); + if (defUser.isSystem == 1) { + var defHandle = this.UnitFight(defUser, atkUser); + myHarm += defHandle.defHarm; + otHarm += defHandle.atkHarm; + myStateData.push(...defHandle.stateData); + myRemData.push(...defHandle.remData); + } + + return { + result, + myHarm, + otHarm, + myStateData, + myRemData, + otStateData, + otRemData + }; + } + + private static UnitFight(atkUser: IUserAttr, defUser: IUserAttr): IUnitFight { + let atkHarm = 0; + let defHarm = 0; + let stateData: Array = []; + let remData: Array = []; + //闪避处理 + if (defUser.dodge > 0) { + let dodgeRide = defUser.dodge - atkUser.deadly + defUser.deadlyLess; + if (dodgeRide > 0) { + if (this.randomTrigger(dodgeRide)) { + return { + atkHarm: 0, + defHarm: 0, + stateData, + remData + }; + } + } + } + + //士气处理 + if (atkUser.upMorale > 0) { + atkUser.minAtk = atkUser.minAtk * (1.0 + (atkUser.morale / atkUser.upMorale) * 0.3); + } + if (defUser.upBlood > 0) { + defUser.defense = defUser.defense * (1.0 + (atkUser.morale / atkUser.upMorale) * 0.3); + } + + if (atkUser.minAtk > defUser.defense && defUser.defense > 0) { + let harmRide = (atkUser.minAtk - defUser.defense) / defUser.defense; + harmRide = harmRide > 1.2 ? 1.2 : harmRide; + let fight_Harm = harmRide * atkUser.maxAtk; + defHarm += 0 - fight_Harm; + } + else { + defHarm = -1; + } + + //暴击处理 + if (atkUser.crit > 0) { + if (this.randomTrigger(atkUser.crit)) { + defHarm = defHarm * 1.5; + } + } + //处理反弹 + if (defUser.rebound > 0) { + let reboundRide = defUser.rebound = atkUser.reboundLess; + if (reboundRide > 0) { + atkHarm = defHarm * reboundRide; + } + } + defHarm += 0 - atkUser.harm_Add;//额外伤害 + //连击处理 + if (atkUser.atk_Next > 0) { + if (this.randomTrigger(atkUser.atk_Next)) { + defHarm = defHarm * 1.3; + atkHarm = atkHarm * 1.3; + } + } + //免伤处理 + if (defUser.noHarm > 0 && defHarm < -1) { + + defHarm = defHarm * (1 - defUser.noHarm); + defHarm = defHarm > 0 ? 0 : defHarm; + } + //吸血处理 + if (defHarm < 0 && atkUser.inBlood > 0) { + let inBloodRide = atkUser.inBlood - defUser.punish + if (inBloodRide > 0) { + atkHarm += (0 - defHarm) * inBloodRide; + } + } + + //#region 状态类处理 + let slow = atkUser.slow - defUser.slowLess; + if (this.randomTrigger(slow)) { + stateData.push("Slow"); + } + let poison = atkUser.poison - defUser.poisonLess; + if (this.randomTrigger(poison)) { + stateData.push("Poison"); + } + let curse = atkUser.curse - defUser.curseLess; + if (this.randomTrigger(curse)) { + stateData.push("Curse"); + } + let weaken = atkUser.weaken - defUser.weakenLess; + if (this.randomTrigger(weaken)) { + stateData.push("Weaken"); + } + + let depressed = atkUser.depressed - defUser.depressedLess; + if (this.randomTrigger(depressed)) { + stateData.push("Depressed"); + } + let breach = atkUser.breach - defUser.breachLess; + if (this.randomTrigger(breach)) { + stateData.push("Breach"); + } + let palsyatk = atkUser.palsyAtk - defUser.palsyAtkLess; + if (this.randomTrigger(palsyatk)) { + stateData.push("PalsyAtk"); + } + if (this.randomTrigger(atkUser.del_Fashion)) { + if (defUser.code == 'Person') { + remData.push({ + "code": "equ", + "par": "Fashion", + "count": 1 + }); + } + } + + //#endregion + //数值处理 + atkHarm = Math.floor(atkHarm); + defHarm = Math.floor(defHarm); + return { + atkHarm, + defHarm, + stateData, + remData + }; + } + + private static randomTrigger(rate: number): boolean { + // Math.random() 返回 [0,1) 浮点 + const rand = Math.random(); + return rand < rate; + } +} \ No newline at end of file