Cancel honeypot traces for orders that were never delivered
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d3302a2f7
commit
205c321840
2 files changed
+22
-6
No files matched your search
@@ -33,6 +33,7 @@ namespace Decentralized.Domain
|
||||
|
||||
public sealed class BmOrder
|
||||
{
|
||||
public int Id;
|
||||
public string Item;
|
||||
public string Seller;
|
||||
public bool SellerScam;
|
||||
@@ -60,6 +61,8 @@ namespace Decentralized.Domain
|
||||
public double Amount;
|
||||
public string Why;
|
||||
public string Item;
|
||||
/// <summary>对应的订单(没收到货的订单不会被追查);0 表示不挂订单(出售记录、落网)。</summary>
|
||||
public int OrderId;
|
||||
}
|
||||
|
||||
/// <summary>夜间发生的订单事件,供日志与新闻使用。</summary>
|
||||
@@ -82,6 +85,10 @@ namespace Decentralized.Domain
|
||||
/// <summary>执法接管平台的最后一天(含);期间的交易之后会被追查。</summary>
|
||||
public int HoneypotUntil = -1;
|
||||
public List<BmTrap> Traps = new List<BmTrap>();
|
||||
public int NextOrderId = 1;
|
||||
|
||||
/// <summary>订单没有交付(退款、被截获、骗子、平台跑路、拒签、被查封):对应的追查一并取消。</summary>
|
||||
private void DropTraps(BmOrder o) => Traps.RemoveAll(t => t.OrderId == o.Id && o.Id != 0);
|
||||
|
||||
public bool Honeypot(int day) => day <= HoneypotUntil;
|
||||
|
||||
@@ -219,13 +226,13 @@ namespace Decentralized.Domain
|
||||
w.Add(asset, -qty);
|
||||
var o = new BmOrder
|
||||
{
|
||||
Item = l.Item, Seller = seller.Name, SellerScam = seller.Scam, Mode = mode, Count = count, Model = l.Model, FakeOf = l.FakeOf, Health = l.Health, Price = credits, Asset = asset, Qty = qty,
|
||||
Id = NextOrderId++, Item = l.Item, Seller = seller.Name, SellerScam = seller.Scam, Mode = mode, Count = count, Model = l.Model, FakeOf = l.FakeOf, Health = l.Health, Price = credits, Asset = asset, Qty = qty,
|
||||
Taint = taint, Basis = basis, PlacedDay = day, DueDay = day + seller.Days,
|
||||
};
|
||||
l.Qty -= count;
|
||||
if (l.Qty <= 0) Catalog.Remove(l);
|
||||
Orders.Add(o);
|
||||
if (Honeypot(day)) Traps.Add(new BmTrap { Day = day + Tuning.BmTrapDelay, Amount = credits, Why = "honeypot", Item = l.Item });
|
||||
if (Honeypot(day)) Traps.Add(new BmTrap { Day = day + Tuning.BmTrapDelay, Amount = credits, Why = "honeypot", Item = l.Item, OrderId = o.Id });
|
||||
return o;
|
||||
}
|
||||
|
||||
@@ -245,7 +252,7 @@ namespace Decentralized.Domain
|
||||
{
|
||||
foreach (var o in Orders.Where(o => o.State == OrderState.Pending))
|
||||
{
|
||||
o.State = OrderState.Lost; o.Why = "rug";
|
||||
o.State = OrderState.Lost; o.Why = "rug"; DropTraps(o);
|
||||
ev.Add(new BmEvent { Kind = "rug", Order = o, Amount = o.Price });
|
||||
}
|
||||
foreach (var sl in Sales.Where(x => x.State == SaleState.Listed || x.State == SaleState.Sold))
|
||||
@@ -263,15 +270,15 @@ namespace Decentralized.Domain
|
||||
if (crackdown) { o.DueDay = day + 1; continue; }
|
||||
if (o.SellerScam)
|
||||
{
|
||||
if (o.Mode == PayMode.Escrow) { Refund(w, o); o.State = OrderState.Refunded; o.Why = "scam"; ev.Add(new BmEvent { Kind = "scam_refund", Order = o, Amount = o.Price }); }
|
||||
else { o.State = OrderState.Lost; o.Why = "scam"; ev.Add(new BmEvent { Kind = "scam_loss", Order = o, Amount = o.Price }); }
|
||||
if (o.Mode == PayMode.Escrow) { Refund(w, o); o.State = OrderState.Refunded; o.Why = "scam"; DropTraps(o); ev.Add(new BmEvent { Kind = "scam_refund", Order = o, Amount = o.Price }); }
|
||||
else { o.State = OrderState.Lost; o.Why = "scam"; DropTraps(o); ev.Add(new BmEvent { Kind = "scam_loss", Order = o, Amount = o.Price }); }
|
||||
continue;
|
||||
}
|
||||
double ic = Tuning.BmInterceptDoor + (crackdown ? Tuning.BmInterceptCrackdown : 0);
|
||||
if (rng.Chance(ic))
|
||||
{
|
||||
if (rng.Chance(Tuning.BmControlled)) { o.Controlled = true; o.State = OrderState.Ready; ev.Add(new BmEvent { Kind = "ready", Order = o }); continue; }
|
||||
o.State = OrderState.Lost; o.Why = "intercept"; ev.Add(new BmEvent { Kind = "intercept", Order = o, Amount = o.Price }); continue;
|
||||
o.State = OrderState.Lost; o.Why = "intercept"; DropTraps(o); ev.Add(new BmEvent { Kind = "intercept", Order = o, Amount = o.Price }); continue;
|
||||
}
|
||||
o.State = OrderState.Ready;
|
||||
ev.Add(new BmEvent { Kind = "ready", Order = o });
|
||||
@@ -299,6 +306,7 @@ namespace Decentralized.Domain
|
||||
{
|
||||
o.State = OrderState.Lost;
|
||||
o.Why = accept ? "seized" : "refused";
|
||||
DropTraps(o);
|
||||
return accept ? o.Price : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -645,6 +645,14 @@ internal static class Program
|
||||
var cm = new BlackMarket();
|
||||
Check(Near(cm.Sign(co2, true), 150, 1e-9) && co2.State == OrderState.Lost && co2.Why == "seized" && Near(cm.Sign(new BmOrder { Price = 50 }, false), 0, 1e-9), "签收记罪证(金额)并查封,拒签不记");
|
||||
Check(BlackMarket.HoneypotChance(100) > BlackMarket.HoneypotChance(0) && BlackMarket.HoneypotChance(100000) <= Tuning.BmHoneypotMax, "治安声望越高越容易被接管,有封顶");
|
||||
// 没收到货的订单不会被追查:骗子退款后蜜罐追查取消
|
||||
var hb = new BlackMarket(); hb.Sellers.Add(bad); hb.HoneypotUntil = 50;
|
||||
var hw2 = new Wallet(); hw2.Add(Assets.CRT, 5000);
|
||||
var hl = new BmListing { Seller = 0, Item = "x", Price = 100, Qty = 9 };
|
||||
var ho2 = hb.Place(hl, 1, PayMode.Escrow, hw2, Assets.CRT, 10, price);
|
||||
Check(hb.Traps.Count == 1 && ho2.Id > 0, "蜜罐期间下单:先挂追查");
|
||||
hb.Night(ho2.DueDay, false, hw2, new Rng(4));
|
||||
Check(ho2.State == OrderState.Refunded && hb.Traps.Count == 0, "骗子卖家退款后追查取消(没拿到货不记罪证)");
|
||||
// 跑路:托管资金多则概率高;跑路后关闭
|
||||
var r = new BlackMarket(); r.Sellers.Add(good);
|
||||
var rw = new Wallet(); rw.Add(Assets.CRT, 1000000);
|
||||
|
||||
Reference in new issue
Block a user