diff --git a/Kx.SeaTime.sln.DotSettings.user b/Kx.SeaTime.sln.DotSettings.user index f1f5bbe..f7d6c25 100644 --- a/Kx.SeaTime.sln.DotSettings.user +++ b/Kx.SeaTime.sln.DotSettings.user @@ -5,8 +5,10 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/Service/Application.Domain.Entity/db/unit_user_load.cs b/Service/Application.Domain.Entity/db/unit_user_load.cs new file mode 100644 index 0000000..d0d9e3d --- /dev/null +++ b/Service/Application.Domain.Entity/db/unit_user_load.cs @@ -0,0 +1,10 @@ +namespace Application.Domain.Entity; + +public class unit_user_load +{ + public string id { get; set; } + public string userId { get; set; } + public string name { get; set; } + public string code { get; set; } + public int count { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_drug.cs b/Service/Application.Domain.Entity/game/user/unit_user_drug.cs new file mode 100644 index 0000000..49dd28d --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_drug.cs @@ -0,0 +1,21 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_drug + { + /// + /// userId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string userId { get; set; } + + /// + /// drug + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List drug { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_monster.cs b/Service/Application.Domain.Entity/game/user/unit_user_monster.cs new file mode 100644 index 0000000..2a6a918 --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_monster.cs @@ -0,0 +1,69 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_monster + { + /// + /// umId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string umId { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// areaCode + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? areaCode { get; set; } + + /// + /// mapId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? mapId { get; set; } + + /// + /// monsterId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? monsterId { get; set; } + + /// + /// monsterName + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? monsterName { get; set; } + + /// + /// code + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// par + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? par { get; set; } + + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public long? addTime { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public long? endTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_ship.cs b/Service/Application.Domain.Entity/game/user/unit_user_ship.cs index 790a786..40df711 100644 --- a/Service/Application.Domain.Entity/game/user/unit_user_ship.cs +++ b/Service/Application.Domain.Entity/game/user/unit_user_ship.cs @@ -47,5 +47,17 @@ namespace Application.Domain.Entity /// [SugarColumn(IsNullable = true)] public int? copper { get; set; } + + /// + /// 出售价格 + /// + [SugarColumn(IsNullable = true)] + public long? sale { get; set; } + + /// + /// remark + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_state.cs b/Service/Application.Domain.Entity/game/user/unit_user_state.cs new file mode 100644 index 0000000..0474c53 --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_state.cs @@ -0,0 +1,63 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_state + { + /// + /// usId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string usId { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// goodsId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? goodsId { get; set; } + + /// + /// name + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// 场景 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? scene { get; set; } + + /// + /// tips + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? tips { get; set; } + + /// + /// attr + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List attr { get; set; } + + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public long? addTime { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public long? endTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_stock.cs b/Service/Application.Domain.Entity/game/user/unit_user_stock.cs new file mode 100644 index 0000000..e60cd51 --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_stock.cs @@ -0,0 +1,60 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_stock + { + /// + /// usId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string usId { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// goodsId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? goodsId { get; set; } + + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// type + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? type { get; set; } + + /// + /// code + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// sign + /// + [SugarColumn(IsNullable = true)] + public long? sign { get; set; } + + /// + /// par + /// + [SugarColumn(IsNullable = true)] + public string? par { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public long? endTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/logdb/db/game_fight_data.cs b/Service/Application.Domain.Entity/logdb/db/game_fight_data.cs new file mode 100644 index 0000000..e376d71 --- /dev/null +++ b/Service/Application.Domain.Entity/logdb/db/game_fight_data.cs @@ -0,0 +1,113 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Log")] + public class game_fight_data + { + /// + /// fightId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string fightId { get; set; } + + /// + /// 作用区域 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? areaCode { get; set; } + + /// + /// 关联ID + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? keyId { get; set; } + + /// + /// 对方主ID + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? mainId { get; set; } + + /// + /// 战斗类型 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// 场景 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? scene { get; set; } + + /// + /// mapId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? mapId { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// state + /// + [SugarColumn(IsNullable = true)] + public int? state { get; set; } + + /// + /// 胜利方 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? winUser { get; set; } + + /// + /// 经验 + /// + [SugarColumn(IsNullable = true)] + public long? exp { get; set; } + + /// + /// 铜贝 + /// + [SugarColumn(IsNullable = true)] + public long? copper { get; set; } + + /// + /// 宠物经验 + /// + [SugarColumn(IsNullable = true)] + public long? petExp { get; set; } + + /// + /// 奖励 + /// + [SugarColumn(IsNullable = true)] + public string? award { get; set; } + + [SugarColumn(IsNullable = true)] + public string? pars { get; set; } + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public long? addTime { get; set; } + + /// + /// 战斗结束时间 + /// + [SugarColumn(IsNullable = true)] + public long? okTime { get; set; } + + /// + /// 删除时间 + /// + [SugarColumn(IsNullable = true)] + public long? endTime { get; set; } + } +} diff --git a/Service/Application.Domain.Entity/logdb/ot/game_broadcast.cs b/Service/Application.Domain.Entity/logdb/ot/game_broadcast.cs new file mode 100644 index 0000000..0ac16cb --- /dev/null +++ b/Service/Application.Domain.Entity/logdb/ot/game_broadcast.cs @@ -0,0 +1,13 @@ +namespace Application.Domain.Entity; + +public class game_broadcast +{ + public string Id { get; set; } + public int area { get; set; } + public string code { get; set; } + public string userId { get; set; } + public string userNo { get; set; } + public string nick { get; set; } + public string msg { get; set; } + public long endTime { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/CheckTowerNeeds.cs b/Service/Application.Domain.Entity/model/CheckTowerNeeds.cs new file mode 100644 index 0000000..98f08a2 --- /dev/null +++ b/Service/Application.Domain.Entity/model/CheckTowerNeeds.cs @@ -0,0 +1,30 @@ +namespace Application.Domain.Entity; + +public class CheckTowerNeeds +{ + private bool _result; + + public bool result + { get { return this._result; } set { this._result = value; } } + + private System.Int32 _isDeal; + + /// + /// 0不可交易1可交易 + /// + public System.Int32 isDeal + { get { return this._isDeal; } set { this._isDeal = value; } } + + private System.Int32 _isGive; + + /// + /// 0不可交易1可交易 + /// + public System.Int32 isGive + { get { return this._isGive; } set { this._isGive = value; } } + + private List _Needs; + + public List Needs + { get { return this._Needs; } set { this._Needs = value; } } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/ChoiceGoods.cs b/Service/Application.Domain.Entity/model/ChoiceGoods.cs new file mode 100644 index 0000000..cee2e53 --- /dev/null +++ b/Service/Application.Domain.Entity/model/ChoiceGoods.cs @@ -0,0 +1,8 @@ +namespace Application.Domain.Entity; + +public class ChoiceGoods +{ + public int id { get; set; } + public string name { get; set; } + public List award { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/EquAwaken.cs b/Service/Application.Domain.Entity/model/EquAwaken.cs index f21bf14..352ba9b 100644 --- a/Service/Application.Domain.Entity/model/EquAwaken.cs +++ b/Service/Application.Domain.Entity/model/EquAwaken.cs @@ -31,7 +31,6 @@ public class EquAwaken /// /// /// - [SqlSugar.SugarColumn(ColumnDataType = "varchar(max)", IsJson = true)] public List awaken { get { return this._awaken; } set { this._awaken = value; } } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/EquAwakenData.cs b/Service/Application.Domain.Entity/model/EquAwakenData.cs new file mode 100644 index 0000000..f9312fa --- /dev/null +++ b/Service/Application.Domain.Entity/model/EquAwakenData.cs @@ -0,0 +1,36 @@ +namespace Application.Domain.Entity; + +public class EquAwakenData +{ + private System.Int32 _lev; + + /// + /// + /// + public System.Int32 lev + { get { return this._lev; } set { this._lev = value; } } + + private System.Int32 _success; + + /// + /// + /// + public System.Int32 success + { get { return this._success; } set { this._success = value; } } + + private List _need; + + /// + /// + /// + public List need + { get { return this._need; } set { this._need = value; } } + + private List _attr; + + /// + /// + /// + public List attr + { get { return this._attr; } set { this._attr = value; } } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/FightAwardModel.cs b/Service/Application.Domain.Entity/model/FightAwardModel.cs new file mode 100644 index 0000000..7cfcfb3 --- /dev/null +++ b/Service/Application.Domain.Entity/model/FightAwardModel.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class FightAwardModel +{ + public string code { get; set; } + public object award { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/MapMonsterModel.cs b/Service/Application.Domain.Entity/model/MapMonsterModel.cs new file mode 100644 index 0000000..7c9d6cf --- /dev/null +++ b/Service/Application.Domain.Entity/model/MapMonsterModel.cs @@ -0,0 +1,13 @@ +namespace Application.Domain.Entity; + +public class MapMonsterModel +{ + public string monterId { get; set; } + public string name { get; set; } + /// + /// 0地图怪物 1生成怪物 + /// + public int type { get; set; } + + public string sign { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/MonsterAwardModel.cs b/Service/Application.Domain.Entity/model/MonsterAwardModel.cs new file mode 100644 index 0000000..41df820 --- /dev/null +++ b/Service/Application.Domain.Entity/model/MonsterAwardModel.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class MonsterAwardModel +{ + public string type { get; set; } + public RandomModel award { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/RandomDataBase.cs b/Service/Application.Domain.Entity/model/RandomDataBase.cs new file mode 100644 index 0000000..cdfbea9 --- /dev/null +++ b/Service/Application.Domain.Entity/model/RandomDataBase.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class RandomDataBase +{ + public double random { get; set; } + public object data { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/RandomModel.cs b/Service/Application.Domain.Entity/model/RandomModel.cs index 28f1277..8c3983f 100644 --- a/Service/Application.Domain.Entity/model/RandomModel.cs +++ b/Service/Application.Domain.Entity/model/RandomModel.cs @@ -22,6 +22,7 @@ public class RandomData public string code { get; set; } public string name { get; set; } public string par { get; set; } - public long count { get; set; } + public int minCount { get; set; } + public int maxCount { get; set; } public double chance { get; set; } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/TowerNeed.cs b/Service/Application.Domain.Entity/model/TowerNeed.cs index 373d076..f27a720 100644 --- a/Service/Application.Domain.Entity/model/TowerNeed.cs +++ b/Service/Application.Domain.Entity/model/TowerNeed.cs @@ -26,20 +26,20 @@ public class TowerNeed public System.String parameter { get { return this._parameter; } set { this._parameter = value; } } - private System.Int32 _count; + private long _count; /// /// /// - public System.Int32 count + public long count { get { return this._count; } set { this._count = value; } } - private System.Int32 _retCount; + private long _retCount; /// /// /// - public System.Int32 retCount + public long retCount { get { return this._retCount; } set { this._retCount = value; } } private System.Int32 _isOp; @@ -57,4 +57,12 @@ public class TowerNeed /// public System.Int32 isAsk { get { return this._isAsk; } set { this._isAsk = value; } } + + private long _onCount; + + /// + /// + /// + public long onCount + { get { return this._onCount; } set { this._onCount = value; } } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/TowerNeeds.cs b/Service/Application.Domain.Entity/model/TowerNeeds.cs new file mode 100644 index 0000000..050df10 --- /dev/null +++ b/Service/Application.Domain.Entity/model/TowerNeeds.cs @@ -0,0 +1,111 @@ +namespace Application.Domain.Entity; + +public class TowerNeeds +{ + private System.Int32 _Id; + + /// + /// + /// + public System.Int32 Id + { + get { return this._Id; } + set { this._Id = value; } + } + + private System.String _code; + + /// + /// + /// + public System.String code + { + get { return this._code; } + set { this._code = value; } + } + + private System.String _name; + + /// + /// + /// + public System.String name + { + get { return this._name; } + set { this._name = value; } + } + + private System.String _parameter; + + /// + /// + /// + public System.String parameter + { + get { return this._parameter; } + set { this._parameter = value; } + } + + private long _count; + + /// + /// + /// + public long count + { + get { return this._count; } + set { this._count = value; } + } + + private long _retCount; + + /// + /// + /// + public long retCount + { + get { return this._retCount; } + set { this._retCount = value; } + } + + private System.Int32 _isOp; + + /// + /// + /// + public System.Int32 isOp + { + get { return this._isOp; } + set { this._isOp = value; } + } + + private System.Int32 _isAsk; + + /// + /// + /// + public System.Int32 isAsk + { + get { return this._isAsk; } + set { this._isAsk = value; } + } + + private long _onCount; + + /// + /// + /// + public long onCount + { + get { return this._onCount; } + set { this._onCount = value; } + } + + private List _NeedItem; + + public List NeedItem + { + get { return this._NeedItem; } + set { this._NeedItem = value; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/UserAttrModel.cs b/Service/Application.Domain.Entity/model/UserAttrModel.cs index a0fae81..168e436 100644 --- a/Service/Application.Domain.Entity/model/UserAttrModel.cs +++ b/Service/Application.Domain.Entity/model/UserAttrModel.cs @@ -8,11 +8,14 @@ public int isCopy { get; set; } public string viceId { get; set; } public string name { get; set; } - public int figState { get; set; } public string sex { get; set; } public string code { get; set; } - public string remark { get; set; } - public string TmImg { get; set; } + public string tips { get; set; } + public decimal addExp { get; set; } + public decimal addGold { get; set; } + public decimal burst { get; set; }//爆率 + public decimal luck { get; set; }//幸运 + public int weight { get; set; }//负重 public int lev { get; set; }//等级 public int minAtk { get; set; }//最小攻击 public int maxAtk { get; set; }//最大攻击 diff --git a/Service/Application.Domain.Entity/model/UserDrugModel.cs b/Service/Application.Domain.Entity/model/UserDrugModel.cs new file mode 100644 index 0000000..8c045a1 --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserDrugModel.cs @@ -0,0 +1,10 @@ +namespace Application.Domain.Entity; + +public class UserDrugModel +{ + public string id { get; set; } + public int goodsId { get; set; } + public string name { get; set; } + public string code { get; set; } + public int count { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/UserEquAttrModel.cs b/Service/Application.Domain.Entity/model/UserEquAttrModel.cs new file mode 100644 index 0000000..b42b685 --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserEquAttrModel.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class UserEquAttrModel +{ + public UserAttrModel equ { get; set; } + public List attr { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/UserEquSuit.cs b/Service/Application.Domain.Entity/model/UserEquSuit.cs new file mode 100644 index 0000000..612af94 --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserEquSuit.cs @@ -0,0 +1,8 @@ +namespace Application.Domain.Entity; + +public class UserEquSuit +{ + public string suitCode { get; set; } + public string suitName { get; set; } + public List SuitAttr { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/UserStateModel.cs b/Service/Application.Domain.Entity/model/UserStateModel.cs new file mode 100644 index 0000000..ddd57e2 --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserStateModel.cs @@ -0,0 +1,10 @@ +namespace Application.Domain.Entity; + +public class UserStateModel +{ + public string name { get; set; } + public int time { get; set; } + public string scene { get; set; } + public string tips { get; set; } + public List attr { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_dic.cs b/Service/Application.Domain.Entity/resource/game/game_dic.cs new file mode 100644 index 0000000..d4013fb --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_dic.cs @@ -0,0 +1,27 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_dic + { + /// + /// code + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// sign + /// + [SugarColumn(IsNullable = true)] + public string? sign { get; set; } + + /// + /// remark + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_ship.cs b/Service/Application.Domain.Entity/resource/game/game_equ_attr.cs similarity index 54% rename from Service/Application.Domain.Entity/resource/game/game_ship.cs rename to Service/Application.Domain.Entity/resource/game/game_equ_attr.cs index c4554cf..145b8f2 100644 --- a/Service/Application.Domain.Entity/resource/game/game_ship.cs +++ b/Service/Application.Domain.Entity/resource/game/game_equ_attr.cs @@ -4,72 +4,78 @@ using System; namespace Application.Domain.Entity { [Tenant("Kg.SeaTime.Resource")] - public class game_ship + public class game_equ_attr { /// - /// shipId + /// erId /// [SugarColumn(IsPrimaryKey = true, Length = 50)] - public int shipId { get; set; } + public string erId { get; set; } /// - /// npc + /// equCode + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? equCode { get; set; } + + /// + /// minLev /// [SugarColumn(IsNullable = true)] - public int? npc { get; set; } + public int? minLev { get; set; } /// - /// shipName + /// maxLev + /// + [SugarColumn(IsNullable = true)] + public int? maxLev { get; set; } + + /// + /// 权重 + /// + [SugarColumn(IsNullable = true)] + public int? random { get; set; } + + /// + /// 属性类型:Number 数值 float 百分比 /// [SugarColumn(Length = 50, IsNullable = true)] - public string shipName { get; set; } + public string? nt { get; set; } /// - /// img + /// 属性 /// [SugarColumn(Length = 50, IsNullable = true)] - public string img { get; set; } + public string? code { get; set; } /// - /// price + /// compute + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? compute { get; set; } + + /// + /// min_v /// [SugarColumn(Length = 18, IsNullable = true)] - public decimal? price { get; set; } + public decimal? min_v { get; set; } /// - /// salePrice + /// max_v /// [SugarColumn(Length = 18, IsNullable = true)] - public decimal? salePrice { get; set; } + public decimal? max_v { get; set; } /// - /// payType + /// tips /// - [SugarColumn(Length = 50, IsNullable = true)] - public string payType { get; set; } - - /// - /// weight - /// - [SugarColumn(IsNullable = true)] - public int? weight { get; set; } - - /// - /// speed - /// - [SugarColumn(IsNullable = true)] - public int? speed { get; set; } - - /// - /// neeGold - /// - [SugarColumn(IsNullable = true)] - public int? neeGold { get; set; } + [SugarColumn(Length = 255, IsNullable = true)] + public string? tips { get; set; } /// /// remark /// - [SugarColumn(Length = 50, IsNullable = true)] - public string remark { get; set; } + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } } } diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_awaken.cs b/Service/Application.Domain.Entity/resource/game/game_equ_awaken.cs new file mode 100644 index 0000000..e7b62ff --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_awaken.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_awaken + { + /// + /// 特性表 + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string atId { get; set; } + + /// + /// 特性名称 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// levAttr + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List levAttr { get; set; } + + /// + /// 权重 + /// + [SugarColumn(IsNullable = true)] + public int? random { get; set; } + + /// + /// 可觉醒装备 + /// + [SugarColumn(IsNullable = true)] + public string? position { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_make.cs b/Service/Application.Domain.Entity/resource/game/game_equ_make.cs new file mode 100644 index 0000000..035b685 --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_make.cs @@ -0,0 +1,45 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_make + { + /// + /// mkId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string mkId { get; set; } + + /// + /// goodsId + /// + [SugarColumn(IsNullable = true)] + public int? goodsId { get; set; } + + /// + /// equId + /// + [SugarColumn(IsNullable = true)] + public int? equId { get; set; } + + /// + /// equName + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? equName { get; set; } + + /// + /// random + /// + [SugarColumn(IsNullable = true)] + public int? random { get; set; } + + /// + /// 是否随机特性 + /// + [SugarColumn(IsNullable = true)] + public int? rdAttr { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_up.cs b/Service/Application.Domain.Entity/resource/game/game_equ_up.cs new file mode 100644 index 0000000..c84fcdc --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_up.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_up + { + /// + /// euId + /// + [SugarColumn(IsPrimaryKey = true)] + public int euId { get; set; } + + /// + /// onLev + /// + [SugarColumn(IsNullable = true)] + public int? onLev { get; set; } + + /// + /// maxLev + /// + [SugarColumn(IsNullable = true)] + public int? maxLev { get; set; } + + /// + /// okChance + /// + [SugarColumn(IsNullable = true)] + public int? okChance { get; set; } + + /// + /// needData + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List needData { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_monster.cs b/Service/Application.Domain.Entity/resource/game/game_monster.cs new file mode 100644 index 0000000..abc3a76 --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_monster.cs @@ -0,0 +1,117 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_monster + { + /// + /// monsterId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string monsterId { get; set; } + + /// + /// name + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// 怪物应用区域 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// lev + /// + [SugarColumn(IsNullable = true)] + public int? lev { get; set; } + + /// + /// exp + /// + [SugarColumn(IsNullable = true)] + public long? exp { get; set; } + + /// + /// copper + /// + [SugarColumn(IsNullable = true)] + public long? copper { get; set; } + + /// + /// petExp + /// + [SugarColumn(IsNullable = true)] + public long? petExp { get; set; } + + /// + /// minAtk + /// + [SugarColumn(IsNullable = true)] + public int? minAtk { get; set; } + + /// + /// maxAtk + /// + [SugarColumn(IsNullable = true)] + public int? maxAtk { get; set; } + + /// + /// defense + /// + [SugarColumn(IsNullable = true)] + public int? defense { get; set; } + + /// + /// agility + /// + [SugarColumn(IsNullable = true)] + public int? agility { get; set; } + + /// + /// blood + /// + [SugarColumn(Length = 62, IsNullable = true)] + public decimal? blood { get; set; } + + /// + /// 怪物属性 + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List attr { get; set; } + + /// + /// 怪物技能 + /// + [SugarColumn(IsNullable = true)] + public string? skill { get; set; } + + /// + /// award + /// + [SugarColumn(Length = 3000, IsNullable = true)] + public string? award { get; set; } + + /// + /// 支持复制战斗0不支持 1支持 + /// + [SugarColumn(IsNullable = true)] + public int? isCopy { get; set; } + + /// + /// 怪物说明 + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } + + /// + /// 用于后台操作标记,无其他作用 + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? markTips { get; set; } + } +} diff --git a/Service/Application.Domain.Entity/resource/game/game_monster_map.cs b/Service/Application.Domain.Entity/resource/game/game_monster_map.cs new file mode 100644 index 0000000..1d40beb --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_monster_map.cs @@ -0,0 +1,57 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_monster_map + { + /// + /// mmId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string mmId { get; set; } + + /// + /// mapId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? mapId { get; set; } + + /// + /// monsterId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? monsterId { get; set; } + + /// + /// monsterName + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? monsterName { get; set; } + + /// + /// addCount + /// + [SugarColumn(IsNullable = true)] + public int? addCount { get; set; } + + /// + /// chance + /// + [SugarColumn(IsNullable = true)] + public int? chance { get; set; } + + /// + /// sTime + /// + [SugarColumn(IsNullable = true)] + public int? sTime { get; set; } + + /// + /// eTime + /// + [SugarColumn(IsNullable = true)] + public int? eTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/view/MakePaperView.cs b/Service/Application.Domain.Entity/view/MakePaperView.cs new file mode 100644 index 0000000..c6ec2f7 --- /dev/null +++ b/Service/Application.Domain.Entity/view/MakePaperView.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class MakePaperView +{ + public game_goods goods { get; set; } + public long count { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain/Cache/FightCache.cs b/Service/Application.Domain/Cache/FightCache.cs new file mode 100644 index 0000000..d58859e --- /dev/null +++ b/Service/Application.Domain/Cache/FightCache.cs @@ -0,0 +1,7 @@ +namespace Application.Domain; + +public class FightCache +{ + public static string FightCacheKey = "GameFightCache:{0}"; + public static string FightCacheKeys = "GameFightCache:{0}:{1}"; +} \ No newline at end of file diff --git a/Service/Application.Domain/Config/GameConfig.cs b/Service/Application.Domain/Config/GameConfig.cs index 9b0ba43..0c643ed 100644 --- a/Service/Application.Domain/Config/GameConfig.cs +++ b/Service/Application.Domain/Config/GameConfig.cs @@ -17,4 +17,5 @@ public static class GameConfig public const int GameAutoDrugGoodsId = 10001;//急救箱物品ID public const int GameToMapNeedCopper = 5;//传送每海里费用 public const int TeamCacheTime = 300;//队伍缓存时间 + public const int GameEquApprGoods = 10001;//鉴定装备道具 } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/EquEnum.cs b/Service/Application.Domain/Enum/EquEnum.cs index 0469997..8c21736 100644 --- a/Service/Application.Domain/Enum/EquEnum.cs +++ b/Service/Application.Domain/Enum/EquEnum.cs @@ -21,5 +21,11 @@ public static class EquEnum Ornaments = 3, //佩戴 Fashion = 1, //时装 Wing = 1, //羽翼 + Decorate = 5, //装饰 + } + + public enum SuitAttrNeedType + { + ON_EQU } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/FightEnum.cs b/Service/Application.Domain/Enum/FightEnum.cs new file mode 100644 index 0000000..7014497 --- /dev/null +++ b/Service/Application.Domain/Enum/FightEnum.cs @@ -0,0 +1,7 @@ +namespace Application.Domain; + +public static class FightEnum +{ + + +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GameEnum.cs b/Service/Application.Domain/Enum/GameEnum.cs index 56434e5..ac93b6e 100644 --- a/Service/Application.Domain/Enum/GameEnum.cs +++ b/Service/Application.Domain/Enum/GameEnum.cs @@ -55,6 +55,89 @@ public static class GameEnum RetBlood, RetMorale, RetVigour, + RetEqu, MapTo, + Store, + Make, + } + + public enum DicCode + { + Awaken,//觉醒配置 + Quality,//洗练配置 + } + public enum ComputeType + { + Plus,//加法计算 + Ride,//乘法计算 + Reduce,//减法计算 + Except,//除法计算 + } + public enum AttrCode + { + AddExp,//经验 + AddGold,//金币 + MinAtk, + MaxAtk, + Atk,//攻击 + Blood,//体力 + Defense,//防御 + Agility,//敏捷 + Morale,//士气 + Burst,//爆率 + InBlood,//吸血 + Crit,//暴击 + Dodge,//闪避 + NoHarm,//免伤 + Rebound,//反弹 + Punish,//制裁 + Slow,//迟缓 + Poison,//中毒 + PoisonLess,//抗毒攻 + Curse,//诅咒 + Weaken,//弱化 + Deadly,//致命 + DeadlyLess,//抗致命 + Depressed,//消沉 沮丧 + Breach,//突破 + Del_Fashion,//卸时装 + Atk_Next,//连击 + ReboundLess,//抗反弹 + Harm_Add,//额外伤害 + PalsyAtk,//麻痹 + PalsyAtkLess,//抗麻痹 + CurseLess,//抗诅咒 + WeakenLess,//抗弱化 + DepressedLess,//抗消沉 + BreachLess,//抗突破 + Luck,//幸运 + SlowLess,//抗迟缓 + Depth,//潜水深度 + Height,//升空高度 + Weight//负重 + } + + public enum GameStockCode + { + Blood, + Durability, + + } + public enum GameStockType + { + Number,//数值 + Time,//时间 + } + + public enum FightCode + { + PVP,//人物对战 + PVE//NPC对战 + } + public enum AreaCode + { + Own,//个人怪物 + Public,//公共怪物 + Team,//队伍怪物 } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GoodsEnum.cs b/Service/Application.Domain/Enum/GoodsEnum.cs index fe24f1b..5066e51 100644 --- a/Service/Application.Domain/Enum/GoodsEnum.cs +++ b/Service/Application.Domain/Enum/GoodsEnum.cs @@ -14,6 +14,19 @@ public static class GoodsEnum Card,//附魔卡片 Mark,//圣痕 Pack,//宝箱 - Practise,//修炼道具 + ChoicePack,//选择宝箱 + Weight,//负重 + Exp,//经验 + State,//状态物品 + Ship,//船只 + } + + public enum DrugCls + { + Blood,//普通体力药品 + BloodStock,//体力储存药品 + Vigour,//活力 + Morale,//士气 + LoadBuff,//消除负面状态 } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/MessageEnum.cs b/Service/Application.Domain/Enum/MessageEnum.cs index c3a18ac..2fd9480 100644 --- a/Service/Application.Domain/Enum/MessageEnum.cs +++ b/Service/Application.Domain/Enum/MessageEnum.cs @@ -8,4 +8,12 @@ public static class MessageEnum Marry,//婚姻消息 Trade,//交易通知 } + public enum BroadcastCode + { + Gift, + System, + Award, + Remind, + Promote + } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/MonsterEnum.cs b/Service/Application.Domain/Enum/MonsterEnum.cs new file mode 100644 index 0000000..cd501cf --- /dev/null +++ b/Service/Application.Domain/Enum/MonsterEnum.cs @@ -0,0 +1,11 @@ +namespace Application.Domain; + +public static class MonsterEnum +{ + public enum AwardCode + { + Default, + + } + +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs index 3b7d4c4..0a7913c 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -6,20 +6,25 @@ public interface IGameEquService Task GetEquInfo(int equId); Task GetEuqSuitInfo(string suitCode); + #endregion + #region 用户装备 Task> GetUserEquData(string userId, int type, string equName, int PageIndex, int PageSize, - RefAsync Total, bool isRemOn = false); + RefAsync Total, bool isRemOn = false, bool isRemLock = false); Task> GetUserEquData(string userId, int equId); + Task> GetUserEquData(string userId, string code, List noUeId); Task GetUserEquInfo(string ueId); Task GetUserEquByEquIdCount(string userId, int equId); Task> GetUserEquByEquId(string userId, int equId); Task AddUserEqu(string userId, int equId, int count, string remark); - + Task AddUserEqu(unit_user_equ equData, string remark); + Task AddUserEqu(string userId, int equId, bool rdAttr = false, string remark = ""); Task UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "", string remark = ""); + Task DeductUserEqu(string userId, List equData, string remark); Task DeductUserEqu(string userId, int equId, int count, string remark); @@ -27,13 +32,36 @@ public interface IGameEquService bool isAddAttr = false); Task> GetUserOnEqu(string userId); + Task GetUserEquAttrModel(string userId); Task EquOnOrDown(unit_user_equ data, int state); + Task> GetUserEquSuit(string userId); + Task> GetUserEquSuitAttrInfo(string userId); #endregion - #region 辅助 + #region 觉醒相关 + + Task GetEquAwakenInfo(string atId); + Task GetRandomOneAwakenByCode(string code); + Task GetEquAwakenInfoByLev(string atId, int lev); + + #endregion + + #region 洗练属性/词条 + + Task> GetRandomEquAttr(string equCode, int lev); + + #endregion + + #region 强化相关 + + Task GetUserEquUpData(int lev); + + #endregion + + #region 辅助 Task GetUserEquWeightSum(string userId); - + Task GetMakeEquByGoodsId(int goodsId); #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs new file mode 100644 index 0000000..725f65f --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs @@ -0,0 +1,26 @@ +namespace Application.Domain; + +public interface IGameFightService +{ + #region 用户战斗索引 + + Task> GetUserFight(string userId); + Task RemoveUserFight(string userId, string fightId); + #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 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 = ""); + + Task SetFightWin(string fightId, string winUser); + + + #endregion + #region 战斗相关 + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs index a537a8e..05814d6 100644 --- a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs +++ b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs @@ -29,7 +29,11 @@ public interface IGameGoodsService #endregion - #region 船只 - Task GetShipInfo(int shipId); + #region 药品 + + Task CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = ""); + Task UseDrug(string userId, int goodsId, string drugConfig, string scene = ""); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs index d4ec39b..34fc0c7 100644 --- a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs +++ b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs @@ -18,6 +18,7 @@ public interface IGameMapService #region 用户地图 Task GetUserOnMapId(string userId); + Task GetUserOnToMapInfo(string userId); Task GetUserOnMap(string userId); Task UpdateUserOnMap(string userId, string ip, string mapId); Task UpdateUserOnMap(unit_user_online data, string mapId); diff --git a/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs b/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs new file mode 100644 index 0000000..1ba4ca9 --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs @@ -0,0 +1,20 @@ +namespace Application.Domain; + +public interface IGameMonsterService +{ + #region 基础资源库 + + Task GetMonsterInfo(string monsterId); + #endregion + #region 地图怪物 + + Task> GetMonsterDataByMap(string mapId); + Task GetMapMonsterInfo(string mmId); + Task CreateMonsterToMap(string userId, string mapId, string areaCode, string monsterId, + int count = 1, int time = 0, string par = ""); + + Task GetCreateMonsterInfo(string umId); + Task> GetMapMonster(string userId, string mapId, string teamId); + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Pub/IGameDicService.cs b/Service/Application.Domain/Services/Interface/Pub/IGameDicService.cs new file mode 100644 index 0000000..f7f34d3 --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Pub/IGameDicService.cs @@ -0,0 +1,6 @@ +namespace Application.Domain; + +public interface IGameDicService +{ + Task GetDicInfo(string code); +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs index bf1ca05..07044cc 100644 --- a/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs +++ b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs @@ -43,4 +43,11 @@ public interface IMessageService List btns = null, int days = 10); #endregion + + #region 广播消息 + + Task> GetBroadcastData(int area); + Task SendBroadcast(string userId, string code, string msg); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs index 09aebd7..c9d10ba 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -4,9 +4,10 @@ public interface IUnitUserAttrService { #region 个人属性 - Task GetUserAttrModel(string userId); + Task GetUserAttrModel(string userId, string scene = "Default"); Task GetUserAttr(string userId); Task GetUserLev(string userId); + #endregion #region 体力操作 @@ -29,6 +30,7 @@ public interface IUnitUserAttrService Task UpdateUserMorale(string userId, int op, int count); Task CheackRecoverMorale(string userId); Task LockRecoverMorale(string userId); + #endregion #region 活力 @@ -43,6 +45,42 @@ public interface IUnitUserAttrService Task UpdateOnLineTime(string userId, string code, int time); + #endregion + + #region 药品栏 + + Task GetUserDrug(string userId); + Task UpdateUserDrug(unit_user_drug data); + + #endregion + + #region BUFF状态 + + Task> GetUserStateData(string userId, string scene = "Default"); + + Task AddUserState(string userId, string groupId, string name, string scene, string tips, + List attr, int time, int count = 1); + + #endregion + + #region 游戏资源储备 + + Task> GetUserStock(string userId, string code = "Default"); + + Task AddUserStock(string userId, string goodsId,string name, string type, string code, long sign, + string par = "", + int minute = 0); + + Task UpdateUserStock(unit_user_stock data); + + #endregion + + #region 负面状态 + + Task> GetUserLoadState(string userId); + Task AddUserLoadState(string userId, string name, string code); + Task RandomRemoveUserLoadState(string userId, int count); + Task RemoveUserLoadState(string userId); #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs index b33d4bd..673911f 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs @@ -19,7 +19,7 @@ public interface IUnitUserWeight Task UpdateUserShipOnWeight(string userId, int op, int weight); Task CheakUserShipWeight(string userId, int useWeight); Task DeleteUserShip(string usId, string userId); - Task AddUserShip(string userId, string name, int goodsId, int speed, int weight); + Task AddUserShip(string userId, string name, int goodsId, int speed, int weight,int copper,long sale,string remark); #endregion diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index c0d54d8..7af2341 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -39,7 +39,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame #region 用户装备 public async Task> GetUserEquData(string userId, int type, string equName, int PageIndex, - int PageSize, RefAsync Total, bool isRemOn = false) + int PageSize, RefAsync Total, bool isRemOn = false, bool isRemLock = false) { long onTime = TimeExtend.GetTimeStampSeconds; var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -48,6 +48,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame .WhereIF(type == 1, it => it.isOn == 1) .WhereIF(type == 3, it => it.isAppr == 0) .WhereIF(isRemOn, it => it.isOn == 0) + .WhereIF(isRemLock, it => it.isLock == 0) .WhereIF(!string.IsNullOrEmpty(equName), it => it.equName.Contains(equName) || it.unitEquName.Contains(equName)) .OrderByDescending(it => it.lev) @@ -56,11 +57,18 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame public async Task> GetUserEquData(string userId, int equId) { - long onTime = TimeExtend.GetTimeStampSeconds; var db = DbClient.AsTenant().GetConnectionWithAttr(); return await db.Queryable().Where(it => it.userId == userId && it.equId == equId).ToListAsync(); } + public async Task> GetUserEquData(string userId, string code, List noUeId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.userId == userId && it.code == code) + .WhereIF(noUeId.Count > 0, it => !noUeId.Contains(it.ueId)) + .ToListAsync(); + } + public async Task GetUserEquInfo(string ueId) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -173,6 +181,115 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return result; } + public async Task AddUserEqu(unit_user_equ equData, string remark) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var result = await db.Insertable(equData).ExecuteCommandAsync() > 0; + if (result) + { + //添加日志 + await AddEquLogs([equData], 1, remark, true); + //更新负重 + int weightCount = Convert.ToInt32(equData.weight); + if (weightCount > 0) + { + var attrService = App.GetService(); + await attrService.UpdateUserWeight(equData.userId, 1, weightCount); + } + } + + return result; + } + + public async Task AddUserEqu(string userId, int equId, bool rdAttr = false, string remark = "") + { + var equ = await GetEquInfo(equId); + if (equ == null) + { + return null; + } + + unit_user_equ ue = new unit_user_equ(); + string ueId = StringAssist.NewGuid; + ue.ueId = ueId; + ue.userId = userId; + ue.owerId = userId; + ue.equId = equ.equId; + ue.equName = equ.equName; + ue.unitEquName = equ.equName; + ue.img = equ.img; + ue.sign = ""; + ue.isAppr = 1; + if (equ.isAppr == 0) + { + ue.minAtk = equ.minAtk; + ue.maxAtk = equ.maxAtk; + ue.Defense = Convert.ToInt32(equ.defense); + ue.Agility = Convert.ToInt32(equ.agility); + ue.Morale = Convert.ToInt32(equ.morale); + ue.Blood = Convert.ToInt32(equ.blood); + } + else + { + ue.minAtk = RandomAssist.GetFormatedNumeric((int)equ.minAtk, (int)equ.maxAtk); + ue.maxAtk = RandomAssist.GetFormatedNumeric((int)equ.minAtk, (int)equ.maxAtk); + string[] def = equ.defense.Split('-'); + ue.Defense = RandomAssist.GetFormatedNumeric(Convert.ToInt32(def[0]), Convert.ToInt32(def[1])); + string[] agi = equ.agility.Split('-'); + ue.Agility = RandomAssist.GetFormatedNumeric(Convert.ToInt32(agi[0]), Convert.ToInt32(agi[1])); + string[] mor = equ.morale.Split('-'); + ue.Morale = RandomAssist.GetFormatedNumeric(Convert.ToInt32(mor[0]), Convert.ToInt32(mor[1])); + string[] blo = equ.blood.Split('-'); + ue.Blood = RandomAssist.GetFormatedNumeric(Convert.ToInt32(blo[0]), Convert.ToInt32(blo[1])); + } + + ue.code = equ.code; + ue.suitCode = equ.suitCode; + ue.lev = equ.lev; + ue.durability = equ.durability; + ue.maxdurability = equ.durability; + ue.isIntensify = equ.isIntensify; + ue.intensifyLev = 0; + ue.isLock = 0; + ue.holeCount = equ.holeCount; + ue.sex = equ.sex; + ue.weight = equ.weight; + ue.sysPrice = equ.sysPrice; + ue.qualityAttr = new List(); + if (rdAttr == false) + { + ue.quality = equ.quality; + ue.qualityName = GameTool.GetEquQualityName((int)ue.quality); + ue.EquAttr = equ.equAttr; + } + else + { + var randomAttr = await GetRandomEquAttr(equ.code, (int)equ.lev); + ue.quality = randomAttr.Count; + ue.qualityName = GameTool.GetEquQualityName((int)ue.quality); + ue.EquAttr = randomAttr; + } + + ue.canEqualUp = equ.canEqualUp; + ue.isDeal = equ.isDeal; + ue.isGive = equ.isGive; + ue.opTime = 0; + ue.start = 0; + ue.EquMent = new EquMent(); + ue.EquAwaken = new List(); + ue.GemMent = new List(); + ue.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddYears(20)); + ue.isOn = 0; + if (await AddUserEqu(ue, remark)) + { + return ue; + } + else + { + return null; + } + } + public async Task UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "", string remark = "") { @@ -184,6 +301,11 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame { await AddEquLog(equData, code, remark); } + + if (equData.isOn == 1) + { + await ClearUserOnEqu(equData.userId); + } } return result; @@ -325,6 +447,52 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame } } + public async Task GetUserEquAttrModel(string userId) + { + var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEquAttr"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync(key, userId); + } + + long endTime = TimeExtend.GetTimeStampSeconds; + UserAttrModel result = new UserAttrModel(); + var myEqu = await GetUserOnEqu(userId); + foreach (var equ in myEqu) + { + if (equ.durability > 0 || equ.useEndTime > endTime) + { + UserAttrModel equTemp = new UserAttrModel(); + var equAttr = EquTool.GetUserEquByIntensify(equ); + equTemp.minAtk = (int)equAttr.minAtk; + equTemp.maxAtk = (int)equAttr.maxAtk; + equTemp.defense = (int)equAttr.Defense; + equTemp.agility = (int)equAttr.Agility; + equTemp.upBlood = (int)equAttr.Blood; + equTemp.upMorale = (int)equAttr.Morale; + List equAttrData = EquTool.GetUserEquAttrData(equ); + equTemp = GameAttrTool.GetRoleAttrTempMerge(equTemp, equAttrData); + result = GameAttrTool.GetRoleAttrTempMerge(result, equTemp); + } + } + + await redis.AddHashAsync(key, userId, result); + return result; + } + + private async Task ClearUserOnEqu(string userId) + { + var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu"); + await redis.DelHashAsync(key, userId); + key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEquAttr"); + await redis.DelHashAsync(key, userId); + //清理套装缓存 + key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuit", userId); + await redis.DelAsync(key); + key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuitAttr", userId); + await redis.DelAsync(key); + } + public async Task EquOnOrDown(unit_user_equ data, int state) { data.isOn = state; @@ -334,21 +502,292 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame var equInfo = await GetEquInfo((int)data.equId); if (equInfo.useTime > 0) { - data.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays((int)equInfo.useTime)) ; + data.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays((int)equInfo.useTime)); } } + var db = DbClient.AsTenant().GetConnectionWithAttr(); bool result = await db.Updateable(data).ExecuteCommandAsync() > 0; if (result) { + await ClearUserOnEqu(data.userId); } return result; } + /// + /// 获取个人套装 + /// + /// + /// + public async Task> GetUserEquSuit(string userId) + { + List result = new List(); + long time = TimeExtend.GetTimeStampSeconds; + var key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuit", userId); + if (await redis.ExistsAsync(key)) + { + result = await redis.GetAsync>(key); + } + else + { + List opSuit = new List(); + var onEquData = await GetUserOnEqu(userId); + string[] onEqu = onEquData.Select(it => it.equId.ToString()).ToArray(); + onEquData = onEquData.FindAll(it => it.useEndTime > time && it.durability > 0); + foreach (var item in onEquData) + { + if (item.suitCode != "0" && !string.IsNullOrEmpty(item.suitCode)) + { + if (!opSuit.Contains(item.suitCode)) + { + opSuit.Add(item.suitCode); + } + } + } + foreach (var suit in opSuit) + { + UserEquSuit temp = new UserEquSuit(); + var suitInfo = await GetEuqSuitInfo(suit); + if (suitInfo != null) + { + temp.suitCode = suitInfo.suitCode; + temp.suitName = suitInfo.suitName; + temp.SuitAttr = new List(); + foreach (var item in suitInfo.attr) + { + if (item.NeedType == nameof(EquEnum.SuitAttrNeedType.ON_EQU)) + { + bool same = item.NeedData.All(item => onEqu.Contains(item)); + if (same) + { + temp.SuitAttr.Add(item); + } + } + } + if (temp.SuitAttr.Count > 0) //存在满足条件得属性 + { + result.Add(temp); + } + } + } + await redis.SetAsync(key, result, 300); + } + + return result; + } + + public async Task> GetUserEquSuitAttrInfo(string userId) + { + List result = new List(); + var key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuitAttr", userId); + if (await redis.ExistsAsync(key)) + { + result = await redis.GetAsync>(key); + } + else + { + var suitData = await GetUserEquSuit(userId); + foreach (var item in suitData) + { + foreach (var attr in item.SuitAttr) + { + result.AddRange(attr.AttrItem); + } + } + await redis.SetAsync(key, result, 300); + } + + return result; + } + + #endregion + + #region 觉醒 + + public async Task GetEquAwakenInfo(string atId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "AwakenData"); + var data = await redis.GetHashAsync(key, atId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(i => i.atId == atId).SingleAsync(); + if (data != null) + { + await redis.AddHashAsync(key, atId, data); + } + } + + return data; + } + + public async Task GetRandomOneAwakenByCode(string code) + { + game_equ_awaken attr = new game_equ_awaken(); + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var list = await db.Queryable().Where(i => i.position.Contains(code)).ToListAsync(); + if (list.Count == 0) + { + return null; + } + + List data = new List(); + List weights = new List(); + List result = new List(); + Random rand = new Random(); + + foreach (var item in list) + { + data.Add(item); + weights.Add(ushort.Parse(item.random.ToString())); + } + + RandomAssist random = new RandomAssist(1); + + result = random.ControllerRandomExtract(rand, data, weights); + if (result.Count > 0) + { + attr = result[0] as game_equ_awaken; + return attr; + } + else + { + return null; + } + } + + public async Task GetEquAwakenInfoByLev(string atId, int lev) + { + var awakenInfo = await GetEquAwakenInfo(atId); + EquAwakenData awaken = new EquAwakenData(); + foreach (var item in awakenInfo.levAttr) + { + if (item.lev == lev) + { + return item; + } + } + + return null; + } + + #endregion + + #region 洗练属性/词条 + + private async Task> GetEquAttrData(string erCode) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquAttrData"); + if (await redis.HExistsHashAsync(key, erCode)) + { + return await redis.GetHashAsync>(key, erCode); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.equCode == erCode).ToListAsync(); + await redis.AddHashAsync(key, erCode, data); + return data; + } + + public async Task> GetRandomEquAttr(string equCode, int lev) + { + //计算出的数量 + List numData = new List() + { + new RandomDataBase() { random = 100, data = 1 }, + new RandomDataBase() { random = 90, data = 2 }, + new RandomDataBase() { random = 80, data = 3 }, + new RandomDataBase() { random = 50, data = 4 }, + new RandomDataBase() { random = 30, data = 5 }, + new RandomDataBase() { random = 15, data = 6 }, + new RandomDataBase() { random = 5, data = 7 }, + }; + var numR = GameBus.GetRandomByWeight(numData); + int onNum = Convert.ToInt32(numR.data); + var attrData = await GetEquAttrData(equCode); + attrData = attrData.FindAll(it => it.minLev <= lev && it.maxLev >= lev); + + //开始随机拿属性权重 + List data = new List(); + List weights = new List(); + List attrResult = new List(); + Random rand = new Random(); + + foreach (var item in attrData) + { + data.Add(item); + weights.Add(ushort.Parse(item.random.ToString())); + } + + RandomAssist random = new RandomAssist(onNum); + + attrResult = random.ControllerRandomExtract(rand, data, weights); + List result = new List(); + if (attrResult.Count > 0) + { + foreach (var item in attrResult) + { + var onAttr = item as game_equ_attr; + + AttrItem temp = new AttrItem(); + temp.code = onAttr.code; + temp.compute = onAttr.compute; + if (onAttr.nt == "Number") + { + int onMin = Convert.ToInt32(onAttr.min_v); + int onMax = Convert.ToInt32(onAttr.max_v); + int onPar = RandomAssist.GetFormatedNumeric(onMin, onMax + 1); + temp.parameter = onPar; + string onTip = temp.parameter.ToString().TrimEnd('0').TrimEnd('.'); + temp.tip = string.Format(onAttr.tips, onTip); + } + else + { + int onMin = Convert.ToInt32(onAttr.min_v * 100); + int onMax = Convert.ToInt32(onAttr.max_v * 100); + int onPar = RandomAssist.GetFormatedNumeric(onMin, onMax + 1); + temp.parameter = Math.Round(Convert.ToDecimal(onPar / 100.000M), 2); + string onTip = (temp.parameter * 100).ToString().TrimEnd('0').TrimEnd('.'); + temp.tip = string.Format(onAttr.tips, onTip); + } + + result.Add(temp); + } + } + + return result; + } + + #endregion + + #region 强化相关 + + public async Task GetUserEquAttr(unit_user_equ equ) + { + return equ; + } + + public async Task GetUserEquUpData(int lev) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquUpData"); + var data = await redis.GetHashAsync(key, lev.ToString()); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(i => i.onLev <= lev && i.maxLev >= lev).FirstAsync(); + if (data != null) + { + await redis.AddHashAsync(key, lev.ToString(), data); + } + } + + return data; + } #endregion @@ -361,5 +800,43 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return data.Sum(it => (int)it.weight); } + private async Task> GetEquMakeData(int goodsId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquUpData"); + if (await redis.HExistsHashAsync(key, goodsId.ToString())) + { + return await redis.GetHashAsync>(key, goodsId.ToString()); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.goodsId == goodsId).ToListAsync(); + await redis.AddHashAsync(key, goodsId.ToString(), data); + return data; + } + + public async Task GetMakeEquByGoodsId(int goodsId) + { + //构建随机数据 + List equBase = new List(); + var equData = await GetEquMakeData(goodsId); + foreach (var me in equData) + { + RandomDataBase temp = new RandomDataBase(); + temp.random = (double)me.random; + temp.data = me; + equBase.Add(temp); + } + + var makeEqu = GameBus.GetRandomByWeight(equBase); + if (makeEqu == null) + { + return null; + } + + var onMakeEqu = makeEqu.data as game_equ_make; + + return onMakeEqu; + } + #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 new file mode 100644 index 0000000..ea9c375 --- /dev/null +++ b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs @@ -0,0 +1,208 @@ +namespace Application.Domain; + +public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGameFightService, ITransient +{ + #region 用户战斗索引 + + public async Task> GetUserFight(string userId) + { + string key = string.Format(FightCache.FightCacheKey, "UserFight"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync>(key, userId); + } + + List data = new List(); + await redis.AddHashAsync(key, userId, data); + return data; + } + + private async Task AddUserFight(string userId, string fightId) + { + var data = await GetUserFight(userId); + data.Add(fightId); + string key = string.Format(FightCache.FightCacheKey, "UserFight"); + bool result = await redis.AddHashAsync(key, userId, data); + + return result; + } + + public async Task RemoveUserFight(string userId, string fightId) + { + var data = await GetUserFight(userId); + data.Remove(fightId); + string key = string.Format(FightCache.FightCacheKey, "UserFight"); + bool result = await redis.AddHashAsync(key, userId, data); + return result; + } + + #endregion + + #region 战斗信息 + + public async Task GetFightInfo(string fightId) + { + string key = string.Format(FightCache.FightCacheKeys, "FightData:Info", fightId); + if (await redis.ExistsAsync(key)) + { + return await redis.GetAsync(key); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + game_fight_data data = await db.Queryable().Where(it => it.fightId == fightId).SingleAsync(); + await redis.SetAsync(key, data, 3600); + 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) + { + string key = string.Format(FightCache.FightCacheKeys, "FightData:Harm", fightId); + if (await redis.HExistsHashAsync(key, userId)) + { + long sum = await redis.GetHashAsync(key, userId); + sum += harm; + await redis.AddHashAsync(key, userId, sum); + } + else + { + await redis.AddHashAsync(key, userId, harm); + } + } + + + private async Task ClearFightInfoCache(string fightId, string keyId) + { + string key1 = string.Format(FightCache.FightCacheKeys, "FightData:Info", fightId); + string key2 = string.Format(FightCache.FightCacheKeys, "FightData:Blood", keyId); + await redis.DelAsync(key1, key2); + } + + public async 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 = "") + { + long addTime = TimeExtend.GetTimeStampSeconds; + long endTime = addTime + 24 * 60 * 60; + + List fights = new List(); + + game_fight_data data = new game_fight_data() + { + fightId = fightId, + areaCode = areaCode, + keyId = keyId, + mainId = mainId, + code = code, + scene = scene, + mapId = mapId, + userId = userId, + state = 0, + winUser = "", + exp = exp, + copper = copper, + petExp = petExp, + award = award, + pars = pars, + addTime = addTime, + okTime = 0, + endTime = endTime + }; + fights.Add(data); + if (code == nameof(GameEnum.FightCode.PVP)) + { + fights.Add(new game_fight_data() + { + fightId = StringAssist.NewGuid, + areaCode = areaCode, + keyId = keyId, + mainId = userId, + code = code, + scene = scene, + mapId = mapId, + userId = mainId, + state = 0, + winUser = "", + exp = exp, + copper = copper, + petExp = petExp, + award = award, + pars = pars, + addTime = addTime, + okTime = 0, + endTime = endTime + }); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Insertable(fights).ExecuteCommandAsync() > 0; + if (result) + { + foreach (var item in fights) + { + await AddUserFight(item.userId, item.fightId); + } + } + + return result; + } + + public async Task SetFightWin(string fightId, string winUser) + { + bool result = false; + var data = await GetFightInfo(fightId); + if (data != null) + { + long okTime = TimeExtend.GetTimeStampSeconds; + data.state = 1; + data.winUser = winUser; + data.okTime = okTime; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + result = await db.Updateable().SetColumns(it => it.state == 1) + .SetColumns(it => it.winUser == winUser) + .SetColumns(it => it.okTime == okTime) + .Where(it => it.fightId == fightId).ExecuteCommandAsync() > 0; + } + + if (result) + { + await ClearFightInfoCache(fightId, data.keyId); + //此处调用战斗结束相关 + await HandleFight(data); + } + + return result; + } + + #endregion + + #region 战斗相关 + + private async Task HandleFight(game_fight_data data) + { + } + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs index 25bd294..1f34601 100644 --- a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs +++ b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs @@ -1,4 +1,5 @@ using System.Reflection.Metadata; +using Newtonsoft.Json; namespace Application.Domain; @@ -68,6 +69,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa .OrderBy(it => it.count, OrderByType.Desc) .ToPageListAsync(page, limit, total); } + public async Task> GetUserGoodsData(string userId, string code) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -163,8 +165,6 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return await db.Insertable(bagLog).SplitTable().ExecuteCommandAsync() > 0; } - - #endregion #region 辅助 @@ -187,19 +187,142 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa #endregion - #region 船只 - public async Task GetShipInfo(int shipId) + #region 药品 + + private async Task GetUserDrugLockTime(string userId, int goodsId) { - string key = string.Format(BaseCache.BaseCacheKey, "ShipData"); - var data = await redis.GetHashAsync(key, shipId.ToString()); - if (data == null) + long result = 0; + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Lock:{userId}_{goodsId}"); + if (await redis.ExistsAsync(key)) { - var db = DbClient.AsTenant().GetConnectionWithAttr(); - data = await db.Queryable().Where(it => it.shipId == shipId).SingleAsync(); - await redis.AddHashAsync(key, shipId.ToString(), data); + long end = await redis.GetAsync(key); + result = end - TimeExtend.GetTimeStampSeconds; + result = result < 0 ? 0 : result; } - return data; + return result; } + + private async Task AddUserDrugLockTime(string userId, int goodsId, int time) + { + if (time > 0) + { + long end = TimeExtend.GetTimeStampSeconds + time; + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Lock:{userId}_{goodsId}"); + await redis.SetAsync(key, end, time); + } + } + + private async Task GetUserDrugLockCount(string userId, int goodsId, string scene = "") + { + int result = 0; + if (!string.IsNullOrEmpty(scene)) + { + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Count:{scene}:{userId}_{goodsId}"); + if (await redis.ExistsAsync(key)) + { + result = await redis.GetAsync(key); + } + } + + return result; + } + + private async Task AddUserDrugLockCount(string userId, int goodsId, string scene = "") + { + if (!string.IsNullOrEmpty(scene)) + { + var count = await GetUserDrugLockCount(userId, goodsId, scene); + count += 1; + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Count:{scene}:{userId}_{goodsId}"); + await redis.SetAsync(key, count, 43200); + } + } + + + public async Task CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = "") + { + string result = string.Empty; + dynamic _drugConfig = JsonConvert.DeserializeObject(drugConfig); + if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Blood)) + { + //判断所定 + long lockTime = await GetUserDrugLockTime(userId, goodsId); + if (lockTime > 0) + { + result = $"药品冷却中,{lockTime}秒后可使用!"; + } + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.BloodStock)) + { + if (_drugConfig.type == nameof(GameEnum.GameStockType.Number)) + { + if (string.IsNullOrEmpty(scene)) + { + var attrService = App.GetService(); + var userStock = await attrService.GetUserStock(userId); + if (userStock.Count(it => it.goodsId == goodsId.ToString()) > 0) + { + result = "您已经使用过该药品啦!"; + } + } + else + { + //要判断使用个数 + if (_drugConfig.use > 0) + { + var count = await GetUserDrugLockCount(userId, goodsId, scene); + if (count >= _drugConfig.use) + { + result = $"当前最多可用{_drugConfig.use}个该物品!"; + } + } + } + } + } + + return result; + } + + public async Task UseDrug(string userId, int goodsId, string drugConfig, string scene = "") + { + bool result = false; + var attrService = App.GetService(); + dynamic _drugConfig = JsonConvert.DeserializeObject(drugConfig); + if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Blood)) + { + result = await attrService.UpdateUserBlood(userId, 1, Convert.ToInt32(_drugConfig.num), true); + if (result) + { + await AddUserDrugLockTime(userId, goodsId, Convert.ToInt32(_drugConfig.time)); + } + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Morale)) + { + result = await attrService.UpdateUserMorale(userId, 1, Convert.ToInt32(_drugConfig.num)); + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Vigour)) + { + result = await attrService.UpdateUserVigour(userId, 1, Convert.ToInt32(_drugConfig.num)); + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.LoadBuff)) + { + result = await attrService.RandomRemoveUserLoadState(userId, Convert.ToInt32(_drugConfig.num)); + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.BloodStock)) + { + result = await attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name),Convert.ToString(_drugConfig.type), + Convert.ToString(_drugConfig.code), + Convert.ToInt64(_drugConfig.num), Convert.ToString(_drugConfig.par), + Convert.ToInt32(_drugConfig.minute)); + if (result) + { + await AddUserDrugLockCount(userId, goodsId, scene); + } + } + + return result; + } + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Map/GameMapService.cs b/Service/Application.Domain/Services/Service/Map/GameMapService.cs index ed31d1e..a93d16a 100644 --- a/Service/Application.Domain/Services/Service/Map/GameMapService.cs +++ b/Service/Application.Domain/Services/Service/Map/GameMapService.cs @@ -148,6 +148,12 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return data.mapId; } + public async Task GetUserOnToMapInfo(string userId) + { + var onMap = await GetUserOnMapId(userId); + return await GetMapInfo(onMap); + } + public async Task GetUserOnMap(string userId) { string key = string.Format(UserCache.BaseCacheKey, "UserOnline"); @@ -832,7 +838,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame if (!string.IsNullOrEmpty(offSet)) { var offsetData = JsonConvert.DeserializeObject(offSet); - var chekResult = await GameBus.CheakNeed(userId, offsetData, ""); + var chekResult = await GameBus.CheckNeed(userId, offsetData); if (chekResult.result) { if (offsetData.isOp == 0) @@ -858,7 +864,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame public async Task> GetMapBus(string BusCode, int v, int l) { - string key = string.Format(BaseCache.BaseCacheKeys, "CITY_MAP_BUS", BusCode); + string key = string.Format(BaseCache.BaseCacheKeys, "CityMapBus", BusCode); var data = await redis.GetAsync>(key); if (data == null) { @@ -877,7 +883,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame public async Task GetMapBusInfo(int busId) { - string key = string.Format(BaseCache.BaseCacheKeys, "CITY_MAP_BUS", "BUS_INFO"); + string key = string.Format(BaseCache.BaseCacheKeys, "CityMapBus", "BUS_INFO"); if (await redis.HExistsHashAsync(key, busId.ToString())) { return await redis.GetHashAsync(key, busId.ToString()); @@ -925,6 +931,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame #endregion #region 地图资源 + public async Task GetMapResInfo(string resId) { string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "MapResInfo"); @@ -938,6 +945,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return data; } + public async Task> GetMapRes(string mapId) { string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "MapRes"); diff --git a/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs b/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs new file mode 100644 index 0000000..d9ede28 --- /dev/null +++ b/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs @@ -0,0 +1,207 @@ +using Microsoft.VisualBasic.CompilerServices; + +namespace Application.Domain; + +public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMonsterService, ITransient +{ + #region 基础资源库 + + public async Task GetMonsterInfo(string monsterId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "MonsterInfo"); + if (await redis.HExistsHashAsync(key, monsterId)) + { + return await redis.GetHashAsync(key, monsterId); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.monsterId == monsterId).SingleAsync(); + await redis.AddHashAsync(key, monsterId, data); + return data; + } + + #endregion + + #region 地图怪物 + + public async Task> GetMonsterDataByMap(string mapId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "MonsterOnMap"); + if (await redis.HExistsHashAsync(key, mapId)) + { + return await redis.GetHashAsync>(key, mapId); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.mapId == mapId).ToListAsync(); + await redis.AddHashAsync(key, mapId, data); + return data; + } + + public async Task GetMapMonsterInfo(string mmId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "MapMonsterInfo"); + if (await redis.HExistsHashAsync(key, mmId)) + { + return await redis.GetHashAsync(key, mmId); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.mmId == mmId).SingleAsync(); + await redis.AddHashAsync(key, mmId, data); + return data; + } + + public async Task CreateMonsterToMap(string userId, string mapId, string areaCode, string monsterId, + int count = 1, int time = 0, string par = "") + { + bool result = false; + var monsterInfo = await GetMonsterInfo(monsterId); + if (monsterInfo != null) + { + time = time <= 0 ? 7 * 24 * 60 : time; + long onTime = TimeExtend.GetTimeStampSeconds; + long endTime = onTime + time * 60; + List data = new List(); + for (int i = 0; i < count; i++) + { + data.Add(new unit_user_monster() + { + umId = StringAssist.NewGuid, + userId = userId, + areaCode = areaCode, + mapId = mapId, + monsterId = monsterId, + monsterName = monsterInfo.name, + code = monsterInfo.code, + par = par, + addTime = onTime, + endTime = endTime + }); + } + + if (data.Count > 0) + { + var createDb = DbClient.AsTenant().GetConnectionWithAttr(); + await createDb.Insertable(data).ExecuteCommandAsync(); + } + + result = true; + } + + if (result) + { + await ClearCreateMonster(mapId); + } + + return result; + } + + private async Task> GetCreateMonsterByMapId(string mapId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "CreateMonsterOnMap"); + if (await redis.HExistsHashAsync(key, mapId)) + { + return await redis.GetHashAsync>(key, mapId); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.mapId == mapId).ToListAsync(); + await redis.AddHashAsync(key, mapId, data); + return data; + } + + public async Task GetCreateMonsterInfo(string umId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.umId == umId).SingleAsync(); + return data; + } + + private async Task ClearCreateMonster(string mapId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "CreateMonsterOnMap"); + await redis.DelHashAsync(key, mapId); + } + + public async Task> GetMapMonster(string userId, string mapId, string teamId) + { + string userKey = await UserKeyTool.GetUserKey(userId); + List result = new List(); + var mapMonster = await GetMonsterDataByMap(mapId); + if (mapMonster.Count > 0) + { + int random = 0; //此处需要判断用户状态中的几率 + int onTime = TimeAssist.GetHourNum; + foreach (var item in mapMonster) + { + if (item.sTime < onTime && item.eTime > onTime) + { + if (RandomAssist.CheakRandom((int)item.chance + random)) + { + for (int i = 0; i < item.addCount; i++) + { + MapMonsterModel temp = new MapMonsterModel() + { + monterId = item.mmId, + name = item.monsterName, + type = 0, + sign = UserKeyTool.GetThickenDataByUserKey(userKey, "0", item.mmId) + }; + result.Add(temp); + } + } + } + } + } + + //此处追加个人生成怪物 + List createData = new List(); + var createMonster = await GetCreateMonsterByMapId(mapId); + if (createMonster.Count > 0) + { + long onTime = TimeExtend.GetTimeStampSeconds; + createMonster = createMonster.FindAll(it => it.endTime > onTime); + + createData.AddRange(createMonster.FindAll(it => + it.userId == userId || it.areaCode == nameof(GameEnum.AreaCode.Public))); + if (!string.IsNullOrEmpty(teamId) && teamId != "0") + { + var teamService = App.GetService(); + var teamMember = await teamService.GetTeamMember(teamId); + teamMember = teamMember.FindAll(it => it.userId != userId); + var onCreate = createMonster.FindAll(it => + teamMember.Any(team => + team.userId == it.userId && it.areaCode == nameof(GameEnum.AreaCode.Team))); + foreach (var item in onCreate) + { + if (createData.Any(it => it.umId == item.umId)) + { + continue; + } + + createData.Add(item); + } + } + } + + if (createData.Count > 0) + { + foreach (var item in createData) + { + MapMonsterModel temp = new MapMonsterModel() + { + monterId = item.umId, + name = item.monsterName, + type = 1, + sign = UserKeyTool.GetThickenDataByUserKey(userKey, "1", item.umId) + }; + result.Add(temp); + } + } + + return result; + } + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/GameDicService.cs b/Service/Application.Domain/Services/Service/Pub/GameDicService.cs new file mode 100644 index 0000000..91d74a5 --- /dev/null +++ b/Service/Application.Domain/Services/Service/Pub/GameDicService.cs @@ -0,0 +1,19 @@ +namespace Application.Domain; + +public class GameDicService(ISqlSugarClient DbClient, IRedisCache redis) : IGameDicService, ITransient +{ + public async Task GetDicInfo(string code) + { + string key = string.Format(BaseCache.BaseCacheKey, "DicData"); + if (await redis.HExistsHashAsync(key, code)) + { + return await redis.GetHashAsync(key, code); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.code == code).SingleAsync(); + await redis.AddHashAsync(key, code, data); + return data; + } + +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs b/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs index 6ee35b2..fac0959 100644 --- a/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs +++ b/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs @@ -33,6 +33,7 @@ public class GameTeamService(ISqlSugarClient DbClient, IRedisCache redis) : IGam await redis.AddHashAsync(key, userId, data); return data; } + public async Task GetTeamInfo(string teamId) { diff --git a/Service/Application.Domain/Services/Service/Pub/MessageService.cs b/Service/Application.Domain/Services/Service/Pub/MessageService.cs index 214af37..9d0a658 100644 --- a/Service/Application.Domain/Services/Service/Pub/MessageService.cs +++ b/Service/Application.Domain/Services/Service/Pub/MessageService.cs @@ -311,8 +311,9 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess return await db.Queryable().Where(it => it.state == 0 && it.token == token).AnyAsync(); } - public async Task SendEventMsg(string userId, string code, string name, string sign, string pars,string token, - List btns=null, int days = 10) + public async Task SendEventMsg(string userId, string code, string name, string sign, string pars, + string token, + List btns = null, int days = 10) { unit_user_message_event data = new unit_user_message_event(); data.eventId = StringAssist.NewGuid; @@ -331,8 +332,9 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess } else { - data.btns = btns; + data.btns = btns; } + data.addTime = DateTime.Now; data.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(days)); data.token = token; @@ -347,4 +349,54 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess } #endregion + + #region 广播消息 + + public async Task> GetBroadcastData(int area) + { + List data = new List(); + string key = string.Format(BaseCache.BaseCacheKey, "GameBroadcast"); + var result = await redis.GetHashAllAsync(key); + if (result.Count > 0) + { + data = result.Values.ToList(); + } + + long time = TimeExtend.GetTimeStampSeconds; + data = data.FindAll(it => (it.area == area || it.area == 0) && it.endTime > time); + data = data.OrderByDescending(it => it.endTime).Take(2).ToList(); + return data; + } + + public async Task SendBroadcast(string userId, string code, string msg) + { + game_broadcast add = new game_broadcast(); + add.Id = StringAssist.NewGuid; + add.userId = userId; + add.code = code; + add.msg = msg; + int area = 0; + if (add.userId == "0") + { + add.area = 0; + add.userNo = "0"; + add.nick = "海精灵"; + } + else + { + var userService = App.GetService(); + var userInfo = await userService.GetUserInfoByUserId(userId); + add.area = (int)userInfo.areaId; + add.userNo = userInfo.userNo; + add.nick = userInfo.nick; + area = add.area; + } + + add.endTime = TimeExtend.GetTimeStampSeconds + 300; + string key = string.Format(BaseCache.BaseCacheKey, "GameBroadcast"); + bool result = await redis.AddHashAsync(key, add.Id, add); + return result; + } + + #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 4ab8a72..117b9eb 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -4,7 +4,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { #region 个人属性 - public async Task GetUserAttrModel(string userId) + public async Task GetUserAttrModel(string userId, string scene = "Default") { UserAttrModel result = new UserAttrModel(); result.id = userId; @@ -24,11 +24,150 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : result.agility = (int)unitAttr.agility; result.upBlood = (int)unitAttr.upBlood; result.upMorale = (int)unitAttr.upMorale; - var bloodInfo = await GetUserBlood(userId); - result.blood = (int)bloodInfo.blood; - var moraleInfo = await GetUserMorale(userId); - result.morale = (int)moraleInfo.morale; + List ExtendAttrData = new List(); + + #region 构造基础加层体系 + + UserAttrModel temp = new UserAttrModel(); + temp.minAtk = (int)unitAttr.minAtk; + temp.maxAtk = (int)unitAttr.maxAtk; + temp.defense = (int)unitAttr.defense; + temp.agility = (int)unitAttr.agility; + temp.upBlood = (int)unitAttr.upBlood; + temp.upMorale = (int)unitAttr.upMorale; + + var equService = App.GetService(); + var equTemp = await equService.GetUserEquAttrModel(userId); + temp = GameAttrTool.GetRoleAttrTempMerge(temp, equTemp); + //套装加层 + var suitAttr = await equService.GetUserEquSuitAttrInfo(userId); + ExtendAttrData.AddRange(suitAttr); + + #endregion + + + #region 参数 + + int minAtk = 0; + int maxAtk = 0; + int Agility = 0; + int Defense = 0; + int upBlood = 0; + int upMorale = 0; + + #endregion 参数 + + #region 队伍加层 + + var teamService = App.GetService(); + var MyTeam = await teamService.GetUserTeamInfo(userId); + if (MyTeam.state == 1) + { + int teamCount = MyTeam.user.Count(it => it.isOnline == 1); + if (teamCount > 0) + { + decimal teamAdd = 0.05m * teamCount; + teamAdd = teamAdd > 0.2m ? 0.2m : teamAdd; + minAtk += Convert.ToInt32(temp.minAtk * teamAdd); + maxAtk += Convert.ToInt32(temp.maxAtk * teamAdd); + Defense += Convert.ToInt32(temp.defense * teamAdd); + result.atkTips += $"(队+{Convert.ToInt32(teamAdd * 100)}%)"; + result.defTips += $"(队+{Convert.ToInt32(teamAdd * 100)}%)"; + } + } + + #endregion + + + #region Buff加层 + + var MyState = await GetUserStateData(userId, scene); + if (MyState.Count > 0) + { + foreach (var item in MyState) + { + minAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), item.attr, + temp.minAtk)); + maxAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), item.attr, + temp.maxAtk)); + Defense += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Defense.ToString(), + item.attr, temp.defense)); + Agility += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Agility.ToString(), + item.attr, temp.agility)); + upBlood += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Blood.ToString(), item.attr, + temp.upBlood)); + upMorale += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Morale.ToString(), + item.attr, temp.upMorale)); + } + } + + #endregion + + #region 加层处理 + + var otTemp = GameAttrTool.GetRoleAttrTemp(temp, ExtendAttrData); + result = GameAttrTool.GetRoleAttrTempMerge(result, otTemp); //加层其他 + result = GameAttrTool.GetRoleAttrTempMerge(result, temp); //加层其他 + + result.minAtk += minAtk; + result.maxAtk += maxAtk; + result.defense += Defense; + result.agility += Agility; + result.upBlood += upBlood; + result.upMorale += upMorale; + + #endregion + + #region 数据效验 + + var userBlood = await GetUserBlood(userId); + result.blood = (int)userBlood.blood; + + //士气 + var userMorale = await GetUserMorale(userId); + result.morale = (int)userMorale.morale; + + //负面状态处理 + var loadState = await GetUserLoadState(userId); + result = await GameAttrTool.CheckRoleLoadBuff(result, loadState); + result = await ReviseUserRoleAttr(result); + return result; + + #endregion + + + return result; + } + + private async Task ReviseUserRoleAttr(UserAttrModel result) + { + //处理上限数据 + if (result.blood > result.upBlood) + { + result.blood = result.upBlood; + await UpdateUserBlood(result.id, 2, result.blood, true); + } + + if (result.morale > result.upMorale) + { + result.morale = result.upMorale; + await UpdateUserMorale(result.id, 2, Convert.ToInt32(result.morale)); + } + + if (result.NoHarm > 0.8M) //免伤上限 + { + result.NoHarm = 0.8M; + } + + if (result.Atk_Next > 0.3M) //连击上限 + { + result.Atk_Next = 0.3M; + } + + //评分 + decimal _score = result.maxAtk + result.defense + result.agility + result.upBlood / 3.00M + result.upMorale; + result.score = Math.Round(_score, 2); return result; } @@ -103,6 +242,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : else if (op == 1) { data.blood += count; + var myAttr = await GetUserAttrModel(userId); + if (myAttr != null) + { + data.blood = data.blood > myAttr.upBlood ? myAttr.upBlood : data.blood; + } } } @@ -200,9 +344,6 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : if (result && IsUpUserAttr) { - //增加负重 - var wightService = App.GetService(); - await wightService.UpdateUserMaxWeight(userId, 1, GameConfig.UpLevAddWeight, 1, 0, "升级增加负重"); await ClearUserAttrCache(userId); } @@ -234,6 +375,8 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : if (op == 1) { data.morale += count; + var myAttr = await GetUserAttrModel(userId); + data.morale = data.morale > myAttr.upMorale ? myAttr.upMorale : data.morale; } else if (op == 2) { @@ -260,10 +403,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", userId); return await redis.ExistsAsync(key); } + public async Task LockRecoverMorale(string userId) { string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", userId); - await redis.SetAsync(key, DateTime.Now,TimeAssist.GetDateTimeYMD(1)); + await redis.SetAsync(key, DateTime.Now, TimeAssist.GetDateTimeYMD(1)); } #endregion 士气 @@ -295,6 +439,13 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : public async Task UpdateUserVigour(string userId, int op, long count, string UpTime = "") { + if (op == 1) + { + var userVigour = await GetUserVigourInfo(userId); + long endVigour = (long)userVigour.upVitality - (long)userVigour.vitality; + count = endVigour > count ? count : endVigour; + } + bool result = false; try { @@ -337,7 +488,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : #endregion 活力 - #region 在线时间 + #region 在线时间 public async Task UpdateOnLineTime(string userId, string code, int time) { @@ -350,6 +501,314 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } + #endregion + + #region 药品栏 + + public async Task GetUserDrug(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserTool", "DrugColumn"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync(key, userId); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); + if (data == null) + { + data = new unit_user_drug(); + data.userId = userId; + data.drug = new List(); + await db.Insertable(data).ExecuteCommandAsync(); + } + + await redis.AddHashAsync(key, userId, data); + return data; + } + + public async Task UpdateUserDrug(unit_user_drug data) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Updateable(data).ExecuteCommandAsync() > 0; + if (result) + { + await ClearUserDrug(data.userId); + } + + return result; + } + + private async Task ClearUserDrug(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserTool", "DrugColumn"); + await redis.DelHashAsync(key, userId); + } + + #endregion + + #region BUFF状态 + + private async Task> GetUserStateData(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "State"); + var data = await redis.GetHashAsync>(key, userId); + if (data == null) + { + long endTime = TimeExtend.GetTimeStampSeconds; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.userId == userId && it.endTime > endTime) + .ToListAsync(); + await redis.AddHashAsync(key, userId, data); + } + + return data; + } + + public async Task> GetUserStateData(string userId, string scene = "Default") + { + var data = await GetUserStateData(userId); + if (scene == "ALL") + { + return data; + } + + data = data.FindAll(it => it.scene == "Default" || it.scene == scene); + return data; + } + + public async Task AddUserState(string userId, string groupId, string name, string scene, string tips, + List attr, int time, int count = 1) + { + bool result = false; + long onTime = TimeExtend.GetTimeStampSeconds; + string usId = $"{userId}_{groupId}"; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var usData = await db.Queryable().Where(it => it.usId == usId).SingleAsync(); + if (usData == null) + { + usData = new unit_user_state(); + usData.usId = usId; + usData.userId = userId; + usData.goodsId = groupId; + usData.name = name; + usData.scene = scene; + usData.tips = tips; + usData.attr = attr; + usData.addTime = onTime; + usData.endTime = onTime + (time * 60 * count); + result = await db.Insertable(usData).ExecuteCommandAsync() > 0; + } + else + { + if (usData.endTime > onTime) + { + usData.endTime = usData.endTime + (time * 60 * count); + } + else + { + usData.addTime = onTime; + usData.endTime = onTime + (time * 60 * count); + } + + result = await db.Updateable(usData).ExecuteCommandAsync() > 0; + } + + if (result) + { + await ClearUserState(userId); + } + + return result; + } + + private async Task ClearUserState(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "State"); + await redis.DelHashAsync(key, userId); + } + + #endregion + + #region 游戏资源储备 + + private async Task> GetUserStock(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Stock"); + var data = await redis.GetHashAsync>(key, userId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.userId == userId).ToListAsync(); + await redis.AddHashAsync(key, userId, data); + } + + return data; + } + + public async Task> GetUserStock(string userId, string code = "Default") + { + var data = await GetUserStock(userId); + if (code != "Default") + { + data = data.FindAll(it => it.code == code); + } + + long endTime = TimeExtend.GetTimeStampSeconds; + data = data.FindAll(it => + ((it.type == "Number" && it.sign > 0) || it.type != "Number") && it.endTime > endTime); + return data; + } + + public async Task AddUserStock(string userId, string goodsId, string name, string type, string code, + long sign, + string par = "", + int minute = 0) + { + if (minute == 0) + { + minute = 525600; + } + + bool result = false; + string usId = $"{userId}_{goodsId}"; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var usInfo = await db.Queryable().Where(it => it.usId == usId).SingleAsync(); + if (usInfo == null) + { + long endTime = TimeExtend.GetTimeStampSeconds + minute * 60; + unit_user_stock stock = new unit_user_stock() + { + usId = usId, + userId = userId, + goodsId = goodsId, + name = name, + type = type, + code = code, + sign = sign, + par = par, + endTime = endTime + }; + result = await db.Insertable(stock).ExecuteCommandAsync() > 0; + } + else + { + if (usInfo.type == nameof(GameEnum.GameStockType.Number)) + { + usInfo.sign += sign; + usInfo.endTime = TimeExtend.GetTimeStampSeconds + minute * 60; + } + else if (usInfo.type == nameof(GameEnum.GameStockType.Time)) + { + long onTime = TimeExtend.GetTimeStampSeconds; + if (usInfo.endTime > onTime) + { + usInfo.endTime = usInfo.endTime + (minute * 60); + } + else + { + usInfo.endTime = TimeExtend.GetTimeStampSeconds + (minute * 60); + } + } + + result = await db.Updateable(usInfo).ExecuteCommandAsync() > 0; + } + + if (result) + { + await ClearUserStockCache(userId); + } + + return result; + } + + private async Task ClearUserStockCache(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Stock"); + await redis.DelHashAsync(key, userId); + } + + public async Task UpdateUserStock(unit_user_stock data) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var result = await db.Updateable(data).ExecuteCommandAsync() > 0; + if (result) + { + await ClearUserAttrCache(data.userId); + } + + return result; + } + + #endregion + + #region 负面状态 + + public async Task> GetUserLoadState(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync>(key, userId); + } + + return new List(); + } + + public async Task AddUserLoadState(string userId, string name, string code) + { + bool result = false; + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + var data = await GetUserLoadState(userId); + var onData = data.Find(it => it.code == code); + if (onData == null) + { + unit_user_load load = new unit_user_load() + { + id = $"{userId}_{code}", + userId = userId, + name = name, + code = code, + count = 1 + }; + data.Add(load); + result = await redis.AddHashAsync(key, userId, data); + } + else + { + data.Remove(onData); + onData.count += 1; + result = await redis.AddHashAsync(key, userId, data); + } + + return result; + } + + public async Task RandomRemoveUserLoadState(string userId, int count) + { + var data = await GetUserLoadState(userId); + int opCount = data.Count - count; + opCount = opCount < 0 ? 0 : opCount; + if (opCount > 0) + { + RandomAssist random = new RandomAssist(opCount); + var result = random.RandomExtract(data); + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + await redis.AddHashAsync(key, userId, result); + } + else + { + await RemoveUserLoadState(userId); + } + + return true; + } + + public async Task RemoveUserLoadState(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + await redis.DelHashAsync(key, userId); + } #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserService.cs b/Service/Application.Domain/Services/Service/User/UnitUserService.cs index af10ad3..82203d4 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserService.cs @@ -268,9 +268,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni if (result)//注册各项后处理 { - //赠送初始负重 - var weightService = App.GetService(); - await weightService.UpdateUserMaxWeight(userId, 1, 100, 1, 0, "初始负重"); + } return result; diff --git a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs index cf771a9..278a23b 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs @@ -19,8 +19,12 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit private async Task GetUserMaxWeight(unit_user_weight data) { - int result = (int)data.maxWeight; + int result = 100 + (int)data.maxWeight; + var attrService = App.GetService(); + int myLev = await attrService.GetUserLev(data.userId); + result += myLev * GameConfig.UpLevAddWeight; //其他属性加层 + return result; } @@ -41,7 +45,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return result; } - + public async Task UpdateUserWeight(string userId, int op, int weight) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -119,6 +123,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit } #region 船只相关 + public async Task GetUserShipInfo(string usId) { string key = string.Format(UserCache.BaseCacheKeys, "UserShip", "Info"); @@ -132,6 +137,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return data; } + public async Task> GetUserShip(string userId) { string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Ship"); @@ -198,7 +204,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return result; } - public async Task AddUserShip(string userId, string name, int goodsId, int speed, int weight) + public async Task AddUserShip(string userId, string name, int goodsId, int speed, int weight,int copper,long sale,string remark) { unit_user_ship ship = new unit_user_ship(); ship.usId = StringAssist.NewGuid; @@ -207,6 +213,9 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit ship.name = name; ship.speed = speed; ship.weight = weight; + ship.copper = copper; + ship.sale = sale; + ship.remark = remark; var db = DbClient.AsTenant().GetConnectionWithAttr(); bool result = await db.Insertable(ship).ExecuteCommandAsync() > 0; if (result) diff --git a/Service/Application.Domain/Tool/Base/EquTool.cs b/Service/Application.Domain/Tool/Base/EquTool.cs new file mode 100644 index 0000000..e9be574 --- /dev/null +++ b/Service/Application.Domain/Tool/Base/EquTool.cs @@ -0,0 +1,166 @@ +namespace Application.Domain; + +public class EquTool +{ + public static unit_user_equ GetUserEquByIntensify(unit_user_equ equ) + { + //强化 + equ = GetIntensifyAttr(equ); + List AttrData = GetUserEquAttrData(equ); + equ.minAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.minAtk)); + equ.minAtk += + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MinAtk), AttrData, (decimal)equ.minAtk)); + equ.maxAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.maxAtk)); + equ.maxAtk += + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MaxAtk), AttrData, (decimal)equ.minAtk)); + equ.Blood += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Blood), AttrData, (decimal)equ.Blood)); + equ.Defense += + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Defense), AttrData, (decimal)equ.Defense)); + equ.Agility += + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Agility), AttrData, (decimal)equ.Agility)); + equ.Morale += + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Morale), AttrData, (decimal)equ.Morale)); + return equ; + } + + private static unit_user_equ GetIntensifyAttr(unit_user_equ equ) + { + equ.minAtk = GetIntensifyAttrBase(equ.minAtk, equ.intensifyLev); + equ.maxAtk = GetIntensifyAttrBase(equ.maxAtk, equ.intensifyLev); + equ.Blood = GetIntensifyAttrBase(equ.Blood, equ.intensifyLev); + equ.Defense = GetIntensifyAttrBase(equ.Defense, equ.intensifyLev); + equ.Agility = GetIntensifyAttrBase(equ.Agility, equ.intensifyLev); + + return equ; + } + + private static int GetIntensifyAttrBase(int? onV, int? lev) + { + if (onV < 1) + { + return 0; + } + + int onAttr = Convert.ToInt32(onV); + int onLev = Convert.ToInt32(lev); //当前强化等级 + if (onLev < 1) + { + return onAttr; + } + + int result = onLev * 3; + result = result > 57 ? 57 : result; + + if (onLev > 19) + { + int addLev = onLev - 19; + addLev = addLev > 10 ? 10 : addLev; + result += addLev * 5; + } + + if (onLev > 29) + { + int addLev = onLev - 29; + addLev = addLev > 10 ? 10 : addLev; + result += addLev * 10; + } + + if (onLev > 39) + { + int addLev = onLev - 39; + addLev = addLev > 10 ? 10 : addLev; + result += addLev * 15; + } + + if (onLev > 49) + { + int addLev = onLev - 49; + addLev = addLev > 10 ? 10 : addLev; + result += addLev * 20; + } + + if (onLev > 59) + { + int addLev = onLev - 59; + addLev = addLev > 10 ? 10 : addLev; + result += addLev * 25; + } + + if (onLev > 69) + { + int addLev = onLev - 69; + addLev = addLev > 10 ? 10 : addLev; + int unitAdd = Convert.ToInt32(onAttr * 0.05); + unitAdd = unitAdd < 30 ? 30 : unitAdd; + result += addLev * unitAdd; + } + + if (onLev > 79) + { + int addLev = onLev - 79; + addLev = addLev > 10 ? 10 : addLev; + int unitAdd = Convert.ToInt32(onAttr * 0.1); + unitAdd = unitAdd < 35 ? 35 : unitAdd; + result += addLev * unitAdd; + } + + if (onLev > 89) + { + int addLev = onLev - 89; + addLev = addLev > 10 ? 10 : addLev; + int unitAdd = Convert.ToInt32(onAttr * 0.15); + unitAdd = unitAdd < 40 ? 40 : unitAdd; + result += addLev * unitAdd; + } + + if (onLev > 99) + { + int unitAdd = Convert.ToInt32(onAttr * 0.35); + unitAdd = unitAdd < 100 ? 100 : unitAdd; + result += unitAdd; + } + + return Convert.ToInt32(result + onAttr); + } + + public static List GetUserEquAttrData(unit_user_equ equ) + { + List AttrData = new List(); + //装备本身特性 + AttrData.AddRange(equ.EquAttr); + + //宝石 + if (equ.GemMent.Count > 0) + { + foreach (var item in equ.GemMent) + { + AttrData.AddRange(item.gemItem.GemAttr); + } + } + + //附魔 + if (equ.EquMent != null) + { + if (equ.EquMent.EquAttr != null) + { + AttrData.AddRange(equ.EquMent.EquAttr); + } + } + + //觉醒 + if (equ.EquAwaken != null) + { + foreach (var item in equ.EquAwaken) + { + if (item.awaken != null) + { + AttrData.AddRange(item.awaken); + } + } + } + + return AttrData; + } + + +} \ No newline at end of file diff --git a/Service/Application.Domain/Tool/Base/GameAttrTool.cs b/Service/Application.Domain/Tool/Base/GameAttrTool.cs new file mode 100644 index 0000000..69f1a10 --- /dev/null +++ b/Service/Application.Domain/Tool/Base/GameAttrTool.cs @@ -0,0 +1,239 @@ + +namespace Application.Domain; + +public class GameAttrTool +{ + public static UserAttrModel GetRoleAttrTemp(UserAttrModel temp, List attrData) + { + UserAttrModel result = new UserAttrModel(); + result.minAtk = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, temp.minAtk)); + result.maxAtk = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, temp.maxAtk)); + result.defense = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Defense.ToString(), attrData, temp.defense)); + result.agility = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Agility.ToString(), attrData, temp.agility)); + result.upBlood = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Blood.ToString(), attrData, temp.upBlood)); + result.upMorale = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Morale.ToString(), attrData, temp.upMorale)); + result.InBlood = GetAttrItemValue(GameEnum.AttrCode.InBlood.ToString(), attrData, temp.InBlood); + result.Crit = GetAttrItemValue(GameEnum.AttrCode.Crit.ToString(), attrData, temp.Crit); + result.NoHarm = GetAttrItemValue(GameEnum.AttrCode.NoHarm.ToString(), attrData, temp.NoHarm); + result.Dodge = GetAttrItemValue(GameEnum.AttrCode.Dodge.ToString(), attrData, temp.Dodge); + result.Rebound = GetAttrItemValue(GameEnum.AttrCode.Rebound.ToString(), attrData, temp.Rebound); + result.ReboundLess = + GetAttrItemValue(GameEnum.AttrCode.ReboundLess.ToString(), attrData, temp.ReboundLess); + result.Punish = GetAttrItemValue(GameEnum.AttrCode.Punish.ToString(), attrData, temp.Punish); + result.Slow = GetAttrItemValue(GameEnum.AttrCode.Slow.ToString(), attrData, temp.Slow); + result.SlowLess = GetAttrItemValue(GameEnum.AttrCode.SlowLess.ToString(), attrData, temp.SlowLess); + result.Poison = GetAttrItemValue(GameEnum.AttrCode.Poison.ToString(), attrData, temp.Poison); + result.PoisonLess = + GetAttrItemValue(GameEnum.AttrCode.PoisonLess.ToString(), attrData, temp.PoisonLess); + result.Curse = GetAttrItemValue(GameEnum.AttrCode.Curse.ToString(), attrData, temp.Curse); + result.CurseLess = GetAttrItemValue(GameEnum.AttrCode.CurseLess.ToString(), attrData, temp.CurseLess); + result.Weaken = GetAttrItemValue(GameEnum.AttrCode.Weaken.ToString(), attrData, temp.Weaken); + result.WeakenLess = + GetAttrItemValue(GameEnum.AttrCode.WeakenLess.ToString(), attrData, temp.WeakenLess); + result.Deadly = GetAttrItemValue(GameEnum.AttrCode.Deadly.ToString(), attrData, temp.Deadly); + result.DeadlyLess = + GetAttrItemValue(GameEnum.AttrCode.DeadlyLess.ToString(), attrData, temp.DeadlyLess); + result.Depressed = GetAttrItemValue(GameEnum.AttrCode.Depressed.ToString(), attrData, temp.Depressed); + result.DepressedLess = + GetAttrItemValue(GameEnum.AttrCode.DepressedLess.ToString(), attrData, temp.DepressedLess); + result.Breach = GetAttrItemValue(GameEnum.AttrCode.Breach.ToString(), attrData, temp.Breach); + result.BreachLess = + GetAttrItemValue(GameEnum.AttrCode.BreachLess.ToString(), attrData, temp.BreachLess); + result.Del_Fashion = + GetAttrItemValue(GameEnum.AttrCode.Del_Fashion.ToString(), attrData, temp.Del_Fashion); + result.Atk_Next = GetAttrItemValue(GameEnum.AttrCode.Atk_Next.ToString(), attrData, temp.Atk_Next); + result.Harm_Add = GetAttrItemValue(GameEnum.AttrCode.Harm_Add.ToString(), attrData, temp.Harm_Add); + result.PalsyAtk = GetAttrItemValue(GameEnum.AttrCode.PalsyAtk.ToString(), attrData, temp.PalsyAtk); + result.PalsyAtkLess = + GetAttrItemValue(GameEnum.AttrCode.PalsyAtkLess.ToString(), attrData, temp.PalsyAtk); + + result.addExp = + GetAttrItemValue(nameof(GameEnum.AttrCode.AddExp), attrData, temp.addExp); + result.addGold = + GetAttrItemValue(nameof(GameEnum.AttrCode.AddGold), attrData, temp.addGold); + result.burst = + GetAttrItemValue(nameof(GameEnum.AttrCode.Burst), attrData, temp.burst); + result.luck = + GetAttrItemValue(nameof(GameEnum.AttrCode.Luck), attrData, temp.luck); + result.weight = Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Weight), attrData, temp.weight)); + + return result; + } + + public static UserAttrModel GetRoleAttrTempMerge(UserAttrModel result, List attrData) + { + result.minAtk += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, result.minAtk)); + result.maxAtk += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, result.maxAtk)); + result.defense += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Defense.ToString(), attrData, result.defense)); + result.agility += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Agility.ToString(), attrData, result.agility)); + result.upBlood += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Blood.ToString(), attrData, result.upBlood)); + result.upMorale += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Morale.ToString(), attrData, result.upMorale)); + result.InBlood += GetAttrItemValue(GameEnum.AttrCode.InBlood.ToString(), attrData, 0); + result.Crit += GetAttrItemValue(GameEnum.AttrCode.Crit.ToString(), attrData, 0); + result.NoHarm += GetAttrItemValue(GameEnum.AttrCode.NoHarm.ToString(), attrData, 0); + result.Dodge += GetAttrItemValue(GameEnum.AttrCode.Dodge.ToString(), attrData, 0); + result.Rebound += GetAttrItemValue(GameEnum.AttrCode.Rebound.ToString(), attrData, 0); + result.ReboundLess += GetAttrItemValue(GameEnum.AttrCode.ReboundLess.ToString(), attrData, 0); + result.Punish += GetAttrItemValue(GameEnum.AttrCode.Punish.ToString(), attrData, 0); + result.Slow += GetAttrItemValue(GameEnum.AttrCode.Slow.ToString(), attrData, 0); + result.SlowLess += GetAttrItemValue(GameEnum.AttrCode.SlowLess.ToString(), attrData, 0); + result.Poison += GetAttrItemValue(GameEnum.AttrCode.Poison.ToString(), attrData, 0); + result.PoisonLess += GetAttrItemValue(GameEnum.AttrCode.PoisonLess.ToString(), attrData, 0); + result.Curse += GetAttrItemValue(GameEnum.AttrCode.Curse.ToString(), attrData, 0); + result.CurseLess += GetAttrItemValue(GameEnum.AttrCode.CurseLess.ToString(), attrData, 0); + result.Weaken += GetAttrItemValue(GameEnum.AttrCode.Weaken.ToString(), attrData, 0); + result.WeakenLess += GetAttrItemValue(GameEnum.AttrCode.WeakenLess.ToString(), attrData, 0); + result.Deadly += GetAttrItemValue(GameEnum.AttrCode.Deadly.ToString(), attrData, 0); + result.DeadlyLess += GetAttrItemValue(GameEnum.AttrCode.DeadlyLess.ToString(), attrData, 0); + result.Depressed += GetAttrItemValue(GameEnum.AttrCode.Depressed.ToString(), attrData, 0); + result.DepressedLess += GetAttrItemValue(GameEnum.AttrCode.DepressedLess.ToString(), attrData, 0); + result.Breach += GetAttrItemValue(GameEnum.AttrCode.Breach.ToString(), attrData, 0); + result.BreachLess += GetAttrItemValue(GameEnum.AttrCode.BreachLess.ToString(), attrData, 0); + result.Del_Fashion += GetAttrItemValue(GameEnum.AttrCode.Del_Fashion.ToString(), attrData, 0); + result.Atk_Next += GetAttrItemValue(GameEnum.AttrCode.Atk_Next.ToString(), attrData, 0); + result.Harm_Add += GetAttrItemValue(GameEnum.AttrCode.Harm_Add.ToString(), attrData, 0); + result.PalsyAtk += GetAttrItemValue(GameEnum.AttrCode.PalsyAtk.ToString(), attrData, 0); + result.PalsyAtkLess += GetAttrItemValue(GameEnum.AttrCode.PalsyAtkLess.ToString(), attrData, 0); + + result.addExp += GetAttrItemValue(GameEnum.AttrCode.AddExp.ToString(), attrData, 0); + result.addGold += GetAttrItemValue(GameEnum.AttrCode.AddGold.ToString(), attrData, 0); + result.burst += GetAttrItemValue(GameEnum.AttrCode.Burst.ToString(), attrData, 0); + result.luck += GetAttrItemValue(GameEnum.AttrCode.Luck.ToString(), attrData, 0); + result.weight += Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Weight.ToString(), attrData, 0)) ; + + return result; + } + + public static UserAttrModel GetRoleAttrTempMerge(UserAttrModel main, UserAttrModel vice) + { + main.minAtk += vice.minAtk; + main.maxAtk += vice.maxAtk; + main.defense += vice.defense; + main.agility += vice.agility; + main.upBlood += vice.upBlood; + main.upMorale += vice.upMorale; + main.InBlood += vice.InBlood; + main.Crit += vice.Crit; + main.NoHarm += vice.NoHarm; + main.Dodge += vice.Dodge; + main.Rebound += vice.Rebound; + main.ReboundLess += vice.ReboundLess; + main.Punish += vice.Punish; + main.Slow += vice.Slow; + main.Poison += vice.Poison; + main.PoisonLess += vice.PoisonLess; + main.Curse += vice.Curse; + main.CurseLess += vice.CurseLess; + main.Weaken += vice.Weaken; + main.WeakenLess += vice.WeakenLess; + main.Deadly += vice.Deadly; + main.DeadlyLess += vice.DeadlyLess; + main.Depressed += vice.Depressed; + main.DepressedLess += vice.DepressedLess; + main.Breach += vice.Breach; + main.BreachLess += vice.BreachLess; + main.Del_Fashion += vice.Del_Fashion; + main.Atk_Next += vice.Atk_Next; + main.Harm_Add += vice.Harm_Add; + main.PalsyAtk += vice.PalsyAtk; + main.PalsyAtkLess += vice.PalsyAtkLess; + + main.addExp += vice.addExp; + main.addGold += vice.addGold; + main.burst += vice.burst; + main.luck += vice.luck; + main.weight += vice.weight; + return main; + } + + public static decimal GetAttrItemValue(string attrCode, List AttrData, decimal unit) + { + decimal result = 0.00M; + foreach (var item in AttrData) + { + if (attrCode == item.code) + { + if (string.IsNullOrEmpty(item.compute)) + { + continue; + } + + if (item.compute == nameof(GameEnum.ComputeType.Ride)) + { + result += unit * Convert.ToDecimal(item.parameter); + } + else if (item.compute == nameof(GameEnum.ComputeType.Plus)) + { + result += Convert.ToDecimal(item.parameter); + } + else if (item.compute == nameof(GameEnum.ComputeType.Reduce)) + { + result = unit - Convert.ToDecimal(item.parameter); + } + else if (item.compute == nameof(GameEnum.ComputeType.Except)) + { + result = unit / Convert.ToDecimal(item.parameter); + } + } + } + + return result; + } + + public static async Task CheckRoleLoadBuff(UserAttrModel temp, List loadBuff) + { + foreach (var item in loadBuff) + { + if (item.code == nameof(GameEnum.AttrCode.Slow)) + { + decimal radio = item.count * 0.05M; + temp.agility = Convert.ToInt32(temp.agility * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Poison)) + { + decimal radio = item.count * 0.08M; + temp.upBlood = Convert.ToInt32(temp.upBlood * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Curse)) + { + decimal radio = item.count * 0.08M; + temp.minAtk = Convert.ToInt32(temp.minAtk * (1.0M - radio)); + temp.maxAtk = Convert.ToInt32(temp.maxAtk * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Weaken)) + { + decimal radio = item.count * 0.02M; + temp.Crit = temp.Crit - radio; + } + else if (item.code == nameof(GameEnum.AttrCode.Depressed)) + { + decimal radio = item.count * 0.07M; + temp.upMorale = Convert.ToInt32(temp.upMorale * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Breach)) + { + 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; + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Tool/Base/GameBus.cs b/Service/Application.Domain/Tool/Base/GameBus.cs index c1e295a..eff9b30 100644 --- a/Service/Application.Domain/Tool/Base/GameBus.cs +++ b/Service/Application.Domain/Tool/Base/GameBus.cs @@ -1,6 +1,6 @@ namespace Application.Domain; -public class GameBus +public static class GameBus { #region 物品资源操作 @@ -64,6 +64,11 @@ public class GameBus isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.teach), count, nameof(AccEnum.Name.其他), remark); } + else if (goodsType.Equals(nameof(GameEnum.PropCode.map))) + { + var mapService = App.GetService(); + isok = await mapService.AddUserCityMap(userId, Convert.ToInt32(parameter)); + } return isok; } @@ -96,20 +101,24 @@ public class GameBus #region 验证 - public static async Task CheakNeed(string userId, TowerNeed item, string sid, int count = 1) + public static async Task CheckNeed(string userId, TowerNeed item, int count = 1) { CheckTowerNeed result = new CheckTowerNeed(); + result.Needs = new List(); bool isok = true; int isDeal = 1; int isGive = 1; - + item.isAsk = 1; if (item.code == nameof(GameEnum.PropCode.Equ)) { var equService = App.GetService(); int MyCount = await equService.GetUserEquByEquIdCount(userId, Convert.ToInt32(item.parameter)); - int neecCount = item.count * count; - if (MyCount < neecCount) + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; + if (MyCount < needCount) { + item.isAsk = 0; isok = false; } } @@ -132,29 +141,38 @@ public class GameBus } } - int needCount = item.count * count; + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; if (MyCount < needCount) { isok = false; + item.isAsk = 0; } } else if (item.code == nameof(GameEnum.PropCode.copper)) { var accService = App.GetService(); var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); - decimal needAcc = item.count * count; + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; if (MyAcc < needAcc) { isok = false; + item.isAsk = 0; } } else if (item.code == nameof(GameEnum.PropCode.gold)) { var accService = App.GetService(); var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold)); - decimal needAcc = item.count * count; + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; if (MyAcc < needAcc) { + item.isAsk = 0; isok = false; } } @@ -162,9 +180,12 @@ public class GameBus { var attrService = App.GetService(); var MyAcc = await attrService.GetUserVigourInfo(userId); - decimal neecAcc = item.count * count; - if (MyAcc.vitality < neecAcc) + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = (long)MyAcc.vitality; + if (MyAcc.vitality < needAcc) { + item.isAsk = 0; isok = false; } } @@ -172,6 +193,8 @@ public class GameBus { var attrService = App.GetService(); var MyLev = await attrService.GetUserLev(userId); + item.count = item.count; + item.onCount = MyLev; if (MyLev < item.count) { isok = false; @@ -181,18 +204,20 @@ public class GameBus result.result = isok; result.isDeal = isDeal; result.isGive = isGive; + result.Needs.Add(item); return result; } - public static async Task CheakNeed(string userId, List needs, string sid, int count = 1) + public static async Task CheckNeed(string userId, List needs, int count = 1) { CheckTowerNeed result = new CheckTowerNeed(); + result.Needs = new List(); bool isok = true; int isDeal = 1; int isGive = 1; foreach (var item in needs) { - var cheakResult = await CheakNeed(userId, item, sid, count); + var cheakResult = await CheckNeed(userId, item, count); if (isok) { isok = cheakResult.result; @@ -208,7 +233,117 @@ public class GameBus isGive = 0; } - item.isAsk = cheakResult.result ? 1 : 0; + result.Needs.AddRange(cheakResult.Needs); + } + + result.result = isok; + result.isDeal = isDeal; + result.isGive = isGive; + return result; + } + + public static async Task CheckNeeds(string userId, List needs, int count = 1) + { + CheckTowerNeeds result = new CheckTowerNeeds(); + bool isok = true; + int isDeal = 1; + int isGive = 1; + result.Needs = new List(); + foreach (var item in needs) + { + item.isAsk = 1; + if (item.code == nameof(GameEnum.PropCode.Equ)) + { + var equService = App.GetService(); + int MyCount = await equService.GetUserEquByEquIdCount(userId, Convert.ToInt32(item.parameter)); + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; + if (MyCount < needCount) + { + item.isAsk = 0; + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.Goods)) + { + int MyCount = 0; + var goodsService = App.GetService(); + var goodsInfo = await goodsService.GetUserGoodsInfo(userId, Convert.ToInt32(item.parameter)); + if (goodsInfo != null) + { + MyCount = (int)goodsInfo.count; + if (goodsInfo.isDeal == 0) + { + isDeal = 0; + } + + if (goodsInfo.isGive == 0) + { + isGive = 0; + } + } + + long needCount = item.count * count; + item.count = needCount; + item.onCount = MyCount; + if (MyCount < needCount) + { + isok = false; + item.isAsk = 0; + } + } + else if (item.code == nameof(GameEnum.PropCode.copper)) + { + var accService = App.GetService(); + var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; + if (MyAcc < needAcc) + { + isok = false; + item.isAsk = 0; + } + } + else if (item.code == nameof(GameEnum.PropCode.gold)) + { + var accService = App.GetService(); + var MyAcc = await accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold)); + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = MyAcc; + if (MyAcc < needAcc) + { + item.isAsk = 0; + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.vigour)) //活力 + { + var attrService = App.GetService(); + var MyAcc = await attrService.GetUserVigourInfo(userId); + long needAcc = item.count * count; + item.count = needAcc; + item.onCount = (long)MyAcc.vitality; + if (MyAcc.vitality < needAcc) + { + item.isAsk = 0; + isok = false; + } + } + else if (item.code == nameof(GameEnum.PropCode.lev)) + { + var attrService = App.GetService(); + var MyLev = await attrService.GetUserLev(userId); + item.count = item.count; + item.onCount = MyLev; + if (MyLev < item.count) + { + isok = false; + } + } + result.Needs.Add(item); } @@ -222,7 +357,30 @@ public class GameBus #region 概率 - public static List GetRandomGoods(RandomModel random, int count = 1, int luck = 0) + public static RandomDataBase GetRandomByWeight(List data) + { + var _randomInstance = new Random(); + if (data.Count == 0) + { + return null; + } + + double totalWeight = data.Sum(it => it.random); + int rnd = _randomInstance.Next(Convert.ToInt32(totalWeight) + 1); + double current = 0; + foreach (var item in data) + { + current += item.random; + if (rnd < current) + { + return item; + } + } + + return null; + } + + public static List GetRandomGoods(RandomModel random, int count = 1, decimal luck = 0) { List result = new List(); for (int i = 0; i < count; i++) @@ -240,9 +398,9 @@ public class GameBus foreach (var item in timeAward) { var onAward = result.FindIndex(it => it.code == item.code && it.parameter == item.par); - if(onAward>-1) + if (onAward > -1) { - result[onAward].count += item.count; + result[onAward].count += RandomAssist.GetFormatedNumeric(item.minCount, item.maxCount); } else { @@ -251,30 +409,31 @@ public class GameBus code = item.code, name = item.name, parameter = item.par, - count = item.count + count = RandomAssist.GetFormatedNumeric(item.minCount, item.maxCount) }; result.Add(add); } } - } return result; } - private static List RandomHandleByWeight(RandomModel random, int luck = 0) + private static List RandomHandleByWeight(RandomModel random, decimal luck = 0) { var _randomInstance = new Random(); List result = new List(); - int empty = random.empty - luck; + int empty = random.empty - Convert.ToInt32(luck * 100); if (_randomInstance.Next(0, 100) < empty) { return result; } + if (random.data.Count == 0) { return result; } + double totalWeight = random.data.Sum(it => it.chance); int rnd = _randomInstance.Next(Convert.ToInt32(totalWeight) + 1); double current = 0; @@ -290,29 +449,32 @@ public class GameBus return result; } - private static List RandomHandleByChance(RandomModel random, int luck = 0) + + private static List RandomHandleByChance(RandomModel random, decimal luck = 0) { var _randomInstance = new Random(); List result = new List(); - int empty = random.empty - luck; + int empty = random.empty; if (_randomInstance.Next(0, 100) < empty) { return result; } + if (random.data.Count == 0) { return result; } - + foreach (var item in random.data) { double rnd = _randomInstance.NextDouble(); - double okChance = item.chance / 100; + double okChance = (item.chance / 100) * (1.0 + Convert.ToDouble(luck)); if (rnd < okChance) { result.Add(item); } } + return result; } diff --git a/Service/Application.Domain/Tool/Base/GameTool.cs b/Service/Application.Domain/Tool/Base/GameTool.cs index 3def85b..f9c2bb5 100644 --- a/Service/Application.Domain/Tool/Base/GameTool.cs +++ b/Service/Application.Domain/Tool/Base/GameTool.cs @@ -138,7 +138,41 @@ public class GameTool return result; } - + + public static string GetEquQualityName(int count) + { + string result = "白"; + switch (count) + { + case 1: + result = "红"; + break; + case 2: + result = "橙"; + break; + case 3: + result = "黄"; + break; + case 4: + result = "绿"; + break; + case 5: + result = "青"; + break; + case 6: + result = "粉"; + break; + case 7: + result = "紫"; + break; + case 8: + result = "金"; + break; + + } + return result; + } + #region 距离计算 /// diff --git a/Service/Application.Domain/Tool/Base/UserKeyTool.cs b/Service/Application.Domain/Tool/Base/UserKeyTool.cs new file mode 100644 index 0000000..341defb --- /dev/null +++ b/Service/Application.Domain/Tool/Base/UserKeyTool.cs @@ -0,0 +1,47 @@ +namespace Application.Domain; + +public static class UserKeyTool +{ + public static async Task GetThickenData(string userId, params string[] data) + { + string key = await GetUserKey(userId); + return GetThickenDataByUserKey(key, data); + } + + public static string GetThickenDataByUserKey(string key, params string[] data) + { + string _data = string.Join("", data); + return EncryptAssist.Md5Encryption($"{key}_{_data}").ToLower(); + } + + + public static async Task CheckUserThickenData(string userId, string sign, params string[] data) + { + string key = await GetUserKey(userId); + string _sign = GetThickenDataByUserKey(key, data); + await ResetUserKey(userId); + return sign.ToLower() == _sign; + } + + public static async Task GetUserKey(string userId) + { + var key = string.Format(UserCache.BaseCacheKey, "UserKey"); + var redis = App.GetService(); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync(key, userId); + } + + string data = StringAssist.RandomString(12); + await redis.AddHashAsync(key, userId, data); + return data; + } + + private static async Task ResetUserKey(string userId) + { + string data = StringAssist.RandomString(12); + var key = string.Format(UserCache.BaseCacheKey, "UserKey"); + var redis = App.GetService(); + await redis.AddHashAsync(key, userId, data); + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Login/LoginController.cs b/Service/Application.Web/Controllers/Login/LoginController.cs index 9d53e6e..306d912 100644 --- a/Service/Application.Web/Controllers/Login/LoginController.cs +++ b/Service/Application.Web/Controllers/Login/LoginController.cs @@ -280,6 +280,34 @@ namespace Application.Web.Controllers.Login return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId }); } + + [HttpPost] + public async Task RefreshTokenByBook([FromBody] RefreshTokenParms parms) + { + if (string.IsNullOrEmpty(parms.refToken)) + { + return PoAction.Message("刷新失败"); + } + + string Key = App.Configuration["JwtTokenOptions:SecurityKey"].ToString(); + string Issuer = App.Configuration["JwtTokenOptions:Issuer"].ToString(); + string Audience = App.Configuration["JwtTokenOptions:Audience"].ToString(); + + var userInfo = await _userService.GetUserInfoByToken(parms.refToken); + if (userInfo == null) + { + return PoAction.Message("刷新失败,用户不存在!"); + } + + Dictionary loadData = new Dictionary(); + loadData.Add("userId", userInfo.userId); + loadData.Add("accId", userInfo.accId); + loadData.Add("areaId", userInfo.areaId); + string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, TokenConfig.TokenTime); + + return PoAction.Ok(new + { token = token, refToken = userInfo.token, userId = userInfo.userId }); + } /// /// 注册角色信息 diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 62b717e..6d47836 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -21,9 +21,13 @@ public class MapController : ControllerBase private readonly IGameSkillService _skillService; private readonly IGameGoodsService _goodsService; private readonly IGameTeamService _teamService; + private readonly IGameMonsterService _monsterService; + private readonly IGameFightService _fightService; + public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService, IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService, - IUnitUserAccService accService, IGameSkillService skillService,IGameGoodsService goodsService,IGameTeamService teamService) + IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService, + IGameTeamService teamService, IGameMonsterService monsterService,IGameFightService fightService) { _userService = userService; _mapService = mapService; @@ -35,6 +39,8 @@ public class MapController : ControllerBase _skillService = skillService; _goodsService = goodsService; _teamService = teamService; + _monsterService = monsterService; + _fightService = fightService; } #region 地图相关 @@ -89,14 +95,17 @@ public class MapController : ControllerBase #endregion //公聊信息 - var myTeam = await _teamService.GetUserTeamData(userId); - string teamId =myTeam.teamId ; + var myTeam = await _teamService.GetUserTeamData(userId); + string teamId = myTeam.teamId; string groupId = ""; var chatData = await _chatService.GetChatTop(userId, area, 2, teamId, groupId); var npcData = await _mapService.GetMapNpc(mapInfo.mapId); //NPC信息 npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId)); + + //获取怪物 + var monsterData = await _monsterService.GetMapMonster(userId, mapInfo.mapId, teamId); var nearUser = await _mapService.GetMapUser(mapInfo.mapId, area, (int)mapInfo.lookArea, [userId], 3); //获取附近的人 @@ -132,7 +141,11 @@ public class MapController : ControllerBase #endregion + var broadcast = await _messageService.GetBroadcastData(area); + var userFight = await _fightService.GetUserFight(userId); + string fightId = userFight.Count > 0 ? userFight[0] : ""; + object ret = new { mapInfo, @@ -143,7 +156,10 @@ public class MapController : ControllerBase nearUser, noReadMsg = noReadMsg[3], business, - mapRes + mapRes, + broadcast, + monster = monsterData, + fightId }; return PoAction.Ok(ret); @@ -684,7 +700,6 @@ public class MapController : ControllerBase } var myVigour = await _attrService.GetUserVigourInfo(userId); - Console.WriteLine($"{myVigour.vitality }-{resInfo.needVigour}"); if (myVigour.vitality < resInfo.needVigour) { return PoAction.Message("活力不足!"); diff --git a/Service/Application.Web/Controllers/Map/StoreController.cs b/Service/Application.Web/Controllers/Map/StoreController.cs index b9ddabe..6a4c20f 100644 --- a/Service/Application.Web/Controllers/Map/StoreController.cs +++ b/Service/Application.Web/Controllers/Map/StoreController.cs @@ -51,6 +51,11 @@ public class StoreController : ControllerBase return PoAction.Message("Npc不存在!"); } + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store))) + { + return PoAction.Message("业务不可用!"); + } + var onMap = await _mapService.GetUserOnMapId(userId); if (npcInfo.mapId != onMap) { @@ -85,6 +90,11 @@ public class StoreController : ControllerBase return PoAction.Message("Npc不存在!"); } + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store))) + { + return PoAction.Message("业务不可用!"); + } + var onMap = await _mapService.GetUserOnMapId(userId); if (npcInfo.mapId != onMap) { @@ -158,6 +168,11 @@ public class StoreController : ControllerBase return PoAction.Message("Npc不存在!"); } + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store))) + { + return PoAction.Message("业务不可用!"); + } + var onMap = await _mapService.GetUserOnMapId(userId); if (npcInfo.mapId != onMap) { @@ -168,25 +183,25 @@ public class StoreController : ControllerBase if (type == 0) { - var data = await _equService.GetUserEquData(userId, 0, query, page, 10, total, true); - return PoAction.Ok(new { data, total.Value }); + var data = await _equService.GetUserEquData(userId, 0, query, page, 10, total, true, true); + return PoAction.Ok(new { data, total = total.Value }); } else if (type == 1) { List code = new List() { nameof(GoodsEnum.Code.Drug) }; var data = await _goodsService.GetUserGoodsData(userId, code, new List(), query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value }); } else if (type == 2) { List code = new List(); List noCode = new List() { nameof(GoodsEnum.Code.Drug) }; var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value }); } else { - return PoAction.Ok(new { data = new List(), total.Value }); + return PoAction.Ok(new { data = new List(), total = total.Value }); } } @@ -218,7 +233,7 @@ public class StoreController : ControllerBase return PoAction.Message("Npc不存在!"); } - if (parms.type == 0)//装备 + if (parms.type == 0) //装备 { var equInfo = await _equService.GetUserEquInfo(parms.id); if (equInfo == null) @@ -248,7 +263,7 @@ public class StoreController : ControllerBase } else { - return PoAction.Message("出售失败,请稍后尝试!"); + return PoAction.Message("出售失败,请稍后尝试!"); } } else //物品 @@ -277,7 +292,7 @@ public class StoreController : ControllerBase } else { - return PoAction.Message("出售失败,请稍后尝试!"); + return PoAction.Message("出售失败,请稍后尝试!"); } } } diff --git a/Service/Application.Web/Controllers/Pub/BusinessController.cs b/Service/Application.Web/Controllers/Pub/BusinessController.cs new file mode 100644 index 0000000..d0c1a8c --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/BusinessController.cs @@ -0,0 +1,134 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; + +namespace Application.Web.Controllers.Pub; + +/// +/// 业务操作接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class BusinessController : ControllerBase +{ + private readonly IGameMapService _mapService; + private readonly IGameEquService _equService; + private readonly IGameGoodsService _goodsService; + + public BusinessController(IGameEquService equService, IGameGoodsService goodsService, IGameMapService mapService) + { + _equService = equService; + _goodsService = goodsService; + _mapService = mapService; + } + + /// + /// 获取打造图纸 + /// + /// + [HttpGet] + public async Task GetEquPaper() + { + string userId = StateHelper.userId; + var data = await _goodsService.GetUserGoodsData(userId, nameof(GoodsEnum.Code.Paper)); + List result = new List(); + foreach (var item in data) + { + MakePaperView temp = new MakePaperView(); + temp.goods = await _goodsService.GetGoodsInfo((int)item.goodsId); + temp.count = (long)item.count; + result.Add(temp); + } + + return PoAction.Ok(result); + } + + /// + /// 打造装备 + /// + /// + /// + /// + [HttpGet] + public async Task HandleEquPaper(int npcId, int goodsId) + { + string userId = StateHelper.userId; + + #region NPC验证 + + var npcInfo = await _mapService.GetNpcInfo(npcId); + if (npcInfo == null) + { + return PoAction.Message("Npc不存在!"); + } + + if (npcInfo.status != 1) + { + return PoAction.Message("Npc不存在!"); + } + + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Make))) + { + return PoAction.Message("业务不可用!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (npcInfo.mapId != onMap) + { + return PoAction.Message("Npc不存在!"); + } + + #endregion + + var myGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId); + if (myGoods == null) + { + return PoAction.Message("暂无图纸!"); + } + + if (myGoods.count < 1) + { + return PoAction.Message("暂无图纸!"); + } + + if (myGoods.code != nameof(GoodsEnum.Code.Paper)) + { + return PoAction.Message("非图纸材料,无法打造!"); + } + + string needstr = await _goodsService.GetGoodsContent(goodsId); + var needs = JsonConvert.DeserializeObject>(needstr); + var check = await GameBus.CheckNeed(userId, needs); + if (check.result) + { + if (await GameBus.UpdateBag(userId, 0, needs, "装备打造")) + { + var onEqu = await _equService.GetMakeEquByGoodsId(goodsId); + if (onEqu == null) + { + return PoAction.Message("打造失败,请联系客服!"); + } + + //发放装备 + bool isRd = onEqu.rdAttr != 0; + var getEqu = await _equService.AddUserEqu(userId, (int)onEqu.equId, isRd, "打造装备"); + if (getEqu != null) + { + return PoAction.Ok(getEqu.ueId, $"打造成功,获得装备[{onEqu.equName}]"); + } + else + { + return PoAction.Message("打造失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("打造失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("材料不足!"); + } + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/EquController.cs b/Service/Application.Web/Controllers/Pub/EquController.cs index 25f6584..1b6d40e 100644 --- a/Service/Application.Web/Controllers/Pub/EquController.cs +++ b/Service/Application.Web/Controllers/Pub/EquController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; namespace Application.Web.Controllers.Pub; @@ -13,12 +14,19 @@ public class EquController : ControllerBase private readonly IGameEquService _equService; private readonly IUnitUserAttrService _attrService; private readonly IUnitUserService _userService; + private readonly IGameDicService _dicService; + private readonly IMessageService _messageService; + private readonly IGameGoodsService _goodsService; - public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService) + public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService, + IGameDicService dicService, IMessageService messageService, IGameGoodsService goodsService) { _equService = equService; _attrService = attrService; _userService = userService; + _dicService = dicService; + _messageService = messageService; + _goodsService = goodsService; } /// @@ -66,6 +74,7 @@ public class EquController : ControllerBase suit = await _equService.GetEuqSuitInfo(ueInfo.suitCode); } + ueInfo = EquTool.GetUserEquByIntensify(ueInfo); user = await UserModelTool.GetUserView(ueInfo.owerId); } @@ -109,12 +118,6 @@ public class EquController : ControllerBase return PoAction.Message("装备不存在!"); } - if (equInfo.isAppr == 0) - { - return PoAction.Message("装备未鉴定!"); - } - - equInfo.isLock = equInfo.isLock == 0 ? 1 : 0; bool result = await _equService.UpdateUserEquInfo(equInfo); @@ -138,7 +141,73 @@ public class EquController : ControllerBase { string userId = StateHelper.userId; var data = await _equService.GetUserOnEqu(userId); - return PoAction.Ok(data); + var suit = await _equService.GetUserEquSuit(userId); + return PoAction.Ok(new { data, suit }); + } + + /// + /// 鉴定装备 + /// + /// + /// + [HttpGet] + public async Task ApprEqu(string ueId) + { + string userId = StateHelper.userId; + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr == 1) + { + return PoAction.Message("装备已鉴定!"); + } + + var resEqu = await _equService.GetEquInfo((int)equInfo.equId); + if (resEqu.isAppr == 0) + { + return PoAction.Message("装备数据异常,联系客服!"); + } + + var myGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameEquApprGoods); + if (myGoods < 1) + { + return PoAction.Message("暂无装备鉴定符!"); + } + + if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameEquApprGoods, 1, "鉴定装备")) + { + equInfo.minAtk = RandomAssist.GetFormatedNumeric((int)resEqu.minAtk, (int)resEqu.maxAtk); + equInfo.maxAtk = RandomAssist.GetFormatedNumeric((int)equInfo.minAtk, (int)resEqu.maxAtk); + string[] def = resEqu.defense.Split('-'); + equInfo.Defense = RandomAssist.GetFormatedNumeric(Convert.ToInt32(def[0]), Convert.ToInt32(def[1])); + string[] agi = resEqu.agility.Split('-'); + equInfo.Agility = RandomAssist.GetFormatedNumeric(Convert.ToInt32(agi[0]), Convert.ToInt32(agi[1])); + string[] mor = resEqu.morale.Split('-'); + equInfo.Morale = RandomAssist.GetFormatedNumeric(Convert.ToInt32(mor[0]), Convert.ToInt32(mor[1])); + string[] blo = resEqu.blood.Split('-'); + equInfo.Blood = RandomAssist.GetFormatedNumeric(Convert.ToInt32(blo[0]), Convert.ToInt32(blo[1])); + equInfo.isAppr = 1; + if (await _equService.UpdateUserEquInfo(equInfo)) + { + return PoAction.Ok(true, "装备鉴定成功!"); + } + else + { + return PoAction.Message("鉴定失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("鉴定失败,请稍后尝试!"); + } } /// @@ -200,6 +269,7 @@ public class EquController : ControllerBase return PoAction.Message($"该装备最多穿戴{equInfo.canEqualUp}件!"); } } + bool isOk = true; if (string.IsNullOrEmpty(de)) { @@ -222,6 +292,7 @@ public class EquController : ControllerBase { return PoAction.Message("装备未穿戴!"); } + if (DownOnEqu.code != equInfo.code) { return PoAction.Message("装备部位不一致!"); @@ -260,6 +331,595 @@ public class EquController : ControllerBase } } } + + /// + /// 获取可穿戴装备 + /// + /// + /// + [HttpGet] + public async Task GetCanOnEqu(int type) + { + string code = nameof(EquEnum.EquPlace.Hold); + switch (type) + { + case 1: + code = nameof(EquEnum.EquPlace.Hold); + break; + case 2: + code = nameof(EquEnum.EquPlace.Vice); + break; + case 3: + code = nameof(EquEnum.EquPlace.Head); + break; + case 4: + code = nameof(EquEnum.EquPlace.Wear); + break; + case 5: + code = nameof(EquEnum.EquPlace.Waist); + break; + case 6: + code = nameof(EquEnum.EquPlace.Foot); + break; + case 7: + code = nameof(EquEnum.EquPlace.Ornaments); + break; + case 8: + code = nameof(EquEnum.EquPlace.Fashion); + break; + case 9: + code = nameof(EquEnum.EquPlace.Wing); + break; + case 10: + code = nameof(EquEnum.EquPlace.Decorate); + break; + } + + string userId = StateHelper.userId; + var userOnEqu = await _equService.GetUserOnEqu(userId); + var NoEqu = userOnEqu.FindAll(it => it.code == code).Select(it => it.ueId).ToList(); + var CanEqu = await _equService.GetUserEquData(userId, code, NoEqu); + long onTime = TimeExtend.GetTimeStampSeconds; + CanEqu = CanEqu.FindAll(it => it.isAppr == 1 && it.useEndTime > onTime); + CanEqu = CanEqu.OrderByDescending(it => it.lev).ToList(); + return PoAction.Ok(CanEqu); + } + + /// + /// 获取激活套装属性 + /// + /// + /// + [HttpGet] + public async Task GetUserOnSuitInfo(string suitCode) + { + var userId = StateHelper.userId; + var onSuit = await _equService.GetUserEquSuit(userId); + var suit = onSuit.Find(it => it.suitCode == suitCode); + if (suit == null) + { + return PoAction.Message("套装不存在!"); + } + + var data = await _equService.GetEuqSuitInfo(suitCode); + if (data == null) + { + return PoAction.Message("套装不存在!"); + } + + return PoAction.Ok(new { data, suit }); + } + + /// + /// 获取装备觉醒所需 + /// + /// + /// + [HttpGet] + public async Task GetEquAwakenInfo(string ue) + { + string userId = StateHelper.userId; + var equData = await _equService.GetUserEquInfo(ue); + if (equData == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + if (equData.useEndTime < TimeExtend.GetTimeStampSeconds) + { + return PoAction.Message("装备已过期!"); + } + + CheckTowerNeed result = new CheckTowerNeed(); + if (equData.EquAwaken.Count == 0) + { + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + result = await GameBus.CheckNeed(userId, need); + } + else + { + var upAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, equData.EquAwaken[0].lev + 1); + if (upAwaken == null) + { + return PoAction.Message("觉醒已达到上限!"); + } + + result = await GameBus.CheckNeed(userId, upAwaken.need); + } + + return PoAction.Ok(result); + } + + /// + /// 觉醒装备 + /// + /// + /// 0重置,1正常觉醒 + /// + [HttpGet] + public async Task HandleEquAwaken(string ue, int type) + { + string userId = StateHelper.userId; + var equData = await _equService.GetUserEquInfo(ue); + if (equData == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equData.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + if (equData.useEndTime < TimeExtend.GetTimeStampSeconds) + { + return PoAction.Message("装备已过期!"); + } + + EquAwakenData onAwaken = new EquAwakenData(); + game_equ_awaken newAwaken = new game_equ_awaken(); + CheckTowerNeed result = new CheckTowerNeed(); + if (type == 0) //重置 + { + newAwaken = await _equService.GetRandomOneAwakenByCode(equData.code); + if (newAwaken == null) + { + return PoAction.Message("该部件装备不可觉醒!"); + } + + onAwaken = newAwaken.levAttr.Find(it => it.lev == 1); + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + result = await GameBus.CheckNeed(userId, need); + } + else + { + if (equData.EquAwaken.Count == 0) + { + newAwaken = await _equService.GetRandomOneAwakenByCode(equData.code); + if (newAwaken == null) + { + return PoAction.Message("该部件装备不可觉醒!"); + } + + onAwaken = newAwaken.levAttr.Find(it => it.lev == 1); + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + result = await GameBus.CheckNeed(userId, need); + } + else + { + var upAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, equData.EquAwaken[0].lev + 1); + if (upAwaken == null) + { + return PoAction.Message("觉醒已达到上限!"); + } + + newAwaken = await _equService.GetEquAwakenInfo(equData.EquAwaken[0].atId); + onAwaken = upAwaken; + result = await GameBus.CheckNeed(userId, upAwaken.need); + } + } + + if (result.result == false) + { + return PoAction.Message("不满足觉醒条件!"); + } + + if (await GameBus.UpdateBag(userId, 0, result.Needs, "觉醒装备")) + { + if (RandomAssist.CheakRandom(onAwaken.success)) + { + EquAwaken awaken = new EquAwaken(); + awaken.atId = newAwaken.atId; + awaken.name = newAwaken.name; + awaken.lev = onAwaken.lev; + awaken.awaken = onAwaken.attr; + equData.EquAwaken = [awaken]; + if (await _equService.UpdateUserEquInfo(equData, true, "觉醒", "装备觉醒")) + { + string msg = $"[{equData.equName}]装备的特性【{awaken.name}】升至{awaken.lev}级!"; + await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg); + //此处为觉醒成功,返回相关数据 + var nextAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, + equData.EquAwaken[0].lev + 1); + var nextResult = new CheckTowerNeed() + { + result = false, + Needs = new List() + }; + if (nextAwaken != null) + { + nextResult = await GameBus.CheckNeed(userId, nextAwaken.need); + } + + return PoAction.Ok(new { state = 1, awaken = equData.EquAwaken, result = nextResult }, "觉醒成功!"); + } + else + { + return PoAction.Message("觉醒异常,请稍后尝试!"); + } + } + else + { + //此处为觉醒成功,返回相关数据 + var nextAwaken = + await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, + equData.EquAwaken[0].lev + 1); + var nextResult = new CheckTowerNeed() + { + result = false, + Needs = new List() + }; + if (nextAwaken != null) + { + nextResult = await GameBus.CheckNeed(userId, nextAwaken.need); + } + + return PoAction.Ok(new { state = 0, awaken = equData.EquAwaken, result = nextResult }, "觉醒失败!"); + } + } + else + { + return PoAction.Message("觉醒异常,请稍后尝试!"); + } + + return PoAction.Ok(result); + } + + /// + /// 获取强化信息 + /// + /// + /// + [HttpGet] + public async Task GetEquUpInfo(string ueId) + { + string userId = StateHelper.userId; + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + long time = TimeExtend.GetTimeStampSeconds; + if (equInfo.useEndTime < time) + { + return PoAction.Message("装备已过期!"); + } + + if (equInfo.isIntensify == 0) + { + return PoAction.Message("装备不可强化!"); + } + + bool isMax = false; + int upLev = (int)equInfo.intensifyLev + 1; + var needs = await _equService.GetUserEquUpData(upLev); + if (needs == null) + { + isMax = true; + } + + CheckTowerNeeds result = new CheckTowerNeeds(); + result.result = false; + result.Needs = new List(); + if (!isMax) + { + result = await GameBus.CheckNeeds(userId, needs.needData); + } + + return PoAction.Ok(new + { + equData = equInfo, + isMax, + result + }); + } + + /// + /// 强化装备 + /// + /// + /// + [HttpPost] + public async Task HandleEquUp([FromBody] EquUpParms parms) + { + string ueId = parms.ueId; + string userId = StateHelper.userId; + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + long time = TimeExtend.GetTimeStampSeconds; + if (equInfo.useEndTime < time) + { + return PoAction.Message("装备已过期!"); + } + + if (equInfo.isIntensify == 0) + { + return PoAction.Message("装备不可强化!"); + } + + int upLev = (int)equInfo.intensifyLev + 1; + var needs = await _equService.GetUserEquUpData(upLev); + if (needs == null) + { + return PoAction.Message("已达到最大强化等级!"); + } + + List reqNeeds = JsonConvert.DeserializeObject>(parms.needs); + //验证材料 + foreach (var item in needs.needData) + { + var onNeed = reqNeeds.Find(it => it.Id == item.Id); + if (item.NeedItem.Any(it => it.code == onNeed.code && it.parameter == onNeed.parameter) == false && + item.code != onNeed.code && item.parameter != onNeed.parameter) + { + return PoAction.Message("材料错误!"); + } + } + + var result = await GameBus.CheckNeeds(userId, reqNeeds); + if (result.result == false) + { + return PoAction.Message("材料不足!"); + } + + if (await GameBus.UpdateBag(userId, 0, reqNeeds, $"强化装备:{ueId}")) + { + CheckTowerNeeds nexResult = new CheckTowerNeeds(); + nexResult.result = false; + nexResult.Needs = new List(); + bool isMax = false; + int state = 0; + int okNum = (int)needs.okChance; + if (RandomAssist.CheakRandom(okNum)) + { + state = 1; + equInfo.intensifyLev = upLev; + equInfo.isDeal = result.isDeal; + equInfo.isGive = result.isGive; + if (await _equService.UpdateUserEquInfo(equInfo, true, "强化", "强化装备") == false) + { + return PoAction.Message("强化异常,请联系客服!"); + } + + var nextNeeds = await _equService.GetUserEquUpData((int)equInfo.intensifyLev + 1); + if (nextNeeds == null) + { + isMax = true; + } + else + { + var nexts = nextNeeds.euId == needs.euId ? reqNeeds : nextNeeds.needData; + nexResult = await GameBus.CheckNeeds(userId, nexts); + } + + if (equInfo.intensifyLev >= 60) + { + string msg = $"[{equInfo.equName}]装备强化至{equInfo.intensifyLev}级!"; + await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg); + } + } + else //执行材料返还 + { + List retProp = new List(); + foreach (var item in reqNeeds) + { + if (item.retCount > 0 && item.isOp == 1) + { + TowerGet temp = new TowerGet() + { + code = item.code, + name = item.name, + parameter = item.parameter, + count = item.retCount + }; + retProp.Add(temp); + } + } + + if (retProp.Count > 0) + { + await GameBus.UpdateBag(userId, 1, retProp, "强化失败,返还"); + } + + nexResult = await GameBus.CheckNeeds(userId, reqNeeds); + } + + + return PoAction.Ok(new + { + state, + equData = equInfo, + isMax, + result = nexResult + }); + } + else + { + return PoAction.Message("强化错误,请稍后尝试!"); + } + } + + /// + /// 获取洗练装备属性 + /// + /// + /// + [HttpGet] + public async Task GetEquQualityInfo(string ueId) + { + string userId = StateHelper.userId; + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + long time = TimeExtend.GetTimeStampSeconds; + if (equInfo.useEndTime < time) + { + return PoAction.Message("装备已过期!"); + } + + List CanOp = new List() + { "Hold", "Vice", "Head", "Wear", "Waist", "Foot", "Ornaments" }; + if (!CanOp.Contains(equInfo.code)) + { + return PoAction.Message("该部件不可洗练!"); + } + + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Quality)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + CheckTowerNeed result = await GameBus.CheckNeed(userId, need); + + return PoAction.Ok(new + { + equData = equInfo, + result + }); + } - + /// + /// 洗练装备 + /// + /// + /// + [HttpGet] + public async Task HandleEquQuality(string ueId) + { + string userId = StateHelper.userId; + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr == 0) + { + return PoAction.Message("装备未鉴定!"); + } + + long time = TimeExtend.GetTimeStampSeconds; + if (equInfo.useEndTime < time) + { + return PoAction.Message("装备已过期!"); + } + + List CanOp = new List() + { "Hold", "Vice", "Head", "Wear", "Waist", "Foot", "Ornaments" }; + if (!CanOp.Contains(equInfo.code)) + { + return PoAction.Message("该部件不可洗练!"); + } + + var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Quality)); + List need = JsonConvert.DeserializeObject>(dicConfig.sign); + CheckTowerNeed result = await GameBus.CheckNeed(userId, need); + if (result.result) + { + if (await GameBus.UpdateBag(userId, 0, need, "洗练装备")) + { + var attr = await _equService.GetRandomEquAttr(equInfo.code, (int)equInfo.lev); + equInfo.quality = attr.Count; + equInfo.qualityName = GameTool.GetEquQualityName(attr.Count); + equInfo.EquAttr = attr; + if (await _equService.UpdateUserEquInfo(equInfo, true, "洗练装备", "洗练装备")) + { + return PoAction.Ok(true, "洗练成功!"); + } + else + { + return PoAction.Message("洗练失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("洗练失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("洗练失败,请稍后尝试!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/FightController.cs b/Service/Application.Web/Controllers/Pub/FightController.cs new file mode 100644 index 0000000..1398cda --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/FightController.cs @@ -0,0 +1,107 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; + +namespace Application.Web.Controllers.Pub; + +/// +/// 战斗接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class FightController : ControllerBase +{ + private readonly IGameFightService _fightService; + private readonly IGameMonsterService _monsterService; + private readonly IUnitUserAttrService _attrService; + private readonly IGameMapService _mapService; + + public FightController(IGameFightService fightService, IGameMonsterService monsterService, + IUnitUserAttrService attrService, IGameMapService mapService) + { + _fightService = fightService; + _monsterService = monsterService; + _attrService = attrService; + _mapService = mapService; + } + + /// + /// 添加怪物战斗 + /// + /// + /// + [HttpPost] + public async Task FightMonster([FromBody] FightMonsterParms parms) + { + string userId = StateHelper.userId; + if (await UserKeyTool.CheckUserThickenData(userId, parms.sign, parms.type.ToString(), parms.monsterId) == false) + { + return PoAction.Message("怪物不存在!", -1); + } + + var mapInfo = await _mapService.GetUserOnToMapInfo(userId); + + //添加怪物战斗 + string fightId = StringAssist.NewGuid; + string areaCode = nameof(GameEnum.AreaCode.Own); + string keyId = fightId; + string mainId = string.Empty; + string code = nameof(GameEnum.FightCode.PVE); + string scene = mapInfo.code; + string mapId = mapInfo.mapId; + long exp = 0; + long copper = 0; + long petExp = 0; + string award = string.Empty; + string pars = ""; + if (parms.type == 0) + { + var monster = await _monsterService.GetMapMonsterInfo(parms.monsterId); + mainId = monster.monsterId; + pars = JsonConvert.SerializeObject(new { type = "Default" }); + } + else + { + var monster = await _monsterService.GetCreateMonsterInfo(parms.monsterId); + keyId = monster.umId; + mainId = monster.monsterId; + 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)) ; + copper = Convert.ToInt64(monsterInfo.copper * (1.0m + userAttr.addGold)); + petExp = (long)monsterInfo.petExp; + 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); + award = JsonConvert.SerializeObject(new FightAwardModel() { code = "Default", award = getAward }); + } + } + } + + bool result = await _fightService.AddFight(fightId, areaCode, keyId, mainId, code, scene, mapId, userId, exp, + copper, petExp, award, pars); + if (result) + { + return PoAction.Ok(fightId); + } + else + { + return PoAction.Message("战斗生成错误!"); + } + } + + [HttpPost] + public async Task Fight([FromBody] FightParms parms) + { + return PoAction.Ok(true); + } +} \ 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 5b0a2ab..0221cab 100644 --- a/Service/Application.Web/Controllers/Pub/GoodsController.cs +++ b/Service/Application.Web/Controllers/Pub/GoodsController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; namespace Application.Web.Controllers.Pub; @@ -11,10 +12,17 @@ namespace Application.Web.Controllers.Pub; public class GoodsController : ControllerBase { private readonly IGameGoodsService _goodsService; + private readonly IUnitUserAttrService _attrService; + private readonly IMessageService _messageService; + private readonly IUnitUserWeight _weightService; - public GoodsController(IGameGoodsService goodsService) + public GoodsController(IGameGoodsService goodsService, IUnitUserAttrService attrService, + IMessageService messageService, IUnitUserWeight weightService) { _goodsService = goodsService; + _attrService = attrService; + _messageService = messageService; + _weightService = weightService; } /// @@ -33,7 +41,205 @@ public class GoodsController : ControllerBase string userId = StateHelper.userId; int count = await _goodsService.GetUserGoodsCount(userId, goodsId); + int UseState = 0; + string[] ShowViewNum = ["Pack", "Weight", "State"]; //显示带数量窗口 + string[] ShowView = ["Ship","Drug"]; //显示只能使用1个的窗口 + if (ShowViewNum.Any(it => it == goodsInfo.code)) + { + UseState = 1; + } + else if (ShowView.Any(it => it == goodsInfo.code)) + { + UseState = 2; + } + else if (goodsInfo.code == nameof(GoodsEnum.Code.ChoicePack)) + { + UseState = 3; + } - return PoAction.Ok(new { goods = goodsInfo, count }); + return PoAction.Ok(new { goods = goodsInfo, count, use = UseState }); + } + + /// + /// 使用物品 + /// + /// + /// + /// + [HttpGet] + public async Task UseGoods(int goodsId, int count) + { + count = count < 1 ? 1 : count; + string userId = StateHelper.userId; + var goodsInfo = await _goodsService.GetGoodsInfo(goodsId); + if (goodsInfo == null) + { + return PoAction.Message("物品不存在!"); + } + + var MyGoods = await _goodsService.GetUserGoodsCount(userId, goodsId); + if (MyGoods < count) + { + return PoAction.Message("物品不足!"); + } + + var myLev = await _attrService.GetUserLev(userId); + if (myLev < (int)goodsInfo.lev) + { + return PoAction.Message($"该物品{goodsInfo.lev}级才可使用!"); + } + + #region 必要判定 + + if (goodsInfo.code == nameof(GoodsEnum.Code.Ship)) + { + var myShip = await _weightService.GetUserShip(userId); + if (myShip.Count >= 5) + { + return PoAction.Message($"每人最多拥有5个船只,您已达到上限!"); + } + } + + if (goodsInfo.code == nameof(GoodsEnum.Code.Drug)) + { + var ck = await _goodsService.CheckUseDrug(userId, goodsId, goodsInfo.content); + if (!string.IsNullOrEmpty(ck)) + { + return PoAction.Message(ck); + } + } + + #endregion + + if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "使用物品")) + { + string message = ""; + if (goodsInfo.code == nameof(GoodsEnum.Code.Pack)) //使用礼包 + { + var park = JsonConvert.DeserializeObject(goodsInfo.content); + var award = GameBus.GetRandomGoods(park, count); + if (award.Count > 0) + { + message = $"打开[{goodsInfo.goodsName}]×{count},获得:"; + foreach (var item in award) + { + message += $"{item.name}+{item.count},"; + } + + message = message.TrimEnd(','); + await GameBus.UpdateBag(userId, 1, award, $"打开礼包:{goodsInfo.goodsName}×{count}获得"); + + await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Award), message); + } + else + { + message = "空空如也,什么也没有得到!"; + } + } + else if (goodsInfo.code == nameof(GoodsEnum.Code.Weight)) + { + int unitWeight = Convert.ToInt32(goodsInfo.content); + await _weightService.UpdateUserMaxWeight(userId, 1, unitWeight, count, goodsInfo.goodsId, + goodsInfo.goodsName); + message = $"使用[{goodsInfo.goodsName}]×{count},负重+{unitWeight * count}"; + } + else if (goodsInfo.code == nameof(GoodsEnum.Code.State)) + { + UserStateModel stateConfig = JsonConvert.DeserializeObject(goodsInfo.content); + await _attrService.AddUserState(userId, goodsInfo.goodsId.ToString(), stateConfig.name, + stateConfig.scene, stateConfig.tips, stateConfig.attr, stateConfig.time, count); + message = $"使用[{goodsInfo.goodsName}]×{count},状态时间+{stateConfig.time * count}分钟"; + } + else if (goodsInfo.code == nameof(GoodsEnum.Code.Ship)) + { + dynamic shipInfo = JsonConvert.DeserializeObject(goodsInfo.content); + string name = shipInfo.name; + int speed = shipInfo.speed; + int weight = shipInfo.weight; + int copper = shipInfo.copper; + long sale = shipInfo.sale; + string remark = shipInfo.remark; + + await _weightService.AddUserShip(userId, name, goodsId, speed, weight, copper, sale, remark); + message = $"使用[{goodsInfo.goodsName}],获得{name}+1"; + } + if (goodsInfo.code == nameof(GoodsEnum.Code.Drug)) + { + message = "使用成功!"; + await _goodsService.UseDrug(userId, goodsId, goodsInfo.content); + } + return PoAction.Ok(true, message); + } + else + { + return PoAction.Message("使用失败,请稍后尝试!"); + } + } + + /// + /// 使用选择物品礼包 + /// + /// + /// + /// + [HttpGet] + public async Task UseChoiceGoods(int goodsId, int num) + { + string userId = StateHelper.userId; + var goodsInfo = await _goodsService.GetGoodsInfo(goodsId); + if (goodsInfo == null) + { + return PoAction.Message("物品不存在!"); + } + + var MyGoods = await _goodsService.GetUserGoodsCount(userId, goodsId); + if (MyGoods < 1) + { + return PoAction.Message("物品不足!"); + } + + var myLev = await _attrService.GetUserLev(userId); + if (myLev < (int)goodsInfo.lev) + { + return PoAction.Message($"该物品{goodsInfo.lev}级才可使用!"); + } + + if (goodsInfo.code != nameof(GoodsEnum.Code.ChoicePack)) + { + return PoAction.Message("无法使用该物品!"); + } + + List choiceGoods = JsonConvert.DeserializeObject>(goodsInfo.content); + var onAward = choiceGoods.Find(it => it.id == num); + if (onAward == null) + { + return PoAction.Message("物品中不包含该选择!"); + } + + + if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "使用物品")) + { + if (await GameBus.UpdateBag(userId, 1, onAward.award, "打开礼包获取")) + { + string message = $"打开[{goodsInfo.goodsName}],获得:"; + foreach (var item in onAward.award) + { + message += $"{item.name}+{item.count},"; + } + + message = message.TrimEnd(','); + + await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Award), message); + return PoAction.Ok(true, message); + } + else + { + return PoAction.Message("使用失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("使用失败,请稍后尝试!"); + } } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/PubController.cs b/Service/Application.Web/Controllers/Pub/PubController.cs index fb0fcaa..c16b58d 100644 --- a/Service/Application.Web/Controllers/Pub/PubController.cs +++ b/Service/Application.Web/Controllers/Pub/PubController.cs @@ -39,6 +39,11 @@ namespace Application.Web.Controllers.Pub account = await _accountService.GetAccInfoByToken(sid); if (account != null) { + account.pwd = ""; + account.npwd = ""; + account.token = ""; + account.openId = ""; + isOnline = true; userData = await _userService.GetUserDataByAccId(account.accId); } diff --git a/Service/Application.Web/Controllers/Pub/RecoverController.cs b/Service/Application.Web/Controllers/Pub/RecoverController.cs index 66bf461..29ec57f 100644 --- a/Service/Application.Web/Controllers/Pub/RecoverController.cs +++ b/Service/Application.Web/Controllers/Pub/RecoverController.cs @@ -12,11 +12,15 @@ public class RecoverController : ControllerBase { private readonly IUnitUserAttrService _attrService; private readonly IGameMapService _mapService; + private readonly IUnitUserAccService _accService; + private readonly IGameEquService _equService; - public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService) + public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService,IUnitUserAccService accService,IGameEquService equService) { _attrService = attrService; _mapService = mapService; + _accService = accService; + _equService = equService; } /// @@ -179,6 +183,194 @@ public class RecoverController : ControllerBase #endregion + var data = await _attrService.GetUserVigourInfo(userId); + string time = TimeAssist.GetDateTimeYMDString(0); + if (data.upTime == time) + { + return PoAction.Message("今天已恢复过活力啦!"); + } + if (data.vitality >= data.upVitality) + { + return PoAction.Message("活力满满,无需恢复!"); + } + + bool result = await _attrService.UpdateUserVigour(userId, 2, (long)data.upVitality,time); + if (result) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("恢复失败,请稍后尝试!"); + } + } + + /// + /// 获取恢复耐久的装备 + /// + /// + /// + [HttpGet] + public async Task GetUserRecoverEqu(int npcId) + { + string userId = StateHelper.userId; + + #region NPC验证 + + var npcInfo = await _mapService.GetNpcInfo(npcId); + if (npcInfo == null) + { + return PoAction.Message("Npc不存在!"); + } + + if (npcInfo.status != 1) + { + return PoAction.Message("Npc不存在!"); + } + + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetEqu))) + { + return PoAction.Message("业务不可用!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (npcInfo.mapId != onMap) + { + return PoAction.Message("Npc不存在!"); + } + + #endregion + + int need = 0; + var data = await _equService.GetUserOnEqu(userId); + var needData = data.FindAll(it => + it.isAppr == 1 && it.durability < it.maxdurability && it.useEndTime > TimeExtend.GetTimeStampSeconds); + need = needData.Sum(it => (int)it.maxdurability - (int)it.durability); + return PoAction.Ok(new { data, need }); + } + + /// + /// 恢复装备耐久 + /// + /// + /// + /// + [HttpGet] + public async Task RecoverEqu(int npcId,string? ueId) + { + string userId = StateHelper.userId; + + #region NPC验证 + + var npcInfo = await _mapService.GetNpcInfo(npcId); + if (npcInfo == null) + { + return PoAction.Message("Npc不存在!"); + } + + if (npcInfo.status != 1) + { + return PoAction.Message("Npc不存在!"); + } + + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetEqu))) + { + return PoAction.Message("业务不可用!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (npcInfo.mapId != onMap) + { + return PoAction.Message("Npc不存在!"); + } + + #endregion + + if (string.IsNullOrEmpty(ueId)) + { + var myEqu = await _equService.GetUserOnEqu(userId); + myEqu = myEqu.FindAll(it => + it.isAppr == 1 && it.durability < it.maxdurability && it.useEndTime > TimeExtend.GetTimeStampSeconds); + int need = myEqu.Sum(it => (int)it.maxdurability - (int)it.durability); + if (need < 1) + { + return PoAction.Message("耐久已满,无需恢复!"); + } + + var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + if (need > myAcc) + { + return PoAction.Message("铜贝不足!"); + } + + if (await _accService.UpdateUserCopper(userId, 0, need, "修复装备")) + { + foreach (var item in myEqu) + { + item.durability = item.maxdurability; + await _equService.UpdateUserEquInfo(item); + } + return PoAction.Ok(true, $"恢复成功,花费{need}铜贝!"); + } + else + { + return PoAction.Message("恢复失败,请稍后尝试!"); + } + } + else + { + var equInfo = await _equService.GetUserEquInfo(ueId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.userId != userId) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.isAppr != 1) + { + return PoAction.Message("装备未鉴定!"); + } + + if (equInfo.useEndTime < TimeExtend.GetTimeStampSeconds) + { + return PoAction.Message("装备已过期!"); + } + + if (equInfo.durability >= equInfo.maxdurability) + { + return PoAction.Message("耐久已满,无需恢复!"); + } + + int need = (int)equInfo.maxdurability - (int)equInfo.durability; + var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + if (need > myAcc) + { + return PoAction.Message("铜贝不足!"); + } + + if (await _accService.UpdateUserCopper(userId, 0, need, "修复装备")) + { + equInfo.durability = equInfo.maxdurability; + if (await _equService.UpdateUserEquInfo(equInfo)) + { + return PoAction.Ok(true, $"恢复成功,花费{need}铜贝!"); + } + else + { + return PoAction.Message("恢复失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("恢复失败,请稍后尝试!"); + } + } + + var data = await _attrService.GetUserVigourInfo(userId); string time = TimeAssist.GetDateTimeYMDString(0); if (data.upTime == time) diff --git a/Service/Application.Web/Controllers/Pub/ShipController.cs b/Service/Application.Web/Controllers/Pub/ShipController.cs index e2fcb7c..e241a7d 100644 --- a/Service/Application.Web/Controllers/Pub/ShipController.cs +++ b/Service/Application.Web/Controllers/Pub/ShipController.cs @@ -10,14 +10,14 @@ namespace Application.Web.Controllers.Pub [Authorize] public class ShipController : ControllerBase { - private readonly IUnitUserWeight weightService; - private readonly IGameGoodsService goodsService; - private readonly IUnitUserAccService accService; - public ShipController(IUnitUserWeight _weightService, IGameGoodsService _goodsService, IUnitUserAccService _accService) + private readonly IUnitUserWeight _weightService; + private readonly IUnitUserAccService _accService; + + public ShipController(IUnitUserWeight weightService, + IUnitUserAccService accService) { - accService = _accService; - goodsService = _goodsService; - weightService = _weightService; + _accService = accService; + _weightService = weightService; } /// @@ -28,27 +28,11 @@ namespace Application.Web.Controllers.Pub public async Task GetUserShip() { string userId = StateHelper.userId; - var data = await weightService.GetUserShip(userId); + var data = await _weightService.GetUserShip(userId); //个人负重 - var weightInfo = await weightService.GetUserWeightInfo(userId); - return PoAction.Ok(new { data, weightInfo }); - } - - /// - /// 获取船只详情 - /// - /// - /// - [HttpGet] - public async Task GetShipInfo(int shipId) - { - var data = await goodsService.GetShipInfo(shipId); - if (data == null) - { - return PoAction.Message("船只详情不存在!"); - } - - return PoAction.Ok(new { data }); + var weightInfo = await _weightService.GetUserWeightInfo(userId); + var maxShipWeight = await _weightService.GetUserShipMaxWeight(userId); + return PoAction.Ok(new { data, onShip = weightInfo.shipOnWeight, maxShip = maxShipWeight }); } /// @@ -57,46 +41,25 @@ namespace Application.Web.Controllers.Pub /// /// [HttpPost] - public async Task BuyShip([FromBody] BuyShipParms parms) + public async Task SaleShip([FromBody] BuyShipParms parms) { - var userShip = await weightService.GetUserShipInfo(parms.usId); + var userShip = await _weightService.GetUserShipInfo(parms.usId); if (userShip == null) { return PoAction.Message("船只不存在!"); } + string userId = StateHelper.userId; if (userShip.userId != userId) { return PoAction.Message("船只不存在!"); } - var shipInfo = await goodsService.GetShipInfo((int)userShip.goodsId); - if (shipInfo == null) + + if (await _weightService.DeleteUserShip(userShip.usId, userId)) { - return PoAction.Message("船只信息不存在!"); - } - if (await weightService.DeleteUserShip(userShip.usId, userId)) - { - if (shipInfo.payType == AccEnum.AccType.copper.ToString()) + if (await _accService.UpdateUserCopper(userId, 1, Convert.ToInt64(userShip.sale), "出售船只获得!")) { - if (await accService.UpdateUserCopper(userId, 1, Convert.ToInt64(shipInfo.salePrice), "出售船只获得!")) - { - return PoAction.Ok(new { price = shipInfo.salePrice }); - } - else - { - return PoAction.Message("出售失败!"); - } - } - else if (shipInfo.payType == AccEnum.AccType.gold.ToString()) - { - if (await accService.UpdateUserAcc(userId, 1, AccEnum.AccType.gold.ToString(), Convert.ToInt64(shipInfo.salePrice))) - { - return PoAction.Ok(new { price = shipInfo.salePrice }); - } - else - { - return PoAction.Message("出售失败!"); - } + return PoAction.Ok(new { price = userShip.sale }); } else { @@ -109,4 +72,4 @@ namespace Application.Web.Controllers.Pub } } } -} +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/BagController.cs b/Service/Application.Web/Controllers/User/BagController.cs index 6b150b5..7d8e1c2 100644 --- a/Service/Application.Web/Controllers/User/BagController.cs +++ b/Service/Application.Web/Controllers/User/BagController.cs @@ -24,7 +24,7 @@ public class BagController : ControllerBase _equService = equService; _accService = accService; } - + /// /// 获取背包信息 /// @@ -33,7 +33,6 @@ public class BagController : ControllerBase public async Task GetUserBagData() { string userId = StateHelper.userId; - var accInfo = await _accService.GetUserAccInfo(userId); long gold = (long)accInfo.gold; long cowry = (long)accInfo.cowry; @@ -76,13 +75,13 @@ public class BagController : ControllerBase } var data = await _equService.GetUserEquData(userId, _t, query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value}); } else if (type == 1) { List code = new List() { nameof(GoodsEnum.Code.Drug) }; var data = await _goodsService.GetUserGoodsData(userId, code, new List(), query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value }); } else if (type == 2) { @@ -101,6 +100,7 @@ public class BagController : ControllerBase break; case 4: code.Add(nameof(GoodsEnum.Code.Pack)); + code.Add(nameof(GoodsEnum.Code.ChoicePack)); break; case 5: code.Add(nameof(GoodsEnum.Code.Mak)); @@ -120,11 +120,35 @@ public class BagController : ControllerBase } var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value }); } else { - return PoAction.Ok(new { data = new List(), total.Value }); + return PoAction.Ok(new { data = new List(), total = total.Value }); + } + } + + /// + /// 验证用户道具 + /// + /// + /// + [HttpPost] + public async Task CheckUserProp([FromBody] CheckUserPropParms parms) + { + string userId = StateHelper.userId; + parms.count = parms.count < 1 ? 1 : parms.count; + if (parms.type == 0) + { + List needs = JsonConvert.DeserializeObject>(parms.needs); + var result = await GameBus.CheckNeed(userId, needs, parms.count); + return PoAction.Ok(result); + } + else + { + List needs = JsonConvert.DeserializeObject>(parms.needs); + var result = await GameBus.CheckNeeds(userId, needs, parms.count); + return PoAction.Ok(result); } } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/UserController.cs b/Service/Application.Web/Controllers/User/UserController.cs index c9d4ed1..9ab4b4d 100644 --- a/Service/Application.Web/Controllers/User/UserController.cs +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -17,9 +17,12 @@ public class UserController : ControllerBase private readonly IGameChatService _chatService; private readonly IGameSkillService _skillService; private readonly IGameTeamService _teamService; + private readonly IGameEquService _equService; + public UserController(IUnitUserService userService, IUnitUserAttrService attrService, IUnitUserAccService accService, IGameMapService mapService, IUnitUserRelationService relationService, - IGameGoodsService goodsService, IGameChatService chatService,IGameSkillService skillService,IGameTeamService teamService) + IGameGoodsService goodsService, IGameChatService chatService, IGameSkillService skillService, + IGameTeamService teamService, IGameEquService equService) { _userService = userService; _attrService = attrService; @@ -30,6 +33,7 @@ public class UserController : ControllerBase _chatService = chatService; _skillService = skillService; _teamService = teamService; + _equService = equService; } @@ -50,7 +54,10 @@ public class UserController : ControllerBase var vigourInfo = await _attrService.GetUserVigourInfo(userId); var accInfo = await _accService.GetUserAccInfo(userId); object acc = new { accInfo.gold, accInfo.cowry, accInfo.teach, accInfo.renown }; - object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc }; + + var buff = await _attrService.GetUserStateData(userId, "ALL"); + var stock = await _attrService.GetUserStock(userId); + object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc, buff, stock }; return PoAction.Ok(result); } @@ -87,7 +94,7 @@ public class UserController : ControllerBase var model = await UserModelTool.GetUserView(userId); return PoAction.Ok(model); } - + /// /// 获取基础属性信息 /// @@ -163,7 +170,13 @@ public class UserController : ControllerBase bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId); bool isEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId); var team = await _teamService.GetUserTeamInfo(userInfo.userId); - object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy ,team}; + + var equ = await _equService.GetUserOnEqu(userInfo.userId); + var suit = await _equService.GetUserEquSuit(userInfo.userId); + object result = new + { + user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ, suit + }; return PoAction.Ok(result); } @@ -284,16 +297,134 @@ public class UserController : ControllerBase return PoAction.Message("操作失败,请稍后尝试!"); } } - + /// /// 获取用户技能 /// /// [HttpGet] - public async TaskGetUserSkill() + public async Task GetUserSkill() { var userId = StateHelper.userId; var data = await _skillService.GetUserSkill(userId); return PoAction.Ok(data); } + + /// + /// 获取个人药品栏 + /// + /// + [HttpGet] + public async Task GetUserDrugColumn() + { + string userId = StateHelper.userId; + var data = await _attrService.GetUserDrug(userId); + return PoAction.Ok(data.drug); + } + + /// + /// 移除药品栏药品 + /// + /// + /// + [HttpGet] + public async Task RemoverUserDrug(string id) + { + string userId = StateHelper.userId; + var data = await _attrService.GetUserDrug(userId); + var onDrug = data.drug.Find(it => it.id == id); + if (onDrug == null) + { + return PoAction.Message("药品栏无此药品!"); + } + + data.drug.Remove(onDrug); + if (await _attrService.UpdateUserDrug(data)) + { + if (onDrug.count > 0) + { + await _goodsService.UpdateUserGoods(userId, 1, onDrug.goodsId, onDrug.count, "药品栏移除,退回背包"); + } + + return PoAction.Ok(true); + } + else + { + return PoAction.Message("移除失败!"); + } + } + + /// + /// 添加到药品栏 + /// + /// + /// + [HttpGet] + public async Task AddUserDrug(int goodsId, int count) + { + count = count < 1 ? 1 : count; + count = count > 999 ? 999 : count; + string userId = StateHelper.userId; + var myGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId); + if (myGoods == null) + { + return PoAction.Message("暂无该物品!"); + } + + if (myGoods.count < count) + { + return PoAction.Message("物品数量不足!"); + } + + if (myGoods.code != nameof(GoodsEnum.Code.Drug)) + { + return PoAction.Message("该物品无法置放到药品栏!"); + } + + bool isAdd = false; + var myDrug = await _attrService.GetUserDrug(userId); + var onDrug = myDrug.drug.Find(it => it.goodsId == goodsId); + if (onDrug == null) + { + if (myDrug.drug.Count >= 5) + { + return PoAction.Message("药品栏最多添加5个药品!"); + } + + isAdd = true; + } + + if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "放置到药品栏")) + { + if (isAdd) + { + UserDrugModel temp = new UserDrugModel(); + temp.id = StringAssist.NewGuid; + temp.goodsId = goodsId; + temp.name = myGoods.goodsName; + temp.code = "Blood"; + temp.count = count; + myDrug.drug.Add(temp); + } + else + { + myDrug.drug.Remove(onDrug); + onDrug.count += count; + myDrug.drug.Add(onDrug); + } + + if (await _attrService.UpdateUserDrug(myDrug)) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("添加失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("添加失败,请稍后尝试!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/GlobalUsings.cs b/Service/Application.Web/GlobalUsings.cs index 7482651..09c4cb9 100644 --- a/Service/Application.Web/GlobalUsings.cs +++ b/Service/Application.Web/GlobalUsings.cs @@ -13,5 +13,4 @@ global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Mvc; global using Application.Web; - \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/Equ/EquUpParms.cs b/Service/Application.Web/Model/RequestParms/Equ/EquUpParms.cs new file mode 100644 index 0000000..e20f461 --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/Equ/EquUpParms.cs @@ -0,0 +1,7 @@ +namespace Application.Web; + +public class EquUpParms +{ + public string ueId { get; set; } + public string needs { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/Fight/FightMonsterParms.cs b/Service/Application.Web/Model/RequestParms/Fight/FightMonsterParms.cs new file mode 100644 index 0000000..cfa5fe1 --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/Fight/FightMonsterParms.cs @@ -0,0 +1,8 @@ +namespace Application.Web; + +public class FightMonsterParms +{ + public int type { get; set; } + public string monsterId { get; set; } + public string sign { get; set; } +} \ 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 new file mode 100644 index 0000000..394459c --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/Fight/FightParms.cs @@ -0,0 +1,6 @@ +namespace Application.Web; + +public class FightParms +{ + public string fightId { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs b/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs new file mode 100644 index 0000000..1d9788e --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs @@ -0,0 +1,8 @@ +namespace Application.Web; + +public class CheckUserPropParms +{ + public int type { get; set; } + public int count { get; set; } + public string needs { get; set; } +} \ No newline at end of file diff --git a/Web/package-lock.json b/Web/package-lock.json index 0fec814..e06cb01 100644 --- a/Web/package-lock.json +++ b/Web/package-lock.json @@ -1856,9 +1856,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1876,9 +1873,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1896,9 +1890,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1916,9 +1907,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1936,9 +1924,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1956,9 +1941,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1976,9 +1958,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1996,9 +1975,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2220,9 +2196,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2240,9 +2213,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2260,9 +2230,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2280,9 +2247,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2300,9 +2264,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2320,9 +2281,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2340,9 +2298,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2360,9 +2315,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2594,9 +2546,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2614,9 +2563,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2634,9 +2580,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2654,9 +2597,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2674,9 +2614,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2694,9 +2631,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2714,9 +2648,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2734,9 +2665,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2959,9 +2887,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2983,9 +2908,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3007,9 +2929,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3031,9 +2950,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3055,9 +2971,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3079,9 +2992,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3572,9 +3482,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3589,9 +3496,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3606,9 +3510,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3623,9 +3524,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3640,9 +3538,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3657,9 +3552,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3674,9 +3566,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3691,9 +3580,6 @@ "ppc64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3708,9 +3594,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3725,9 +3608,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3742,9 +3622,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3759,9 +3636,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3776,9 +3650,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ diff --git a/Web/public/images/broad/award.gif b/Web/public/images/broad/award.gif new file mode 100644 index 0000000..c1c151b Binary files /dev/null and b/Web/public/images/broad/award.gif differ diff --git a/Web/public/images/broad/gift.gif b/Web/public/images/broad/gift.gif new file mode 100644 index 0000000..8e75525 Binary files /dev/null and b/Web/public/images/broad/gift.gif differ diff --git a/Web/public/images/broad/hot1.gif b/Web/public/images/broad/hot1.gif new file mode 100644 index 0000000..5d6d015 Binary files /dev/null and b/Web/public/images/broad/hot1.gif differ diff --git a/Web/public/images/broad/promote.gif b/Web/public/images/broad/promote.gif new file mode 100644 index 0000000..f86aca1 Binary files /dev/null and b/Web/public/images/broad/promote.gif differ diff --git a/Web/public/images/broad/remind.gif b/Web/public/images/broad/remind.gif new file mode 100644 index 0000000..b667ccd Binary files /dev/null and b/Web/public/images/broad/remind.gif differ diff --git a/Web/public/images/broad/system.gif b/Web/public/images/broad/system.gif new file mode 100644 index 0000000..aeff515 Binary files /dev/null and b/Web/public/images/broad/system.gif differ diff --git a/Web/public/images/equ/gw.png b/Web/public/images/equ/gw.png new file mode 100644 index 0000000..f312486 Binary files /dev/null and b/Web/public/images/equ/gw.png differ diff --git a/Web/public/images/equ/hm.gif b/Web/public/images/equ/hm.gif new file mode 100644 index 0000000..617119b Binary files /dev/null and b/Web/public/images/equ/hm.gif differ diff --git a/Web/public/images/equ/l.gif b/Web/public/images/equ/l.gif new file mode 100644 index 0000000..ccb64a8 Binary files /dev/null and b/Web/public/images/equ/l.gif differ diff --git a/Web/public/images/equ/ly.gif b/Web/public/images/equ/ly.gif new file mode 100644 index 0000000..0b0f091 Binary files /dev/null and b/Web/public/images/equ/ly.gif differ diff --git a/Web/public/images/equ/ms.png b/Web/public/images/equ/ms.png new file mode 100644 index 0000000..7c48fcd Binary files /dev/null and b/Web/public/images/equ/ms.png differ diff --git a/Web/public/images/equ/r.gif b/Web/public/images/equ/r.gif new file mode 100644 index 0000000..d4c6282 Binary files /dev/null and b/Web/public/images/equ/r.gif differ diff --git a/Web/public/images/equ/sy.png b/Web/public/images/equ/sy.png new file mode 100644 index 0000000..745b18c Binary files /dev/null and b/Web/public/images/equ/sy.png differ diff --git a/Web/public/images/equ/tq.png b/Web/public/images/equ/tq.png new file mode 100644 index 0000000..13c5e37 Binary files /dev/null and b/Web/public/images/equ/tq.png differ diff --git a/Web/public/images/equ/ty.png b/Web/public/images/equ/ty.png new file mode 100644 index 0000000..a9f3e11 Binary files /dev/null and b/Web/public/images/equ/ty.png differ diff --git a/Web/public/images/equ/zx.png b/Web/public/images/equ/zx.png new file mode 100644 index 0000000..3d9d9e6 Binary files /dev/null and b/Web/public/images/equ/zx.png differ diff --git a/Web/src/assets/css/style.css b/Web/src/assets/css/style.css index 15de8d8..5f7ee99 100644 --- a/Web/src/assets/css/style.css +++ b/Web/src/assets/css/style.css @@ -19,7 +19,9 @@ body { font-size: 18px; } -.main {} +.main { + margin: 5px 2px; +} div img { @@ -106,9 +108,11 @@ a:focus { margin-right: 2px; vertical-align: middle; } + .border-btm { border-bottom: 1px solid #E3E6EB; } + .input { line-height: 30px; } @@ -124,30 +128,33 @@ a:focus { border: 1px solid #ccc; border-radius: 4px; box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%); - transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; } + .ipt-btn-gray-m { width: 60px; height: 20px; border: none; } -.serch{ - display: flex; + +.serch { + display: flex; align-items: flex-end; } -.search-ipt{ + +.search-ipt { width: 80px; font-size: 11px; - padding: 0 ; + padding: 0; } -.ipt-btn{ +.ipt-btn { width: 61px; height: 21px; font-size: 13px; border: none; margin-top: 5px; - background: url(/css/images/btn_b_gold.gif) no-repeat; + background: url(/css/images/btn_b_gold.gif) no-repeat; color: #af4c00; } @@ -155,14 +162,16 @@ a:focus { word-wrap: break-word; } - .chat img { - margin-right: 2px; - vertical-align: middle; - } +.chat img { + margin-right: 2px; + vertical-align: middle; +} + .em { height: 30px; width: 30px; } + .badge { max-height: 25px; max-width: 25px; @@ -205,3 +214,141 @@ a:focus { background: 0 0; color: #666; } + +/******装备样式******/ +.equImg { + max-width: 130px; + max-height: 230px; +} + +.tq { + background-image: url('/images/equ/tq.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.ty { + background-image: url('/images/equ/ty.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.ms { + background-image: url('/images/equ/ms.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.zx { + background-image: url('/images/equ/zx.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.sy { + background-image: url('/images/equ/sy.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.gw { + background-image: url('/images/equ/gw.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.ly { + background-image: url('/images/equ/ly.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.hm { + background-image: url('/images/equ/hm.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.j_r { + background-image: url('/images/equ/r.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.j_l { + background-image: url('/images/equ/l.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.equ_red { + color: #912334; +} + +.equ_orange { + color: #c75e18; +} + +.equ_yellow { + color: #c28a10; +} + +.equ_green { + color: #2f9130; +} + +.equ_cyan { + color: #269680; +} + +.equ_blue { + color: #c94868; +} + +.equ_purple { + color: #873ea1; +} + +.equ_glod { + color: #e6b020; +} \ No newline at end of file diff --git a/Web/src/components/Base/Abar.vue b/Web/src/components/Base/Abar.vue index d87a99b..45ff170 100644 --- a/Web/src/components/Base/Abar.vue +++ b/Web/src/components/Base/Abar.vue @@ -1,5 +1,5 @@ diff --git a/Web/src/components/Base/Abutton.vue b/Web/src/components/Base/Abutton.vue index d487b6e..497b716 100644 --- a/Web/src/components/Base/Abutton.vue +++ b/Web/src/components/Base/Abutton.vue @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/Web/src/components/Business/GameBroadcast.vue b/Web/src/components/Business/GameBroadcast.vue new file mode 100644 index 0000000..aa5778f --- /dev/null +++ b/Web/src/components/Business/GameBroadcast.vue @@ -0,0 +1,408 @@ + + + \ No newline at end of file diff --git a/Web/src/components/Business/GameEqu.vue b/Web/src/components/Business/GameEqu.vue new file mode 100644 index 0000000..67e3fdc --- /dev/null +++ b/Web/src/components/Business/GameEqu.vue @@ -0,0 +1,25 @@ + + \ No newline at end of file diff --git a/Web/src/components/Business/GamePopup.vue b/Web/src/components/Business/GamePopup.vue index 5f766b7..5feba96 100644 --- a/Web/src/components/Business/GamePopup.vue +++ b/Web/src/components/Business/GamePopup.vue @@ -17,7 +17,10 @@ const props = defineProps({ // 字段名、类型、默认值 - isShow: Boolean, + isShow: { + type: Boolean, + default: false + }, title: String }) const visible = ref(props.isShow) diff --git a/Web/src/components/Business/GamePropVerify.vue b/Web/src/components/Business/GamePropVerify.vue new file mode 100644 index 0000000..02255c2 --- /dev/null +++ b/Web/src/components/Business/GamePropVerify.vue @@ -0,0 +1,18 @@ + + \ No newline at end of file diff --git a/Web/src/components/Page/Footer.vue b/Web/src/components/Page/Footer.vue index 3eb1bff..886a951 100644 --- a/Web/src/components/Page/Footer.vue +++ b/Web/src/components/Page/Footer.vue @@ -5,7 +5,7 @@ 首页- 挂机- - 反馈 + 反馈
diff --git a/Web/src/config/BaseConfig.ts b/Web/src/config/BaseConfig.ts index 5ef10a7..8f881cf 100644 --- a/Web/src/config/BaseConfig.ts +++ b/Web/src/config/BaseConfig.ts @@ -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://kx.iyba.cn:5291"; -// public static BaseMediaUrl:string="http://kx.iyba.cn:5291"; -} \ No newline at end of file + public static BaseUrl: string = 'https://localhost:7198' + public static BaseMediaUrl: string = 'https://localhost:7198/' + // public static BaseUrl:string="http://kx.iyba.cn:5291"; + // public static BaseMediaUrl:string="http://kx.iyba.cn:5291"; +} diff --git a/Web/src/extends/MessageExtend.ts b/Web/src/extends/MessageExtend.ts index 09dbf81..e86434d 100644 --- a/Web/src/extends/MessageExtend.ts +++ b/Web/src/extends/MessageExtend.ts @@ -3,11 +3,11 @@ */ export class MessageExtend { // 消息通知 - static Notify(message: any, type?: 'primary' | 'success' | 'danger' | 'warning') { + static Notify(message: any, type?: 'primary' | 'success' | 'danger' | 'warning', time?: number) { showNotify({ type: type, message: message, - duration: 1500, + duration: time || 1500, }); } diff --git a/Web/src/extends/PageExtend.ts b/Web/src/extends/PageExtend.ts index 5acfcc1..2cde0c1 100644 --- a/Web/src/extends/PageExtend.ts +++ b/Web/src/extends/PageExtend.ts @@ -7,6 +7,10 @@ export class PageExtend { navigateTo(route, { replace: true }) } + public static GetPath(): string { + const route = useRoute() + return route.fullPath; + } public static QueryString(params: string): string { const route = useRoute() const value = route.query[params] diff --git a/Web/src/extends/TimeExtend.ts b/Web/src/extends/TimeExtend.ts index 192bb96..4846fa8 100644 --- a/Web/src/extends/TimeExtend.ts +++ b/Web/src/extends/TimeExtend.ts @@ -1,100 +1,115 @@ export class TimeExtend { - /** - * 格式化日期 - * @param date 日期对象/时间戳/日期字符串 - * @param format 格式化模板 - * 示例:yyyy-MM-dd、yyyy-MM-dd HH:mm:ss、HH:mm:ss、yyyy年MM月dd日 - */ - public static Format(date: Date | string | number, format = 'yyyy-MM-dd HH:mm:ss'): string { - let targetDate: Date - if (typeof date === 'number') { - date = date - 28800; - targetDate = date.toString().length === 10 ? new Date(date * 1000) : new Date(date) - } else { - targetDate = new Date(date) - } - - if (isNaN(targetDate.getTime())) return '' - - const year = targetDate.getFullYear() - const month = targetDate.getMonth() + 1 - const day = targetDate.getDate() - const hours = targetDate.getHours() - const minutes = targetDate.getMinutes() - const seconds = targetDate.getSeconds() - - const pad = (num: number) => num.toString().padStart(2, '0') - - return format - .replace('yyyy', String(year)) - .replace('MM', pad(month)) - .replace('dd', pad(day)) - .replace('HH', pad(hours)) - .replace('hh', pad(hours > 12 ? hours - 12 : hours)) - .replace('mm', pad(minutes)) - .replace('ss', pad(seconds)) + /** + * 格式化日期 + * @param date 日期对象/时间戳/日期字符串 + * @param format 格式化模板 + * 示例:yyyy-MM-dd、yyyy-MM-dd HH:mm:ss、HH:mm:ss、yyyy年MM月dd日 + */ + public static Format(date: Date | string | number, format = 'yyyy-MM-dd HH:mm:ss'): string { + let targetDate: Date + if (typeof date === 'number') { + date = date - 28800 + targetDate = date.toString().length === 10 ? new Date(date * 1000) : new Date(date) + } else { + targetDate = new Date(date) } - /** - * 获取当前时间格式化字符串 - * @param format 格式 - */ - public static Now(format = 'yyyy-MM-dd HH:mm:ss'): string { - return this.Format(new Date(), format) - } + if (isNaN(targetDate.getTime())) return '' - /** - * 获取当前毫秒时间戳 - */ - public static GetTimeStamp(): number { - return Date.now() - } + const year = targetDate.getFullYear() + const month = targetDate.getMonth() + 1 + const day = targetDate.getDate() + const hours = targetDate.getHours() + const minutes = targetDate.getMinutes() + const seconds = targetDate.getSeconds() - /** - * 获取当前秒级时间戳 - */ - public static GetSecondStamp(): number { - return Math.floor(Date.now() / 1000) + 28800 - } + const pad = (num: number) => num.toString().padStart(2, '0') - /** - * 获取当前日期 yyyy-MM-dd - */ - public static GetDateStr(): string { - return this.Now('yyyy-MM-dd') - } + return format + .replace('yyyy', String(year)) + .replace('MM', pad(month)) + .replace('dd', pad(day)) + .replace('HH', pad(hours)) + .replace('hh', pad(hours > 12 ? hours - 12 : hours)) + .replace('mm', pad(minutes)) + .replace('ss', pad(seconds)) + } - /** - * 获取当前时分秒 HH:mm:ss - */ - public static GetTimeStr(): string { - return this.Now('HH:mm:ss') - } + /** + * 获取当前时间格式化字符串 + * @param format 格式 + */ + public static Now(format = 'yyyy-MM-dd HH:mm:ss'): string { + return this.Format(new Date(), format) + } - /** - * 时间字符串 转换为 指定格式字符串 - * 场景:把 "2025-01-01 12:30:45" 转成 "2025年01月01日" / "01-01 12:30" 等 - * @param timeStr 时间字符串(如 2025-01-01、2025/01/01 12:30、2025-01-01 12:30:45) - * @param format 目标格式 - */ - public static StrToFormat(timeStr: string, format = 'yyyy-MM-dd HH:mm:ss'): string { - return this.Format(timeStr, format); - } - /** - * 时间字符串 转 日期对象 - * @param timeStr 时间字符串 - */ - public static StrToDate(timeStr: string): Date | null { - const date = new Date(timeStr); - return isNaN(date.getTime()) ? null : date; - } + /** + * 获取当前毫秒时间戳 + */ + public static GetTimeStamp(): number { + return Date.now() + } - /** - * 时间字符串 转 秒级时间戳 - * @param timeStr 时间字符串 - */ - public static StrToSecondStamp(timeStr: string): number | null { - const date = this.StrToDate(timeStr); - return date ? Math.floor(date.getTime() / 1000) : null; + /** + * 获取当前秒级时间戳 + */ + public static GetSecondStamp(): number { + return Math.floor(Date.now() / 1000) + 28800 + } + + /** + * 获取当前日期 yyyy-MM-dd + */ + public static GetDateStr(): string { + return this.Now('yyyy-MM-dd') + } + + /** + * 获取当前时分秒 HH:mm:ss + */ + public static GetTimeStr(): string { + return this.Now('HH:mm:ss') + } + + /** + * 时间字符串 转换为 指定格式字符串 + * 场景:把 "2025-01-01 12:30:45" 转成 "2025年01月01日" / "01-01 12:30" 等 + * @param timeStr 时间字符串(如 2025-01-01、2025/01/01 12:30、2025-01-01 12:30:45) + * @param format 目标格式 + */ + public static StrToFormat(timeStr: string, format = 'yyyy-MM-dd HH:mm:ss'): string { + return this.Format(timeStr, format) + } + /** + * 时间字符串 转 日期对象 + * @param timeStr 时间字符串 + */ + public static StrToDate(timeStr: string): Date | null { + const date = new Date(timeStr) + return isNaN(date.getTime()) ? null : date + } + + /** + * 时间字符串 转 秒级时间戳 + * @param timeStr 时间字符串 + */ + public static StrToSecondStamp(timeStr: string): number | null { + const date = this.StrToDate(timeStr) + return date ? Math.floor(date.getTime() / 1000) : null + } + + /** + * 计算目标时间与当前时间的剩余分钟数 + * @param timeStr 时间字符串 + */ + public static GetRemainingMinutes(timeStr: string): number { + const target = new Date(timeStr.replace(/-/g, '/')) + const now = new Date() + const diffMs = target.getTime() - now.getTime() + if (Math.floor(diffMs / 1000 / 60) <= 0) { + return 0 + } else { + return Math.floor(diffMs / 1000 / 60) } -} \ No newline at end of file + } +} diff --git a/Web/src/layouts/empty.vue b/Web/src/layouts/empty.vue index fd6766c..cc89a40 100644 --- a/Web/src/layouts/empty.vue +++ b/Web/src/layouts/empty.vue @@ -1,11 +1,12 @@ - \ No newline at end of file diff --git a/Web/src/pages/user/bag/drug.vue b/Web/src/pages/user/bag/drug.vue new file mode 100644 index 0000000..1db9e16 --- /dev/null +++ b/Web/src/pages/user/bag/drug.vue @@ -0,0 +1,67 @@ + + \ 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 e749c2f..5fafd37 100644 --- a/Web/src/pages/user/bag/index.vue +++ b/Web/src/pages/user/bag/index.vue @@ -1,19 +1,23 @@ diff --git a/Web/src/pages/user/ship/index.vue b/Web/src/pages/user/ship/index.vue index 0061996..29875c8 100644 --- a/Web/src/pages/user/ship/index.vue +++ b/Web/src/pages/user/ship/index.vue @@ -1,10 +1,10 @@