12121
This commit is contained in:
@@ -62,12 +62,14 @@ namespace Application.Domain.Entity
|
||||
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? winCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 胜利方
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? winUser { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 经验
|
||||
/// </summary>
|
||||
@@ -94,6 +96,13 @@ namespace Application.Domain.Entity
|
||||
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string? pars { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预计用时
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public long? dueTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// addTime
|
||||
/// </summary>
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface IGameFightService
|
||||
Task RemoveFightHarm(string fightId, string userId);
|
||||
Task<bool> 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 = "");
|
||||
string userId,long dueTime, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = "");
|
||||
|
||||
Task<bool> SetFightWin(game_fight_data fightData, string winUser, bool setDefMap=true);
|
||||
Task HandleFightData();
|
||||
@@ -29,6 +29,7 @@ public interface IGameFightService
|
||||
Task RemoveFightGoods(string mapId, string mgId);
|
||||
Task AutoUseDrug(UserAttrModel user, game_fight_data fight);
|
||||
Task HandelFightEnd(string userId, List<FightRemoveData> data);
|
||||
Task<bool> ValidFight(game_fight_data fight, bool isBlack = true);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public interface IUnitUserService
|
||||
Task<bool> UpdateUserNick(string userId, string nick);
|
||||
Task<bool> UpdateUserSex(string userId, string sex);
|
||||
Task<bool> UpdateUserSign(string userId, string sign);
|
||||
Task<bool> BlackUser(string userId);
|
||||
#endregion
|
||||
|
||||
#region 用户注册
|
||||
|
||||
@@ -94,7 +94,8 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
|
||||
public async Task<bool> 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 = "")
|
||||
string userId, long dueTime, long exp = 0, long copper = 0, long petExp = 0, string award = "",
|
||||
string pars = "")
|
||||
{
|
||||
long addTime = TimeExtend.GetTimeStampMilliseconds;
|
||||
long endTime = TimeExtend.GetTimeStampSeconds + 24 * 60 * 60;
|
||||
@@ -118,6 +119,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
petExp = petExp,
|
||||
award = award,
|
||||
pars = pars,
|
||||
dueTime = dueTime,
|
||||
addTime = addTime,
|
||||
okTime = 0,
|
||||
endTime = endTime
|
||||
@@ -161,6 +163,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> SetFightWin(game_fight_data fightData, string winUser, bool setDefMap = true)
|
||||
{
|
||||
bool result = false;
|
||||
@@ -379,6 +382,11 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
|
||||
public async Task HandleFight(game_fight_data fightData)
|
||||
{
|
||||
if (await ValidFight(fightData) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string winUser = fightData.winUser;
|
||||
string lowUser = fightData.userId == winUser ? fightData.mainId : fightData.userId;
|
||||
|
||||
@@ -448,7 +456,6 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
await attrService.DeductUserExp(lowUser, 1, 1); //扣除1级
|
||||
//设置回威尼斯
|
||||
await mapService.UpdateUserOnMap(lowUser, "15_27");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,5 +702,26 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<bool> ValidFight(game_fight_data fight, bool isBlack = true)
|
||||
{
|
||||
bool result = true;
|
||||
if (fight.dueTime > 0)
|
||||
{
|
||||
int diffTime = Convert.ToInt32(fight.okTime - fight.addTime);
|
||||
if (diffTime < 3000)
|
||||
{
|
||||
result = diffTime >= fight.dueTime;
|
||||
if (result == false && isBlack) //异常处理
|
||||
{
|
||||
//封禁账号
|
||||
var userService = App.GetService<IUnitUserService>();
|
||||
await userService.BlackUser(fight.userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace Application.Domain;
|
||||
|
||||
public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserService, ITransient
|
||||
{
|
||||
|
||||
#region 用户信息
|
||||
|
||||
public async Task<List<unit_user>> GetUserDataByAccId(string accId)
|
||||
@@ -101,6 +100,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserSex(string userId, string sex)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
|
||||
@@ -113,6 +113,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserSign(string userId, string sign)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
|
||||
@@ -126,6 +127,21 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> BlackUser(string userId)
|
||||
{
|
||||
string newToken = await GetToken();
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
|
||||
bool result = await db.Updateable<unit_user>().SetColumns(it => it.status == 0)
|
||||
.SetColumns(it => it.token == newToken)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserInfo(0, userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 用户注册
|
||||
@@ -273,7 +289,6 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
|
||||
if (result) //注册各项后处理
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -370,8 +385,8 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
case "MsgRole":
|
||||
result = (int)config.msgRole;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -400,6 +415,5 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
65
Service/Application.Domain/Tool/Base/FightTool.cs
Normal file
65
Service/Application.Domain/Tool/Base/FightTool.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class FightTool
|
||||
{
|
||||
/// <summary>
|
||||
/// 攻击冷却时间
|
||||
/// </summary>
|
||||
/// <param name="atk"></param>
|
||||
/// <param name="def"></param>
|
||||
/// <param name="loads"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetFightCool(long atk, long def, List<unit_user_load> loads = null)
|
||||
{
|
||||
int result = 1000;
|
||||
if (atk > def && def > 0)
|
||||
{
|
||||
decimal diff = atk - def;
|
||||
decimal bl = diff / def;
|
||||
result = Convert.ToInt32((1 - bl) * result);
|
||||
result = result < 300 ? 300 : result;
|
||||
result = result > 1000 ? 1000 : result;
|
||||
}
|
||||
|
||||
if (loads != null)
|
||||
{
|
||||
//麻痹状态增加冷却时间
|
||||
var atkCoolData = loads.Find(it => it.code == nameof(GameEnum.AttrCode.PalsyAtk));
|
||||
if (atkCoolData != null)
|
||||
{
|
||||
result = Convert.ToInt32(result * (1 + atkCoolData.count * 0.1M));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 战斗预计时间
|
||||
/// </summary>
|
||||
/// <param name="atkUser"></param>
|
||||
/// <param name="defUser"></param>
|
||||
/// <returns></returns>
|
||||
public static long GetFightDueTime(UserAttrModel atkUser, UserAttrModel defUser)
|
||||
{
|
||||
long result = 3 * 60 * 60 * 1000;
|
||||
if (atkUser.minAtk > defUser.defense && defUser.defense > 0)
|
||||
{
|
||||
decimal harmRide = (atkUser.minAtk - defUser.defense) / defUser.defense;
|
||||
harmRide = harmRide > 1.2M ? 1.2M : harmRide;
|
||||
decimal fight_Harm = harmRide * atkUser.maxAtk;
|
||||
if (fight_Harm >= defUser.blood)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int cool = GetFightCool(atkUser.agility, defUser.agility);
|
||||
int count = Convert.ToInt32(defUser.blood / fight_Harm);
|
||||
result = count * cool;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -83,10 +83,10 @@ public class FightController : ControllerBase
|
||||
pars = JsonConvert.SerializeObject(new { type = "Create", code = monster.code, par = monster.par });
|
||||
}
|
||||
|
||||
var userAttr = await _attrService.GetUserAttrModel(userId, scene);
|
||||
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));
|
||||
copper = Convert.ToInt64(monsterInfo.copper * (1.0m + userAttr.addGold));
|
||||
@@ -102,7 +102,10 @@ public class FightController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, mainId, code, scene, mapId, userId, exp,
|
||||
var otAttr = await _monsterService.GetMonsterAttrModel(keyId, mainId);
|
||||
long dueTime = FightTool.GetFightDueTime(userAttr, otAttr);
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, mainId, code, scene, mapId, userId,
|
||||
dueTime, exp,
|
||||
copper, petExp, award, pars);
|
||||
if (result)
|
||||
{
|
||||
@@ -174,8 +177,11 @@ public class FightController : ControllerBase
|
||||
long petExp = 0;
|
||||
string award = string.Empty;
|
||||
string pars = "";
|
||||
var userAttr = await _attrService.GetUserAttrModel(userId);
|
||||
var otAttr = await _attrService.GetUserAttrModel(otUser.userId);
|
||||
long dueTime = FightTool.GetFightDueTime(userAttr, otAttr);
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, otUser.userId, code, onMapInfo.code,
|
||||
onMapInfo.mapId, userId, exp,
|
||||
onMapInfo.mapId, userId, dueTime, exp,
|
||||
copper, petExp, award, pars);
|
||||
if (result)
|
||||
{
|
||||
@@ -257,6 +263,7 @@ public class FightController : ControllerBase
|
||||
|
||||
otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene);
|
||||
}
|
||||
|
||||
if (fightResult.result == 0)
|
||||
{
|
||||
if (otAttr.blood > 0)
|
||||
@@ -306,22 +313,8 @@ public class FightController : ControllerBase
|
||||
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((1 - bl) * 1000.0m);
|
||||
cool = cool < 10 ? 10 : cool;
|
||||
cool = cool > 1000 ? 1000 : cool;
|
||||
}
|
||||
int cool = FightTool.GetFightCool(myAttr.agility, otAttr.agility);
|
||||
|
||||
//麻痹状态增加冷却时间
|
||||
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
|
||||
@@ -638,8 +631,14 @@ public class FightController : ControllerBase
|
||||
return PoAction.Message("该战斗不可复刻挂机!");
|
||||
}
|
||||
|
||||
if (await _fightService.ValidFight(fight,false) == false)
|
||||
{
|
||||
return PoAction.Message("异常的战斗,无法挂机!");
|
||||
}
|
||||
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
int diffTime = Convert.ToInt32(fight.okTime - fight.addTime);
|
||||
diffTime = diffTime < 300 ? 300 : diffTime;
|
||||
decimal score = myAttr.score * 0.7M;
|
||||
bool result = await _hookService.StartOnHook(userId, fight.scene, (long)monster.copper, (long)monster.exp,
|
||||
monster.name,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
统一配置中心
|
||||
*/
|
||||
export class BaseConfig {
|
||||
// public static BaseUrl: string = 'https://localhost:7198'
|
||||
// public static BaseMediaUrl: string = 'https://localhost:7198/'
|
||||
public static BaseUrl:string="http://v3.pccsh.com";
|
||||
public static BaseMediaUrl:string="http://v3.pccsh.com";
|
||||
public static BaseUrl: string = 'https://localhost:7198'
|
||||
public static BaseMediaUrl: string = 'https://localhost:7198/'
|
||||
// public static BaseUrl:string="http://v3.pccsh.com";
|
||||
// public static BaseMediaUrl:string="http://v3.pccsh.com";
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export class FightTool {
|
||||
if (defUser.rebound > 0) {
|
||||
let reboundRide = defUser.rebound = atkUser.reboundLess;
|
||||
if (reboundRide > 0) {
|
||||
atkHarm = defHarm * reboundRide;
|
||||
atkHarm += defHarm * reboundRide;
|
||||
}
|
||||
}
|
||||
defHarm += 0 - atkUser.harm_Add;//额外伤害
|
||||
@@ -92,7 +92,7 @@ export class FightTool {
|
||||
if (atkUser.atk_Next > 0) {
|
||||
if (this.randomTrigger(atkUser.atk_Next)) {
|
||||
defHarm = defHarm * 1.3;
|
||||
atkHarm = atkHarm * 1.3;
|
||||
atkHarm += atkHarm * 1.3;
|
||||
}
|
||||
}
|
||||
//免伤处理
|
||||
|
||||
Reference in New Issue
Block a user