Mod: mining rig, graphics cards, trading terminal, nightly settlement

First playable slice, tested in game on the test save:
- Network upgrade "Mining Access" (300) delivers a trading terminal, a
  mining rig and an RZX 50.
- The rig is a machine with a battery slot and four card slots; each night
  it draws its total power from the battery and its cards mine PSCoin.
  Cards show hashrate, power draw and condition, wear every night and can
  burn out. All state lives on item tags or in the mod save data.
- Trading terminal with wallet, trade (four pairs, deposit credits as CRC,
  withdraw CRC through the compliance desk) and report pages.
- Nightly log lines; exchange opening and halving news on the paper.
- English and Chinese text; sprites generated by art/sprites.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZHU MINCHAOandClaude Opus 5.5 committed 2026-11-03 09:11:46 +08:00
1 parent efc58888f3
commit 750b26e4b3
21 files changed
+1040

No files matched your search

+76
View File
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using Decentralized.Domain;
using Newtonsoft.Json;
namespace Decentralized
{
/// <summary>上一晚的挖矿报告(终端"报告"页和晨间日志)。</summary>
public sealed class NightReport
{
public int Day;
public int Rigs, PoweredRigs;
public double Hash, NetworkHash, Mined, Price, Kj;
public List<string> Burnt = new List<string>();
}
/// <summary>一局的 mod 状态。整体序列化成 JSON 存进游戏的 mod 存档数据;显卡的健康度等存在显卡物品的标签上。</summary>
public sealed class SaveData
{
public int Version = 1;
public int Day;
public Rng Rng = new Rng((ulong)DateTime.UtcNow.Ticks);
public Market Market;
public Stablecoins Stable = new Stablecoins();
public Network Network = new Network();
public Wallet Hot = new Wallet { Address = "hot" };
public Exchange Exchange = new Exchange();
public List<MarketEvent> ActiveEvents = new List<MarketEvent>();
public NightReport LastNight;
public bool OpeningNewsShown;
}
/// <summary>当前这一局的状态:读档 / 新游戏时载入,睡觉结算后写回。</summary>
public static class Session
{
private const string Key = "state";
public static SaveData Data;
/// <summary>今晚有电的矿架上的显卡(矿架在夜间早段扣电时登记,结算时用)。</summary>
public static readonly List<GameItem> TonightCards = new List<GameItem>();
public static int TonightRigs, TonightPoweredRigs;
public static double TonightKj;
public static void Load()
{
Data = null;
try
{
string json = ModHelper.GetModData(ModInfo.Id, Key);
if (!string.IsNullOrEmpty(json)) Data = JsonConvert.DeserializeObject<SaveData>(json);
}
catch (Exception ex) { Log.Error($"读取存档数据失败,重新开始:{ex.Message}"); }
if (Data == null) Data = new SaveData();
if (Data.Market == null) Data.Market = Market.CreateDefault(StoreStation.GetDayCounter());
Log.Info($"状态已载入(第 {Data.Day} 天,PSCoin {Data.Market.Price:0.00})");
}
public static void Save()
{
if (Data == null) return;
try { ModHelper.SetModData(ModInfo.Id, Key, JsonConvert.SerializeObject(Data)); }
catch (Exception ex) { Log.Error($"写入存档数据失败:{ex.Message}"); }
}
/// <summary>链上资产的信用点价格。</summary>
public static double Price(string asset)
{
if (asset == Assets.PSC) return Data.Market.Price;
var spec = Assets.Get(asset);
if (spec != null && spec.Stable) return Data.Stable.Price(asset);
return 0;
}
public static double Rent() => PlayerStore.Instance != null ? PlayerStore.Instance.rentValue : 200;
}
}