Seller claim lapses when the card is bought unless edited with a labeler; test helpers for sell and buy sides
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f564a895d0
commit
393dd8057a
2 files changed
+45
-4
No files matched your search
@@ -41,6 +41,33 @@ namespace Decentralized
|
||||
Walk(m.panel.transform, 0);
|
||||
Log.Info(sb.ToString());
|
||||
}));
|
||||
ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Edit claim + offer to buyer (test)", () => Log.Guard("卖出侧测试", () =>
|
||||
{
|
||||
var rng = Session.Data.Rng;
|
||||
// 自己的一张真卡:标签机改成旗舰型号并把成色说成没问题,再摆给一位买家
|
||||
var item = Items.NewCard("RZX70", 55, null, rng);
|
||||
Items.Give(item);
|
||||
var u = Items.ToUnit(item);
|
||||
var c = Claim.Truth(u); c.Model = "RZX90"; c.Fan = 0; c.Fingers = 0; c.Bracket = 0; c.Sticker = 0;
|
||||
item.EnableTag(Items.EditedTag);
|
||||
Items.SetClaim(item, c, 0);
|
||||
var client = new StoreClient { identifier = "pd_test_buyer", displayName = "买家", spriteName = SpriteDict.GetRandomScavSpriteName(), clientIntent = StoreClient.ClientIntent.BUY };
|
||||
client.CompleteClientCreation();
|
||||
PlayerStore.Instance.currentClientInstance = StoreClientInstance.CreateClientInstance(client);
|
||||
Log.Info($"测试:卡 #{item.uniqueId} 说法 {c.Encode()},真实 {Claim.Truth(u).Encode()},价格 {item.unitValue},信誉前");
|
||||
Items.OfferForTest(item);
|
||||
Log.Info($"测试:验货后 Exposed={Items.Exposed(item)} 价格 {item.unitValue}");
|
||||
}));
|
||||
ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Buy scam card (test)", () => Log.Guard("买入侧测试", () =>
|
||||
{
|
||||
var rng = Session.Data.Rng;
|
||||
var item = Items.NewCard("RZX90", 60, "RZX60", rng, DealerKind.Scammer, 0);
|
||||
long before = item.unitValue;
|
||||
GeneralHelper.SetItemOwned(item, true);
|
||||
Items.Refresh(item);
|
||||
Items.Give(item);
|
||||
Log.Info($"买入测试:卡 #{item.uniqueId} 买前报价 {before},买下后价值 {item.unitValue},真实 {CardValue.True(Items.ToUnit(item))},说法 {(Items.GetClaim(item)?.Encode() ?? "无")}");
|
||||
}));
|
||||
ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Dr. Jackson stock (test)", () =>
|
||||
{
|
||||
EmporiumEntry.Instance.ClearFrontInv();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Decentralized
|
||||
public const string FakeTag = "PD_FAKE_OF";
|
||||
public const string RefurbTag = "PD_REFURBISHED";
|
||||
public const string DeadTag = "PD_DEAD";
|
||||
public const string LookTag = "PD_LOOK", BackTag = "PD_BACK", SeedTag = "PD_SEED", ClaimTag = "PD_CLAIM", ExposedTag = "PD_EXPOSED", MarkupTag = "PD_MARKUP";
|
||||
public const string LookTag = "PD_LOOK", BackTag = "PD_BACK", SeedTag = "PD_SEED", ClaimTag = "PD_CLAIM", ExposedTag = "PD_EXPOSED", MarkupTag = "PD_MARKUP", EditedTag = "PD_EDITED";
|
||||
|
||||
public static Action OpenTerminal;
|
||||
|
||||
@@ -111,7 +111,11 @@ namespace Decentralized
|
||||
var item = ModHelper.SpawnItem(GpuId(model));
|
||||
var u = new Unit { Model = model, FakeOf = fakeOf, Health = health, Look = CardLook.Generate(rng, health, fakeOf != null) };
|
||||
Store(item, u);
|
||||
if (seller != null) SetClaim(item, CardLabels.DealerClaim(u, seller.Value, rng), 0, markupPct);
|
||||
if (seller != null)
|
||||
{
|
||||
GeneralHelper.SetItemOwned(item, false); // 卖家的货:买下之前不属于玩家,说法才有效
|
||||
SetClaim(item, CardLabels.DealerClaim(u, seller.Value, rng), 0, markupPct);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -125,9 +129,11 @@ namespace Decentralized
|
||||
/// 自己的卡摆给想买的顾客:说法里隐瞒的每一项,顾客有 35% 的概率看出来;看出来就拆穿这一项(价格回到真实情况),
|
||||
/// 并且掉一点信誉。每位顾客对每张卡只看一次。说法比实际更差(把好卡说差了)顾客不会去指。
|
||||
/// </summary>
|
||||
private static void OnOffered(GameItem item)
|
||||
public static void OfferForTest(GameItem item) { checkedItems.Clear(); OnOffered(item, true); }
|
||||
|
||||
private static void OnOffered(GameItem item, bool force = false)
|
||||
{
|
||||
if (item.IsTag(DeadTag) || !GeneralHelper.IsItemOwned(item) || !item.IsRootedInBackInv()) return;
|
||||
if (item.IsTag(DeadTag) || !GeneralHelper.IsItemOwned(item) || (!force && !item.IsRootedInBackInv())) return;
|
||||
var ci = PlayerStore.Instance.currentClientInstance;
|
||||
var client = ci?.GetClientBlueprint();
|
||||
if (client == null || (client.clientIntent != StoreClient.ClientIntent.BUY && client.clientIntent != StoreClient.ClientIntent.SELLNBUY)) return;
|
||||
@@ -210,6 +216,7 @@ namespace Decentralized
|
||||
var claim = GetClaim(item) ?? Claim.Truth(u);
|
||||
claim = row == CardLabels.RowSpec ? new Claim { Model = model ?? claim.Model, Fan = claim.Fan, Fingers = claim.Fingers, Bracket = claim.Bracket, Print = claim.Print, Sticker = claim.Sticker } : claim.With(row, value);
|
||||
int exposed = Exposed(item) & ~row;
|
||||
item.EnableTag(EditedTag);
|
||||
SetClaim(item, claim, exposed);
|
||||
}
|
||||
|
||||
@@ -226,6 +233,13 @@ namespace Decentralized
|
||||
private static void SyncValue(GameItem item)
|
||||
{
|
||||
if (item.IsTag(DeadTag)) return;
|
||||
// 买下之后卖家的说法作废:卡回到真实情况,除非玩家用标签机自己改过
|
||||
if (GeneralHelper.IsItemOwned(item) && item.IsTag(ClaimTag) && !item.IsTag(EditedTag))
|
||||
{
|
||||
item.ModifyTag(ClaimTag, t => t.Disable());
|
||||
item.ModifyTag(ExposedTag, t => t.Disable());
|
||||
item.ModifyTag(MarkupTag, t => t.Disable());
|
||||
}
|
||||
var u = ToUnit(item);
|
||||
string desc = Desc(item, u);
|
||||
if (item.shortDescription != desc) item.shortDescription = desc;
|
||||
|
||||
Reference in new issue
Block a user