2222
This commit is contained in:
72
Service/Application.Domain/Tool/Base/GameBus.cs
Normal file
72
Service/Application.Domain/Tool/Base/GameBus.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class GameBus
|
||||
{
|
||||
#region 物品资源操作
|
||||
|
||||
public static async Task<bool> UpdateBag(string userId, int operate, string goodsType, string parameter, long count,
|
||||
string remark)
|
||||
{
|
||||
bool isok = false;
|
||||
if (goodsType.Equals(nameof(GameEnum.PropCode.Goods)))
|
||||
{
|
||||
var goodsService = App.GetService<IGameGoodsService>();
|
||||
isok = await goodsService.UpdateUserGoods(userId, operate, Convert.ToInt32(parameter), (int)count, remark);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.Equ)))
|
||||
{
|
||||
var equService = App.GetService<IGameEquService>();
|
||||
if (operate == 1)
|
||||
{
|
||||
isok = await equService.AddUserEqu(userId, Convert.ToInt32(parameter), (int)count, remark);
|
||||
}
|
||||
else
|
||||
{
|
||||
isok = await equService.DeductUserEqu(userId, Convert.ToInt32(parameter), (int)count, remark);
|
||||
}
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.copper)))
|
||||
{
|
||||
var accService = App.GetService<IUnitUserAccService>();
|
||||
isok = await accService.UpdateUserCopper(userId, operate, count);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.gold)))
|
||||
{
|
||||
var accService = App.GetService<IUnitUserAccService>();
|
||||
isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.gold), count,
|
||||
nameof(AccEnum.Name.其他), remark);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.cowry)))
|
||||
{
|
||||
var accService = App.GetService<IUnitUserAccService>();
|
||||
isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.cowry), count,
|
||||
nameof(AccEnum.Name.其他), remark);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.vigour)))
|
||||
{
|
||||
var attrService = App.GetService<IUnitUserAttrService>();
|
||||
isok = await attrService.UpdateUserVigour(userId, operate, count);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.exp)))
|
||||
{
|
||||
var attrService = App.GetService<IUnitUserAttrService>();
|
||||
isok = await attrService.UpdateUserExp(userId, count, operate);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.renown)))
|
||||
{
|
||||
var accService = App.GetService<IUnitUserAccService>();
|
||||
isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.renown), count,
|
||||
nameof(AccEnum.Name.其他), remark);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.teach)))
|
||||
{
|
||||
var accService = App.GetService<IUnitUserAccService>();
|
||||
isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.teach), count,
|
||||
nameof(AccEnum.Name.其他), remark);
|
||||
}
|
||||
|
||||
return isok;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
namespace Application.Domain;
|
||||
namespace Application.Domain;
|
||||
|
||||
public class GameTool
|
||||
{
|
||||
@@ -21,6 +20,7 @@ public class GameTool
|
||||
data.levUpdate = TimeExtend.GetTimeStampSeconds;
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取等级升级经验
|
||||
/// </summary>
|
||||
@@ -32,10 +32,59 @@ public class GameTool
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool AreaVerify( int area,string areas)
|
||||
public static bool AreaVerify(int area, string areas)
|
||||
{
|
||||
List<string> onArea = new List<string>() {"0",area.ToString() };
|
||||
List<string> onArea = new List<string>() { "0", area.ToString() };
|
||||
return onArea.Any(it => areas.Contains(it));
|
||||
}
|
||||
|
||||
|
||||
public static string GetCurrencyName(string payCode)
|
||||
{
|
||||
string result = "";
|
||||
switch (payCode)
|
||||
{
|
||||
case "gold":
|
||||
result = "金元";
|
||||
break;
|
||||
case "cowry":
|
||||
result = "金贝";
|
||||
break;
|
||||
case "copper":
|
||||
result = "铜贝";
|
||||
break;
|
||||
case "teach":
|
||||
result = "师德";
|
||||
break;
|
||||
case "renown":
|
||||
result = "声望";
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<int> GetPropWeight(string goodsType, string parameter)
|
||||
{
|
||||
int weight = 0;
|
||||
if (goodsType.Equals(nameof(GameEnum.PropCode.Goods)))
|
||||
{
|
||||
var goodsService = App.GetService<IGameGoodsService>();
|
||||
var info = await goodsService.GetGoodsInfo(Convert.ToInt32(parameter));
|
||||
if (info != null)
|
||||
{
|
||||
weight = (int)info.weight;
|
||||
}
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.Equ)))
|
||||
{
|
||||
var equService = App.GetService<IGameEquService>();
|
||||
var info = await equService.GetEquInfo(Convert.ToInt32(parameter));
|
||||
if (info != null)
|
||||
{
|
||||
weight = (int)info.weight;
|
||||
}
|
||||
}
|
||||
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user