Skip to content

Conversation

Copy link

Copilot AI commented Dec 25, 2025

Implements core game mechanics for factory production queues, market trading with depreciation, and technology upgrades with character buff application.

Changes

Produce.cs

  • Production queue per team with async Task-based processing
  • Atomic CAS resource deduction prevents race conditions
  • Production parameters: Semiconductor(10r/5s), Medicine(5r/4s), Toys(1r/2s), Clothes(8r/6s), Food(3r/1s)

Trade.cs

  • Buy: Characters load goods from team factory with capacity validation
  • Sell: Market prices with ×2 multiplier, 10% depreciation per 100 units sold
  • Score calculation: revenue × 10 per game rules
  • Depreciation applies to future sales, not current transaction

Uplevel.cs

  • Tech upgrades consume power and apply buffs to all team characters
  • HP tech: +50% max HP with proportional current HP increase
  • Attack tech: +30% power
  • Speed/Efficiency tech: +1 efficiency stat
  • Carry tech: +50% capacity
  • Cached enum values to avoid repeated allocations

Game.cs

  • Wired Trade() and UplevelTech() APIs to partial class implementations
  • Added InitProductionQueues() to constructor

Thread Safety

All implementations use ConcurrentDictionary, AtomicInt/AtomicLong, and CAS operations where appropriate.

// Atomic resource check and deduction
while (!resourcesDeducted) {
    int current = factory.Source.Get();
    if (current < needed) return;
    if (factory.Source.CompareExROri(current - needed, current) == current)
        resourcesDeducted = true;
}
Original prompt

阅读整个项目,撰写logic文件夹下的Produce.cs,Teams.cs,Trade.cs和Uplevel.cs文件


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 25, 2025 10:58
Co-authored-by: jxd136 <185790153+jxd136@users.noreply.github.com>
Co-authored-by: jxd136 <185790153+jxd136@users.noreply.github.com>
…Task-based threading, cached enum values

Co-authored-by: jxd136 <185790153+jxd136@users.noreply.github.com>
Co-authored-by: jxd136 <185790153+jxd136@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Produce, Teams, Trade, and Uplevel files to logic folder Implement production, trade, and technology upgrade logic for game engine Dec 25, 2025
Copilot AI requested a review from jxd136 December 25, 2025 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants