mirror of
https://github.com/oshima-studios/OshimaGameModule.git
synced 2025-12-05 08:09:04 +00:00
完善报价;优化抽卡
This commit is contained in:
parent
0f2b8f6321
commit
08f9a4fe26
@ -40,6 +40,8 @@
|
||||
智慧之果 = 18005,
|
||||
奥术符文 = 18006,
|
||||
混沌之核 = 18007,
|
||||
奖券 = 18008,
|
||||
十连奖券 = 18009
|
||||
}
|
||||
|
||||
public enum GiftBoxID : long
|
||||
|
||||
13
OshimaModules/Items/SpecialItem/十连奖券.cs
Normal file
13
OshimaModules/Items/SpecialItem/十连奖券.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Oshima.FunGame.OshimaModules.Items
|
||||
{
|
||||
public class 十连奖券() : Item(ItemType.SpecialItem)
|
||||
{
|
||||
public override long Id => (long)SpecialItemID.十连奖券;
|
||||
public override string Name => "十连奖券";
|
||||
public override string Description => "进行十连抽卡时,优先使用十连奖券替代金币。";
|
||||
public override QualityType QualityType => QualityType.Purple;
|
||||
}
|
||||
}
|
||||
13
OshimaModules/Items/SpecialItem/奖券.cs
Normal file
13
OshimaModules/Items/SpecialItem/奖券.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Oshima.FunGame.OshimaModules.Items
|
||||
{
|
||||
public class 奖券() : Item(ItemType.SpecialItem)
|
||||
{
|
||||
public override long Id => (long)SpecialItemID.奖券;
|
||||
public override string Name => "奖券";
|
||||
public override string Description => "进行抽卡时,优先使用奖券替代金币。";
|
||||
public override QualityType QualityType => QualityType.Blue;
|
||||
}
|
||||
}
|
||||
@ -49,6 +49,8 @@ namespace Oshima.FunGame.OshimaModules
|
||||
(long)SpecialItemID.智慧之果 => new 智慧之果(),
|
||||
(long)SpecialItemID.奥术符文 => new 奥术符文(),
|
||||
(long)SpecialItemID.混沌之核 => new 混沌之核(),
|
||||
(long)SpecialItemID.奖券 => new 奖券(),
|
||||
(long)SpecialItemID.十连奖券 => new 十连奖券(),
|
||||
(long)ConsumableID.小回复药 => new 小回复药(),
|
||||
(long)ConsumableID.中回复药 => new 中回复药(),
|
||||
(long)ConsumableID.大回复药 => new 大回复药(),
|
||||
|
||||
@ -14,6 +14,8 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
public const int ItemsPerPage2 = 10;
|
||||
public const int ExploreTime = 2;
|
||||
public const int MaxExploreTimes = 60;
|
||||
public const int DrawCardReduce = 1000;
|
||||
public const int DrawCardReduce_Material = 5;
|
||||
public static List<Character> Characters { get; } = [];
|
||||
public static List<Skill> Skills { get; } = [];
|
||||
public static List<Skill> PassiveSkills { get; } = [];
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
};
|
||||
|
||||
public static Dictionary<string, string> CharacterHelp { get; } = new() {
|
||||
{"我角色 [序号]", "查看角色简略信息(默认1)"},
|
||||
{"我的角色 [序号]", "查看角色详细信息(默认1)"},
|
||||
{"设置主战 <序号>", "将指定角色设置为主战"},
|
||||
{"我角色 [角色序号]", "查看角色简略信息(默认1)"},
|
||||
{"我的角色 [角色序号]", "查看角色详细信息(默认1)"},
|
||||
{"设置主战 <角色序号>", "将指定角色设置为主战"},
|
||||
{"我的主战", "查看当前主战角色"},
|
||||
{"开启练级 [角色序号]", "启动练级模式"},
|
||||
{"练级结算", "收取练级奖励"},
|
||||
{"练级结算", "收取练级奖励,并且回血和复活"},
|
||||
{"练级信息", "查看练级进度"},
|
||||
{"我的状态", "查看主战角色状态"},
|
||||
{"装备 <角色序号> <物品序号>", "装备指定物品给角色"},
|
||||
@ -30,8 +30,8 @@
|
||||
{"角色改名", "修改角色名字"},
|
||||
{"我的小队", "查看小队角色名单"},
|
||||
{"设置小队 <{序号...}>", "设置小队角色(1-4个参数)"},
|
||||
{"小队添加 <序号>", "将角色加入小队"},
|
||||
{"小队移除 <序号>", "将角色移出小队"},
|
||||
{"小队添加 <角色序号>", "将角色加入小队"},
|
||||
{"小队移除 <角色序号>", "将角色移出小队"},
|
||||
{"小队状态", "查看小队所有角色状态"},
|
||||
{"清空小队", "清空所有小队成员"},
|
||||
{"生命之泉", "使用金币回复角色状态"},
|
||||
@ -43,26 +43,26 @@
|
||||
{"分类库存 <索引> [页码]", "按索引分类查看物品"},
|
||||
{"物品库存 [页码]", "显示库存中所有物品"},
|
||||
{"角色库存 [页码]", "显示库存中所有角色"},
|
||||
{"我的物品 <序号>", "查看指定物品详细信息"},
|
||||
{"我的物品 <物品序号>", "查看指定物品详细信息"},
|
||||
{"抽卡/十连抽卡", "金币抽卡(1000/次)"},
|
||||
{"材料抽卡/材料十连抽卡", "材料抽卡(5/次)"},
|
||||
{"兑换金币 <材料数>", "1材料=200金币"},
|
||||
{"使用 <名称> <数量> [角色] [角色序号]", "使用物品(可指定角色)举例:使用大经验书 100 角色1"},
|
||||
{"使用 <序号> [角色] [角色序号]", "使用物品(可指定角色)"},
|
||||
{"使用 <物品名称> <数量> [角色] [角色序号]", "使用物品(可指定角色)举例:使用大经验书 100 角色1"},
|
||||
{"使用 <物品序号> [使用次数] [角色] [角色序号]", "使用物品(可指定角色)"},
|
||||
{"使用魔法卡 <物品序号> <卡包序号>", "使用指定魔法卡"},
|
||||
{"合成魔法卡 <{序号...}>", "3张魔法卡合成(空格隔开)"},
|
||||
{"分解物品 <{序号...}>", "分解指定物品"},
|
||||
{"分解 <名称> <数量>", "分解指定数量物品"},
|
||||
{"品质分解 <品质索引>", "按品质分解(0-6)"},
|
||||
{"合成魔法卡 <{物品序号...}>", "3张魔法卡合成(空格隔开)"},
|
||||
{"分解物品 <{物品序号...}>", "分解指定物品"},
|
||||
{"分解 <物品名称> <数量>", "分解指定数量物品"},
|
||||
{"品质分解 <品质索引>", "按品质分解(0-6:普通/优秀/稀有/史诗/传说/神话/不朽)"},
|
||||
};
|
||||
|
||||
public static Dictionary<string, string> BattleHelp { get; } = new() {
|
||||
{"决斗 <对方UID/昵称>", "和对方切磋(简化版)"},
|
||||
{"完整决斗 <对方UID/昵称>", "和对方切磋(完整版)"},
|
||||
{"小队决斗 <对方UID/昵称>", "小队切磋"},
|
||||
{"查询boss [序号]", "查看boss信息(默认列表)"},
|
||||
{"讨伐boss <序号>", "主战角色讨伐指定boss"},
|
||||
{"小队讨伐boss <序号>", "小队讨伐指定boss"},
|
||||
{"查询boss [boss序号]", "查看boss信息(缺省返回列表)"},
|
||||
{"讨伐boss <boss序号>", "主战角色讨伐指定boss"},
|
||||
{"小队讨伐boss <boss序号>", "小队讨伐指定boss"},
|
||||
{"开启练级 [角色序号]", "启动练级模式"},
|
||||
{"练级结算", "收取练级奖励,并且回血和复活"},
|
||||
{"练级信息", "查看练级进度"},
|
||||
@ -71,42 +71,74 @@
|
||||
|
||||
public static Dictionary<string, string> QuestHelp { get; } = new() {
|
||||
{"任务列表", "查看今日任务列表"},
|
||||
{"做任务 <序号>", "开始指定任务"},
|
||||
{"做任务 <任务序号>", "开始指定任务"},
|
||||
{"任务信息", "查看进行中任务详情"},
|
||||
{"任务结算", "结算进行中的任务"},
|
||||
{"任务结算", "结算所有未完成的任务"},
|
||||
{"世界地图", "查看当前地图"},
|
||||
{"主城", "查看主城信息"},
|
||||
{"查地区 <序号>", "查看指定地区信息"},
|
||||
{"探索 <地区序号> <{角色序号...}>", "探索指定地区(可多角色)"}
|
||||
{"查地区 <地区序号>", "查看指定地区信息"},
|
||||
{"探索 <地区序号> <{角色序号...}>", "探索指定地区(可多角色)"},
|
||||
{"探索结算", "结算所有未完成的探索"},
|
||||
};
|
||||
|
||||
public static Dictionary<string, string> ClubHelp { get; } = new() {
|
||||
{"我的社团", "查看社团信息"},
|
||||
{"加入社团 <编号>", "申请加入社团"},
|
||||
{"加入社团 <社团序号>", "申请加入社团"},
|
||||
{"退出社团", "退出当前社团"},
|
||||
{"创建社团 <前缀>", "创建一个公开社团,若指令中包含私密一词,将创建私密社团\r\n社团前缀:3-4个字符,允许:英文字母和数字、部分特殊字符"},
|
||||
{"查看社团成员", "查看社团成员列表"},
|
||||
{"查看社团管理", "查看管理员列表"},
|
||||
{"查看申请人列表", "查看申请加入的玩家列表"},
|
||||
{"解散社团", "解散当前社团"},
|
||||
{"社团批准 <@对方>", "批准加入申请"},
|
||||
{"社团拒绝 <@对方>", "拒绝加入申请"},
|
||||
{"社团踢出 <@对方>", "踢出社团成员"},
|
||||
{"社团转让 <@对方>", "转让社团所有权"},
|
||||
{"社团批准 <对方UID>", "批准加入申请"},
|
||||
{"社团拒绝 <对方UID>", "拒绝加入申请"},
|
||||
{"社团踢出 <对方UID>", "踢出社团成员"},
|
||||
{"社团转让 <对方UID>", "转让社团所有权"},
|
||||
{"社团设置 <设置项> <{参数...}>", "修改社团设置"},
|
||||
{"社团捐献 <金币数>", "捐献金币到社团基金"},
|
||||
{"社团任务列表", "查看社团任务列表"},
|
||||
{"做社团任务 <任务序号>", "开始指定社团任务"},
|
||||
{"社团任务结算", "结算所有未完成的社团任务"},
|
||||
{"社团商店", "查看社团商店商品"},
|
||||
{"社团商店查看 <商品序号>", "查看指定商品详情"},
|
||||
{"社团商店购买 <商品序号>", "购买指定商品"},
|
||||
{"社团商店出售 <物品序号>", "向商店出售具有回收价的指定物品"},
|
||||
{"社团市场上架 <物品序号> <定价>", "将物品寄售到社团市场上,手续费10%,并且8%进入社团基金"},
|
||||
{"社团市场下架 <市场物品序号>", "下架指定物品"},
|
||||
{"社团市场购买 <市场物品序号>", "购买指定物品"},
|
||||
{"社团市场清空", "管理员可下架所有物品"},
|
||||
};
|
||||
|
||||
public static Dictionary<string, string> ActivityHelp { get; } = new() {
|
||||
{"签到", "每日签到奖励"},
|
||||
{"活动", "查看活动中心"},
|
||||
{"查活动 <编号>", "查看指定活动详情"},
|
||||
{"查活动 <活动序号>", "查看指定活动详情"},
|
||||
{"做活动任务 <活动序号> <任务序号>", "开始指定活动任务"},
|
||||
{"领取奖励 <活动序号>", "领取活动的奖励"},
|
||||
};
|
||||
|
||||
public static Dictionary<string, string> StoreHelp { get; } = new() {
|
||||
{"每日商店", "查看每日商店商品"},
|
||||
{"商店查看 <序号>", "查看指定商品详情"},
|
||||
{"商店购买 <序号>", "购买指定商品"},
|
||||
{"商店查看 <商品序号>", "查看指定商品详情"},
|
||||
{"商店购买 <商品序号>", "购买指定商品"},
|
||||
{"商店出售 <物品序号>", "向商店出售具有回收价的指定物品"},
|
||||
{"市场上架 <物品序号> <定价>", "将物品寄售到市场上,手续费15%"},
|
||||
{"市场下架 <市场物品序号>", "下架指定物品"},
|
||||
{"市场购买 <市场物品序号>", "购买指定物品"},
|
||||
{"社团市场上架 <物品序号> <定价>", "将物品寄售到社团市场上,手续费10%,并且8%进入社团基金"},
|
||||
{"社团市场下架 <市场物品序号>", "下架指定物品"},
|
||||
{"社团市场购买 <市场物品序号>", "购买指定物品"},
|
||||
{"社团市场清空", "管理员可下架所有物品"},
|
||||
{"创建报价", "创建一个交易报价"},
|
||||
{"我的报价 [页码]/查报价 <报价序号>", "查询指定报价详情"},
|
||||
{"发送报价 <报价序号>", "仅发起方可操作"},
|
||||
{"取消报价 <报价序号>", "仅发起方可操作"},
|
||||
{"接受报价 <报价序号>", "仅接收方可操作"},
|
||||
{"拒绝报价 <报价序号>", "仅接收方可操作"},
|
||||
{"报价添加物品 <报价序号> <{物品序号}...>", "仅发起方可操作"},
|
||||
{"报价添加对方物品 <报价序号> <{物品序号}...>", "仅发起方可操作"},
|
||||
{"报价移除物品 <报价序号> <{报价物品序号}...>", "仅发起方可操作"},
|
||||
{"报价移除对方物品 <报价序号> <{报价物品序号}...>", "仅发起方可操作"},
|
||||
};
|
||||
|
||||
public static IEnumerable<KeyValuePair<string, string>> GetPage(Dictionary<string, string> dict, int page, int pageSize = 10)
|
||||
|
||||
@ -63,7 +63,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
FunGameConstant.Items.AddRange(exItems.Values.Where(i => (int)i.ItemType > 4));
|
||||
FunGameConstant.Items.AddRange([new 小经验书(), new 中经验书(), new 大经验书(), new 升华之印(), new 流光之印(), new 永恒之印(), new 技能卷轴(), new 智慧之果(), new 奥术符文(), new 混沌之核(),
|
||||
new 小回复药(), new 中回复药(), new 大回复药(), new 魔力填充剂1(), new 魔力填充剂2(), new 魔力填充剂3(), new 能量饮料1(), new 能量饮料2(), new 能量饮料3(), new 年夜饭(), new 蛇年大吉(), new 新春快乐(), new 毕业礼包(),
|
||||
new 复苏药1(), new 复苏药2(), new 复苏药3(), new 全回复药(), new 魔法卡礼包()
|
||||
new 复苏药1(), new 复苏药2(), new 复苏药3(), new 全回复药(), new 魔法卡礼包(), new 奖券(), new 十连奖券()
|
||||
]);
|
||||
|
||||
FunGameConstant.AllItems.AddRange(FunGameConstant.Equipment);
|
||||
@ -628,10 +628,91 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
return [.. list.Skip((showPage - 1) * pageSize).Take(pageSize)];
|
||||
}
|
||||
|
||||
public static string GetDrawCardResult(int reduce, User user, bool isMulti = false, int multiCount = 1, bool useCurrency = true)
|
||||
public static List<string> DrawCards(User user, bool is10 = false, bool useCurrency = true)
|
||||
{
|
||||
List<string> msgs = [];
|
||||
int reduce;
|
||||
string reduceUnit;
|
||||
IEnumerable<Item>? items = null;
|
||||
if (useCurrency)
|
||||
{
|
||||
if (is10)
|
||||
{
|
||||
items = user.Inventory.Items.Where(i => i is 十连奖券);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = user.Inventory.Items.Where(i => i is 奖券);
|
||||
}
|
||||
if (items.Any())
|
||||
{
|
||||
reduceUnit = items.First().Name;
|
||||
reduce = 1;
|
||||
user.Inventory.Items.Remove(items.First());
|
||||
}
|
||||
else
|
||||
{
|
||||
reduceUnit = General.GameplayEquilibriumConstant.InGameCurrency;
|
||||
reduce = is10 ? FunGameConstant.DrawCardReduce * 10 : FunGameConstant.DrawCardReduce;
|
||||
if (user.Inventory.Credits < reduce)
|
||||
{
|
||||
msgs.Add($"你的{reduceUnit}不足 {reduce} 呢,无法抽卡!");
|
||||
return msgs;
|
||||
}
|
||||
user.Inventory.Credits -= reduce;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reduceUnit = General.GameplayEquilibriumConstant.InGameMaterial;
|
||||
reduce = is10 ? FunGameConstant.DrawCardReduce_Material * 10 : FunGameConstant.DrawCardReduce_Material;
|
||||
if (user.Inventory.Materials < reduce)
|
||||
{
|
||||
msgs.Add($"你的{reduceUnit}不足 {reduce} 呢,无法抽卡!");
|
||||
return msgs;
|
||||
}
|
||||
user.Inventory.Materials -= reduce;
|
||||
}
|
||||
|
||||
if (is10)
|
||||
{
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (dice > 0.8)
|
||||
{
|
||||
msgs.Add(GetDrawCardResult(reduce, reduceUnit, user, is10, i));
|
||||
}
|
||||
}
|
||||
if (msgs.Count == 1)
|
||||
{
|
||||
msgs[0] = $"消耗 {reduce} {reduceUnit},你什么也没抽中……";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (dice > 0.8)
|
||||
{
|
||||
msgs.Add(GetDrawCardResult(reduce, reduceUnit, user));
|
||||
}
|
||||
else
|
||||
{
|
||||
msgs.Add($"消耗 {reduce} {reduceUnit},你什么也没抽中……");
|
||||
}
|
||||
}
|
||||
|
||||
if (items != null && items.Any())
|
||||
{
|
||||
msgs.Insert(0, $"你的库存中拥有 {items.Count()} 张{reduceUnit},本次抽卡优先使用一张代替金币抽卡!");
|
||||
}
|
||||
|
||||
return msgs;
|
||||
}
|
||||
|
||||
public static string GetDrawCardResult(int reduce, string reduceUnit, User user, bool isMulti = false, int multiCount = 1)
|
||||
{
|
||||
string msg = "";
|
||||
string reduceUnit = useCurrency ? General.GameplayEquilibriumConstant.InGameCurrency : General.GameplayEquilibriumConstant.InGameMaterial;
|
||||
if (!isMulti)
|
||||
{
|
||||
msg = $"消耗 {reduce} {reduceUnit},恭喜你抽到了:";
|
||||
@ -2688,7 +2769,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
if (sql.Success)
|
||||
{
|
||||
long offerId = sql.LastInsertId;
|
||||
Offer? offer = sql.GetOffer(offerId);
|
||||
Offer? offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null)
|
||||
{
|
||||
return offerId;
|
||||
@ -2698,42 +2779,64 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static string AddItemsToOffer(PluginConfig pc, User user, long offerId, bool isOfferee, int[] itemIds)
|
||||
public static string AddOfferItems(User user, long offerId, bool isOpposite, int[] itemIds)
|
||||
{
|
||||
using SQLHelper? sql = Factory.OpenFactory.GetSQLHelper();
|
||||
if (sql != null)
|
||||
{
|
||||
bool result = true;
|
||||
string msg = "";
|
||||
Offer? offer = sql.GetOffer(offerId);
|
||||
Offer? offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null && offer.Offeror == user.Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
sql.NewTransaction();
|
||||
|
||||
User addUser = user;
|
||||
if (isOfferee)
|
||||
if (offer.Status != OfferState.Created)
|
||||
{
|
||||
PluginConfig pc2 = new("saved", offer.Offeror.ToString());
|
||||
|
||||
if (pc2.Count > 0)
|
||||
{
|
||||
addUser = GetUser(pc2);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "目标玩家不存在,请稍后再试。";
|
||||
}
|
||||
msg = "当前状态不允许修改报价内容。";
|
||||
return msg;
|
||||
}
|
||||
|
||||
User user2;
|
||||
PluginConfig pc2 = new("saved", offer.Offeree.ToString());
|
||||
pc2.LoadConfig();
|
||||
|
||||
if (pc2.Count > 0)
|
||||
{
|
||||
user2 = GetUser(pc2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "无法找到报价的接收方,请稍后再试。";
|
||||
}
|
||||
User addUser = isOpposite ? user2: user;
|
||||
offer.OfferorItems = [.. SQLService.GetOfferItemsByOfferIdAndUserId(sql, offerId, user)];
|
||||
offer.OffereeItems = [.. SQLService.GetOfferItemsByOfferIdAndUserId(sql, offerId, user2)];
|
||||
|
||||
sql.NewTransaction();
|
||||
List<int> failedItems = [];
|
||||
foreach (int itemIndex in itemIds)
|
||||
{
|
||||
if (itemIndex > 0 && itemIndex <= user.Inventory.Items.Count)
|
||||
if (itemIndex > 0 && itemIndex <= addUser.Inventory.Items.Count)
|
||||
{
|
||||
Item item = user.Inventory.Items.ToList()[itemIndex - 1];
|
||||
Item item = addUser.Inventory.Items.ToList()[itemIndex - 1];
|
||||
|
||||
if (addUser.Id == offer.Offeror && offer.OfferorItems.Contains(item.Guid) || addUser.Id == offer.Offeree && offer.OffereeItems.Contains(item.Guid))
|
||||
{
|
||||
result = false;
|
||||
if (msg != "") msg += "\r\n";
|
||||
msg += $"物品 {itemIndex}. {item.Name}:此物品已在报价中,无需重复添加。";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.IsLock)
|
||||
{
|
||||
result = false;
|
||||
if (msg != "") msg += "\r\n";
|
||||
msg += $"物品 {itemIndex}. {item.Name}:此物品已锁定,无法进行交易。";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!item.IsTradable)
|
||||
{
|
||||
result = false;
|
||||
@ -2769,7 +2872,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
|
||||
if (result)
|
||||
{
|
||||
offer = sql.GetOffer(offerId);
|
||||
offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null)
|
||||
{
|
||||
sql.Commit();
|
||||
@ -2789,7 +2892,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "报价不存在或您无权修改。";
|
||||
msg = "报价不存在或你不是该报价的发起方。";
|
||||
}
|
||||
|
||||
return msg;
|
||||
@ -2803,7 +2906,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
if (sql != null)
|
||||
{
|
||||
string msg = "";
|
||||
Offer? offer = sql.GetOffer(offerId);
|
||||
Offer? offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null && offer.Offeror == user.Id)
|
||||
{
|
||||
try
|
||||
@ -2820,11 +2923,11 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
|
||||
if (result)
|
||||
{
|
||||
offer = sql.GetOffer(offerId);
|
||||
offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null)
|
||||
{
|
||||
sql.Commit();
|
||||
AddNotice(offer.Offeree, $"你收到了一个报价!请通过【我的报价】查询报价记录。");
|
||||
AddNotice(offer.Offeree, $"你收到了一个报价!请通过【查报价{offerId}】查询报价记录。");
|
||||
return $"报价编号 {offerId} 已发送。";
|
||||
}
|
||||
}
|
||||
@ -2842,7 +2945,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "报价不存在或您无权修改。";
|
||||
msg = "报价不存在或你不是该报价的发起方。";
|
||||
}
|
||||
|
||||
return msg;
|
||||
@ -2859,30 +2962,133 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
{
|
||||
if (offerId > 0)
|
||||
{
|
||||
Offer? offer = sql.GetOffer(offerId);
|
||||
if (offer != null) offers.Add(offer);
|
||||
Offer? offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null)
|
||||
{
|
||||
if (offer.Offeror == user.Id || offer.Offeree == user.Id)
|
||||
{
|
||||
offers.Add(offer);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = $"你无权查看报价编号 {offerId}。";
|
||||
}
|
||||
}
|
||||
else msg = $"报价编号 {offerId} 不存在。";
|
||||
}
|
||||
else
|
||||
{
|
||||
offers = sql.GetOffersByOfferor(user.Id);
|
||||
offers = [.. offers, ..sql.GetOffersByOfferee(user.Id)];
|
||||
offers = [.. offers.DistinctBy(o => o.Id)];
|
||||
}
|
||||
}
|
||||
return offers;
|
||||
}
|
||||
|
||||
public static string RemoveOfferItems(User user, long offerId, bool isOpposite, int[] itemIds)
|
||||
{
|
||||
using SQLHelper? sql = Factory.OpenFactory.GetSQLHelper();
|
||||
if (sql != null)
|
||||
{
|
||||
bool result = true;
|
||||
string msg = "";
|
||||
Offer? offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null && offer.Offeror == user.Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (offer.Status != OfferState.Created)
|
||||
{
|
||||
msg = "当前状态不允许修改报价内容。";
|
||||
return msg;
|
||||
}
|
||||
|
||||
User removeUser;
|
||||
List<Guid> guids = [];
|
||||
|
||||
if (isOpposite)
|
||||
{
|
||||
PluginConfig pc2 = new("saved", offer.Offeree.ToString());
|
||||
pc2.LoadConfig();
|
||||
|
||||
if (pc2.Count > 0)
|
||||
{
|
||||
removeUser = GetUser(pc2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "无法找到报价的接收方,请稍后再试。";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
removeUser = user;
|
||||
}
|
||||
|
||||
guids = [.. SQLService.GetOfferItemsByOfferIdAndUserId(sql, offerId, removeUser)];
|
||||
|
||||
sql.NewTransaction();
|
||||
List<int> failedItems = [];
|
||||
foreach (int itemIndex in itemIds)
|
||||
{
|
||||
if (itemIndex > 0 && itemIndex <= guids.Count)
|
||||
{
|
||||
Guid itemGuid = guids[itemIndex - 1];
|
||||
SQLService.DeleteOfferItemsByOfferIdAndItemGuid(sql, offerId, itemGuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
failedItems.Add(itemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (failedItems.Count > 0)
|
||||
{
|
||||
if (msg != "") msg += "\r\n";
|
||||
msg += $"在报价的{(isOpposite ? "接收方" : "发起方")}物品列表中没有找到与这个序号相对应的物品:{string.Join(",", failedItems)}";
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null)
|
||||
{
|
||||
sql.Commit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Rollback();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
sql.Rollback();
|
||||
msg = "修改报价时发生错误,请稍后再试。";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "报价不存在或你不是该报价的发起方。";
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
return "服务器繁忙,请稍后再试。";
|
||||
}
|
||||
|
||||
public static string RespondOffer(PluginConfig pc, User user, long offerId, OfferActionType action)
|
||||
{
|
||||
using SQLHelper? sql = Factory.OpenFactory.GetSQLHelper();
|
||||
if (sql != null)
|
||||
{
|
||||
string msg = "";
|
||||
Offer? offer = sql.GetOffer(offerId);
|
||||
Offer? offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null && offer.Offeree == user.Id)
|
||||
{
|
||||
bool canProceed = false;
|
||||
bool isNegotiating = false;
|
||||
|
||||
try
|
||||
{
|
||||
@ -2894,10 +3100,6 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
case OfferActionType.OffereeAccept:
|
||||
if (offer.Status == OfferState.Sent || offer.Status == OfferState.Negotiating || offer.Status == OfferState.NegotiationAccepted)
|
||||
{
|
||||
if (offer.Status == OfferState.Negotiating)
|
||||
{
|
||||
isNegotiating = true;
|
||||
}
|
||||
sql.UpdateOfferStatus(offerId, OfferState.Completed);
|
||||
sql.UpdateOfferFinishTime(offerId, DateTime.Now);
|
||||
canProceed = true;
|
||||
@ -2922,17 +3124,21 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
|
||||
if (canProceed)
|
||||
{
|
||||
offer = sql.GetOffer(offerId, isNegotiating);
|
||||
offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null)
|
||||
{
|
||||
if (offer.Status == OfferState.Completed)
|
||||
{
|
||||
PluginConfig pc2 = new("saved", offer.Offeror.ToString());
|
||||
pc2.LoadConfig();
|
||||
|
||||
if (pc2.Count > 0)
|
||||
{
|
||||
User user2 = GetUser(pc2);
|
||||
|
||||
offer.OffereeItems = [.. SQLService.GetOfferItemsByOfferIdAndUserId(sql, offerId, user)];
|
||||
offer.OfferorItems = [.. SQLService.GetOfferItemsByOfferIdAndUserId(sql, offerId, user2)];
|
||||
|
||||
foreach (Guid itemGuid in offer.OffereeItems)
|
||||
{
|
||||
if (user.Inventory.Items.FirstOrDefault(i => i.Guid == itemGuid) is Item item)
|
||||
@ -2971,7 +3177,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
pc2.Add("user", user2);
|
||||
pc2.SaveConfig();
|
||||
|
||||
AddNotice(offer.Offeror, $"报价编号 {offerId} 已交易完成,请通过【我的报价】查询报价记录。");
|
||||
AddNotice(offer.Offeror, $"报价编号 {offerId} 已交易完成,请通过【查报价{offerId}】查询报价记录。");
|
||||
|
||||
msg = "";
|
||||
}
|
||||
@ -2982,7 +3188,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
}
|
||||
else if (offer.Status == OfferState.Rejected)
|
||||
{
|
||||
AddNotice(offer.Offeror, $"报价编号 {offerId} 已被拒绝,请通过【我的报价】查询报价记录。");
|
||||
AddNotice(offer.Offeror, $"报价编号 {offerId} 已被拒绝,请通过【查报价{offerId}】查询报价记录。");
|
||||
}
|
||||
sql.Commit();
|
||||
}
|
||||
@ -2994,7 +3200,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"报价编号 {offerId} 已交易完成,请通过【我的报价】查询报价记录。";
|
||||
return $"报价编号 {offerId} 已交易完成,请通过【查报价{offerId}】查询报价记录。";
|
||||
}
|
||||
}
|
||||
catch
|
||||
@ -3006,7 +3212,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "报价不存在或您无权回应。";
|
||||
msg = "报价不存在或你不是该报价的接收方。";
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
@ -3019,12 +3225,12 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
if (sql != null)
|
||||
{
|
||||
string msg = "";
|
||||
Offer? offer = sql.GetOffer(offerId);
|
||||
Offer? offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null && offer.Offeror == user.Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (offer.Status != OfferState.Created || offer.Status != OfferState.Sent)
|
||||
if (offer.Status != OfferState.Created && offer.Status != OfferState.Sent)
|
||||
{
|
||||
msg = "此报价已被处理。";
|
||||
return msg;
|
||||
@ -3036,7 +3242,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
|
||||
if (result)
|
||||
{
|
||||
offer = sql.GetOffer(offerId);
|
||||
offer = SQLService.GetOffer(sql, offerId);
|
||||
if (offer != null)
|
||||
{
|
||||
sql.Commit();
|
||||
@ -3057,7 +3263,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "报价不存在或您无权修改。";
|
||||
msg = "报价不存在或你不是该报价的发起方。";
|
||||
}
|
||||
|
||||
return msg;
|
||||
|
||||
262
OshimaServers/Service/SQLService.cs
Normal file
262
OshimaServers/Service/SQLService.cs
Normal file
@ -0,0 +1,262 @@
|
||||
using System.Data;
|
||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
||||
using ProjectRedbud.FunGame.SQLQueryExtension;
|
||||
|
||||
namespace Oshima.FunGame.OshimaServers.Service
|
||||
{
|
||||
public class SQLService
|
||||
{
|
||||
public static Offer? GetOffer(SQLHelper helper, long offerId)
|
||||
{
|
||||
DataRow? dr = helper.ExecuteDataRow(OffersQuery.Select_OfferById(helper, offerId));
|
||||
if (dr != null)
|
||||
{
|
||||
Offer offer = new();
|
||||
SetValue(dr, offer);
|
||||
return offer;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Offer> GetOffersByOfferor(SQLHelper helper, long offerorId)
|
||||
{
|
||||
List<Offer> offers = [];
|
||||
DataSet ds = helper.ExecuteDataSet(OffersQuery.Select_OffersByOfferor(helper, offerorId));
|
||||
if (helper.Success)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
Offer offer = new();
|
||||
SetValue(dr, offer);
|
||||
offers.Add(offer);
|
||||
}
|
||||
}
|
||||
return offers;
|
||||
}
|
||||
|
||||
public static List<Offer> GetOffersByOfferee(SQLHelper helper, long offereeId)
|
||||
{
|
||||
List<Offer> offers = [];
|
||||
DataSet ds = helper.ExecuteDataSet(OffersQuery.Select_OffersByOfferee(helper, offereeId));
|
||||
if (helper.Success)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
Offer offer = new();
|
||||
SetValue(dr, offer);
|
||||
offers.Add(offer);
|
||||
}
|
||||
}
|
||||
return offers;
|
||||
}
|
||||
|
||||
public static List<Guid> GetOfferItemsByOfferIdAndUserId(SQLHelper helper, long offerId, User user)
|
||||
{
|
||||
List<Guid> itemGuids = [];
|
||||
DataSet ds = helper.ExecuteDataSet(OfferItemsQuery.Select_OfferItemsByOfferIdAndUserId(helper, offerId, user.Id));
|
||||
if (user != null && helper.Success)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
if (user.Inventory.Items.FirstOrDefault(i => i.Guid.ToString().EqualsGuid(dr[OfferItemsQuery.Column_ItemGuid])) is Item item)
|
||||
{
|
||||
itemGuids.Add(item.Guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemGuids;
|
||||
}
|
||||
|
||||
public static void AddOffer(SQLHelper helper, long offeror, long offeree, OfferState status = OfferState.Created, int negotiatedTimes = 0)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OffersQuery.Insert_Offer(helper, offeror, offeree, status, negotiatedTimes));
|
||||
if (!helper.Success) throw new Exception($"新增报价 (Offeror: {offeror}, Offeree: {offeree}) 失败。");
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddOfferItem(SQLHelper helper, long offerId, long userId, Guid itemGuid)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OfferItemsQuery.Insert_OfferItem(helper, offerId, userId, itemGuid));
|
||||
if (!helper.Success) throw new Exception($"新增报价物品 (OfferId: {offerId}, UserId: {userId}, ItemGuid: {itemGuid}) 失败。");
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateOfferStatus(SQLHelper helper, long id, OfferState status)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OffersQuery.Update_OfferStatus(helper, id, status));
|
||||
if (!helper.Success) throw new Exception($"更新报价 {id} 状态失败。");
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateOfferNegotiatedTimes(SQLHelper helper, long id, int negotiatedTimes)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OffersQuery.Update_OfferNegotiatedTimes(helper, id, negotiatedTimes));
|
||||
if (!helper.Success) throw new Exception($"更新报价 {id} 协商次数失败。");
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateOfferFinishTime(SQLHelper helper, long id, DateTime finishTime)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OffersQuery.Update_OfferFinishTime(helper, id, finishTime));
|
||||
if (!helper.Success) throw new Exception($"更新报价 {id} 完成时间失败。");
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteOffer(SQLHelper helper, long id)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
// 删除 Offer 相关的 OfferItems
|
||||
helper.DeleteOfferItemsByOfferId(id);
|
||||
helper.Execute(OffersQuery.Delete_Offer(helper, id));
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteOfferItemsByOfferId(SQLHelper helper, long offerId)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OfferItemsQuery.Delete_OfferItemsByOfferId(helper, offerId));
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteOfferItemsByOfferIdAndItemGuid(SQLHelper helper, long offerId, Guid itemGuid)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OfferItemsQuery.Delete_OfferItemsByOfferIdAndItemGuid(helper, offerId, itemGuid));
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteOfferItem(SQLHelper helper, long id)
|
||||
{
|
||||
bool hasTransaction = helper.Transaction != null;
|
||||
if (!hasTransaction) helper.NewTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
helper.Execute(OfferItemsQuery.Delete_OfferItem(helper, id));
|
||||
|
||||
if (!hasTransaction) helper.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!hasTransaction) helper.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetValue(DataRow dr, Offer offer)
|
||||
{
|
||||
offer.Id = (long)dr[OffersQuery.Column_Id];
|
||||
offer.Offeror = (long)dr[OffersQuery.Column_Offeror];
|
||||
offer.Offeree = (long)dr[OffersQuery.Column_Offeree];
|
||||
offer.Status = (OfferState)Convert.ToInt32(dr[OffersQuery.Column_Status]);
|
||||
offer.NegotiatedTimes = Convert.ToInt32(dr[OffersQuery.Column_NegotiatedTimes]);
|
||||
|
||||
if (dr[OffersQuery.Column_CreateTime] != DBNull.Value && DateTime.TryParseExact(dr[OffersQuery.Column_CreateTime].ToString(), General.GeneralDateTimeFormat, null, System.Globalization.DateTimeStyles.None, out DateTime dt))
|
||||
{
|
||||
offer.CreateTime = dt;
|
||||
}
|
||||
|
||||
if (dr[OffersQuery.Column_FinishTime] != DBNull.Value && DateTime.TryParseExact(dr[OffersQuery.Column_FinishTime].ToString(), General.GeneralDateTimeFormat, null, System.Globalization.DateTimeStyles.None, out dt))
|
||||
{
|
||||
offer.FinishTime = dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,8 +26,6 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
private ILogger<FunGameController> Logger { get; set; } = logger;
|
||||
|
||||
private readonly SemaphoreSlim _semaphore = new(1, 1);
|
||||
private const int drawCardReduce = 1000;
|
||||
private const int drawCardReduce_Material = 5;
|
||||
private const string noSaved = "你还没有创建存档!请发送【创建存档】创建。";
|
||||
private const string refused = "暂时无法使用此指令。";
|
||||
private const string busy = "服务器繁忙,请稍后再试。";
|
||||
@ -495,7 +493,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
catch (Exception e)
|
||||
{
|
||||
sqlHelper.Rollback();
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
}
|
||||
return "无法处理注册,创建存档失败!";
|
||||
}
|
||||
@ -1229,7 +1227,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
|
||||
[HttpPost("drawcard")]
|
||||
public string DrawCard([FromQuery] long? uid = null)
|
||||
public List<string> DrawCard([FromQuery] long? uid = null)
|
||||
{
|
||||
long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
|
||||
|
||||
@ -1240,34 +1238,16 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
User user = FunGameService.GetUser(pc);
|
||||
|
||||
int reduce = drawCardReduce;
|
||||
if (user.Inventory.Credits >= reduce)
|
||||
{
|
||||
user.Inventory.Credits -= reduce;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"你的{General.GameplayEquilibriumConstant.InGameCurrency}不足 {reduce} 呢,无法抽卡!";
|
||||
}
|
||||
List<string> result = FunGameService.DrawCards(user, false, true);
|
||||
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (dice > 0.8)
|
||||
{
|
||||
string msg = FunGameService.GetDrawCardResult(reduce, user);
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.SaveConfig();
|
||||
return $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},你什么也没抽中……";
|
||||
}
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return noSaved;
|
||||
return [noSaved];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1283,31 +1263,8 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
User user = FunGameService.GetUser(pc);
|
||||
|
||||
int reduce = drawCardReduce * 10;
|
||||
if (user.Inventory.Credits >= reduce)
|
||||
{
|
||||
user.Inventory.Credits -= reduce;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [$"你的{General.GameplayEquilibriumConstant.InGameCurrency}不足 {reduce} 呢,无法十连抽卡!"];
|
||||
}
|
||||
List<string> result = FunGameService.DrawCards(user, true, true);
|
||||
|
||||
List<string> result = [$"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},恭喜你抽到了:"];
|
||||
int count = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (dice > 0.8)
|
||||
{
|
||||
count++;
|
||||
result.Add(FunGameService.GetDrawCardResult(reduce, user, true, count));
|
||||
}
|
||||
}
|
||||
if (result.Count == 1)
|
||||
{
|
||||
result[0] = $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},你什么也没抽中……";
|
||||
}
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
@ -1320,7 +1277,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
|
||||
[HttpPost("drawcardm")]
|
||||
public string DrawCard_Material([FromQuery] long? uid = null)
|
||||
public List<string> DrawCard_Material([FromQuery] long? uid = null)
|
||||
{
|
||||
long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
|
||||
|
||||
@ -1331,34 +1288,16 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
User user = FunGameService.GetUser(pc);
|
||||
|
||||
int reduce = drawCardReduce_Material;
|
||||
if (user.Inventory.Materials >= reduce)
|
||||
{
|
||||
user.Inventory.Materials -= reduce;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce} 呢,无法抽卡!";
|
||||
}
|
||||
List<string> result = FunGameService.DrawCards(user, false, false);
|
||||
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (dice > 0.8)
|
||||
{
|
||||
string msg = FunGameService.GetDrawCardResult(reduce, user, useCurrency: false);
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.SaveConfig();
|
||||
return $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameMaterial},你什么也没抽中……";
|
||||
}
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return noSaved;
|
||||
return [noSaved];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1374,31 +1313,8 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
User user = FunGameService.GetUser(pc);
|
||||
|
||||
int reduce = drawCardReduce_Material * 10;
|
||||
if (user.Inventory.Materials >= reduce)
|
||||
{
|
||||
user.Inventory.Materials -= reduce;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [$"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce} 呢,无法十连抽卡!"];
|
||||
}
|
||||
List<string> result = FunGameService.DrawCards(user, true, false);
|
||||
|
||||
List<string> result = [$"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameMaterial},恭喜你抽到了:"];
|
||||
int count = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (dice > 0.8)
|
||||
{
|
||||
count++;
|
||||
result.Add(FunGameService.GetDrawCardResult(reduce, user, true, count, useCurrency: false));
|
||||
}
|
||||
}
|
||||
if (result.Count == 1)
|
||||
{
|
||||
result[0] = $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameMaterial},你什么也没抽中……";
|
||||
}
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
@ -1494,7 +1410,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -1538,7 +1454,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -1582,7 +1498,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -1619,7 +1535,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -1731,7 +1647,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -1798,7 +1714,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -1846,7 +1762,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -1905,7 +1821,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return [busy];
|
||||
}
|
||||
}
|
||||
@ -1928,7 +1844,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return [busy];
|
||||
}
|
||||
}
|
||||
@ -2005,7 +1921,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return [busy];
|
||||
}
|
||||
}
|
||||
@ -2028,7 +1944,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return [busy];
|
||||
}
|
||||
}
|
||||
@ -2120,7 +2036,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -2201,7 +2117,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -2318,7 +2234,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -2453,7 +2369,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -2523,7 +2439,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -2659,7 +2575,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -2866,7 +2782,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -2943,7 +2859,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3014,7 +2930,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3092,7 +3008,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3135,7 +3051,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3183,7 +3099,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3260,7 +3176,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3307,7 +3223,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3497,7 +3413,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3663,7 +3579,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3802,7 +3718,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3850,7 +3766,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3897,7 +3813,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3930,7 +3846,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -3957,7 +3873,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -5564,7 +5480,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
catch (Exception e)
|
||||
{
|
||||
_semaphore.Release();
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return (busy, exploreId);
|
||||
}
|
||||
}
|
||||
@ -5870,7 +5786,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -5890,6 +5806,11 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
User user = FunGameService.GetUser(pc);
|
||||
|
||||
if (user.Id == offeree)
|
||||
{
|
||||
return "报价的目标玩家不能是自己。";
|
||||
}
|
||||
|
||||
if (FunGameConstant.UserIdAndUsername.TryGetValue(offeree ?? -1, out User? user2) && user2 != null)
|
||||
{
|
||||
long offerId = FunGameService.MakeOffer(user, user2);
|
||||
@ -5913,13 +5834,13 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("additemstooffer")]
|
||||
public string AddItemsToOffer([FromQuery] long? uid = null, [FromQuery] long? offer = null, [FromQuery] bool isOfferee = true, [FromBody] int[]? itemIds = null)
|
||||
[HttpPost("addofferitems")]
|
||||
public string AddOfferItems([FromQuery] long? uid = null, [FromQuery] long? offer = null, [FromQuery] bool isOpposite = true, [FromBody] int[]? itemIds = null)
|
||||
{
|
||||
long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
|
||||
long offerId = offer ?? -1;
|
||||
@ -5937,13 +5858,17 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
|
||||
if (offerId > 0)
|
||||
{
|
||||
msg = FunGameService.AddItemsToOffer(pc, user, offerId, isOfferee, itemsIndex);
|
||||
msg = FunGameService.AddOfferItems(user, offerId, isOpposite, itemsIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "没有找到对应的报价。";
|
||||
}
|
||||
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
@ -5953,7 +5878,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -5988,7 +5913,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -6011,7 +5936,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
|
||||
if (offerId > 0)
|
||||
{
|
||||
FunGameService.RespondOffer(pc, user, offerId, accept ? OfferActionType.OffereeAccept : OfferActionType.OffereeReject);
|
||||
msg = FunGameService.RespondOffer(pc, user, offerId, accept ? OfferActionType.OffereeAccept : OfferActionType.OffereeReject);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -6027,12 +5952,12 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("getoffer")]
|
||||
[HttpGet("getoffer")]
|
||||
public string GetOffer([FromQuery] long? uid = null, [FromQuery] long? offerId = null, [FromQuery] int? page = null)
|
||||
{
|
||||
long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
|
||||
@ -6056,6 +5981,8 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
return msg;
|
||||
}
|
||||
|
||||
using SQLHelper? sql = Factory.OpenFactory.GetSQLHelper();
|
||||
|
||||
int maxPage = (int)Math.Ceiling((double)offers.Count);
|
||||
if (maxPage < 1) maxPage = 1;
|
||||
if (showPage <= maxPage)
|
||||
@ -6072,7 +5999,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
user1 = offeror;
|
||||
}
|
||||
if (FunGameConstant.UserIdAndUsername.TryGetValue(offer.Offeror, out User? offeree) && offeree != null)
|
||||
if (FunGameConstant.UserIdAndUsername.TryGetValue(offer.Offeree, out User? offeree) && offeree != null)
|
||||
{
|
||||
user2 = offeree;
|
||||
}
|
||||
@ -6084,21 +6011,25 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
builder.AppendLine($"接收方:{user2}");
|
||||
builder.AppendLine($"状态:{CommonSet.GetOfferStatus(offer.Status)}");
|
||||
|
||||
if (sql != null)
|
||||
{
|
||||
offer.OfferorItems = [.. SQLService.GetOfferItemsByOfferIdAndUserId(sql, offer.Id, user1)];
|
||||
offer.OffereeItems = [.. SQLService.GetOfferItemsByOfferIdAndUserId(sql, offer.Id, user2)];
|
||||
}
|
||||
|
||||
List<string> user1Item = [];
|
||||
List<string> user2Item = [];
|
||||
foreach (Item item in user1.Inventory.Items)
|
||||
int count = 0;
|
||||
foreach (Item item in user1.Inventory.Items.Where(i => offer.OfferorItems.Contains(i.Guid)))
|
||||
{
|
||||
if (offer.OfferorItems.Contains(item.Guid))
|
||||
{
|
||||
user1Item.Add($"[{ItemSet.GetQualityTypeName(item.QualityType)}]" + ItemSet.GetItemTypeName(item.ItemType) + ":" + item.Name);
|
||||
}
|
||||
count++;
|
||||
user1Item.Add($"{count}. [{ItemSet.GetQualityTypeName(item.QualityType)}]" + ItemSet.GetItemTypeName(item.ItemType) + ":" + item.Name);
|
||||
}
|
||||
foreach (Item item in user2.Inventory.Items)
|
||||
count = 0;
|
||||
foreach (Item item in user2.Inventory.Items.Where(i => offer.OffereeItems.Contains(i.Guid)))
|
||||
{
|
||||
if (offer.OffereeItems.Contains(item.Guid))
|
||||
{
|
||||
user2Item.Add($"[{ItemSet.GetQualityTypeName(item.QualityType)}]" + ItemSet.GetItemTypeName(item.ItemType) + ":" + item.Name);
|
||||
}
|
||||
count++;
|
||||
user2Item.Add($"{count}. [{ItemSet.GetQualityTypeName(item.QualityType)}]" + ItemSet.GetItemTypeName(item.ItemType) + ":" + item.Name);
|
||||
}
|
||||
|
||||
if (user1Item.Count > 0)
|
||||
@ -6136,7 +6067,51 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("removeofferitems")]
|
||||
public string RemoveOfferItems([FromQuery] long? uid = null, [FromQuery] long? offer = null, [FromQuery] bool isOpposite = true, [FromBody] int[]? itemIds = null)
|
||||
{
|
||||
long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
|
||||
long offerId = offer ?? -1;
|
||||
int[] itemsIndex = itemIds ?? [];
|
||||
|
||||
try
|
||||
{
|
||||
PluginConfig pc = new("saved", userid.ToString());
|
||||
pc.LoadConfig();
|
||||
|
||||
string msg = "";
|
||||
if (pc.Count > 0)
|
||||
{
|
||||
User user = FunGameService.GetUser(pc);
|
||||
|
||||
if (offerId > 0)
|
||||
{
|
||||
msg = FunGameService.RemoveOfferItems(user, offerId, isOpposite, itemsIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "没有找到对应的报价。";
|
||||
}
|
||||
|
||||
user.LastTime = DateTime.Now;
|
||||
pc.Add("user", user);
|
||||
pc.SaveConfig();
|
||||
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
return noSaved;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -6171,7 +6146,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
@ -6204,7 +6179,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "Error: ");
|
||||
Logger.LogError(e, "Error: {e.Message}", e.Message);
|
||||
return busy;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Oshima.Core.Configs;
|
||||
using Oshima.FunGame.WebAPI.Models;
|
||||
|
||||
@ -17,17 +16,17 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
if (b.Openid.Trim() == "" || b.QQ <= 0)
|
||||
{
|
||||
return NetworkUtility.JsonSerialize("请输入正确的OpenID和QQ!");
|
||||
return "请输入正确的OpenID和QQ!";
|
||||
}
|
||||
|
||||
if (QQOpenID.QQAndOpenID.TryGetValue(b.Openid, out long bindqq) && bindqq != 0)
|
||||
{
|
||||
return NetworkUtility.JsonSerialize($"你已经绑定过:{bindqq},如绑定错误请联系客服处理。");
|
||||
return $"你已经绑定过:{bindqq},如绑定错误请联系客服处理。";
|
||||
}
|
||||
|
||||
if (QQOpenID.QQAndOpenID.Values.Any(qq => qq == b.QQ && b.Openid != b.Openid))
|
||||
{
|
||||
return NetworkUtility.JsonSerialize($"此QQ {b.QQ} 已被其他人绑定,如果你是此QQ的主人,请联系客服处理。");
|
||||
return $"此QQ {b.QQ} 已被其他人绑定,如果你是此QQ的主人,请联系客服处理。";
|
||||
}
|
||||
|
||||
if (QQOpenID.QQAndOpenID.TryAdd(b.Openid, b.QQ))
|
||||
@ -36,10 +35,10 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
return NetworkUtility.JsonSerialize($"绑定失败,请稍后再试!如持续绑定失败请联系客服处理。");
|
||||
return $"绑定失败,请稍后再试!如持续绑定失败请联系客服处理。";
|
||||
}
|
||||
|
||||
return NetworkUtility.JsonSerialize("绑定成功!如果需要解除绑定,请发送【解绑+QQ号】(如:解绑123456789)!");
|
||||
return "绑定成功!如果需要解除绑定,请发送【解绑+QQ号】(如:解绑123456789)!";
|
||||
}
|
||||
|
||||
[HttpPost("unbind")]
|
||||
@ -47,10 +46,10 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
{
|
||||
if (QQOpenID.QQAndOpenID.TryGetValue(b.Openid, out long bindqq) && bindqq == b.QQ && QQOpenID.QQAndOpenID.Remove(b.Openid))
|
||||
{
|
||||
return NetworkUtility.JsonSerialize($"解绑成功!");
|
||||
return $"解绑成功!";
|
||||
}
|
||||
|
||||
return NetworkUtility.JsonSerialize("解绑失败!没有查到绑定的信息或者此账号已被其他人绑定,如果你是此QQ的主人,请联系客服处理。");
|
||||
return "解绑失败!没有查到绑定的信息或者此账号已被其他人绑定,如果你是此QQ的主人,请联系客服处理。";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,23 +71,23 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
string time = date.ToString("HH:mm:ss", CultureInfo.InvariantCulture);
|
||||
|
||||
string msg = "服务器最后启动时间:" + $"{month}. {day}, {date.Year} {time}";
|
||||
return NetworkUtility.JsonSerialize(msg);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Statics.RunningPlugin.Controller.Error(e);
|
||||
return NetworkUtility.JsonSerialize("无法调用此接口。原因:\r\n" + e.GetErrorInfo());
|
||||
return "无法调用此接口。原因:\r\n" + e.GetErrorInfo();
|
||||
}
|
||||
}
|
||||
return NetworkUtility.JsonSerialize("无法调用此接口。原因:与 SQL 服务器通信失败。");
|
||||
return "无法调用此接口。原因:与 SQL 服务器通信失败。";
|
||||
}
|
||||
|
||||
[HttpGet("gettask")]
|
||||
public string GetTaskScheduler(string name)
|
||||
{
|
||||
return NetworkUtility.JsonSerialize(TaskScheduler.Shared.GetRunTimeInfo(name));
|
||||
return TaskScheduler.Shared.GetRunTimeInfo(name);
|
||||
}
|
||||
|
||||
[HttpGet("sendtest")]
|
||||
@ -100,17 +100,17 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
MailSender? sender = Statics.RunningPlugin.Controller.MailSender;
|
||||
if (sender != null && sender.Send(new(sender, "Test Mail", "Hello!", to)) == Milimoe.FunGame.Core.Library.Constant.MailSendResult.Success)
|
||||
{
|
||||
return NetworkUtility.JsonSerialize("发送成功。");
|
||||
return "发送成功。";
|
||||
}
|
||||
return NetworkUtility.JsonSerialize("发送失败。");
|
||||
return "发送失败。";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Statics.RunningPlugin.Controller.Error(e);
|
||||
return NetworkUtility.JsonSerialize("无法调用此接口。原因:\r\n" + e.GetErrorInfo());
|
||||
return "无法调用此接口。原因:\r\n" + e.GetErrorInfo();
|
||||
}
|
||||
}
|
||||
return NetworkUtility.JsonSerialize("无法调用此接口。");
|
||||
return "无法调用此接口。";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Oshima.Core.Configs;
|
||||
using Oshima.FunGame.WebAPI.Models;
|
||||
using Oshima.FunGame.WebAPI.Services;
|
||||
@ -55,7 +54,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
6 => "dx" + (Random.Shared.Next(2) + 1) + ".png",
|
||||
_ => ""
|
||||
};
|
||||
return NetworkUtility.JsonSerialize(img);
|
||||
return img;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -686,10 +686,10 @@ namespace Oshima.FunGame.WebAPI.Services
|
||||
|
||||
if (e.Detail == "抽卡")
|
||||
{
|
||||
string msg = Controller.DrawCard(uid);
|
||||
if (msg != "")
|
||||
List<string> msgs = Controller.DrawCard(uid);
|
||||
if (msgs.Count > 0)
|
||||
{
|
||||
await SendAsync(e, "抽卡", "\r\n" + msg);
|
||||
await SendAsync(e, "抽卡", "\r\n" + string.Join("\r\n", msgs));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -706,10 +706,10 @@ namespace Oshima.FunGame.WebAPI.Services
|
||||
|
||||
if (e.Detail == "材料抽卡")
|
||||
{
|
||||
string msg = Controller.DrawCard_Material(uid);
|
||||
if (msg != "")
|
||||
List<string> msgs = Controller.DrawCard_Material(uid);
|
||||
if (msgs.Count > 0)
|
||||
{
|
||||
await SendAsync(e, "材料抽卡", "\r\n" + msg);
|
||||
await SendAsync(e, "材料抽卡", "\r\n" + string.Join("\r\n", msgs));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -2351,14 +2351,18 @@ namespace Oshima.FunGame.WebAPI.Services
|
||||
indexs.Add(c);
|
||||
}
|
||||
}
|
||||
if (long.TryParse(detail, out long id))
|
||||
if (indexs.Count > 1)
|
||||
{
|
||||
msg = Controller.AddItemsToOffer(uid, id, false, [.. indexs]);
|
||||
msg = Controller.AddOfferItems(uid, indexs[0], false, [.. indexs[1..]]);
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
await SendAsync(e, "报价添加物品", msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "格式不正确,请先输入报价序号再输入物品序号,使用空格隔开。";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2375,14 +2379,74 @@ namespace Oshima.FunGame.WebAPI.Services
|
||||
indexs.Add(c);
|
||||
}
|
||||
}
|
||||
if (long.TryParse(detail, out long id))
|
||||
if (indexs.Count > 1)
|
||||
{
|
||||
msg = Controller.AddItemsToOffer(uid, id, true, [.. indexs]);
|
||||
msg = Controller.AddOfferItems(uid, indexs[0], true, [.. indexs[1..]]);
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
await SendAsync(e, "报价添加对方物品", msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "格式不正确,请先输入报价序号再输入物品序号,使用空格隔开。";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (e.Detail.StartsWith(value: "报价移除物品"))
|
||||
{
|
||||
string detail = e.Detail.Replace("报价移除物品", "").Trim();
|
||||
string msg = "";
|
||||
string[] strings = detail.Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
|
||||
List<int> indexs = [];
|
||||
foreach (string s in strings)
|
||||
{
|
||||
if (int.TryParse(s, out int c))
|
||||
{
|
||||
indexs.Add(c);
|
||||
}
|
||||
}
|
||||
if (indexs.Count > 1)
|
||||
{
|
||||
msg = Controller.RemoveOfferItems(uid, indexs[0], false, [.. indexs[1..]]);
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
await SendAsync(e, "报价移除物品", msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "格式不正确,请先输入报价序号再输入物品序号,使用空格隔开。";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (e.Detail.StartsWith(value: "报价移除对方物品"))
|
||||
{
|
||||
string detail = e.Detail.Replace("报价移除对方物品", "").Trim();
|
||||
string msg = "";
|
||||
string[] strings = detail.Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
|
||||
List<int> indexs = [];
|
||||
foreach (string s in strings)
|
||||
{
|
||||
if (int.TryParse(s, out int c))
|
||||
{
|
||||
indexs.Add(c);
|
||||
}
|
||||
}
|
||||
if (indexs.Count > 1)
|
||||
{
|
||||
msg = Controller.RemoveOfferItems(uid, indexs[0], true, [.. indexs[1..]]);
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
await SendAsync(e, "报价移除对方物品", msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "格式不正确,请先输入报价序号再输入物品序号,使用空格隔开。";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user