Refactor alot of stuff
This commit is contained in:
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: lang_cpp_malloc
|
||||
displayName: malloc()
|
||||
description: 'Deal 15. Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 12. Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'Space reserved. Contents unspecified. Confidence excessive.'
|
||||
language: 1
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: lang_cpp_pointer
|
||||
displayName: pointer
|
||||
description: 'Deal 12; 20 if the previous card was C++. Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 9; 15 if the previous card was C++. Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'The address is valid. The thing it used to point to is another matter.'
|
||||
language: 1
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: lang_cpp_printf
|
||||
displayName: printf()
|
||||
description: 'Deal 6, then repair 2 corrupted cards. Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 4, then repair 2 corrupted cards. Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'The last checkpoint printed successfully. That narrows it down.'
|
||||
language: 1
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: lang_ts_console_log
|
||||
displayName: console.log()
|
||||
description: 'Deal 9. Fixed damage; no critical roll.'
|
||||
description: 'Deal 6. Fixed damage; cannot crit.'
|
||||
flavorText: 'It says undefined. The investigation continues.'
|
||||
language: 5
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: lang_ts_fetch
|
||||
displayName: fetch()
|
||||
description: 'Deal 13. Fixed damage; no critical roll.'
|
||||
description: 'Deal 9. Fixed damage; cannot crit.'
|
||||
flavorText: 'Request sent. Optimism remains pending.'
|
||||
language: 5
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: lang_ts_typeof
|
||||
displayName: typeof
|
||||
description: 'Deal 16. Always succeeds. Fixed damage; no critical roll.'
|
||||
description: 'Deal 11. Always succeeds. Fixed damage; cannot crit.'
|
||||
flavorText: 'NaN is a number. Damage is occasionally a philosophical question.'
|
||||
language: 5
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_cpp_free
|
||||
displayName: free()
|
||||
description: 'Deal 22. Repair 2 corrupted cards. Draw 2 (fixed). Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 18. Repair 2 corrupted cards. Draw 2 (fixed). Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'Release the allocation. Please don''t keep using the address.'
|
||||
language: 1
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_cpp_kernel_exploit
|
||||
displayName: kernel_exploit
|
||||
description: 'Deal 40 ignoring Shield. Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 36 ignoring Shield. Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'The Shield check was in userspace. You aren''t anymore.'
|
||||
language: 1
|
||||
rarity: 1
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_cpp_memcpy
|
||||
displayName: memcpy()
|
||||
description: 'Deal 9. Draw 1 (fixed). Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 6. Draw 1 (fixed). Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'Copies exactly the bytes you asked for. Check how many you asked for.'
|
||||
language: 1
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_cpp_memset
|
||||
displayName: memset()
|
||||
description: 'Deal 6 to all enemies. Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 4 to all enemies. Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'A consistent value across the whole battlefield. Usually zero.'
|
||||
language: 1
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_cpp_realloc
|
||||
displayName: realloc()
|
||||
description: 'Deal 16. Repair 3 corrupted cards. Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 12. Repair 3 corrupted cards. Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'More room, possibly a new address. Update your assumptions accordingly.'
|
||||
language: 1
|
||||
rarity: 1
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_cpp_sizeof
|
||||
displayName: sizeof()
|
||||
description: 'Deal 6 x C and C++ cards in hand. Full overkill spills. No segfault recoil.'
|
||||
description: 'Deal 5 x C and C++ cards in hand. Full overkill spills. No segfault recoil.'
|
||||
flavorText: 'Measure first. Remember that a pointer is not the array.'
|
||||
language: 1
|
||||
rarity: 1
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: "shop_ts_array_map"
|
||||
displayName: "Array.map()"
|
||||
description: 'Deal 6 to all enemies. Fixed damage; no critical roll.'
|
||||
description: 'Deal 4 to all enemies. Fixed damage; cannot crit.'
|
||||
flavorText: 'One callback per target. Results may vary; that part is intentional.'
|
||||
language: 5
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: "shop_ts_eval"
|
||||
displayName: "eval()"
|
||||
description: 'Deal 30. Fixed damage; no critical roll.'
|
||||
description: 'Deal 15. Fixed damage; cannot crit.'
|
||||
flavorText: 'The string is code now. This was a decision.'
|
||||
language: 5
|
||||
rarity: 1
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_ts_json_parse
|
||||
displayName: JSON.parse()
|
||||
description: 'Deal 9. Draw 1 (fixed). Fixed damage; no critical roll.'
|
||||
description: 'Deal 6. Draw 1 (fixed). Fixed damage; cannot crit.'
|
||||
flavorText: 'Expected JSON. Received an HTML apology.'
|
||||
language: 5
|
||||
rarity: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_ts_math_random
|
||||
displayName: Math.random()
|
||||
description: 'Deal 20. Fixed damage; no critical roll.'
|
||||
description: 'Deal 11. Fixed damage; cannot crit.'
|
||||
flavorText: 'The damage estimate is technically within specification.'
|
||||
language: 5
|
||||
rarity: 1
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_ts_promise_all
|
||||
displayName: Promise.all()
|
||||
description: 'Deal 10 three times. Fixed damage; no critical roll.'
|
||||
description: 'Deal 7 three times. Fixed damage; cannot crit.'
|
||||
flavorText: 'One result for the group. One rejection can ruin the meeting.'
|
||||
language: 5
|
||||
rarity: 1
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: shop_ts_promise_resolve
|
||||
displayName: Promise.resolve()
|
||||
description: 'Deal 5. Fixed damage; no critical roll.'
|
||||
description: 'Deal 3. Fixed damage; cannot crit.'
|
||||
flavorText: 'Resolved. The callback will be with you after the current stack clears.'
|
||||
language: 5
|
||||
rarity: 0
|
||||
|
||||
@@ -6,8 +6,10 @@ MonoBehaviour:
|
||||
m_Name: Apt
|
||||
id: pkg_ubuntu_apt
|
||||
displayName: apt
|
||||
slot: 2
|
||||
slot: 1
|
||||
legacySlot: 2
|
||||
rarity: 5
|
||||
maxUpgradeLevel: 1
|
||||
description: Each time you play your 3rd card in a TURN, add a random 0-cost card of your languages to hand; on Ubuntu also refund 1 Cycle.
|
||||
flavourText: 'Dependency resolution is a surprisingly effective way to expand a collection.'
|
||||
designNotes: Ubuntu 5-star Daemon. TURN third-card trigger. requiresSystem: card-generation + per-turn-card-count. On Ubuntu refunds 1 Cycle.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: apt-fast
|
||||
slot: 1
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 1
|
||||
description: Start of each WAVE, gain +1 Cycle that WAVE's first TURN.
|
||||
flavourText: 'Same packages, more connections. The mirrors are doing their best.'
|
||||
designNotes: Generic 3-star Runtime powerspike. First-turn WAVE cycle hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: auditd
|
||||
slot: 2
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 3
|
||||
description: Start of each TURN, if you have no debuffs, gain 3 Shield.
|
||||
flavourText: 'A clean audit trail. For now.'
|
||||
designNotes: Generic 3-star Daemon powerspike. Uses status descriptor harmful query.
|
||||
|
||||
@@ -13,9 +13,10 @@ MonoBehaviour:
|
||||
m_Name: Aur
|
||||
m_EditorClassIdentifier:
|
||||
id: pkg_aur
|
||||
displayName: AUR
|
||||
displayName: AUR integration
|
||||
slot: 1
|
||||
rarity: 4
|
||||
maxUpgradeLevel: 0
|
||||
description: start each TURN with a generated C/Rust card. on Arch, any rarity and costs 1 less this turn; off-distro, common only with no discount.
|
||||
flavourText: 'If it exists, someone probably wrote a PKGBUILD. Review quality varies.'
|
||||
designNotes: Arch 4-star Runtime package. Scope TURN. On Arch: generate random C/Rust card up to Legendary rarity and apply -1 temporary cost. Off-distro: generate Common C/Rust only with no discount. Uses existing generated-card pool; requiresSystem card-generation if no eligible pool is available. Runtime slot intentionally does not conflict with systemd Daemon.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: ccache
|
||||
slot: 1
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 2
|
||||
description: Every 4th card played in a WAVE costs 0.
|
||||
flavourText: 'Already built that. Kept the useful part.'
|
||||
designNotes: Generic 3-star Runtime powerspike. Existing nth-card WAVE free-cost hook.
|
||||
|
||||
@@ -6,8 +6,10 @@ MonoBehaviour:
|
||||
m_Name: CinnamonPackage
|
||||
id: pkg_mint_cinnamon
|
||||
displayName: Cinnamon
|
||||
slot: 1
|
||||
slot: 0
|
||||
legacySlot: 1
|
||||
rarity: 4
|
||||
maxUpgradeLevel: 3
|
||||
description: JavaScript cards deal +3 flat on Mint, +2 off-distro.
|
||||
flavourText: 'A little JavaScript makes the desktop friendlier. Here, it also hits harder.'
|
||||
designNotes: Mint 4-star Runtime. Flat add through DamagePipeline additive step. On Mint +3; off-distro +2.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: coreutils
|
||||
slot: 0
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 8
|
||||
description: +2 max Uptime (COMBAT).
|
||||
flavourText: 'Small tools, doing their jobs. The system tends to notice when they''re missing.'
|
||||
designNotes: Generic 1-star Kernel baseline. COMBAT stat package. On/off distro identical.
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: cron
|
||||
slot: 2
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 5
|
||||
description: Every 3rd TURN, gain 2 Shield.
|
||||
flavourText: 'Scheduled maintenance. Your shell environment was not invited.'
|
||||
designNotes: Generic 1-star Daemon. TURN counter shield. On/off distro identical.
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: curl
|
||||
slot: 1
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 1
|
||||
description: Draw 1 extra card at the start of each WAVE.
|
||||
flavourText: 'One request, one response, several flags you looked up last time too.'
|
||||
designNotes: Generic 1-star Runtime. WAVE start draw. On/off distro identical.
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: DNF
|
||||
slot: 1
|
||||
rarity: 5
|
||||
maxUpgradeLevel: 3
|
||||
description: On Fedora, Bleeding Edge applies to the 2nd card each TURN. Also builds a stacking +2 damage buff this WAVE.
|
||||
flavourText: 'Another transaction completed. The changelog is becoming a damage report.'
|
||||
designNotes: Fedora 5-star Runtime. Ties into Bleeding Edge crash logic; on Fedora enables 2nd-card passive discount+bonus. Off-distro only uses the WAVE stacking +2 damage buff hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: dbus
|
||||
slot: 2
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 6
|
||||
description: First time you play a queued (InterpreterQueue) card each WAVE, gain 2 Shield.
|
||||
flavourText: 'The services are talking. This is usually better than the alternative.'
|
||||
designNotes: Generic 1-star Daemon. InterpreterQueue play hook.
|
||||
|
||||
@@ -6,8 +6,10 @@ MonoBehaviour:
|
||||
m_Name: Docker
|
||||
id: pkg_docker
|
||||
displayName: docker
|
||||
slot: 1
|
||||
slot: 2
|
||||
legacySlot: 1
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 1
|
||||
description: At the start of each WAVE, add a random 0-cost basic card of the distro's languages to hand.
|
||||
flavourText: 'Works on my machine. The image includes enough of it to help.'
|
||||
designNotes: Generic 3-star Runtime powerspike. WAVE start generation. requiresSystem: card-generation; uses existing generated-card pool when available, TODO logged if not.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: ext4
|
||||
slot: 0
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 8
|
||||
description: +4 max Uptime (COMBAT).
|
||||
flavourText: 'Write down the plan before the power goes out.'
|
||||
designNotes: Generic 2-star Kernel. COMBAT stat package.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: firewalld
|
||||
slot: 2
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 0
|
||||
description: The first debuff applied to you each WAVE is reduced by 1 stack.
|
||||
flavourText: 'The incoming problem has been assigned to a less welcoming zone.'
|
||||
designNotes: Generic 2-star Daemon. TODO status prevention/rewrite hook missing.
|
||||
|
||||
@@ -5,9 +5,10 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 48447d3db18343398488d3064324147d, type: 3}
|
||||
m_Name: GentooCcache
|
||||
id: pkg_gentoo_ccache
|
||||
displayName: ccache
|
||||
displayName: ccache — Gentoo build cache
|
||||
slot: 1
|
||||
rarity: 4
|
||||
maxUpgradeLevel: 5
|
||||
description: First accepted card each round costs 1 less. L1-L5 grants 1-5 Shield on its successful play. On Gentoo gain 1 Cycle next round if Compilation advanced this round.
|
||||
flavourText: 'The fastest compilation is the one you don''t have to repeat.'
|
||||
intendedDistroId: gentoo
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: OpenRC
|
||||
slot: 2
|
||||
rarity: 5
|
||||
maxUpgradeLevel: 5
|
||||
description: After the first round gain 2 Shield (+1 per level) each round. On Gentoo also advance Compilation by 1, capped by version, without triggering increase hooks.
|
||||
flavourText: 'Bring up the services in order. Let the rest of the system get on with it.'
|
||||
intendedDistroId: gentoo
|
||||
|
||||
@@ -6,8 +6,10 @@ MonoBehaviour:
|
||||
m_Name: GentooPortage
|
||||
id: pkg_gentoo_portage
|
||||
displayName: Portage
|
||||
slot: 0
|
||||
slot: 1
|
||||
legacySlot: 0
|
||||
rarity: 4
|
||||
maxUpgradeLevel: 5
|
||||
description: Max Uptime +4 (+2 per level). On Gentoo also gain the same amount of Shield once per wave, minimum 4.
|
||||
flavourText: 'A dependency tree with a build plan attached. Settle in.'
|
||||
intendedDistroId: gentoo
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: git
|
||||
slot: 1
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 1
|
||||
description: The first card played each WAVE costs 1 less.
|
||||
flavourText: 'A known starting point, before the working tree develops opinions.'
|
||||
designNotes: Generic 2-star Runtime. WAVE first-card economy. On/off distro identical.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: glibc
|
||||
slot: 0
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 8
|
||||
description: +2 max Uptime (COMBAT).
|
||||
flavourText: 'So much depends on this that replacing it feels like a boss fight.'
|
||||
designNotes: Generic 1-star Kernel. COMBAT stat package. Upgrade scaling increases amount at runtime.
|
||||
|
||||
@@ -14,8 +14,10 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: pkg_htop
|
||||
displayName: htop
|
||||
slot: 0
|
||||
slot: 1
|
||||
legacySlot: 0
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 6
|
||||
description: +5 max Uptime (COMBAT).
|
||||
flavourText: 'Find the process eating your resources. Try not to take the answer personally.'
|
||||
designNotes: Generic 2-star Kernel. COMBAT stat package. On/off distro identical.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: less
|
||||
slot: 1
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 0
|
||||
description: Once per WAVE, the first card drawn is free to play (0 cost) that TURN.
|
||||
flavourText: 'Inspect before committing. Press q when you''ve learned enough.'
|
||||
designNotes: Generic 1-star Runtime. TODO free-cast/draw-tag hook missing.
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: logrotate
|
||||
slot: 2
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 3
|
||||
description: When you exhaust a card, gain 1 Shield.
|
||||
flavourText: 'Keep the useful history. Retire the files that became the problem.'
|
||||
designNotes: Generic 2-star Daemon. Exhaust hook; current authored exhaust path is dnf autoremove.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: lvm
|
||||
slot: 0
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 6
|
||||
description: +8 max Uptime (COMBAT).
|
||||
flavourText: 'Room to grow without pretending the disk grew with it.'
|
||||
designNotes: Generic 3-star Kernel powerspike. COMBAT stat package.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: make
|
||||
slot: 1
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 6
|
||||
description: The first Native card each WAVE deals +3.
|
||||
flavourText: 'Resolve the dependencies. Then hit the target.'
|
||||
designNotes: Generic 2-star Runtime. Routes through existing flat effect bonus before first Native card resolves.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: nano
|
||||
slot: 1
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 1
|
||||
description: The first card played each WAVE costs 1 less.
|
||||
flavourText: 'The exit shortcut is on screen. A modest but welcome feature.'
|
||||
designNotes: Generic 1-star Runtime. Existing first-card-per-WAVE cost hook.
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: nginx
|
||||
slot: 2
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 1
|
||||
description: Every 3rd card played in a WAVE costs 0.
|
||||
flavourText: 'Let the proxy handle it. The application has enough problems.'
|
||||
designNotes: Generic 3-star Daemon powerspike. WAVE card counter cost override.
|
||||
|
||||
@@ -14,8 +14,10 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: pkg_ntp
|
||||
displayName: ntp
|
||||
slot: 0
|
||||
slot: 2
|
||||
legacySlot: 0
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 8
|
||||
description: +3 max Uptime (COMBAT); first TURN of each WAVE, gain 2 Shield.
|
||||
flavourText: 'Agree on the time before disagreeing about the logs.'
|
||||
designNotes: Generic 2-star Kernel. Uses MaxUptime now; first-turn shield TODO until multi-effect packages exist.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: openssl
|
||||
slot: 0
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 8
|
||||
description: +1 max Uptime (COMBAT), +1 Shield at WAVE start.
|
||||
flavourText: 'Secure the connection. Put the certificate renewal somewhere you''ll actually see it.'
|
||||
designNotes: Generic 1-star Kernel. Uses MaxUptime now; WAVE shield portion TODO until multi-effect packages exist.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: polkit
|
||||
slot: 2
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 3
|
||||
description: First time you gain Shield each TURN, gain +2 extra.
|
||||
flavourText: 'A little authorization before a lot of consequences.'
|
||||
designNotes: Generic 2-star Daemon. Existing first shield each TURN bonus hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: rsync
|
||||
slot: 1
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 1
|
||||
description: At WAVE start, draw 1 extra card.
|
||||
flavourText: 'Bring over what''s changed. Leave the rest where it works.'
|
||||
designNotes: Generic 2-star Runtime. WAVE draw hook.
|
||||
|
||||
@@ -6,8 +6,10 @@ MonoBehaviour:
|
||||
m_Name: SELinuxPackage
|
||||
id: pkg_fedora_selinux
|
||||
displayName: SELinux
|
||||
slot: 2
|
||||
slot: 0
|
||||
legacySlot: 2
|
||||
rarity: 4
|
||||
maxUpgradeLevel: 3
|
||||
description: First time you gain Shield each TURN, gain +5 extra on Fedora, +3 off-distro.
|
||||
flavourText: 'Least privilege. Even for processes with very confident names.'
|
||||
designNotes: Fedora 4-star Daemon. TURN first-shield trigger. On Fedora +5; off-distro +3.
|
||||
|
||||
@@ -8,6 +8,7 @@ MonoBehaviour:
|
||||
displayName: Snap Store
|
||||
slot: 1
|
||||
rarity: 4
|
||||
maxUpgradeLevel: 1
|
||||
description: First cards played each TURN cost 1 less; first 2 on Ubuntu, first 1 off-distro.
|
||||
flavourText: 'Installation is straightforward. Disk usage has follow-up questions.'
|
||||
designNotes: Ubuntu 4-star Runtime. TURN card-count cost discount. On Ubuntu threshold 2; off-distro threshold 1.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: sshd
|
||||
slot: 2
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 5
|
||||
description: Every 3rd TURN, gain 3 Shield.
|
||||
flavourText: 'Keys accepted. Random guesses from the internet, less so.'
|
||||
designNotes: Generic 2-star Daemon. Existing nth-TURN shield hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: swapfile
|
||||
slot: 0
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 2
|
||||
description: +1 max RAM (COMBAT).
|
||||
flavourText: 'A little breathing room. Disk latency is part of the arrangement.'
|
||||
designNotes: Generic 2-star Kernel. COMBAT RAM stat package.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: syslog
|
||||
slot: 2
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 3
|
||||
description: When you exhaust a card, gain 1 Shield.
|
||||
flavourText: 'The card is gone. Its final complaint is on record.'
|
||||
designNotes: Generic 1-star Daemon. Existing exhaust shield hook.
|
||||
|
||||
@@ -13,9 +13,10 @@ MonoBehaviour:
|
||||
m_Name: Systemd
|
||||
m_EditorClassIdentifier:
|
||||
id: pkg_systemd
|
||||
displayName: systemd
|
||||
displayName: systemd — Arch integration
|
||||
slot: 2
|
||||
rarity: 5
|
||||
maxUpgradeLevel: 5
|
||||
description: first C card each TURN deals 50% more damage. on Arch, btw stacks persist for the whole WAVE.
|
||||
flavourText: 'Dependencies ordered. Services ready. Opinions still loading.'
|
||||
designNotes: Arch signature Daemon. Off-distro grants only the first-C-card DamagePipeline multiplier. On Arch also sets persistArchBtw, so the Arch passive skips end-of-TURN btw reset and clears only on WAVE start or rolling-release recovery.
|
||||
|
||||
@@ -13,9 +13,11 @@ MonoBehaviour:
|
||||
m_Name: SystemdCore
|
||||
m_EditorClassIdentifier:
|
||||
id: pkg_systemd_core
|
||||
displayName: systemd-core
|
||||
slot: 0
|
||||
displayName: systemd — service manager
|
||||
slot: 2
|
||||
legacySlot: 0
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 1
|
||||
description: +1 max Cycles (COMBAT).
|
||||
flavourText: 'PID 1 has a long shift ahead.'
|
||||
designNotes: Generic 3-star Kernel powerspike. COMBAT max Cycle package. On/off distro identical.
|
||||
|
||||
@@ -13,9 +13,10 @@ MonoBehaviour:
|
||||
m_Name: SystemdTimer
|
||||
m_EditorClassIdentifier:
|
||||
id: pkg_systemd_timer
|
||||
displayName: systemd-timer
|
||||
displayName: systemd timers
|
||||
slot: 2
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 1
|
||||
description: Every 3rd card played in a WAVE, gain 1 Cycle.
|
||||
flavourText: 'A schedule with service management attached. Check both unit files.'
|
||||
designNotes: Generic 3-star Daemon powerspike. Nth-card WAVE cycle hook.
|
||||
|
||||
@@ -6,8 +6,10 @@ MonoBehaviour:
|
||||
m_Name: TimeshiftPackage
|
||||
id: pkg_mint_timeshift
|
||||
displayName: Timeshift
|
||||
slot: 0
|
||||
slot: 1
|
||||
legacySlot: 0
|
||||
rarity: 5
|
||||
maxUpgradeLevel: 5
|
||||
description: First time each WAVE Uptime would drop below a threshold, restore to it; 50% + cleanse on Mint, 30% off-distro.
|
||||
flavourText: 'A working snapshot beats a detailed memory of what used to work.'
|
||||
designNotes: Mint 5-star Kernel. WAVE damage/heal hook through DamagePipeline event; status cleanse on Mint only.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: udev
|
||||
slot: 2
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 2
|
||||
description: Every 4th TURN, draw 1 card.
|
||||
flavourText: 'A device arrived. Give it a name before the scripts start guessing.'
|
||||
designNotes: Generic 1-star Daemon. TURN draw hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: vim
|
||||
slot: 1
|
||||
rarity: 2
|
||||
maxUpgradeLevel: 1
|
||||
description: First card played each TURN costs 1 less.
|
||||
flavourText: 'One practiced motion saves a surprising amount of work.'
|
||||
designNotes: Generic 2-star Runtime. Existing first-card-per-TURN cost hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: wget
|
||||
slot: 1
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 2
|
||||
description: Draw 1 extra card on the first TURN of the first WAVE.
|
||||
flavourText: 'Fetch it once. Resume if the connection has other plans.'
|
||||
designNotes: Generic 1-star Runtime. First WAVE opening draw hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: zlib
|
||||
slot: 0
|
||||
rarity: 1
|
||||
maxUpgradeLevel: 6
|
||||
description: Start each WAVE with 3 Shield.
|
||||
flavourText: 'Less space wasted. More room for something useful.'
|
||||
designNotes: Generic 1-star Kernel. WAVE shield hook.
|
||||
|
||||
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
displayName: zram
|
||||
slot: 0
|
||||
rarity: 3
|
||||
maxUpgradeLevel: 1
|
||||
description: +1 max Cycles (COMBAT).
|
||||
flavourText: 'Compress what you have. The download-more-RAM joke can wait.'
|
||||
designNotes: Generic 3-star Kernel powerspike. COMBAT cycle stat package.
|
||||
|
||||
@@ -14,6 +14,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
id: ubuntu_apt_update
|
||||
displayName: sudo apt update
|
||||
rulesText: at the start of each turn, look at the top 2 cards of your draw pile and add the cheaper one to your hand (you choose ties).
|
||||
rulesText: instead of your normal turn draw, choose one of the top 2 cards of your draw pile to add to your hand. the others stay in order.
|
||||
flavorText: 'Refresh the index before choosing your next dependency.'
|
||||
designNotes: start-of-turn peek top 2, compare cost, player picks on tie, add chosen to hand; card-selection/advantage passive; must feel impactful within a 3-turn fight; no stacking/scaling.
|
||||
designNotes: replaces normal turn draw with a mandatory card choice; top 2 at V1, top 3 at V2, top 4 at V4; V4 discounts the chosen card by 1 this turn. Opening hand unchanged. Respect RAM and preserve unchosen draw order.
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace KernelPanic.Editor
|
||||
public string routePolicy = "legacy";
|
||||
public bool startersOnly;
|
||||
public bool prefetch = true;
|
||||
public string combatPolicy = "language";
|
||||
public string outputDirectory = "Artifacts/Balance";
|
||||
|
||||
public static Options Parse(string[] args)
|
||||
@@ -109,6 +110,7 @@ namespace KernelPanic.Editor
|
||||
break;
|
||||
case "-balanceWaves": result.maxWaves = int.Parse(Value(args, ref i), CultureInfo.InvariantCulture); break;
|
||||
case "-balancePrefetch": result.prefetch = bool.Parse(Value(args, ref i)); break;
|
||||
case "-balanceCombatPolicy": result.combatPolicy = Value(args, ref i).ToLowerInvariant(); break;
|
||||
case "-balanceStartersOnly": result.startersOnly = bool.Parse(Value(args, ref i)); break;
|
||||
case "-balanceRoutePolicy": result.routePolicy = Value(args, ref i).ToLowerInvariant(); break;
|
||||
case "-balanceRoute":
|
||||
@@ -130,6 +132,7 @@ namespace KernelPanic.Editor
|
||||
if (!new[] { "legacy", "repair", "elite", "deck", "adaptive" }.Contains(result.routePolicy))
|
||||
throw new ArgumentException("balanceRoutePolicy must be legacy, repair, elite, deck, or adaptive.");
|
||||
result.outputDirectory = Path.GetFullPath(result.outputDirectory);
|
||||
if (result.combatPolicy != "greedy" && result.combatPolicy != "language") throw new ArgumentException("balanceCombatPolicy must be greedy or language.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -278,11 +281,11 @@ namespace KernelPanic.Editor
|
||||
[Serializable]
|
||||
public sealed class Report
|
||||
{
|
||||
public int schemaVersion = 5;
|
||||
public int schemaVersion = 6;
|
||||
public string generatedUtc = DateTime.UtcNow.ToString("o");
|
||||
public string unityVersion = Application.unityVersion;
|
||||
public string policy = "Greedy preview value per (cost+1), lowest-uptime target, hand-order ties; 64 plays/round cap. First four authored distro exclusives plus both language starter decks. Paired no-shop and upgrade-shop policies, package levels 0 and 5 by default. Upgrade-shop buys affordable offers in this order: healing at <=50% uptime, draw riders, magnitude, cost reduction, max uptime, RAM, Cycles, cards, then useful healing; offer-order ties; no rerolls/removals. Actual Play Mode combat; death visuals acknowledged on the next editor update. First seed repeats for every scenario.";
|
||||
public string limitations = "A bounded heuristic benchmark, not optimal play or a balance verdict. Conditional/draw/setup effects are undervalued during combat; fixed exclusive choice; upgrade-first shopping is not optimal deckbuilding; different loadouts consume RNG differently. Wave/round caps are censored survivors, not wins. Uptime damage excludes shield and overkill; partial final rounds count. Resource metrics sample explicitly ended Execute turns only: native clears and mid-turn defeats are excluded. Empty hand does not prove lack of draw is the cause of a defeat.";
|
||||
public string policy = "Combat policy selected by options.combatPolicy: greedy preview or language-aware setup/draw/persistent-work scoring; lowest-uptime target, hand-order ties; 64 plays/round cap. First four authored distro exclusives plus both language starter decks. Paired no-shop and upgrade-shop policies, package levels 0 and 5 by default. Upgrade-shop buys affordable offers in this order: healing at <=50% uptime, draw riders, magnitude, cost reduction, max uptime, RAM, Cycles, cards, then useful healing; offer-order ties; no rerolls/removals. Actual Play Mode combat; death visuals acknowledged on the next editor update. First seed repeats for every scenario.";
|
||||
public string limitations = "A bounded heuristic benchmark, not optimal play or a balance verdict. Language-aware scoring estimates setup value but does not search future turns; fixed exclusive choice; upgrade-first shopping is not optimal deckbuilding; different loadouts consume RNG differently. Wave/round caps are censored survivors, not wins. Uptime damage excludes shield and overkill; partial final rounds count. Resource metrics sample explicitly ended Execute turns only: native clears and mid-turn defeats are excluded. Empty hand does not prove lack of draw is the cause of a defeat.";
|
||||
public Options options;
|
||||
public List<Scenario> scenarios;
|
||||
public List<RunResult> runs = new();
|
||||
@@ -398,7 +401,7 @@ namespace KernelPanic.Editor
|
||||
{
|
||||
var text = new StringBuilder("# Seeded combat comparison\n\n");
|
||||
text.AppendLine(report.policy).AppendLine().AppendLine(report.limitations).AppendLine();
|
||||
text.AppendLine($"Encounter/map revision 2, ten-wave campaign, then endless. Route policy: {report.options.routePolicy}; legacy preference: {report.options.route}. Legacy skips events; other policies prefer reachable nodes using RoutePriority, and resolve events by improving the highest preview-value eligible card and removing the lowest preview-value card only above eight cards. Deck-order ties. Adaptive prioritizes repair at <=60% Uptime and ranks elites above Cache at >=80%; otherwise prefers deck improvements. Repair restores up to {RunJourney.RepairUptime} Uptime; elites award Bits and a draw rider on clear. Build rewards take Bits for all policies. Shopping happens before route choice/events, matching the UI. Prefetch: {report.options.prefetch}, only when no further play is possible; total {report.runs.Sum(run => run.prefetches)}. Endless starts only if the cap exceeds the campaign milestone. These results are not directly comparable to benchmarks without the route map.").AppendLine();
|
||||
text.AppendLine($"Encounter revision 4 / map revision 2, ten-wave campaign, then endless. Combat policy: {report.options.combatPolicy}. Route policy: {report.options.routePolicy}; legacy preference: {report.options.route}. Legacy skips events; other policies prefer reachable nodes using RoutePriority, and resolve events by improving the highest preview-value eligible card and removing the lowest preview-value card only above eight cards. Deck-order ties. Adaptive prioritizes repair at <=60% Uptime and ranks elites above Cache at >=80%; otherwise prefers deck improvements. Repair restores up to {RunJourney.RepairUptime} Uptime; elites award Bits and a draw rider on clear. Build rewards take Bits for all policies. Shopping happens before route choice/events, matching the UI. Prefetch: {report.options.prefetch}, only when no further play is possible; total {report.runs.Sum(run => run.prefetches)}. Endless starts only if the cap exceeds the campaign milestone. These results are not directly comparable to benchmarks without the route map.").AppendLine();
|
||||
text.AppendLine($"Seeds: {string.Join(", ", report.options.seeds)}. Limits: {report.options.maxWaves} waves / {report.options.maxRounds} total rounds. Unity {report.unityVersion}.").AppendLine();
|
||||
text.AppendLine($"Package levels: {string.Join(", ", report.options.packageLevels)}. Shop policies: {string.Join(", ", report.options.shoppingPolicies.Select(shop => shop ? "upgrade-shop" : "no-shop"))}.").AppendLine();
|
||||
text.AppendLine("| Loadout | Runs | Uptime damage / round | Mean rounds | Mean waves cleared | Wave cap reached | Round cap alive | Died | Repeat checked |");
|
||||
@@ -524,9 +527,7 @@ namespace KernelPanic.Editor
|
||||
if (card.Definition == null || card.Definition.IsToken || card.IsBroken || card.IsLocked
|
||||
|| _combat.GoPlayBlockReason(card) != null
|
||||
|| _combat.GetDisplayedPlayCost(card) > _combat.PlayerState.Cycles) continue;
|
||||
var preview = CardPreviewService.Build(_combat, card, target);
|
||||
double damage = (preview.MinimumDamage + (double)preview.MaximumDamage) / 2;
|
||||
double score = (damage + preview.Shield * 0.7 + preview.Heal * 1.5 + preview.Repairs * 3 + 1) / (preview.Cost + 1);
|
||||
double score = BalancePolicy.Score(_combat, card, target, _report.options.combatPolicy == "language");
|
||||
if (score <= best) continue;
|
||||
best = score;
|
||||
chosen = card;
|
||||
@@ -685,6 +686,7 @@ namespace KernelPanic.Editor
|
||||
if (++_seedIndex >= _report.options.seeds.Length) { _seedIndex = 0; _scenarioIndex++; }
|
||||
if (_scenarioIndex < _report.scenarios.Count) { Begin(); return; }
|
||||
Directory.CreateDirectory(_report.options.outputDirectory);
|
||||
// Export standalone reports without a baseline-comparison dependency.
|
||||
File.WriteAllText(Path.Combine(_report.options.outputDirectory, "balance-comparison.json"), JsonUtility.ToJson(_report, true), new UTF8Encoding(false));
|
||||
File.WriteAllText(Path.Combine(_report.options.outputDirectory, "balance-comparison.md"), ToMarkdown(_report), new UTF8Encoding(false));
|
||||
Debug.Log($"Balance comparison complete: {_report.runs.Count} measured runs, {_report.scenarios.Count} verified repeats. {_report.options.outputDirectory}");
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using KernelPanic.Combat;
|
||||
using KernelPanic.Core;
|
||||
|
||||
namespace KernelPanic.Editor
|
||||
{
|
||||
/// <summary>Public-state heuristics; no hidden intent, random sampling or speculative execution.</summary>
|
||||
public static class BalancePolicy
|
||||
{
|
||||
public static double Score(CombatManager combat, CardInstance card, CombatantState target, bool languageAware)
|
||||
{
|
||||
var preview = CardPreviewService.Build(combat, card, target);
|
||||
double damage = (preview.MinimumDamage + (double)preview.MaximumDamage) / 2;
|
||||
double value = damage + preview.Shield * .7 + preview.Heal * 1.5 + preview.Repairs * 3 + 1;
|
||||
if (!languageAware || !CardCatalog.TryGet(card.Definition.Id, out var entry)) return value / (preview.Cost + 1);
|
||||
int remainingCycles = combat.PlayerState.Cycles - preview.Cost;
|
||||
int freeRam = combat.HandController.RemainingRam + HandController.GetRamCost(card);
|
||||
var payloads = combat.HandController.Cards.Where(c => c != card && !c.IsBroken && !c.IsLocked
|
||||
&& PythonPipeline.IsPayload(c.Definition) && combat.GetDisplayedPlayCost(c) <= remainingCycles).ToArray();
|
||||
double payloadValue = payloads.Select(c => CardPreviewService.Build(combat, c, target))
|
||||
.Select(p => (p.MinimumDamage + (double)p.NormalMaximumDamage) / 2 + p.Shield * .7).DefaultIfEmpty(0).Max();
|
||||
foreach (var effect in entry.Effects)
|
||||
{
|
||||
switch (effect.Kind)
|
||||
{
|
||||
case CardEffectKind.Draw: case CardEffectKind.FixedDraw:
|
||||
value += Math.Min(freeRam, Math.Max(0, effect.Amount)) * (remainingCycles > 0 ? 5 : 1); break;
|
||||
case CardEffectKind.Python:
|
||||
switch ((PythonOperation)effect.SecondaryAmount)
|
||||
{
|
||||
case PythonOperation.Loop: if (combat.Python.RepeatCount == 0) value += payloadValue; break;
|
||||
case PythonOperation.Zip: if (combat.Python.AreaCount == 0) value += payloadValue * Math.Min(2, combat.Enemies.Count(e => !e.State.IsDefeated) - 1); break;
|
||||
case PythonOperation.Async: if (combat.Python.AutomationCount < 2) value += payloadValue * 1.5; break;
|
||||
case PythonOperation.Draw: case PythonOperation.Inspect: value += Math.Min(2, freeRam) * (remainingCycles > 0 ? 5 : 1); break;
|
||||
case PythonOperation.Install: value += Math.Min(3, combat.HandController.Cards.Count(c => c != card && c.Definition.Language == Language.Python)) * 3; break;
|
||||
}
|
||||
break;
|
||||
case CardEffectKind.Go:
|
||||
if ((GoOperation)effect.SecondaryAmount == GoOperation.Deploy) value += damage * Math.Min(2, Math.Max(0, effect.MaxAmount - 1));
|
||||
if ((GoOperation)effect.SecondaryAmount == GoOperation.Extend)
|
||||
value += combat.Go.Active.Where(g => combat.Go.CanExtend(g)).Select(g => (double)g.BaseDamage).DefaultIfEmpty(0).Max();
|
||||
if ((GoOperation)effect.SecondaryAmount == GoOperation.ExtendAll)
|
||||
value += combat.Go.Active.Where(g => combat.Go.CanExtend(g)).Sum(g => (double)g.BaseDamage);
|
||||
break;
|
||||
case CardEffectKind.MakeJ4: value += combat.LazyStack.Count * 4; break;
|
||||
case CardEffectKind.CompilationDraw: value += Math.Min(freeRam, combat.Compilation.Level) * 4; break;
|
||||
}
|
||||
}
|
||||
if (card.Definition.Language == Language.Java && preview.Cost > 0) value += 1.5;
|
||||
if (card.Definition.Language == Language.Haskell && card.Definition.ResolutionTrack == ResolutionTrack.LazyStack)
|
||||
{
|
||||
// Cheap setup entries deepen the stack before the larger payload is placed on top.
|
||||
double nextPayload = combat.HandController.Cards.Where(c => c != card && c.Definition.Language == Language.Haskell
|
||||
&& !c.IsBroken && !c.IsLocked && combat.GetDisplayedPlayCost(c) <= remainingCycles)
|
||||
.Select(c => CardPreviewService.Build(combat, c, target)).Select(p => (double)p.NormalMaximumDamage).DefaultIfEmpty(0).Max();
|
||||
if (nextPayload > damage) value += nextPayload * .5;
|
||||
}
|
||||
// Shield loses value beyond the publicly announced attack total; hidden intents remain unknown.
|
||||
int incoming = combat.Enemies.Where(e => !e.State.IsDefeated).Sum(e =>
|
||||
e.DisplayIntent.Kind is EnemyIntentKind.Attack or EnemyIntentKind.StatusAttack ? e.DisplayIntent.MaxValue : 0);
|
||||
if (combat.PlayerState.Shield >= incoming && incoming > 0) value -= preview.Shield * .4;
|
||||
return value / (preview.Cost + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad13c81c8b4580447a294437a99596bb
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using KernelPanic.Combat;
|
||||
using KernelPanic.Core;
|
||||
using KernelPanic.Data;
|
||||
using KernelPanic.Editor;
|
||||
using KernelPanic.Run;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class BalancePolicyTests
|
||||
{
|
||||
[Test]
|
||||
public void PythonSetupGetsValueOnlyWhenAnAffordablePayloadCanFollow()
|
||||
{
|
||||
var cards = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
||||
var distro = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset");
|
||||
CardDefinition Find(PythonOperation operation) => cards.AllCards.First(c => c != null && CardCatalog.TryGet(c.Id, out var e)
|
||||
&& e.Effects.Any(f => f.Kind == CardEffectKind.Python && f.SecondaryAmount == (int)operation));
|
||||
var owner = new GameObject("balance policy test"); owner.SetActive(false);
|
||||
try
|
||||
{
|
||||
var combat = owner.AddComponent<CombatManager>();
|
||||
void Set(string field, object value) => typeof(CombatManager).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(combat, value);
|
||||
var loop = new CardInstance(Find(PythonOperation.Loop)); var payload = new CardInstance(Find(PythonOperation.Print));
|
||||
Set("_runConfig", new RunConfig(distro, Language.Python, Language.Go, new[] { loop.Definition, payload.Definition }, Array.Empty<PackageInstance>(), 123, 1));
|
||||
Set("_playerState", new CombatantState(60, 8, 10)); Set("_handController", new HandController(8));
|
||||
combat.Python.Bind(combat); combat.HandController.Add(loop); combat.HandController.Add(payload);
|
||||
var enemy = new EnemyInstance(EnemyArchetypeCatalog.Get("firewalld"), 100);
|
||||
((List<EnemyInstance>)combat.Enemies).Add(enemy);
|
||||
int cursor = RandomRoll.DrawCount;
|
||||
double greedy = BalancePolicy.Score(combat, loop, enemy.State, false);
|
||||
Assert.That(BalancePolicy.Score(combat, loop, enemy.State, true), Is.GreaterThan(greedy));
|
||||
combat.HandController.Remove(payload);
|
||||
Assert.That(BalancePolicy.Score(combat, loop, enemy.State, true), Is.EqualTo(greedy));
|
||||
Assert.That(RandomRoll.DrawCount, Is.EqualTo(cursor));
|
||||
}
|
||||
finally { UnityEngine.Object.DestroyImmediate(owner); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ab219f11f294145bf115ce0b054ceb1
|
||||
@@ -2119,7 +2119,7 @@
|
||||
.first-battle-guide .guide-resource { flex-basis: 120px; flex-shrink: 0; white-space: normal; max-width: 100%; font-size: var(--type-meta); background-color: var(--kp-bg-deep); padding: 4px 8px; margin: 2px 6px 2px 0; }
|
||||
.guide-track { border-left-width: 2px; border-left-color: var(--kp-beneficial); padding-left: 8px; margin: 4px 0; }
|
||||
.first-battle-guide > Foldout { margin-top: 4px; font-size: var(--type-meta); }
|
||||
.first-battle-guide Button, .battle-guide-toggle {
|
||||
.first-battle-guide Button, .battle-guide-toggle, .combat-status-action {
|
||||
background-color: rgb(19, 35, 31);
|
||||
color: var(--kp-beneficial);
|
||||
border-color: rgb(80, 118, 108);
|
||||
@@ -2141,15 +2141,32 @@
|
||||
.route-choice { flex-grow: 1; flex-basis: 240px; min-width: 0; padding: 8px; margin: 4px; border-left-width: 2px; border-left-color: rgb(60, 70, 66); }
|
||||
.route-selected { border-left-color: rgb(112, 211, 150); background-color: rgba(112, 211, 150, 0.07); }
|
||||
.run-route-section .primary-action { white-space: normal; height: auto; min-height: 34px; margin-bottom: 6px; }
|
||||
.execution-preview { margin: 6px 10px; flex-shrink: 0; }
|
||||
.execution-preview .terminal-body { margin-bottom: 8px; white-space: normal; }
|
||||
#EncounterBrief { margin: 6px 10px; white-space: normal; }
|
||||
.kernel-ui .run-victory .death-content .overlay-title { color: var(--kp-beneficial); }
|
||||
.kernel-ui .run-victory .death-content { border-top-color: var(--kp-beneficial); }
|
||||
.execution-preview-shade { position: absolute; left: 0; right: 0; top: 0; bottom: 0; align-items: center; justify-content: center; background-color: rgba(0, 0, 0, 0.88); }
|
||||
.execution-preview-dialog { width: 90%; max-width: 820px; height: 80%; min-height: 0; padding: 16px; border-width: 1px; border-color: var(--kp-beneficial); background-color: var(--kp-panel); }
|
||||
.execution-preview-dialog .terminal-body { white-space: normal; margin-bottom: 10px; }
|
||||
.kernel-ui .execution-preview-dialog.terminal-section { width: 92%; max-width: 720px; height: 86%; max-height: 780px; min-height: 0; padding: 16px; margin: 0; border-width: 1px; border-color: var(--kp-beneficial); background-color: var(--kp-panel); }
|
||||
.kernel-ui .execution-preview-dialog .terminal-body { white-space: normal; margin-bottom: 4px; min-width: 0; }
|
||||
.execution-preview-dialog .terminal-heading { white-space: normal; flex-shrink: 0; }
|
||||
.execution-dialog-scroll { flex-grow: 1; flex-shrink: 1; min-height: 0; }
|
||||
.execution-subtitle { color: var(--kp-text-dim); flex-shrink: 0; }
|
||||
.kernel-ui .execution-preview-dialog .execution-step, .kernel-ui .execution-preview-dialog .execution-result { padding: 10px 12px; margin: 0 4px 8px 0; border-left-width: 2px; border-left-color: var(--kp-border); background-color: var(--kp-bg-deep); flex-shrink: 0; }
|
||||
.kernel-ui .execution-step .terminal-heading, .kernel-ui .execution-result .terminal-heading { border-width: 0; padding-bottom: 0; font-size: var(--type-body); margin-bottom: 4px; }
|
||||
.execution-item { margin-top: 6px; padding-top: 6px; border-top-width: 1px; border-top-color: var(--kp-border-subtle); }
|
||||
.execution-item-title { -unity-font-style: bold; }
|
||||
.kernel-ui .execution-preview-dialog .execution-muted { color: var(--kp-text-dim); font-size: var(--type-meta); }
|
||||
.execution-estimate { color: var(--kp-cyan); }
|
||||
.execution-phases, .execution-metrics { flex-direction: row; flex-wrap: wrap; flex-shrink: 0; }
|
||||
.execution-phases { margin: 6px 0 10px; }
|
||||
.kernel-ui .execution-phase { color: var(--kp-text-dim); font-size: var(--type-meta); padding: 3px 5px; margin: 0 4px 4px 0; }
|
||||
.kernel-ui .execution-phase-active { color: var(--kp-bg); background-color: var(--kp-beneficial); }
|
||||
.kernel-ui .execution-preview-dialog .execution-metric { color: var(--kp-cyan); background-color: var(--kp-panel); padding: 4px 6px; margin: 2px 6px 4px 0; }
|
||||
.execution-preview-dialog Foldout { margin-top: 4px; flex-shrink: 0; }
|
||||
.execution-preview-dialog Foldout > Toggle { white-space: normal; }
|
||||
.kernel-ui .execution-preview-dialog .unity-foldout__text { white-space: normal; flex-shrink: 1; min-width: 0; }
|
||||
.kernel-ui.narrow .execution-preview-dialog { padding: 10px; }
|
||||
.execution-preview-dialog .primary-action { flex-shrink: 0; white-space: normal; height: auto; min-height: 38px; margin-top: 12px; }
|
||||
.kernel-ui .scheduler .combat-status-action { min-height: 22px; padding: 0 6px; margin: 0 0 0 8px; }
|
||||
.kernel-ui .overlay.tutorial-overlay {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
@@ -2195,3 +2212,5 @@
|
||||
.kernel-ui.narrow.tutorial-card-focus .turn-panel { display: none; }
|
||||
.kernel-ui.narrow.tutorial-card-focus .hand-panel { width: 100%; }
|
||||
.tutorial-shop-highlight { padding: 8px; margin-bottom: 12px; border-width: 2px; border-color: rgb(153, 239, 206); }
|
||||
|
||||
.combat-status-action { min-height: 28px; margin: 0 0 0 8px; padding: 3px 10px; flex-shrink: 0; }
|
||||
|
||||
@@ -484,15 +484,17 @@
|
||||
.kernel-ui .terminal-stat-value.compilation-value { flex-grow: 0; flex-shrink: 0; }
|
||||
.kernel-ui .terminal-stat-row.turn-stat-row { margin-bottom: 4px; }
|
||||
.kernel-ui .terminal-stat-key.turn-stat-label { width: 72px; margin-right: 8px; }
|
||||
.kernel-ui .combat-packages { flex-shrink: 0; min-width: 0; padding: 0 18px 6px; }
|
||||
.kernel-ui .package-readiness-strip { flex-direction: row; flex-wrap: wrap; min-width: 0; }
|
||||
.kernel-ui .package-readiness-chip { flex-direction: row; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; padding: 5px 8px; margin: 0 8px 4px 0; border-width: 1px; border-color: var(--kp-border-subtle); }
|
||||
.kernel-ui .combat-packages { flex-shrink: 0; min-width: 0; width: 100%; padding: 10px 0 0; margin-top: 10px; border-top-width: 1px; border-top-color: var(--kp-border-subtle); }
|
||||
.kernel-ui .package-loadout-title { font-size: var(--type-meta); color: var(--kp-text-dim); margin-bottom: 6px; }
|
||||
.kernel-ui .package-readiness-strip { flex-direction: column; min-width: 0; }
|
||||
.kernel-ui .package-readiness-chip { flex-direction: row; align-items: center; flex-shrink: 0; min-width: 0; max-width: 100%; overflow: hidden; padding: 4px 0; margin: 0 0 3px; border-width: 0; border-bottom-width: 1px; border-color: var(--kp-border-subtle); }
|
||||
.kernel-ui .package-readiness-copy { flex-grow: 1; flex-shrink: 1; min-width: 0; }
|
||||
.kernel-ui .package-readiness-chip:focus { border-color: var(--kp-text); background-color: var(--kp-hover); }
|
||||
.kernel-ui .card-chip:focus { border-color: var(--kp-text); background-color: var(--kp-hover); }
|
||||
.kernel-ui .package-readiness-chip .package-rarity { margin-right: 6px; }
|
||||
.kernel-ui .package-readiness-name { font-size: var(--type-meta); color: var(--kp-text); margin-right: 8px; white-space: normal; }
|
||||
.kernel-ui .package-readiness-state { font-size: var(--type-meta); color: var(--kp-cyan); white-space: normal; }
|
||||
.kernel-ui .package-activation { font-size: var(--type-meta); color: var(--kp-success); white-space: normal; min-height: 18px; }
|
||||
.kernel-ui .package-readiness-chip .package-rarity { margin-right: 6px; flex-shrink: 0; }
|
||||
.kernel-ui .package-readiness-name { font-size: var(--type-meta); color: var(--kp-text); margin-right: 6px; min-width: 0; flex-shrink: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.kernel-ui .package-readiness-state { font-size: var(--type-meta); color: var(--kp-cyan); min-width: 0; max-width: 100%; flex-shrink: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.kernel-ui .package-activation { font-size: var(--type-meta); color: var(--kp-success); min-width: 0; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.kernel-ui .software-live-preview { margin-top: 8px; padding-top: 6px; border-top-width: 1px; border-top-color: var(--kp-border-subtle); color: var(--kp-cyan); font-size: var(--type-meta); white-space: normal; flex-shrink: 0; }
|
||||
.kernel-ui .software-live-crit { margin-top: 2px; color: var(--kp-muted); font-size: var(--type-meta); white-space: normal; flex-shrink: 0; }
|
||||
.distro-nixos { --kp-distro: #7dc7f5; }
|
||||
@@ -808,6 +810,7 @@
|
||||
.kernel-ui.narrow .player-panel .panel-subtitle { display: none; }
|
||||
.kernel-ui.narrow .player-panel .host-statuses { width: 100%; margin-right: 0; }
|
||||
.kernel-ui.narrow .player-panel > .compilation-panel { width: 100%; max-width: 360px; margin: 6px 0 10px; padding-top: 10px; }
|
||||
.kernel-ui.narrow .player-panel > .combat-packages { width: 100%; margin: 6px 0 0; }
|
||||
.kernel-ui.narrow .death-content { padding: 20px; }
|
||||
.kernel-ui.narrow .death-content .overlay-title { font-size: 30px; }
|
||||
.kernel-ui.narrow .death-report-header { margin-bottom: 18px; }
|
||||
@@ -886,7 +889,7 @@
|
||||
.kernel-ui .process-intent-slot { min-height: 48px; }
|
||||
.kernel-ui .process-behavior { color: var(--kp-muted); white-space: normal; font-size: var(--type-meta); min-height: 0; margin-top: var(--space-1); }
|
||||
.kernel-ui .scheduler { padding-top: 4px; padding-bottom: 4px; flex-direction: row; flex-wrap: wrap; }
|
||||
.kernel-ui .scheduler .panel-header { width: 100%; }
|
||||
.kernel-ui .scheduler .panel-header { width: 100%; flex-wrap: wrap; }
|
||||
.kernel-ui .scheduler .track-zone { width: 100%; min-width: 0; }
|
||||
.kernel-ui .scheduler .track-idle { width: 50%; }
|
||||
.kernel-ui .scheduler .track-idle .track-header { width: auto; padding-right: 12px; }
|
||||
|
||||
@@ -9,6 +9,42 @@ namespace KernelPanic.Combat
|
||||
/// </summary>
|
||||
public sealed class CardInstance
|
||||
{
|
||||
// Explicit checkpoint values: no gameplay hooks or random draws during restoration.
|
||||
internal CardInstanceValues CaptureValues() => new()
|
||||
{
|
||||
_isBroken = _isBroken,
|
||||
_corruptionLastRecoveryRound = _corruptionLastRecoveryRound,
|
||||
InstanceId = InstanceId,
|
||||
TemporaryCostDelta = TemporaryCostDelta,
|
||||
PermanentCostDelta = PermanentCostDelta,
|
||||
MagnitudeBonus = MagnitudeBonus,
|
||||
DrawRider = DrawRider,
|
||||
ExhaustOnPlay = ExhaustOnPlay,
|
||||
UpgradeLevel = UpgradeLevel,
|
||||
QueuePlayCount = QueuePlayCount,
|
||||
WasFirstCardThisTurn = WasFirstCardThisTurn,
|
||||
HadFedoraNonCrashBonus = HadFedoraNonCrashBonus,
|
||||
CorruptionRoundsRemaining = CorruptionRoundsRemaining,
|
||||
IsLocked = IsLocked,
|
||||
};
|
||||
internal void RestoreValues(CardInstanceValues value)
|
||||
{
|
||||
_isBroken = value._isBroken;
|
||||
_corruptionLastRecoveryRound = value._corruptionLastRecoveryRound;
|
||||
InstanceId = value.InstanceId;
|
||||
TemporaryCostDelta = value.TemporaryCostDelta;
|
||||
PermanentCostDelta = value.PermanentCostDelta;
|
||||
MagnitudeBonus = value.MagnitudeBonus;
|
||||
DrawRider = value.DrawRider;
|
||||
ExhaustOnPlay = value.ExhaustOnPlay;
|
||||
UpgradeLevel = value.UpgradeLevel;
|
||||
QueuePlayCount = value.QueuePlayCount;
|
||||
WasFirstCardThisTurn = value.WasFirstCardThisTurn;
|
||||
HadFedoraNonCrashBonus = value.HadFedoraNonCrashBonus;
|
||||
CorruptionRoundsRemaining = value.CorruptionRoundsRemaining;
|
||||
IsLocked = value.IsLocked;
|
||||
}
|
||||
|
||||
private readonly List<CombatantState> _targetSnapshot = new();
|
||||
private bool _isBroken;
|
||||
private int _corruptionLastRecoveryRound;
|
||||
@@ -189,6 +225,9 @@ namespace KernelPanic.Combat
|
||||
_targetSnapshot.Clear();
|
||||
}
|
||||
|
||||
internal void RestoreSnapshotTargets(IEnumerable<CombatantState> targets)
|
||||
{ _targetSnapshot.Clear(); _targetSnapshot.AddRange(targets); }
|
||||
|
||||
public void ResetCombatState()
|
||||
{
|
||||
TemporaryCostDelta = 0;
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace KernelPanic.Combat
|
||||
if (source.ForceMaxRolls) low = high;
|
||||
if (chance) low = 0; // Runtime chance failure passes zero through flat/multiplier stages.
|
||||
random |= low != high;
|
||||
critical |= effect.CanCrit && !source.ForceMaxRolls;
|
||||
critical |= effect.CanCrit && effect.Language != Language.TypeScript && !source.ForceMaxRolls;
|
||||
rust |= effect.Language == Language.Rust || card.Definition.Language == Language.Rust;
|
||||
trueDamage |= effect.TrueDamage;
|
||||
var minimum = DamageRequest.PreviewCard(source, previewTarget, low, effect.Language, effect.TrueDamage, effect.CanCrit, lazy, combat.Compilation.DamagePercent);
|
||||
@@ -285,6 +285,9 @@ namespace KernelPanic.Combat
|
||||
int maxHit = combat.DamagePipeline.PreviewIncomingDamage(maximum, true, archStacks, damageMultiplier, cardMultiplier);
|
||||
int normalMaxHit = combat.DamagePipeline.PreviewIncomingDamage(maximum, false, archStacks, damageMultiplier, cardMultiplier);
|
||||
int criticalMinHit = combat.DamagePipeline.PreviewIncomingDamage(minimum, true, archStacks, damageMultiplier, cardMultiplier);
|
||||
string targetName = combat.Enemies.FirstOrDefault(e => ReferenceEquals(e.State, previewTarget))?.Name ?? "Target";
|
||||
AddNote(notes, targetName + " / per hit: " + combat.DamagePipeline.DescribePreview(minimum, archStacks, damageMultiplier, cardMultiplier));
|
||||
if (low != high) AddNote(notes, targetName + " / high roll: " + combat.DamagePipeline.DescribePreview(maximum, archStacks, damageMultiplier, cardMultiplier));
|
||||
for (int hit = 0; hit < repeats; hit++)
|
||||
{
|
||||
targetMin = CardScaling.Add(targetMin, minHit);
|
||||
@@ -335,7 +338,7 @@ namespace KernelPanic.Combat
|
||||
if (hitCount > 1) notes.Add($"{hitCount} hits in total; later hits can stop when a target dies or combat ends.");
|
||||
if (trueDamage) notes.Add("True damage bypasses Shield.");
|
||||
if (random) notes.Add("Random amounts show the full normal range.");
|
||||
if (critical) notes.Add($"Critical chance: C {CombatTuning.CCriticalChancePercent}%, C++ {CombatTuning.CCriticalChancePercent}%, other languages 25%; each hit rolls independently.");
|
||||
if (critical) notes.Add($"Critical chance: C {CombatTuning.CCriticalChancePercent}%, C++ {CombatTuning.CCriticalChancePercent}%, TypeScript 0%, other languages 25%; each eligible hit rolls independently.");
|
||||
if (card.Definition.Language == Language.CPlusPlus) notes.Add("C++ spills all remaining excess damage. No segfault recoil.");
|
||||
if (card.Definition.Language == Language.C)
|
||||
notes.Add($"C spills {CombatTuning.COverkillSpillPercent}% of remaining overkill per jump, rounded down; spill cannot crit or reapply source bonuses.");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KernelPanic.Core;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
@@ -15,6 +16,7 @@ namespace KernelPanic.Combat
|
||||
public long PlayerUptimeLost { get; internal set; }
|
||||
public long PlayerShieldBlocked { get; internal set; }
|
||||
public List<string> Details { get; } = new();
|
||||
public List<string> DamageBreakdowns { get; } = new();
|
||||
}
|
||||
|
||||
/// <summary>A bounded journal of observed actions. Never predicts or executes combat.</summary>
|
||||
@@ -66,6 +68,13 @@ namespace KernelPanic.Combat
|
||||
bool standalone = _active.Count == 0;
|
||||
if (standalone) Begin(Stage, value.Cause ?? "Status or passive damage");
|
||||
var action = _active.Peek();
|
||||
if (!string.IsNullOrEmpty(value.Breakdown))
|
||||
{
|
||||
if (action.DamageBreakdowns.Count >= 32) action.DamageBreakdowns.RemoveAt(0);
|
||||
string target = ReferenceEquals(value.Target, _combat?.PlayerState) ? "Host"
|
||||
: _combat?.Enemies.FirstOrDefault(e => ReferenceEquals(e.State, value.Target))?.Name ?? "Target";
|
||||
action.DamageBreakdowns.Add(target + " / " + value.Breakdown);
|
||||
}
|
||||
if (_combat != null && ReferenceEquals(value.Target, _combat.PlayerState))
|
||||
{
|
||||
action.PlayerUptimeLost += Math.Max(0, value.UptimeDamage);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Linq;
|
||||
using KernelPanic.Core;
|
||||
using KernelPanic.Run;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
public sealed partial class CombatManager
|
||||
{
|
||||
public bool CanSaveCombat => CanSurrenderRun && _runConfig?.IsTutorial != true && _runConfig?.IsLanguageTraining != true
|
||||
&& _runManager != null && !_runManager.IsSuspended && _turnNumberThisWave > 0
|
||||
&& _pendingTargetCard == null && _pendingGoroutineCard == null && !_switchingGovernor
|
||||
&& !_interpretingTracks && !_evaluatingLazyStack && _activeLazyEntry == null && _handController != null;
|
||||
|
||||
public CombatSnapshot CaptureCombatSnapshot()
|
||||
{
|
||||
RunCheckpoint.Require(CanSaveCombat, "Finish resolving actions and choices before saving combat.");
|
||||
var writer = new CombatSnapshotWriter();
|
||||
var snapshot = writer.Snapshot;
|
||||
snapshot.manager = CaptureValues(); snapshot.player = writer.State(_playerState);
|
||||
snapshot.handRam = _handController.RamCapacity;
|
||||
snapshot.compilation = Compilation.CaptureValues(); snapshot.nix = Nix.CaptureValues(); snapshot.scheduler = Go.CaptureValues();
|
||||
foreach (var card in _runManager.RunDeck) writer.Card(card);
|
||||
foreach (var enemy in _enemies)
|
||||
snapshot.enemies.Add(new SavedEnemy { archetype = enemy.ArchetypeId, state = writer.State(enemy.State),
|
||||
values = enemy.CaptureValues(), intent = SavedIntent.Capture(enemy.CurrentIntent) });
|
||||
snapshot.hand = _handController.Cards.Select(writer.Card).ToList();
|
||||
snapshot.draw = _deckController.DrawPile.Select(writer.Card).ToList();
|
||||
snapshot.discard = _deckController.DiscardPile.Select(writer.Card).ToList();
|
||||
snapshot.exhaust = _deckController.ExhaustPile.Select(writer.Card).ToList();
|
||||
snapshot.queue = _interpreterQueue.Cards.Select(writer.Card).ToList();
|
||||
foreach (var entry in _lazyStack.Entries)
|
||||
snapshot.stack.Add(new SavedStackEntry { card = writer.Card(entry.Card), multiplier = entry.MultiplierPercent, targets = entry.Targets.Select(writer.State).ToList() });
|
||||
foreach (var work in Go.Active)
|
||||
snapshot.goroutines.Add(new SavedGoroutine { id = work.Id, card = writer.Card(work.SourceCard), target = writer.State(work.Target),
|
||||
damage = work.BaseDamage, remaining = work.RemainingTicks, deploymentRound = work.DeploymentRound, lastTickRound = work.LastTickRound });
|
||||
snapshot.python = Python.CaptureSnapshot(writer);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public void RestoreCombatSnapshot(ResolvedRunCheckpoint resume)
|
||||
{
|
||||
var saved = resume.Snapshot;
|
||||
var snapshot = saved.fullCombat;
|
||||
RunCheckpoint.Require(snapshot?.Prepared != null, "Combat checkpoint was not validated before resuming.");
|
||||
var graph = snapshot.Prepared;
|
||||
StopAllCoroutines(); _phaseCoroutine = null;
|
||||
_runConfig = resume.Config; _runManager = GetComponent<RunManager>();
|
||||
RestoreValues(snapshot.manager);
|
||||
_playerState = graph.State(snapshot.player);
|
||||
_enemies.Clear(); _enemies.AddRange(graph.Enemies);
|
||||
_handController = new HandController(snapshot.handRam);
|
||||
foreach (int card in snapshot.hand) _handController.Add(graph.Cards[card]);
|
||||
_deckController.RestorePiles(snapshot.draw.Select(i => graph.Cards[i]), snapshot.discard.Select(i => graph.Cards[i]), snapshot.exhaust.Select(i => graph.Cards[i]));
|
||||
_interpreterQueue.Clear(); foreach (int card in snapshot.queue) _interpreterQueue.Enqueue(graph.Cards[card]);
|
||||
_lazyStack.RestoreEntries(snapshot.stack.Select(s => new LazyStackEntry(graph.Cards[s.card], s.multiplier, s.targets.Select(graph.State))));
|
||||
Go.RestoreValues(snapshot.scheduler);
|
||||
Go.RestoreActive(snapshot.goroutines.Select(g => new Goroutine { Id = g.id, SourceCard = graph.Cards[g.card], Target = graph.State(g.target),
|
||||
BaseDamage = g.damage, RemainingTicks = g.remaining, DeploymentRound = g.deploymentRound, LastTickRound = g.lastTickRound, Active = true }));
|
||||
Go.Terminated -= OnGoroutineTerminated; Go.Terminated += OnGoroutineTerminated;
|
||||
Nix.RestoreValues(snapshot.nix); Compilation.RestoreValues(snapshot.compilation);
|
||||
Python.Bind(this); Python.RestoreSnapshot(snapshot.python, graph);
|
||||
_delayedEffects.Clear();
|
||||
foreach (var effect in saved.combat.delayed)
|
||||
_delayedEffects.Add(effect.kind == 0 ? DelayedCombatEffect.UpdateManagerRepeat(effect.amount, effect.rounds)
|
||||
: DelayedCombatEffect.TimeshiftRestore(effect.amount, effect.rounds));
|
||||
_pendingTargetCard = null; _pendingGoroutineCard = null; SelectedGoroutine = null; _activeLazyEntry = null;
|
||||
_enemyExitAwaitingVisual = null; _enemiesPendingExit.Clear(); _enemyExitQueue.Clear(); _pendingDeathSpawns.Clear(); _completedDeathVisuals.Clear();
|
||||
_damagePipeline.ResistanceResolver = ResolveDamageResistance;
|
||||
_damagePipeline.PreviewResistanceResolver = ResolveDamageResistance;
|
||||
CurrentEncounter = EncounterDirector.Plan(CurrentWaveNumber, _runManager.Journey.activeRoute, _runConfig.RunSeed, _runManager.Journey.encounterRevision);
|
||||
RandomRoll.Restore(saved.combat.randomSeed, saved.combat.randomDraws);
|
||||
StateChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a5e07044c25f614fafbced2d498aa60
|
||||
@@ -16,6 +16,82 @@ namespace KernelPanic.Combat
|
||||
/// </summary>
|
||||
public sealed partial class CombatManager : MonoBehaviour
|
||||
{
|
||||
// Explicit checkpoint values: no gameplay hooks or random draws during restoration.
|
||||
internal CombatManagerValues CaptureValues() => new()
|
||||
{
|
||||
currentPhase = currentPhase,
|
||||
_selectedEnemyIndex = _selectedEnemyIndex,
|
||||
_awaitingWaveContinue = _awaitingWaveContinue,
|
||||
_waveTransitionActive = _waveTransitionActive,
|
||||
_runLost = _runLost,
|
||||
_skipNextAllocateDraw = _skipNextAllocateDraw,
|
||||
_ubuntuEmptyHandRefillUsed = _ubuntuEmptyHandRefillUsed,
|
||||
_fedoraCardsDiscountedThisTurn = _fedoraCardsDiscountedThisTurn,
|
||||
_fedoraCrashChance = _fedoraCrashChance,
|
||||
_cardsPlayedThisTurn = _cardsPlayedThisTurn,
|
||||
_prefetchUsed = _prefetchUsed,
|
||||
_cardsPlayedThisWave = _cardsPlayedThisWave,
|
||||
_cCardsPlayedThisTurn = _cCardsPlayedThisTurn,
|
||||
_turnNumberThisWave = _turnNumberThisWave,
|
||||
_packageWaveStartApplied = _packageWaveStartApplied,
|
||||
_packageLastRoundApplied = _packageLastRoundApplied,
|
||||
_packageShieldBonusTriggeredThisTurn = _packageShieldBonusTriggeredThisTurn,
|
||||
_packageTimeshiftTriggeredThisWave = _packageTimeshiftTriggeredThisWave,
|
||||
_packageInterpreterQueueShieldTriggeredThisWave = _packageInterpreterQueueShieldTriggeredThisWave,
|
||||
_packageNativeDamageTriggeredThisWave = _packageNativeDamageTriggeredThisWave,
|
||||
_javaCardsPlayedThisCombat = _javaCardsPlayedThisCombat,
|
||||
_javaCardsDiscountThisTurn = _javaCardsDiscountThisTurn,
|
||||
_rawhideBonusCharges = _rawhideBonusCharges,
|
||||
_queuedRepeatCharges = _queuedRepeatCharges,
|
||||
_nextTurnCycleBonus = _nextTurnCycleBonus,
|
||||
_nextRacePairId = _nextRacePairId,
|
||||
_activeKernelRamPenalty = _activeKernelRamPenalty,
|
||||
_deathSpawnSequencesActive = _deathSpawnSequencesActive,
|
||||
_enemyExitQueueDraining = _enemyExitQueueDraining,
|
||||
_interpretingTracks = _interpretingTracks,
|
||||
_evaluatingLazyStack = _evaluatingLazyStack,
|
||||
RunCompleted = RunCompleted,
|
||||
RunEndedBySurrender = RunEndedBySurrender,
|
||||
TutorialReading = TutorialReading,
|
||||
};
|
||||
internal void RestoreValues(CombatManagerValues value)
|
||||
{
|
||||
currentPhase = value.currentPhase;
|
||||
_selectedEnemyIndex = value._selectedEnemyIndex;
|
||||
_awaitingWaveContinue = value._awaitingWaveContinue;
|
||||
_waveTransitionActive = value._waveTransitionActive;
|
||||
_runLost = value._runLost;
|
||||
_skipNextAllocateDraw = value._skipNextAllocateDraw;
|
||||
_ubuntuEmptyHandRefillUsed = value._ubuntuEmptyHandRefillUsed;
|
||||
_fedoraCardsDiscountedThisTurn = value._fedoraCardsDiscountedThisTurn;
|
||||
_fedoraCrashChance = value._fedoraCrashChance;
|
||||
_cardsPlayedThisTurn = value._cardsPlayedThisTurn;
|
||||
_prefetchUsed = value._prefetchUsed;
|
||||
_cardsPlayedThisWave = value._cardsPlayedThisWave;
|
||||
_cCardsPlayedThisTurn = value._cCardsPlayedThisTurn;
|
||||
_turnNumberThisWave = value._turnNumberThisWave;
|
||||
_packageWaveStartApplied = value._packageWaveStartApplied;
|
||||
_packageLastRoundApplied = value._packageLastRoundApplied;
|
||||
_packageShieldBonusTriggeredThisTurn = value._packageShieldBonusTriggeredThisTurn;
|
||||
_packageTimeshiftTriggeredThisWave = value._packageTimeshiftTriggeredThisWave;
|
||||
_packageInterpreterQueueShieldTriggeredThisWave = value._packageInterpreterQueueShieldTriggeredThisWave;
|
||||
_packageNativeDamageTriggeredThisWave = value._packageNativeDamageTriggeredThisWave;
|
||||
_javaCardsPlayedThisCombat = value._javaCardsPlayedThisCombat;
|
||||
_javaCardsDiscountThisTurn = value._javaCardsDiscountThisTurn;
|
||||
_rawhideBonusCharges = value._rawhideBonusCharges;
|
||||
_queuedRepeatCharges = value._queuedRepeatCharges;
|
||||
_nextTurnCycleBonus = value._nextTurnCycleBonus;
|
||||
_nextRacePairId = value._nextRacePairId;
|
||||
_activeKernelRamPenalty = value._activeKernelRamPenalty;
|
||||
_deathSpawnSequencesActive = value._deathSpawnSequencesActive;
|
||||
_enemyExitQueueDraining = value._enemyExitQueueDraining;
|
||||
_interpretingTracks = value._interpretingTracks;
|
||||
_evaluatingLazyStack = value._evaluatingLazyStack;
|
||||
RunCompleted = value.RunCompleted;
|
||||
RunEndedBySurrender = value.RunEndedBySurrender;
|
||||
TutorialReading = value.TutorialReading;
|
||||
}
|
||||
|
||||
[SerializeField] private TurnPhase currentPhase = TurnPhase.Boot;
|
||||
|
||||
private readonly DeckController _deckController = new();
|
||||
@@ -124,6 +200,7 @@ namespace KernelPanic.Combat
|
||||
public int RoundNumber => _turnNumberThisWave;
|
||||
public int ActiveKernelRamPenalty => _activeKernelRamPenalty;
|
||||
public bool CanSurrenderRun => currentPhase == TurnPhase.Execute
|
||||
&& _runManager?.IsSuspended != true
|
||||
&& !Python.HasChoice
|
||||
&& !TutorialReading
|
||||
&& !_waveTransitionActive
|
||||
@@ -197,7 +274,7 @@ namespace KernelPanic.Combat
|
||||
|
||||
public CheckpointCombat CaptureBoundaryState()
|
||||
{
|
||||
RunCheckpoint.Require(_awaitingWaveContinue && !_runLost && _playerState != null && !VisualResolutionPending,
|
||||
RunCheckpoint.Require((_awaitingWaveContinue || CanSaveCombat) && !_runLost && _playerState != null && !VisualResolutionPending,
|
||||
"Combat is not at a safe repository boundary.");
|
||||
var snapshot = new CheckpointCombat
|
||||
{
|
||||
@@ -760,7 +837,7 @@ namespace KernelPanic.Combat
|
||||
case PackageEffectKind.ThirdCardEachTurnGenerate:
|
||||
state = _cardsPlayedThisTurn < Mathf.Max(1, effect.Threshold)
|
||||
? $"in {Mathf.Max(1, effect.Threshold) - _cardsPlayedThisTurn} cards" : "used";
|
||||
details.Add("Generate a language card" + (effect.RefundCycle ? " and refund 1 Cycle" : "")); break;
|
||||
details.Add($"Generate {effect.Amount} language card(s)" + (effect.RefundCycle ? " and refund 1 Cycle" : "")); break;
|
||||
case PackageEffectKind.DnfFedoraPassive:
|
||||
state = _cardsPlayedThisTurn == 0 ? "ready" : "used";
|
||||
if (effect.Amount > 0) details.Add($"First card each round, if it does not crash: +{effect.Amount} card damage after play for this wave (not draw, Shield or status stacks)");
|
||||
@@ -770,7 +847,7 @@ namespace KernelPanic.Combat
|
||||
details.Add($"+{effect.Amount} Shield at round start with no debuffs"); break;
|
||||
case PackageEffectKind.WaveGenerateBasicCard:
|
||||
state = _packageWaveStartApplied ? "wave checked" : "wave ready";
|
||||
details.Add("Generate a basic language card at wave start if hand space is available"); break;
|
||||
details.Add($"Generate {effect.Amount} basic language card(s) at wave start if hand space is available"); break;
|
||||
case PackageEffectKind.TurnStartGenerateLanguageCard:
|
||||
state = "each round";
|
||||
details.Add("Generate a language card at round start if hand space is available"); break;
|
||||
@@ -1307,8 +1384,6 @@ namespace KernelPanic.Combat
|
||||
yield break;
|
||||
}
|
||||
|
||||
TryApplyUbuntuAptUpdate();
|
||||
|
||||
if (_skipNextAllocateDraw)
|
||||
{
|
||||
_skipNextAllocateDraw = false;
|
||||
@@ -1522,6 +1597,14 @@ namespace KernelPanic.Combat
|
||||
|
||||
private IEnumerator DrawForTurnSequenced()
|
||||
{
|
||||
if (IsDistro("ubuntu"))
|
||||
{
|
||||
while (Python.HasChoice) yield return null;
|
||||
TryApplyUbuntuAptUpdate();
|
||||
while (Python.HasChoice && !_runLost && !_awaitingWaveContinue) yield return null;
|
||||
yield break;
|
||||
}
|
||||
|
||||
int requested = CombatTuning.DrawPerTurn;
|
||||
if (CombatTuning.MinimumHandFloor > 0 && _handController.Cards.Count < CombatTuning.MinimumHandFloor && _deckController.AvailableToDrawCount > 0)
|
||||
{
|
||||
@@ -1589,26 +1672,25 @@ namespace KernelPanic.Combat
|
||||
return;
|
||||
}
|
||||
|
||||
int lookCount = _runConfig.DistroVersion >= 2 ? 3 : 2;
|
||||
if (!_deckController.TryDrawCheapestFromTop(lookCount, out CardInstance card, out IReadOnlyList<PeekedCardInfo> peeked, out bool wasTie))
|
||||
int lookCount = _runConfig.DistroVersion >= 4 ? 4 : _runConfig.DistroVersion >= 2 ? 3 : 2;
|
||||
var cards = _deckController.PeekTop(lookCount).ToArray();
|
||||
if (cards.Length == 0 || !cards.Any(_handController.CanAdd))
|
||||
{
|
||||
Log(cards.Length == 0 ? "apt update: no cards to draw" : "apt update: not enough RAM");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_runConfig.DistroVersion >= 4)
|
||||
int discount = _runConfig.DistroVersion >= 4 ? 1 : 0;
|
||||
Python.Offer("sudo apt update: choose one card; the others keep their order", cards.Select(card =>
|
||||
new PythonChoiceOption(card, Mathf.Max(0, GetDisplayedPlayCost(card) - discount),
|
||||
_handController.CanAdd(card) ? $"> take card / {HandController.GetRamCost(card)} RAM" : $"needs {HandController.GetRamCost(card)} free RAM",
|
||||
_handController.CanAdd(card))), index =>
|
||||
{
|
||||
card.TemporaryCostDelta -= 1;
|
||||
}
|
||||
|
||||
if (_handController.Add(card))
|
||||
{
|
||||
Log($"apt update: staged {GetCardName(card)} from top {lookCount}");
|
||||
GameEvents.RaiseUbuntuAptUpdatePeeked(new UbuntuAptUpdatePeekedEvent(peeked, card, wasTie, lookCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
_deckController.AddToDrawPile(card, shuffle: false);
|
||||
}
|
||||
CardInstance card = cards[index];
|
||||
if (!_deckController.TakeToHand(card, _handController)) return;
|
||||
Python.DiscountForTurn(card, discount);
|
||||
Log($"apt update: chose {GetCardName(card)} from top {lookCount}");
|
||||
});
|
||||
}
|
||||
|
||||
private void TryApplyUbuntuEmptyHandRefill()
|
||||
@@ -1790,7 +1872,8 @@ namespace KernelPanic.Combat
|
||||
}
|
||||
break;
|
||||
case PackageEffectKind.WaveGenerateBasicCard:
|
||||
GeneratePackageLanguageCard(package.Definition.DisplayName);
|
||||
for (int generated = 0; generated < Mathf.Max(0, effect.Amount); generated++)
|
||||
GeneratePackageLanguageCard(package.Definition.DisplayName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1879,7 +1962,8 @@ namespace KernelPanic.Combat
|
||||
if (HasPackageEffect(PackageEffectKind.ThirdCardEachTurnGenerate, out PackageEffectData aptEffect)
|
||||
&& _cardsPlayedThisTurn == Mathf.Max(1, aptEffect.Threshold))
|
||||
{
|
||||
GeneratePackageLanguageCard("apt");
|
||||
for (int generated = 0; generated < Mathf.Max(0, aptEffect.Amount); generated++)
|
||||
GeneratePackageLanguageCard("apt");
|
||||
if (aptEffect.RefundCycle)
|
||||
{
|
||||
_playerState.Cycles += 1;
|
||||
@@ -3044,6 +3128,15 @@ namespace KernelPanic.Combat
|
||||
|
||||
private void ExecuteSpecialEnemyIntent(EnemyInstance enemy, int value)
|
||||
{
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.Countdown))
|
||||
{ Log($"{enemy.Name}: countdown {enemy.CountdownRemaining}"); return; }
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.ProcessSpawner))
|
||||
{
|
||||
int count = Math.Min(Math.Max(0, value), Math.Max(0, 8 - _enemies.Count(e => !e.State.IsDefeated)));
|
||||
for (int i = 0; i < count; i++) SpawnEnemy("orphan_process", Math.Max(0, CurrentWaveNumber / 2));
|
||||
Log($"{enemy.Name}: spawned {count} workers (8-process cap)");
|
||||
return;
|
||||
}
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.CardLocker))
|
||||
{
|
||||
LockRandomHandCard(enemy);
|
||||
@@ -3344,7 +3437,7 @@ namespace KernelPanic.Combat
|
||||
|| _enemyExitAwaitingVisual != null
|
||||
|| _deathSpawnSequencesActive > 0;
|
||||
|
||||
private bool IsCombatPaused => Python.HasChoice || _awaitingWaveContinue || _waveTransitionActive || RunFinished || VisualResolutionPending;
|
||||
private bool IsCombatPaused => _runManager?.IsSuspended == true || Python.HasChoice || _awaitingWaveContinue || _waveTransitionActive || RunFinished || VisualResolutionPending;
|
||||
|
||||
private enum DelayedCombatEffectKind
|
||||
{
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace KernelPanic.Combat
|
||||
}
|
||||
|
||||
public void MarkSurrender() => _surrendering = true;
|
||||
public void RestorePlanningRound(int round) => Round = Math.Max(1, round);
|
||||
|
||||
private void OnWaveAdvanced(WaveAdvancedEvent payload)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KernelPanic.Core;
|
||||
using KernelPanic.Data;
|
||||
using KernelPanic.Run;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
/// <summary>Versioned object graph at a quiescent Execute boundary. Indices preserve shared references.</summary>
|
||||
[Serializable]
|
||||
public sealed class CombatSnapshot
|
||||
{
|
||||
public int version = 1, player, handRam;
|
||||
public CombatManagerValues manager;
|
||||
public CompilationStateValues compilation;
|
||||
public NixGovernorStateValues nix;
|
||||
public GoroutineSchedulerValues scheduler;
|
||||
public List<SavedCombatant> combatants = new();
|
||||
public List<SavedCard> cards = new();
|
||||
public List<SavedEnemy> enemies = new();
|
||||
public List<int> hand = new(), draw = new(), discard = new(), exhaust = new(), queue = new();
|
||||
public List<SavedStackEntry> stack = new();
|
||||
public List<SavedGoroutine> goroutines = new();
|
||||
public SavedPython python;
|
||||
[NonSerialized] internal CombatSnapshotGraph Prepared;
|
||||
|
||||
internal void Prepare(Func<string, CardDefinition> find, IReadOnlyList<CardInstance> runDeck)
|
||||
{
|
||||
void Require(bool condition, string message) => RunCheckpoint.Require(condition, "Combat checkpoint: " + message);
|
||||
Require(version == 1 && manager != null && compilation != null && nix != null && scheduler != null, "unsupported or missing state.");
|
||||
Require(combatants != null && combatants.Count > 0 && combatants.Count <= 10000 && cards != null && cards.Count <= 20000
|
||||
&& enemies != null && enemies.Count > 0 && enemies.Count <= 1000, "invalid graph size.");
|
||||
bool StateIndex(int id) => id >= -1 && id < combatants.Count;
|
||||
bool CardIndex(int id) => id >= 0 && id < cards.Count;
|
||||
Require(player >= 0 && player < combatants.Count && handRam > 0 && handRam <= 10000, "invalid player/hand.");
|
||||
Require(manager.currentPhase == TurnPhase.Execute && manager._turnNumberThisWave >= 1 && !manager._runLost
|
||||
&& !manager._awaitingWaveContinue && !manager.RunCompleted && !manager._waveTransitionActive
|
||||
&& !manager._interpretingTracks && !manager._evaluatingLazyStack && manager._deathSpawnSequencesActive == 0
|
||||
&& !manager._enemyExitQueueDraining, "not a planning boundary.");
|
||||
foreach (var record in combatants)
|
||||
{
|
||||
Require(record?.values != null && record.statuses != null && record.statuses.Count <= 100, "missing combatant.");
|
||||
var v = record.values;
|
||||
Require(v.MaxUptime > 0 && v.CurrentUptime >= 0 && v.CurrentUptime <= v.MaxUptime && v.Shield >= 0 && v.Cycles >= 0, "invalid combatant values.");
|
||||
foreach (var status in record.statuses)
|
||||
Require(status != null && Enum.IsDefined(typeof(StatusType), status.type) && status.stacks >= 0 && StateIndex(status.source), "invalid status.");
|
||||
}
|
||||
Require(!combatants[player].values.IsDefeated && combatants[player].values.CurrentUptime > 0, "host is defeated.");
|
||||
var ids = new HashSet<string>();
|
||||
foreach (var record in cards)
|
||||
{
|
||||
Require(record?.values != null && record.targets != null && record.targets.Count <= combatants.Count, "missing card.");
|
||||
var v = record.values;
|
||||
Require(Guid.TryParseExact(v.InstanceId, "N", out _) && ids.Add(v.InstanceId) && v.MagnitudeBonus >= 0
|
||||
&& v.DrawRider >= 0 && v.UpgradeLevel >= 0 && v.PermanentCostDelta <= 0 && record.targets.All(id => id >= 0 && StateIndex(id)), "invalid card values.");
|
||||
}
|
||||
foreach (var enemy in enemies)
|
||||
Require(enemy?.values != null && enemy.intent != null && enemy.state >= 0 && StateIndex(enemy.state)
|
||||
&& enemy.state != player && EnemyArchetypeCatalog.Get(enemy.archetype).Id == enemy.archetype
|
||||
&& Enum.IsDefined(typeof(EnemyIntentKind), enemy.intent.kind), "unknown enemy or intent.");
|
||||
Require(manager._selectedEnemyIndex >= -1 && manager._selectedEnemyIndex < enemies.Count
|
||||
&& !float.IsNaN(manager._fedoraCrashChance) && !float.IsInfinity(manager._fedoraCrashChance)
|
||||
&& manager._fedoraCrashChance >= 0 && manager._fedoraCrashChance <= 100
|
||||
&& Enum.IsDefined(typeof(NixGovernor), nix.Governor) && nix.Version >= 0 && nix.Version <= 5
|
||||
&& compilation._version >= 0 && compilation._version <= 5 && compilation.Level >= 0 && compilation.Level <= 6, "invalid combat modifiers.");
|
||||
Require(enemies.Select(e => e.state).Distinct().Count() == enemies.Count, "duplicate enemy.");
|
||||
var zones = new[] { hand, draw, discard, exhaust, queue };
|
||||
Require(zones.All(z => z != null && z.Count <= cards.Count && z.All(CardIndex)) && stack != null && stack.Count <= cards.Count
|
||||
&& stack.All(s => s != null && CardIndex(s.card) && s.multiplier >= 100 && s.targets != null
|
||||
&& s.targets.Count <= combatants.Count && s.targets.All(i => i >= 0 && StateIndex(i))), "invalid card zone.");
|
||||
Require(goroutines != null && goroutines.Count <= GoroutineScheduler.Capacity && goroutines.All(g => g != null
|
||||
&& CardIndex(g.card) && StateIndex(g.target) && g.id > 0 && g.id <= scheduler._nextId && g.remaining > 0
|
||||
&& g.remaining <= GoroutineScheduler.MaximumTicks && g.damage >= 0 && g.deploymentRound <= manager._turnNumberThisWave
|
||||
&& g.lastTickRound <= manager._turnNumberThisWave), "invalid goroutine.");
|
||||
Require(goroutines.Select(g => g.id).Distinct().Count() == goroutines.Count, "duplicate PID.");
|
||||
var occupied = zones.SelectMany(z => z).Concat(stack.Select(s => s.card)).Concat(goroutines.Select(g => g.card)).ToArray();
|
||||
Require(occupied.Distinct().Count() == occupied.Length, "card belongs to multiple zones.");
|
||||
Require(python != null && python.scripts != null && python.scripts.Count <= 2 && python.loops != null && python.loops.Count <= 10000
|
||||
&& python.areas != null && python.areas.Count <= 10000 && python.discounts != null && python.discounts.Count <= cards.Count, "invalid Python state.");
|
||||
foreach (var script in python.scripts)
|
||||
{
|
||||
if (script != null && !script.hasPayload) script.payload = null;
|
||||
Require(script != null && CardIndex(script.owner) && script.remaining > 0 && script.remaining <= 100
|
||||
&& (script.payload == null ? script.waiting || script.restore : CardIndex(script.payload.card) && StateIndex(script.payload.target)
|
||||
&& script.payload.damage >= 0 && script.payload.shield >= 0), "invalid automation.");
|
||||
}
|
||||
Require(python.discounts.All(d => d != null && CardIndex(d.card)) && python.discounts.Select(d => d.card).Distinct().Count() == python.discounts.Count, "invalid temporary discounts.");
|
||||
|
||||
var graph = new CombatSnapshotGraph();
|
||||
foreach (var record in combatants)
|
||||
{
|
||||
var state = new CombatantState(1, 0, 0); state.RestoreValues(record.values); graph.States.Add(state);
|
||||
}
|
||||
foreach (var record in cards)
|
||||
{
|
||||
var definition = find(record.definition);
|
||||
var card = runDeck.FirstOrDefault(c => c.InstanceId == record.values.InstanceId) ?? new CardInstance(definition);
|
||||
Require(card.Definition.Id == definition.Id, "card identity changed.");
|
||||
card.RestoreValues(record.values); graph.Cards.Add(card);
|
||||
}
|
||||
for (int i = 0; i < cards.Count; i++) graph.Cards[i].RestoreSnapshotTargets(cards[i].targets.Select(id => graph.State(id)));
|
||||
for (int i = 0; i < combatants.Count; i++)
|
||||
foreach (var status in combatants[i].statuses)
|
||||
graph.States[i].MutableStatuses.Add(new StatusInstance(status.type, status.stacks, status.duration, graph.State(status.source), status.skip));
|
||||
foreach (var record in enemies)
|
||||
{
|
||||
var enemy = new EnemyInstance(EnemyArchetypeCatalog.Get(record.archetype), graph.State(record.state), record.intent.Restore());
|
||||
enemy.RestoreValues(record.values); graph.Enemies.Add(enemy);
|
||||
}
|
||||
Require(hand.Sum(i => HandController.GetRamCost(graph.Cards[i])) <= handRam, "hand exceeds RAM.");
|
||||
Prepared = graph;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class CombatSnapshotGraph
|
||||
{
|
||||
public readonly List<CombatantState> States = new();
|
||||
public readonly List<CardInstance> Cards = new();
|
||||
public readonly List<EnemyInstance> Enemies = new();
|
||||
public CombatantState State(int index) => index < 0 ? null : States[index];
|
||||
}
|
||||
|
||||
internal sealed class CombatSnapshotWriter
|
||||
{
|
||||
public readonly CombatSnapshot Snapshot = new();
|
||||
private readonly Dictionary<CombatantState, int> _states = new();
|
||||
private readonly Dictionary<CardInstance, int> _cards = new();
|
||||
public int State(CombatantState state)
|
||||
{
|
||||
if (state == null) return -1;
|
||||
if (_states.TryGetValue(state, out int id)) return id;
|
||||
id = Snapshot.combatants.Count; _states.Add(state, id);
|
||||
var record = new SavedCombatant { values = state.CaptureValues() }; Snapshot.combatants.Add(record);
|
||||
foreach (var status in state.Statuses)
|
||||
record.statuses.Add(new SavedStatus { type = status.Type, stacks = status.Stacks, duration = status.Duration, skip = status.SkipNextTick, source = State(status.Source) });
|
||||
return id;
|
||||
}
|
||||
public int Card(CardInstance card)
|
||||
{
|
||||
if (card == null) return -1;
|
||||
if (_cards.TryGetValue(card, out int id)) return id;
|
||||
id = Snapshot.cards.Count; _cards.Add(card, id);
|
||||
Snapshot.cards.Add(new SavedCard { definition = card.Definition.Id, values = card.CaptureValues(), targets = card.TargetSnapshot.Select(State).ToList() });
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable] public sealed class SavedCombatant { public CombatantStateValues values; public List<SavedStatus> statuses = new(); }
|
||||
[Serializable] public sealed class SavedStatus { public StatusType type; public int stacks, duration, source; public bool skip; }
|
||||
[Serializable] public sealed class SavedCard { public string definition; public CardInstanceValues values; public List<int> targets = new(); }
|
||||
[Serializable] public sealed class SavedEnemy { public string archetype; public int state; public EnemyInstanceValues values; public SavedIntent intent; }
|
||||
[Serializable] public sealed class SavedStackEntry { public int card, multiplier; public List<int> targets = new(); }
|
||||
[Serializable] public sealed class SavedGoroutine { public long id; public int card, target, damage, remaining, deploymentRound, lastTickRound; }
|
||||
[Serializable] public sealed class SavedPython
|
||||
{
|
||||
public int round; public bool damage, automated;
|
||||
public List<int> loops = new(), areas = new();
|
||||
public List<SavedScript> scripts = new(); public List<SavedDiscount> discounts = new();
|
||||
}
|
||||
[Serializable] public sealed class SavedScript
|
||||
{ public string name; public int owner, firstRound, remaining, uptime, lastRunRound; public bool waiting, restore, hasPayload; public SavedPayload payload; }
|
||||
[Serializable] public sealed class SavedPayload { public int card, damage, shield, target; public bool all; }
|
||||
[Serializable] public sealed class SavedDiscount { public int card, cost; }
|
||||
[Serializable] public sealed class SavedIntent
|
||||
{
|
||||
public EnemyIntentKind kind; public int min, max, stacks, duration; public Language language; public StatusType status;
|
||||
public string label, icon, value; public bool trueDamage;
|
||||
public static SavedIntent Capture(EnemyIntent intent) => new() { kind = intent.Kind, min = intent.MinValue, max = intent.MaxValue,
|
||||
stacks = intent.StatusStacks, duration = intent.StatusDuration, language = intent.DamageType, status = intent.StatusType,
|
||||
label = intent.DisplayLabel, icon = intent.IconKey, value = intent.ValueTextOverride, trueDamage = intent.TrueDamage };
|
||||
public EnemyIntent Restore() => new(kind, min, max, language, label, icon, trueDamage, status, stacks, duration, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ca42825ab216854ab366724065f910f
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using KernelPanic.Core;
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
[Serializable] public sealed class CardInstanceValues
|
||||
{
|
||||
public bool _isBroken;
|
||||
public int _corruptionLastRecoveryRound;
|
||||
public string InstanceId;
|
||||
public int TemporaryCostDelta;
|
||||
public int PermanentCostDelta;
|
||||
public int MagnitudeBonus;
|
||||
public int DrawRider;
|
||||
public bool ExhaustOnPlay;
|
||||
public int UpgradeLevel;
|
||||
public int QueuePlayCount;
|
||||
public bool WasFirstCardThisTurn;
|
||||
public bool HadFedoraNonCrashBonus;
|
||||
public int CorruptionRoundsRemaining;
|
||||
public bool IsLocked;
|
||||
}
|
||||
[Serializable] public sealed class CombatantStateValues
|
||||
{
|
||||
public int CurrentUptime;
|
||||
public int MaxUptime;
|
||||
public int Shield;
|
||||
public int Ram;
|
||||
public int Cycles;
|
||||
public int MaxCycles;
|
||||
public bool IsDefeated;
|
||||
public bool ForceMaxRolls;
|
||||
public bool IgnoreDamageMultipliers;
|
||||
public bool AllowFlatDamageBuffs;
|
||||
public int FlatEffectBonus;
|
||||
public int FlatCardDamageBonus;
|
||||
public int JavaScriptFlatDamageBonus;
|
||||
public int DamageMultiplierPercent;
|
||||
public int CurrentCardDamageMultiplierPercent;
|
||||
public int GovernorDamagePercent;
|
||||
public int GovernorShieldPercent;
|
||||
public int IncomingAttackHalfCharges;
|
||||
public int ArchBtwStacks;
|
||||
public int ArchBtwDamagePerStack;
|
||||
public int ArchMakepkgBtwMultiplier;
|
||||
public int ArchRollingReleaseSavesRemaining;
|
||||
public int ArchRollingReleaseShieldOnSave;
|
||||
public int ArchRollingReleaseCyclesOnSave;
|
||||
public bool ArchRollingReleaseAvailableThisWave;
|
||||
public bool ArchRollingReleaseRecoveredThisHit;
|
||||
public bool HasLastPlayedCardLanguage;
|
||||
public Language LastPlayedCardLanguage;
|
||||
public bool HasPreviousPlayedCardLanguage;
|
||||
public Language PreviousPlayedCardLanguage;
|
||||
}
|
||||
[Serializable] public sealed class EnemyInstanceValues
|
||||
{
|
||||
public int TurnsAlive;
|
||||
public int CountdownRemaining;
|
||||
public bool IntentRevealed;
|
||||
public bool HasRevived;
|
||||
public bool PendingRevive;
|
||||
public bool Reaped;
|
||||
public bool LethalHitThisTurn;
|
||||
public bool DefeatedPendingRemoval;
|
||||
public int PairId;
|
||||
public int RaceEnrageStacks;
|
||||
public int TelemetryStacks;
|
||||
public bool SpawnedFromDeath;
|
||||
public bool DeathSpawnIntentRevealed;
|
||||
}
|
||||
[Serializable] public sealed class CompilationStateValues
|
||||
{
|
||||
public int _version;
|
||||
public int _lastCompletedRound;
|
||||
public int LastAdvancedRound;
|
||||
public int Level;
|
||||
}
|
||||
[Serializable] public sealed class NixGovernorStateValues
|
||||
{
|
||||
public NixGovernor Governor;
|
||||
public int Version;
|
||||
public bool FreeSwitchUsed;
|
||||
public int LastSwitchRound;
|
||||
}
|
||||
[Serializable] public sealed class GoroutineSchedulerValues
|
||||
{
|
||||
public long _nextId;
|
||||
}
|
||||
[Serializable] public sealed class CombatManagerValues
|
||||
{
|
||||
public TurnPhase currentPhase;
|
||||
public int _selectedEnemyIndex;
|
||||
public bool _awaitingWaveContinue;
|
||||
public bool _waveTransitionActive;
|
||||
public bool _runLost;
|
||||
public bool _skipNextAllocateDraw;
|
||||
public bool _ubuntuEmptyHandRefillUsed;
|
||||
public int _fedoraCardsDiscountedThisTurn;
|
||||
public float _fedoraCrashChance;
|
||||
public int _cardsPlayedThisTurn;
|
||||
public bool _prefetchUsed;
|
||||
public int _cardsPlayedThisWave;
|
||||
public int _cCardsPlayedThisTurn;
|
||||
public int _turnNumberThisWave;
|
||||
public bool _packageWaveStartApplied;
|
||||
public int _packageLastRoundApplied;
|
||||
public bool _packageShieldBonusTriggeredThisTurn;
|
||||
public bool _packageTimeshiftTriggeredThisWave;
|
||||
public bool _packageInterpreterQueueShieldTriggeredThisWave;
|
||||
public bool _packageNativeDamageTriggeredThisWave;
|
||||
public int _javaCardsPlayedThisCombat;
|
||||
public int _javaCardsDiscountThisTurn;
|
||||
public int _rawhideBonusCharges;
|
||||
public int _queuedRepeatCharges;
|
||||
public int _nextTurnCycleBonus;
|
||||
public int _nextRacePairId;
|
||||
public int _activeKernelRamPenalty;
|
||||
public int _deathSpawnSequencesActive;
|
||||
public bool _enemyExitQueueDraining;
|
||||
public bool _interpretingTracks;
|
||||
public bool _evaluatingLazyStack;
|
||||
public bool RunCompleted;
|
||||
public bool RunEndedBySurrender;
|
||||
public bool TutorialReading;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89d5d217a0258184894f0cfac502f60d
|
||||
@@ -8,6 +8,74 @@ namespace KernelPanic.Combat
|
||||
/// </summary>
|
||||
public sealed class CombatantState
|
||||
{
|
||||
// Explicit checkpoint values: no gameplay hooks or random draws during restoration.
|
||||
internal CombatantStateValues CaptureValues() => new()
|
||||
{
|
||||
CurrentUptime = CurrentUptime,
|
||||
MaxUptime = MaxUptime,
|
||||
Shield = Shield,
|
||||
Ram = Ram,
|
||||
Cycles = Cycles,
|
||||
MaxCycles = MaxCycles,
|
||||
IsDefeated = IsDefeated,
|
||||
ForceMaxRolls = ForceMaxRolls,
|
||||
IgnoreDamageMultipliers = IgnoreDamageMultipliers,
|
||||
AllowFlatDamageBuffs = AllowFlatDamageBuffs,
|
||||
FlatEffectBonus = FlatEffectBonus,
|
||||
FlatCardDamageBonus = FlatCardDamageBonus,
|
||||
JavaScriptFlatDamageBonus = JavaScriptFlatDamageBonus,
|
||||
DamageMultiplierPercent = DamageMultiplierPercent,
|
||||
CurrentCardDamageMultiplierPercent = CurrentCardDamageMultiplierPercent,
|
||||
GovernorDamagePercent = GovernorDamagePercent,
|
||||
GovernorShieldPercent = GovernorShieldPercent,
|
||||
IncomingAttackHalfCharges = IncomingAttackHalfCharges,
|
||||
ArchBtwStacks = ArchBtwStacks,
|
||||
ArchBtwDamagePerStack = ArchBtwDamagePerStack,
|
||||
ArchMakepkgBtwMultiplier = ArchMakepkgBtwMultiplier,
|
||||
ArchRollingReleaseSavesRemaining = ArchRollingReleaseSavesRemaining,
|
||||
ArchRollingReleaseShieldOnSave = ArchRollingReleaseShieldOnSave,
|
||||
ArchRollingReleaseCyclesOnSave = ArchRollingReleaseCyclesOnSave,
|
||||
ArchRollingReleaseAvailableThisWave = ArchRollingReleaseAvailableThisWave,
|
||||
ArchRollingReleaseRecoveredThisHit = ArchRollingReleaseRecoveredThisHit,
|
||||
HasLastPlayedCardLanguage = HasLastPlayedCardLanguage,
|
||||
LastPlayedCardLanguage = LastPlayedCardLanguage,
|
||||
HasPreviousPlayedCardLanguage = HasPreviousPlayedCardLanguage,
|
||||
PreviousPlayedCardLanguage = PreviousPlayedCardLanguage,
|
||||
};
|
||||
internal void RestoreValues(CombatantStateValues value)
|
||||
{
|
||||
CurrentUptime = value.CurrentUptime;
|
||||
MaxUptime = value.MaxUptime;
|
||||
Shield = value.Shield;
|
||||
Ram = value.Ram;
|
||||
Cycles = value.Cycles;
|
||||
MaxCycles = value.MaxCycles;
|
||||
IsDefeated = value.IsDefeated;
|
||||
ForceMaxRolls = value.ForceMaxRolls;
|
||||
IgnoreDamageMultipliers = value.IgnoreDamageMultipliers;
|
||||
AllowFlatDamageBuffs = value.AllowFlatDamageBuffs;
|
||||
FlatEffectBonus = value.FlatEffectBonus;
|
||||
FlatCardDamageBonus = value.FlatCardDamageBonus;
|
||||
JavaScriptFlatDamageBonus = value.JavaScriptFlatDamageBonus;
|
||||
DamageMultiplierPercent = value.DamageMultiplierPercent;
|
||||
CurrentCardDamageMultiplierPercent = value.CurrentCardDamageMultiplierPercent;
|
||||
GovernorDamagePercent = value.GovernorDamagePercent;
|
||||
GovernorShieldPercent = value.GovernorShieldPercent;
|
||||
IncomingAttackHalfCharges = value.IncomingAttackHalfCharges;
|
||||
ArchBtwStacks = value.ArchBtwStacks;
|
||||
ArchBtwDamagePerStack = value.ArchBtwDamagePerStack;
|
||||
ArchMakepkgBtwMultiplier = value.ArchMakepkgBtwMultiplier;
|
||||
ArchRollingReleaseSavesRemaining = value.ArchRollingReleaseSavesRemaining;
|
||||
ArchRollingReleaseShieldOnSave = value.ArchRollingReleaseShieldOnSave;
|
||||
ArchRollingReleaseCyclesOnSave = value.ArchRollingReleaseCyclesOnSave;
|
||||
ArchRollingReleaseAvailableThisWave = value.ArchRollingReleaseAvailableThisWave;
|
||||
ArchRollingReleaseRecoveredThisHit = value.ArchRollingReleaseRecoveredThisHit;
|
||||
HasLastPlayedCardLanguage = value.HasLastPlayedCardLanguage;
|
||||
LastPlayedCardLanguage = value.LastPlayedCardLanguage;
|
||||
HasPreviousPlayedCardLanguage = value.HasPreviousPlayedCardLanguage;
|
||||
PreviousPlayedCardLanguage = value.PreviousPlayedCardLanguage;
|
||||
}
|
||||
|
||||
private readonly List<StatusInstance> _statuses = new();
|
||||
|
||||
public CombatantState(int maxUptime, int ram, int cycles)
|
||||
|
||||
@@ -5,6 +5,22 @@ namespace KernelPanic.Combat
|
||||
/// <summary>Wave-scoped Gentoo progression. Round IDs make completion idempotent.</summary>
|
||||
public sealed class CompilationState
|
||||
{
|
||||
// Explicit checkpoint values: no gameplay hooks or random draws during restoration.
|
||||
internal CompilationStateValues CaptureValues() => new()
|
||||
{
|
||||
_version = _version,
|
||||
_lastCompletedRound = _lastCompletedRound,
|
||||
LastAdvancedRound = LastAdvancedRound,
|
||||
Level = Level,
|
||||
};
|
||||
internal void RestoreValues(CompilationStateValues value)
|
||||
{
|
||||
_version = value._version;
|
||||
_lastCompletedRound = value._lastCompletedRound;
|
||||
LastAdvancedRound = value.LastAdvancedRound;
|
||||
Level = value.Level;
|
||||
}
|
||||
|
||||
private int _version;
|
||||
private int _lastCompletedRound;
|
||||
public int LastAdvancedRound { get; private set; }
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace KernelPanic.Combat
|
||||
Amount = amount;
|
||||
Language = language;
|
||||
TrueDamage = trueDamage;
|
||||
CanCrit = canCrit;
|
||||
CanCrit = canCrit && language != Language.TypeScript;
|
||||
ApplySourceModifiers = applySourceModifiers;
|
||||
LazyMultiplierPercent = 100;
|
||||
CompilationPercent = 100;
|
||||
@@ -137,6 +137,19 @@ namespace KernelPanic.Combat
|
||||
return PreviewResistanceResolver == null ? amount : PreviewResistanceResolver(request, amount);
|
||||
}
|
||||
|
||||
public string DescribePreview(DamageRequest request, int archStacks, int sourceMultiplierPercent, int cardMultiplierPercent)
|
||||
{
|
||||
int input = Mathf.Max(0, request.Amount);
|
||||
int flat = request.ApplySourceModifiers ? ApplyFlatAdditions(input, request, out _, archStacks) : input;
|
||||
int scaled = request.ApplySourceModifiers ? ApplyMultipliers(flat, request, sourceMultiplierPercent, cardMultiplierPercent) : flat;
|
||||
int normal = PreviewIncomingDamage(request, false, archStacks, sourceMultiplierPercent, cardMultiplierPercent);
|
||||
int critical = PreviewIncomingDamage(request, true, archStacks, sourceMultiplierPercent, cardMultiplierPercent);
|
||||
return $"Input {input} -> flat bonuses {flat} -> multipliers {scaled} -> defenses {normal}"
|
||||
+ (critical != normal ? $" ({critical} if critical)" : "")
|
||||
+ (request.TrueDamage ? "; bypasses Shield." : "; Shield absorbs damage before Uptime.")
|
||||
+ (!CanPreviewResistance ? " Custom defense cannot be estimated." : "");
|
||||
}
|
||||
|
||||
public DamageResult DefeatCombatant(CombatantState target, CombatantState source, Language language)
|
||||
{
|
||||
if (target == null || target.IsDefeated)
|
||||
@@ -162,19 +175,32 @@ namespace KernelPanic.Combat
|
||||
int amount = Mathf.Max(0, request.Amount);
|
||||
bool wasCritical = false;
|
||||
int archBtwBonus = 0;
|
||||
int baseAmount = amount, flatAmount = amount, scaledAmount = amount;
|
||||
if (request.ApplySourceModifiers)
|
||||
{
|
||||
amount = ApplyFlatAdditions(amount, request, out archBtwBonus);
|
||||
flatAmount = amount;
|
||||
amount = ApplyMultipliers(amount, request);
|
||||
scaledAmount = amount;
|
||||
amount = ApplyCrit(amount, request, out wasCritical);
|
||||
}
|
||||
|
||||
int criticalAmount = amount;
|
||||
amount = ApplyResistancesAndWeaknesses(amount, request);
|
||||
|
||||
int finalAmount = ApplyShieldAndUptime(amount, request, out int absorbedAmount, out int shieldDamage, out int uptimeDamage);
|
||||
ApplyArchRollingReleaseSave(request);
|
||||
bool rollingReleaseSaveTriggered = request.Target != null && request.Target.ArchRollingReleaseRecoveredThisHit;
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(request.Source, request.Target, finalAmount, request.Language, amount, absorbedAmount, wasCritical, shieldDamage, uptimeDamage, request.TrueDamage, archBtwBonus, rollingReleaseSaveTriggered).WithCause(request.Cause));
|
||||
string breakdown = $"{request.Language}: input {baseAmount} -> flat bonuses {flatAmount} -> multipliers {scaledAmount}"
|
||||
+ $" -> {(wasCritical ? "critical" : "no critical")} {criticalAmount} -> defenses {amount}"
|
||||
+ $" -> Shield {shieldDamage}, Uptime {uptimeDamage}, excess {absorbedAmount}."
|
||||
+ (request.TrueDamage ? " Bypasses Shield." : "")
|
||||
+ (rollingReleaseSaveTriggered ? " Rolling Release prevented defeat." : "");
|
||||
if (request.IsCardDamage)
|
||||
breakdown += $" Multipliers: stack {request.LazyMultiplierPercent}%, Compilation {request.CompilationPercent}%, source {request.Source?.DamageMultiplierPercent ?? 100}%, card {request.Source?.CurrentCardDamageMultiplierPercent ?? 100}%, governor {request.Source?.GovernorDamagePercent ?? 100}%."
|
||||
+ (request.Source?.IgnoreDamageMultipliers == true ? " Multipliers ignored by Mint." : "")
|
||||
+ " Input includes the card's rolled/conditional base and magnitude bonuses.";
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(request.Source, request.Target, finalAmount, request.Language, amount, absorbedAmount, wasCritical, shieldDamage, uptimeDamage, request.TrueDamage, archBtwBonus, rollingReleaseSaveTriggered).WithCause(request.Cause).WithBreakdown(breakdown));
|
||||
|
||||
bool defeated = false;
|
||||
if (request.Target.CurrentUptime <= 0 && !request.Target.IsDefeated)
|
||||
|
||||
@@ -32,6 +32,13 @@ namespace KernelPanic.Combat
|
||||
public IReadOnlyList<CardInstance> ExhaustPile => _exhaustPile;
|
||||
public int AvailableToDrawCount => _drawPile.Count + _discardPile.Count;
|
||||
|
||||
internal void RestorePiles(IEnumerable<CardInstance> draw, IEnumerable<CardInstance> discard, IEnumerable<CardInstance> exhaust)
|
||||
{
|
||||
_drawPile.Clear(); _drawPile.AddRange(draw);
|
||||
_discardPile.Clear(); _discardPile.AddRange(discard);
|
||||
_exhaustPile.Clear(); _exhaustPile.AddRange(exhaust);
|
||||
}
|
||||
|
||||
public void Initialize(IEnumerable<CardInstance> cards)
|
||||
{
|
||||
_drawPile.Clear();
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace KernelPanic.Combat
|
||||
// A stable integer mixer, independent of both gameplay random streams and runtime hash codes.
|
||||
public static EncounterPlan Plan(int wave, WaveRoute route, int seed, int revision)
|
||||
{
|
||||
if (revision >= 4 && wave >= 2 && wave <= RunJourney.BossWave) return SpecialistPlan(wave, route, seed);
|
||||
if (revision >= 3 && wave >= 5 && wave <= 9) return VariedCampaignPlan(wave, route, seed);
|
||||
if (revision >= 2) return CampaignPlan(wave, route, seed);
|
||||
if (revision == 0) return Plan(wave, route);
|
||||
@@ -79,6 +80,28 @@ namespace KernelPanic.Combat
|
||||
return plan;
|
||||
}
|
||||
|
||||
private static EncounterPlan SpecialistPlan(int wave, WaveRoute route, int seed)
|
||||
{
|
||||
uint hash = unchecked((uint)seed * 0x9E3779B9u + (uint)wave * 0x7FEB352Du);
|
||||
hash ^= hash >> 16;
|
||||
int variant = (int)(hash % 3);
|
||||
var baseline = Plan(wave, route, seed, 3);
|
||||
if (wave == RunJourney.BossWave)
|
||||
{
|
||||
if (variant == 0) return baseline;
|
||||
return variant == 1
|
||||
? new EncounterPlan("Process Supervisor", "Cycle: summon two workers, Shield, interrupt. Workers accumulate up to eight living processes; clear them with area damage or race the supervisor. At half Uptime its next attacks gain 3 damage.", baseline.UptimeBonus, "process_supervisor", "firewalld")
|
||||
: new EncounterPlan("OOM Reaper", "Two RAM are unavailable while the Reaper lives. Cycle: charge with Shield, 14-damage OOM kill, weak recovery attack. Prepare defense for the burst; at half Uptime its next attacks gain 3 damage.", baseline.UptimeBonus, "oom_reaper", "cron_job");
|
||||
}
|
||||
if (route != WaveRoute.Challenge || variant == 0) return baseline;
|
||||
var standard = Plan(wave, WaveRoute.Repair, seed, 3);
|
||||
var enemies = new List<string>(standard.Enemies) { variant == 1 ? "watchdog" : "process_broker" };
|
||||
string advice = variant == 1
|
||||
? "Watchdog escort: two countdown turns, then 12-14 damage. Defeat it before timeout or bank Shield."
|
||||
: "Process Broker escort: alternates summoning a worker and attacking. Workers accumulate up to eight living processes; stop the broker early.";
|
||||
return new EncounterPlan(standard.Title + " (elite)", standard.Advice + " " + advice, standard.UptimeBonus, enemies.ToArray());
|
||||
}
|
||||
|
||||
public static EncounterPlan Plan(int wave, WaveRoute route)
|
||||
{
|
||||
string title, advice;
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace KernelPanic.Combat
|
||||
RamPressure = 1 << 11,
|
||||
TelemetryCollector = 1 << 12,
|
||||
CardLocker = 1 << 13,
|
||||
BossCycle = 1 << 14
|
||||
BossCycle = 1 << 14,
|
||||
ProcessSpawner = 1 << 15
|
||||
}
|
||||
|
||||
public enum EnemyTier
|
||||
@@ -241,11 +242,45 @@ namespace KernelPanic.Combat
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 10, 10, Language.C, "heavy interrupt", "!!")
|
||||
}, EnemyTier.Boss);
|
||||
|
||||
private static readonly EnemyArchetypeDescriptor ProcessSupervisor = new(
|
||||
"process_supervisor", "Process Supervisor", 36, 36,
|
||||
EnemyBehaviorFlags.BossCycle | EnemyBehaviorFlags.ProcessSpawner,
|
||||
new[] {
|
||||
new EnemyIntent(EnemyIntentKind.Special, 2, 2, Language.C, "spawn workers (8-process cap)", "+"),
|
||||
new EnemyIntent(EnemyIntentKind.Defend, 5, 5, Language.C, "protect supervisor", "#"),
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 8, 8, Language.C, "dispatch interrupt", "!")
|
||||
}, EnemyTier.Boss);
|
||||
|
||||
private static readonly EnemyArchetypeDescriptor OomReaper = new(
|
||||
"oom_reaper", "OOM Reaper", 34, 34,
|
||||
EnemyBehaviorFlags.BossCycle | EnemyBehaviorFlags.RamPressure,
|
||||
new[] {
|
||||
new EnemyIntent(EnemyIntentKind.Defend, 4, 4, Language.C, "charge OOM kill", "#"),
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 14, 14, Language.C, "OOM kill", "!!"),
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 2, 2, Language.C, "reclaim memory", "!")
|
||||
}, EnemyTier.Boss);
|
||||
|
||||
private static readonly EnemyArchetypeDescriptor Watchdog = new(
|
||||
"watchdog", "Watchdog", 12, 14, EnemyBehaviorFlags.Elite | EnemyBehaviorFlags.Countdown,
|
||||
new[] { new EnemyIntent(EnemyIntentKind.Attack, 12, 14, Language.C, "watchdog timeout", "!!") }, EnemyTier.Elite);
|
||||
|
||||
private static readonly EnemyArchetypeDescriptor ProcessBroker = new(
|
||||
"process_broker", "Process Broker", 12, 14,
|
||||
EnemyBehaviorFlags.Elite | EnemyBehaviorFlags.BossCycle | EnemyBehaviorFlags.ProcessSpawner,
|
||||
new[] {
|
||||
new EnemyIntent(EnemyIntentKind.Special, 1, 1, Language.C, "spawn worker (8-process cap)", "+"),
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 4, 4, Language.C, "broker interrupt", "!")
|
||||
}, EnemyTier.Elite);
|
||||
|
||||
public static EnemyArchetypeDescriptor Get(string id)
|
||||
{
|
||||
return id switch
|
||||
{
|
||||
"kernel_overseer" => KernelOverseer,
|
||||
"process_supervisor" => ProcessSupervisor,
|
||||
"oom_reaper" => OomReaper,
|
||||
"watchdog" => Watchdog,
|
||||
"process_broker" => ProcessBroker,
|
||||
"memory_leak" => MemoryLeak,
|
||||
"fork_bomb" => ForkBomb,
|
||||
"daemon" => Daemon,
|
||||
|
||||
@@ -7,6 +7,40 @@ namespace KernelPanic.Combat
|
||||
/// </summary>
|
||||
public sealed class EnemyInstance
|
||||
{
|
||||
// Explicit checkpoint values: no gameplay hooks or random draws during restoration.
|
||||
internal EnemyInstanceValues CaptureValues() => new()
|
||||
{
|
||||
TurnsAlive = TurnsAlive,
|
||||
CountdownRemaining = CountdownRemaining,
|
||||
IntentRevealed = IntentRevealed,
|
||||
HasRevived = HasRevived,
|
||||
PendingRevive = PendingRevive,
|
||||
Reaped = Reaped,
|
||||
LethalHitThisTurn = LethalHitThisTurn,
|
||||
DefeatedPendingRemoval = DefeatedPendingRemoval,
|
||||
PairId = PairId,
|
||||
RaceEnrageStacks = RaceEnrageStacks,
|
||||
TelemetryStacks = TelemetryStacks,
|
||||
SpawnedFromDeath = SpawnedFromDeath,
|
||||
DeathSpawnIntentRevealed = DeathSpawnIntentRevealed,
|
||||
};
|
||||
internal void RestoreValues(EnemyInstanceValues value)
|
||||
{
|
||||
TurnsAlive = value.TurnsAlive;
|
||||
CountdownRemaining = value.CountdownRemaining;
|
||||
IntentRevealed = value.IntentRevealed;
|
||||
HasRevived = value.HasRevived;
|
||||
PendingRevive = value.PendingRevive;
|
||||
Reaped = value.Reaped;
|
||||
LethalHitThisTurn = value.LethalHitThisTurn;
|
||||
DefeatedPendingRemoval = value.DefeatedPendingRemoval;
|
||||
PairId = value.PairId;
|
||||
RaceEnrageStacks = value.RaceEnrageStacks;
|
||||
TelemetryStacks = value.TelemetryStacks;
|
||||
SpawnedFromDeath = value.SpawnedFromDeath;
|
||||
DeathSpawnIntentRevealed = value.DeathSpawnIntentRevealed;
|
||||
}
|
||||
|
||||
private readonly List<EnemyIntent> _intentPool = new();
|
||||
|
||||
public EnemyInstance(string name, int maxUptime, IEnumerable<EnemyIntent> intentPool)
|
||||
@@ -30,6 +64,8 @@ namespace KernelPanic.Combat
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
internal EnemyInstance(EnemyArchetypeDescriptor archetype, CombatantState state, EnemyIntent intent) : this(archetype, state.MaxUptime)
|
||||
{ State = state; CurrentIntent = intent; }
|
||||
public EnemyArchetypeDescriptor Archetype { get; }
|
||||
public string ArchetypeId => Archetype.Id;
|
||||
public int CurrentUptime => State.CurrentUptime;
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace KernelPanic.Combat
|
||||
public void Execute(CombatContext context)
|
||||
{
|
||||
int count = context.HandController.Cards.Count(c => c.Definition?.Language is Language.C or Language.CPlusPlus);
|
||||
new DealDamageEffect(6 * count, 6 * count, Language.CPlusPlus).Execute(context);
|
||||
int amount = SizeofDamageEffect.DamagePerCard * count;
|
||||
new DealDamageEffect(amount, amount, Language.CPlusPlus).Execute(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,33 +23,33 @@ namespace KernelPanic.Combat
|
||||
=> entries.Add(new CardCatalogEntry(id, target, bleeding, rules, effects));
|
||||
CardEffectSpec Typed(int amount, bool all = false) => new(CardEffectKind.Damage, amount,
|
||||
language: Language.TypeScript, allEnemies: all, canCrit: false);
|
||||
Add("lang_cpp_malloc", Single, true, "deal {amount:0}." + cpp, Damage(15, Language.CPlusPlus));
|
||||
Add("lang_cpp_malloc", Single, true, "deal {amount:0}." + cpp, Damage(12, Language.CPlusPlus));
|
||||
Add("lang_cpp_printf", Single, true, "deal {amount:0}. repair {amount:1} corrupted cards." + cpp,
|
||||
Damage(6, Language.CPlusPlus), Fx(CardEffectKind.RepairCorruptedCards, 2));
|
||||
Damage(4, Language.CPlusPlus), Fx(CardEffectKind.RepairCorruptedCards, 2));
|
||||
Add("lang_cpp_pointer", Single, true, "deal {amount:0}; {secondary:0} if the previous card was C++." + cpp,
|
||||
Fx(CardEffectKind.PreviousLanguageDamage, 12, secondary: 20, language: Language.CPlusPlus));
|
||||
Fx(CardEffectKind.PreviousLanguageDamage, 9, secondary: 15, language: Language.CPlusPlus));
|
||||
Add("shop_cpp_free", Single, true, "deal {amount:0}. repair {amount:1} corrupted cards. draw 2 (fixed)." + cpp,
|
||||
Damage(22, Language.CPlusPlus), Fx(CardEffectKind.RepairCorruptedCards, 2), Fx(CardEffectKind.FixedDraw, 2));
|
||||
Add("shop_cpp_sizeof", Single, true, "deal 6 x C and C++ cards in hand." + cpp,
|
||||
Fx(CardEffectKind.SizeofDamage, 6, language: Language.CPlusPlus));
|
||||
Add("shop_cpp_kernel_exploit", Single, true, "deal {amount:0} ignoring Shield." + cpp, Damage(40, Language.CPlusPlus, trueDamage: true));
|
||||
Damage(18, Language.CPlusPlus), Fx(CardEffectKind.RepairCorruptedCards, 2), Fx(CardEffectKind.FixedDraw, 2));
|
||||
Add("shop_cpp_sizeof", Single, true, "deal {raw:0} x C and C++ cards in hand." + cpp,
|
||||
Fx(CardEffectKind.SizeofDamage, SizeofDamageEffect.DamagePerCard, language: Language.CPlusPlus));
|
||||
Add("shop_cpp_kernel_exploit", Single, true, "deal {amount:0} ignoring Shield." + cpp, Damage(36, Language.CPlusPlus, trueDamage: true));
|
||||
Add("shop_cpp_gdb", None, false, "repair {amount:0} corrupted cards. draw {amount:1}.", Fx(CardEffectKind.RepairCorruptedCards, 3), Draw(2));
|
||||
Add("shop_cpp_valgrind", None, false, "repair {amount:0} corrupted cards. gain {shield:1} Shield.", Fx(CardEffectKind.RepairCorruptedCards, 4), Shield(9));
|
||||
Add("shop_cpp_memcpy", Single, true, "deal {amount:0}. draw 1 (fixed)." + cpp, Damage(9, Language.CPlusPlus), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_cpp_memset", All, true, "deal {amount:0} to all enemies." + cpp, Damage(6, Language.CPlusPlus, all: true));
|
||||
Add("shop_cpp_realloc", Single, true, "deal {amount:0}. repair {amount:1} corrupted cards." + cpp, Damage(16, Language.CPlusPlus), Fx(CardEffectKind.RepairCorruptedCards, 3));
|
||||
const string fixedHit = " Fixed damage; no critical roll.";
|
||||
Add("lang_ts_console_log", Single, true, "deal {amount:0}." + fixedHit, Typed(9));
|
||||
Add("lang_ts_fetch", Single, true, "deal {amount:0}." + fixedHit, Typed(13));
|
||||
Add("lang_ts_typeof", Single, true, "deal {amount:0}. Always succeeds." + fixedHit, Typed(16));
|
||||
Add("shop_ts_math_random", Single, true, "deal {amount:0}." + fixedHit, Typed(20));
|
||||
Add("shop_ts_promise_all", Single, true, "deal {amount:0} three times." + fixedHit, Typed(10), Typed(10), Typed(10));
|
||||
Add("shop_cpp_memcpy", Single, true, "deal {amount:0}. draw 1 (fixed)." + cpp, Damage(6, Language.CPlusPlus), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_cpp_memset", All, true, "deal {amount:0} to all enemies." + cpp, Damage(4, Language.CPlusPlus, all: true));
|
||||
Add("shop_cpp_realloc", Single, true, "deal {amount:0}. repair {amount:1} corrupted cards." + cpp, Damage(12, Language.CPlusPlus), Fx(CardEffectKind.RepairCorruptedCards, 3));
|
||||
const string fixedHit = " Fixed damage; cannot crit.";
|
||||
Add("lang_ts_console_log", Single, true, "deal {amount:0}." + fixedHit, Typed(6));
|
||||
Add("lang_ts_fetch", Single, true, "deal {amount:0}." + fixedHit, Typed(9));
|
||||
Add("lang_ts_typeof", Single, true, "deal {amount:0}. Always succeeds." + fixedHit, Typed(11));
|
||||
Add("shop_ts_math_random", Single, true, "deal {amount:0}." + fixedHit, Typed(11));
|
||||
Add("shop_ts_promise_all", Single, true, "deal {amount:0} three times." + fixedHit, Typed(7), Typed(7), Typed(7));
|
||||
Add("shop_ts_spread", None, false, "copy the lowest-cost card in hand. gain {shield:1} Shield.", Fx(CardEffectKind.CopyLowestCostHandCard), Shield(3));
|
||||
Add("shop_ts_array_map", All, true, "deal {amount:0} to each enemy." + fixedHit, Typed(6, true));
|
||||
Add("shop_ts_promise_resolve", Single, true, "deal {amount:0}." + fixedHit, Typed(5));
|
||||
Add("shop_ts_array_map", All, true, "deal {amount:0} to each enemy." + fixedHit, Typed(4, true));
|
||||
Add("shop_ts_promise_resolve", Single, true, "deal {amount:0}." + fixedHit, Typed(3));
|
||||
Add("shop_ts_try_catch", None, false, "gain {shield:0} Shield. cleanse harmful statuses.", Shield(8), Fx(CardEffectKind.Cleanse));
|
||||
Add("shop_ts_json_parse", Single, true, "deal {amount:0}. draw 1 (fixed)." + fixedHit, Typed(9), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_ts_eval", Single, true, "deal {amount:0}." + fixedHit, Typed(30));
|
||||
Add("shop_ts_json_parse", Single, true, "deal {amount:0}. draw 1 (fixed)." + fixedHit, Typed(6), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_ts_eval", Single, true, "deal {amount:0}." + fixedHit, Typed(15));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,16 @@ namespace KernelPanic.Combat
|
||||
/// <summary>Bounded persistent work, advanced only by the authoritative Interpret phase.</summary>
|
||||
public sealed class GoroutineScheduler
|
||||
{
|
||||
// Explicit checkpoint values: no gameplay hooks or random draws during restoration.
|
||||
internal GoroutineSchedulerValues CaptureValues() => new()
|
||||
{
|
||||
_nextId = _nextId,
|
||||
};
|
||||
internal void RestoreValues(GoroutineSchedulerValues value)
|
||||
{
|
||||
_nextId = value._nextId;
|
||||
}
|
||||
|
||||
public const int Capacity = 3, MaximumTicks = 5;
|
||||
private readonly List<Goroutine> _active = new();
|
||||
private long _nextId;
|
||||
@@ -65,5 +75,7 @@ namespace KernelPanic.Combat
|
||||
return true;
|
||||
}
|
||||
public void Clear() { foreach (var work in _active.ToArray()) Terminate(work); }
|
||||
internal void RestoreActive(IEnumerable<Goroutine> active)
|
||||
{ _active.Clear(); _active.AddRange(active); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace KernelPanic.Combat
|
||||
MultiplierPercent = multiplierPercent;
|
||||
Targets = Array.AsReadOnly(card.TargetSnapshot.ToArray());
|
||||
}
|
||||
internal LazyStackEntry(CardInstance card, int multiplierPercent, IEnumerable<CombatantState> targets)
|
||||
{ Card = card; MultiplierPercent = multiplierPercent; Targets = Array.AsReadOnly(targets.ToArray()); }
|
||||
}
|
||||
|
||||
/// <summary>Top-first immutable snapshots. CombatManager alone executes/disposes cards.</summary>
|
||||
@@ -39,6 +41,9 @@ namespace KernelPanic.Combat
|
||||
_cards.Insert(0, card);
|
||||
}
|
||||
|
||||
internal void RestoreEntries(IEnumerable<LazyStackEntry> entries)
|
||||
{ _entries.Clear(); _cards.Clear(); foreach (var entry in entries) { _entries.Add(entry); _cards.Add(entry.Card); } }
|
||||
|
||||
public void Resolve(CombatContext context) => ForceEvaluate(context);
|
||||
public void ForceEvaluate(CombatContext context) => context?.CombatManager?.EvaluateLazyStack();
|
||||
|
||||
|
||||
@@ -7,6 +7,22 @@ namespace KernelPanic.Combat
|
||||
/// <summary>Wave-local policy state. Commit only after combat validates phase and target.</summary>
|
||||
public sealed class NixGovernorState
|
||||
{
|
||||
// Explicit checkpoint values: no gameplay hooks or random draws during restoration.
|
||||
internal NixGovernorStateValues CaptureValues() => new()
|
||||
{
|
||||
Governor = Governor,
|
||||
Version = Version,
|
||||
FreeSwitchUsed = FreeSwitchUsed,
|
||||
LastSwitchRound = LastSwitchRound,
|
||||
};
|
||||
internal void RestoreValues(NixGovernorStateValues value)
|
||||
{
|
||||
Governor = value.Governor;
|
||||
Version = value.Version;
|
||||
FreeSwitchUsed = value.FreeSwitchUsed;
|
||||
LastSwitchRound = value.LastSwitchRound;
|
||||
}
|
||||
|
||||
public NixGovernor Governor { get; private set; } = NixGovernor.Schedutil;
|
||||
public int Version { get; private set; }
|
||||
public bool Active => Version > 0;
|
||||
|
||||
@@ -91,6 +91,32 @@ namespace KernelPanic.Combat
|
||||
: $"{s.Name}{(s.Name == "async def" ? " / " + s.Payload.Card.Definition.DisplayName : "")}: {s.Remaining} runs remaining"));
|
||||
|
||||
public void Bind(CombatManager combat) => _combat = combat;
|
||||
internal SavedPython CaptureSnapshot(CombatSnapshotWriter writer)
|
||||
{
|
||||
var state = new SavedPython { round = _round, damage = DamageThisPhase, automated = AutomationRan,
|
||||
loops = new List<int>(_loops), areas = new List<int>(_areas) };
|
||||
foreach (var entry in _temporaryDiscounts) state.discounts.Add(new SavedDiscount { card = writer.Card(entry.Key), cost = entry.Value });
|
||||
foreach (var script in _scripts)
|
||||
state.scripts.Add(new SavedScript { name = script.Name, owner = writer.Card(script.Owner), waiting = script.Waiting,
|
||||
restore = script.Restore, firstRound = script.FirstRound, remaining = script.Remaining, uptime = script.Uptime, lastRunRound = script.LastRunRound, hasPayload = script.Payload != null,
|
||||
payload = script.Payload == null ? null : new SavedPayload { card = writer.Card(script.Payload.Card), damage = script.Payload.Damage,
|
||||
shield = script.Payload.Shield, all = script.Payload.All, target = writer.State(script.Payload.Target) } });
|
||||
return state;
|
||||
}
|
||||
internal void RestoreSnapshot(SavedPython state, CombatSnapshotGraph graph)
|
||||
{
|
||||
_choose = null; _afterChoice = null; Choices = Array.Empty<PythonChoiceOption>(); ChoiceTitle = null;
|
||||
_round = state.round; DamageThisPhase = state.damage; AutomationRan = state.automated;
|
||||
_loops.Clear(); _loops.AddRange(state.loops); _areas.Clear(); _areas.AddRange(state.areas);
|
||||
_temporaryDiscounts.Clear();
|
||||
foreach (var entry in state.discounts) _temporaryDiscounts.Add(graph.Cards[entry.card], entry.cost);
|
||||
_scripts.Clear();
|
||||
foreach (var script in state.scripts)
|
||||
_scripts.Add(new Script { Name = script.name, Owner = graph.Cards[script.owner], Waiting = script.waiting,
|
||||
Restore = script.restore, FirstRound = script.firstRound, Remaining = script.remaining, Uptime = script.uptime, LastRunRound = script.lastRunRound,
|
||||
Payload = script.payload == null ? null : new Payload { Card = graph.Cards[script.payload.card], Damage = script.payload.damage,
|
||||
Shield = script.payload.shield, All = script.payload.all, Target = graph.State(script.payload.target) } });
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
ExpireDiscounts();
|
||||
@@ -103,6 +129,12 @@ namespace KernelPanic.Combat
|
||||
foreach (var entry in _temporaryDiscounts) entry.Key.TemporaryCostDelta = entry.Value;
|
||||
_temporaryDiscounts.Clear();
|
||||
}
|
||||
internal void DiscountForTurn(CardInstance card, int amount)
|
||||
{
|
||||
if (amount <= 0) return;
|
||||
if (!_temporaryDiscounts.ContainsKey(card)) _temporaryDiscounts[card] = card.TemporaryCostDelta;
|
||||
card.TemporaryCostDelta -= amount;
|
||||
}
|
||||
public bool Choose(int index)
|
||||
{
|
||||
if (!HasChoice || index < 0 || index >= Choices.Count || !Choices[index].Enabled) return false;
|
||||
@@ -120,7 +152,7 @@ namespace KernelPanic.Combat
|
||||
if (HasChoice) _afterChoice += action;
|
||||
else action();
|
||||
}
|
||||
private void Offer(string title, IEnumerable<PythonChoiceOption> options, Action<int> choose)
|
||||
internal void Offer(string title, IEnumerable<PythonChoiceOption> options, Action<int> choose)
|
||||
{
|
||||
if (HasChoice) throw new InvalidOperationException("Resolve the current Python choice first.");
|
||||
ChoiceTitle = title; Choices = Array.AsReadOnly(options.ToArray()); _choose = choose;
|
||||
|
||||
@@ -229,6 +229,7 @@ namespace KernelPanic.Core
|
||||
ArchBtwBonusAmount = archBtwBonusAmount;
|
||||
ArchRollingReleaseSaveTriggered = archRollingReleaseSaveTriggered;
|
||||
Cause = null;
|
||||
Breakdown = null;
|
||||
}
|
||||
|
||||
public CombatantState Source { get; }
|
||||
@@ -243,6 +244,10 @@ namespace KernelPanic.Core
|
||||
public bool TrueDamage { get; }
|
||||
public int ArchBtwBonusAmount { get; }
|
||||
public bool ArchRollingReleaseSaveTriggered { get; }
|
||||
public string Breakdown { get; }
|
||||
public DamageDealtEvent WithBreakdown(string breakdown) => new(this, breakdown, true);
|
||||
private DamageDealtEvent(DamageDealtEvent payload, string breakdown, bool observed) : this(payload, payload.Cause)
|
||||
{ Breakdown = breakdown; }
|
||||
public string Cause { get; }
|
||||
public DamageDealtEvent WithCause(string cause) => new(this, cause);
|
||||
|
||||
@@ -252,6 +257,7 @@ namespace KernelPanic.Core
|
||||
payload.TrueDamage, payload.ArchBtwBonusAmount, payload.ArchRollingReleaseSaveTriggered)
|
||||
{
|
||||
Cause = cause;
|
||||
Breakdown = payload.Breakdown;
|
||||
}
|
||||
public bool WasFullyBlocked => IncomingAmount > 0 && UptimeDamage <= 0;
|
||||
public bool WasMitigated => ShieldDamage > 0 || AbsorbedAmount > 0 || WasFullyBlocked;
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace KernelPanic.Data
|
||||
private static readonly LanguageCatalogEntry[] Entries =
|
||||
{
|
||||
new(Language.C, "C", "bare metal", ResolutionTrack.Native, $"C is immediate, high-risk burst damage. C damage rolls a {CombatTuning.CCriticalChancePercent}% crit chance instead of the normal 25%, spills {CombatTuning.COverkillSpillPercent}% of remaining overkill into other enemies per jump (rounded down), and C cards can segfault: hurting you and corrupting a hand card. Segfault corruption recovers automatically after 3 rounds. C repair cards restore corrupted cards sooner.", null, Distro("arch", "Arch"), Distro("gentoo", "Gentoo"), Distro("templeos", "TempleOS")),
|
||||
new(Language.CPlusPlus, "C++", "compiled evolution", ResolutionTrack.Native, "Upgraded C cards: stronger immediate attacks, full overkill spill, the same elevated critical chance, and no segfault recoil. Chain C++ cards for pointer's combo. sizeof counts both C and C++ cards in hand.", "unlock: clear all 10 campaign waves with C selected"),
|
||||
new(Language.CPlusPlus, "C++", "compiled evolution", ResolutionTrack.Native, "Upgraded C cards: the same base attack damage, full overkill spill, the same elevated critical chance, and no segfault recoil. Chain C++ cards for pointer's combo. sizeof counts both C and C++ cards in hand.", "unlock: clear all 10 campaign waves with C selected"),
|
||||
new(Language.Rust, "Rust", "safe systems", ResolutionTrack.Native, "Rust is immediate, reliable damage with defensive payoff. Rust overkill becomes Shield, and Rust damage has a tiny 0.001% chance to overflow into the unsigned 64-bit limit.", null, Distro("arch", "Arch"), Distro("fedora", "Fedora")),
|
||||
new(Language.Python, "Python", "pipelines and automation", ResolutionTrack.InterpreterQueue, "Preparation acts immediately. Payloads and modifiers resolve FIFO before enemies: for loop repeats the next payload, zip spreads a single-target payload to all enemies. Unused modifiers expire after the following round. Two automation slots run captured operations for two future rounds. Replays copy damage and Shield only, never draw, growth or installation. Scripts and modifiers clear each wave.", null, Distro("ubuntu", "Ubuntu"), Distro("kali", "Kali"), Distro("mint", "Mint")),
|
||||
new(Language.JavaScript, "JavaScript", "runtime chaos", ResolutionTrack.Native, "JavaScript resolves immediately and is intentionally swingy: wide damage ranges, chance-based outcomes, and conditional repeat effects. It rewards embracing variance.", null, Distro("ubuntu", "Ubuntu"), Distro("endeavouros", "EndeavourOS"), Distro("mint", "Mint")),
|
||||
new(Language.TypeScript, "TypeScript", "typed evolution", ResolutionTrack.Native, "Upgraded JavaScript cards with fixed damage, guaranteed typeof, and stronger utility. TypeScript damage never rolls critical hits. Current buffs, Shield and enemy defenses still apply.", "unlock: clear all 10 campaign waves with JavaScript selected"),
|
||||
new(Language.TypeScript, "TypeScript", "typed evolution", ResolutionTrack.Native, "Upgraded JavaScript cards with fixed average damage (halves rounded up), guaranteed typeof, and stronger utility. TypeScript damage cannot crit. typeof averages in its failure chance. Current buffs, Shield and enemy defenses still apply.", "unlock: clear all 10 campaign waves with JavaScript selected"),
|
||||
new(Language.Haskell, "Haskell", "lazy proofs", ResolutionTrack.LazyStack, "Lazy proofs. Build a stack of delayed operations. Later cards gain stronger effects when evaluated. Snapshot x1.5 / x1.75 / x2.0 / x2.5 at play; LIFO after Python. Only damage and explicit Shield multiply.", null, Distro("gentoo", "Gentoo"), Distro("nixos", "NixOS")),
|
||||
new(Language.Assembly, "Assembly", "raw opcodes", ResolutionTrack.Native, "Assembly is planned as the most direct Native language: low-level, high-commitment effects that should trade flexibility for extreme precision or shield-bypass pressure.", null, Distro("templeos", "TempleOS")),
|
||||
new(Language.Java, "Java", "warming vm", ResolutionTrack.Native, "Each Java card uses 2 RAM and spills overkill into other enemies. JIT gives -1 Cycle per 2 Java plays, capped at -3. Store at most 6 warmup plays; lose 2 after each wave, cooling the discount by 1.", null, Distro("debian", "Debian"), Distro("fedora", "Fedora")),
|
||||
|
||||
@@ -6,9 +6,21 @@ namespace KernelPanic.Data
|
||||
{
|
||||
public enum PackageSlot
|
||||
{
|
||||
Kernel,
|
||||
Runtime,
|
||||
Daemon
|
||||
// Keep serialized identities stable for existing assets and saves.
|
||||
[InspectorName("System")] Kernel = 0,
|
||||
[InspectorName("Tools")] Runtime = 1,
|
||||
[InspectorName("Services")] Daemon = 2
|
||||
}
|
||||
|
||||
public static class PackageSlotPresentation
|
||||
{
|
||||
public static string DisplayName(this PackageSlot slot) => slot switch
|
||||
{
|
||||
PackageSlot.Kernel => "System",
|
||||
PackageSlot.Runtime => "Tools",
|
||||
PackageSlot.Daemon => "Services",
|
||||
_ => "Unknown"
|
||||
};
|
||||
}
|
||||
|
||||
public enum PackageEffectKind
|
||||
@@ -80,7 +92,7 @@ namespace KernelPanic.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines persistent meta packages equipped into distro Kernel/Runtime/Daemon slots.
|
||||
/// Defines persistent meta packages equipped into System/Tools/Services slots.
|
||||
/// Package loadouts are meta progression and carry into every run for that distro.
|
||||
/// Card loadouts remain run setup only.
|
||||
/// </summary>
|
||||
@@ -89,7 +101,9 @@ namespace KernelPanic.Data
|
||||
[SerializeField] private string id;
|
||||
[SerializeField] private string displayName;
|
||||
[SerializeField] private PackageSlot slot;
|
||||
[SerializeField] private int legacySlot = -1;
|
||||
[SerializeField, Range(1, 5)] private int rarity = 1;
|
||||
[SerializeField, Range(0, KernelPanic.Meta.PackageTuning.MaxPackageLevel)] private int maxUpgradeLevel = 5;
|
||||
[SerializeField, TextArea] private string description;
|
||||
[SerializeField] private string flavourText;
|
||||
[SerializeField, TextArea] private string designNotes;
|
||||
@@ -103,7 +117,10 @@ namespace KernelPanic.Data
|
||||
public string Id => id;
|
||||
public string DisplayName => displayName;
|
||||
public PackageSlot Slot => slot;
|
||||
public bool AcceptsSavedSlot(PackageSlot savedSlot) => savedSlot == slot
|
||||
|| (legacySlot >= 0 && (int)savedSlot == legacySlot);
|
||||
public int Rarity => Mathf.Clamp(rarity, 1, 5);
|
||||
public int MaxUpgradeLevel => Mathf.Clamp(maxUpgradeLevel, 0, KernelPanic.Meta.PackageTuning.MaxPackageLevel);
|
||||
public string Description => description;
|
||||
public string FlavourText => flavourText;
|
||||
public string FlavorText => flavourText;
|
||||
@@ -140,10 +157,13 @@ namespace KernelPanic.Data
|
||||
public PackageInstance(PackageDefinition definition, int upgradeLevel)
|
||||
{
|
||||
Definition = definition;
|
||||
UpgradeLevel = Mathf.Clamp(upgradeLevel, 0, KernelPanic.Meta.PackageTuning.MaxPackageLevel);
|
||||
SavedSlot = definition == null ? default : definition.Slot;
|
||||
UpgradeLevel = Mathf.Clamp(upgradeLevel, 0, definition == null ? 0 : definition.MaxUpgradeLevel);
|
||||
}
|
||||
|
||||
public PackageDefinition Definition { get; }
|
||||
// Preserve the original allocation when resuming pre-taxonomy runs.
|
||||
public PackageSlot SavedSlot { get; set; }
|
||||
public int UpgradeLevel { get; }
|
||||
|
||||
public IEnumerable<PackageEffectData> EffectsFor(string distroId)
|
||||
@@ -170,30 +190,71 @@ namespace KernelPanic.Data
|
||||
return effect;
|
||||
}
|
||||
|
||||
int amount = effect.Amount + GetAmountPerLevel(effect.Kind, effect.Amount) * level;
|
||||
return new PackageEffectData(effect.Kind, amount, effect.Threshold, effect.RefundCycle, effect.CleanseDebuffs, effect.EnableFedoraSecondCardPassive, effect.PersistArchBtw);
|
||||
}
|
||||
|
||||
private static int GetAmountPerLevel(PackageEffectKind kind, int baseAmount)
|
||||
{
|
||||
return kind switch
|
||||
int amount = effect.Amount;
|
||||
int threshold = effect.Threshold;
|
||||
// Counts, trigger intervals, percentages and flags are different units.
|
||||
// Explicit cases prevent new effects from accidentally inheriting +1 to everything.
|
||||
switch (effect.Kind)
|
||||
{
|
||||
PackageEffectKind.MaxUptime => Mathf.Max(1, Mathf.CeilToInt(Mathf.Max(1, baseAmount) * 0.5f)),
|
||||
PackageEffectKind.MaxCycles => 1,
|
||||
PackageEffectKind.MaxRam => 1,
|
||||
PackageEffectKind.WaveDraw => 1,
|
||||
PackageEffectKind.FirstTurnFirstWaveDraw => 1,
|
||||
PackageEffectKind.FirstTurnEachWaveCycle => 1,
|
||||
PackageEffectKind.FirstCardsEachTurnCostReduction => 1,
|
||||
PackageEffectKind.FirstCardEachWaveCostReduction => 1,
|
||||
PackageEffectKind.FirstNativeCardEachWaveFlatDamage => 1,
|
||||
PackageEffectKind.JavaScriptFlatDamage => 1,
|
||||
PackageEffectKind.TurnStartGenerateLanguageCard => 0,
|
||||
PackageEffectKind.PortageWaveStartShield => 2,
|
||||
PackageEffectKind.CompilationAdvancedPreviousRoundCycle => 0,
|
||||
PackageEffectKind.AfterFirstRoundCompilation => 0,
|
||||
_ => 1
|
||||
};
|
||||
case PackageEffectKind.MaxUptime:
|
||||
amount += Mathf.Clamp(Mathf.CeilToInt(effect.Amount * .5f), 1, 2) * level;
|
||||
break;
|
||||
case PackageEffectKind.PortageWaveStartShield:
|
||||
amount += 2 * level;
|
||||
break;
|
||||
case PackageEffectKind.WaveStartShield:
|
||||
case PackageEffectKind.FirstTurnEachWaveShield:
|
||||
case PackageEffectKind.EveryNthTurnShield:
|
||||
case PackageEffectKind.ExhaustShield:
|
||||
case PackageEffectKind.FirstInterpreterQueueCardEachWaveShield:
|
||||
case PackageEffectKind.FirstShieldEachTurnBonus:
|
||||
case PackageEffectKind.StartTurnNoDebuffShield:
|
||||
case PackageEffectKind.FirstCardEachRoundDiscountAndShield:
|
||||
case PackageEffectKind.AfterFirstRoundShield:
|
||||
case PackageEffectKind.FirstNativeCardEachWaveFlatDamage:
|
||||
case PackageEffectKind.JavaScriptFlatDamage:
|
||||
case PackageEffectKind.DnfFedoraPassive:
|
||||
amount += level;
|
||||
break;
|
||||
case PackageEffectKind.MaxCycles:
|
||||
case PackageEffectKind.FirstTurnEachWaveCycle:
|
||||
case PackageEffectKind.EveryNthCardEachWaveCycle:
|
||||
case PackageEffectKind.WaveDraw:
|
||||
case PackageEffectKind.WaveGenerateBasicCard:
|
||||
case PackageEffectKind.ThirdCardEachTurnGenerate:
|
||||
case PackageEffectKind.FirstCardEachWaveCostReduction:
|
||||
amount += Math.Min(level, 1);
|
||||
break;
|
||||
case PackageEffectKind.MaxRam:
|
||||
case PackageEffectKind.FirstTurnFirstWaveDraw:
|
||||
amount += Math.Min(level, 2);
|
||||
break;
|
||||
case PackageEffectKind.EveryNthTurnDraw:
|
||||
threshold = Math.Max(2, threshold - 1);
|
||||
amount += level >= 2 ? 1 : 0;
|
||||
break;
|
||||
case PackageEffectKind.FirstCardsEachTurnCostReduction:
|
||||
// Extend the one-Cycle discount to one more card, never make it six Cycles.
|
||||
threshold += Math.Min(level, 1);
|
||||
break;
|
||||
case PackageEffectKind.EveryNthCardEachWaveFree:
|
||||
threshold = Math.Max(2, threshold - level);
|
||||
break;
|
||||
case PackageEffectKind.FirstCThisTurnDamageMultiplier:
|
||||
amount += 10 * level;
|
||||
break;
|
||||
case PackageEffectKind.WaveThresholdRestore:
|
||||
threshold = Math.Min(75, threshold + 5 * level);
|
||||
break;
|
||||
// AUR's amount is a mode flag. Compilation and its Cycle reward stay fixed.
|
||||
case PackageEffectKind.TurnStartGenerateLanguageCard:
|
||||
case PackageEffectKind.CompilationAdvancedPreviousRoundCycle:
|
||||
case PackageEffectKind.AfterFirstRoundCompilation:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new PackageEffectData(effect.Kind, amount, threshold, effect.RefundCycle, effect.CleanseDebuffs,
|
||||
effect.EnableFedoraSecondCardPassive, effect.PersistArchBtw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ namespace KernelPanic.Meta
|
||||
},
|
||||
"ubuntu" => safeVersion switch
|
||||
{
|
||||
1 => "start of turn: apt update chooses the cheaper of top 2 draw cards",
|
||||
2 => "apt update looks at top 3 instead of top 2",
|
||||
1 => "turn draw: choose one of the top 2 cards with apt update",
|
||||
2 => "apt update lets you choose from the top 3 cards",
|
||||
3 => "ask ubuntu inspects 5 cards instead of 3; take one",
|
||||
4 => "apt update card costs 1 less this turn",
|
||||
4 => "apt update lets you choose from the top 4 cards; chosen card costs 1 less this turn",
|
||||
5 => "once per combat, empty hand refills up to RAM",
|
||||
_ => "--"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KernelPanic.Data;
|
||||
|
||||
namespace KernelPanic.Meta
|
||||
@@ -22,6 +23,7 @@ namespace KernelPanic.Meta
|
||||
private readonly PlayerCollection _collection;
|
||||
private readonly PackageDatabase _database;
|
||||
private readonly Dictionary<string, Dictionary<PackageSlot, string>> _equippedByDistro = new(StringComparer.OrdinalIgnoreCase);
|
||||
public List<string> MigrationNotices { get; } = new();
|
||||
|
||||
public PackageLoadout(PlayerCollection collection, PackageDatabase database)
|
||||
{
|
||||
@@ -137,21 +139,35 @@ namespace KernelPanic.Meta
|
||||
|
||||
Dictionary<PackageSlot, string> equipped = EnsureDistro(distroId);
|
||||
equipped.Clear();
|
||||
foreach (PackageLoadoutSlotSaveEntry slotEntry in slots ?? Array.Empty<PackageLoadoutSlotSaveEntry>())
|
||||
// Keep items already in their category first, then relocate old equipment.
|
||||
// A collision never changes ownership or upgrade levels.
|
||||
foreach (PackageLoadoutSlotSaveEntry slotEntry in (slots ?? Array.Empty<PackageLoadoutSlotSaveEntry>())
|
||||
.Where(s => s != null)
|
||||
.OrderBy(s => _database?.FindById(s.packageId)?.Slot == s.slot ? 0 : 1)
|
||||
.ThenBy(s => s.slot).ThenBy(s => s.packageId, StringComparer.Ordinal))
|
||||
{
|
||||
PackageDefinition package = _database == null ? null : _database.FindById(slotEntry?.packageId);
|
||||
if (package == null || !_collection.IsPackageOwned(package.Id) || package.Slot != slotEntry.slot)
|
||||
if (package == null || !_collection.IsPackageOwned(package.Id) || !package.AcceptsSavedSlot(slotEntry.slot))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (equipped.TryGetValue(package.Slot, out string existing))
|
||||
{
|
||||
if (existing != package.Id)
|
||||
MigrationNotices.Add($"{distroId}: {package.DisplayName} is now in {package.Slot.DisplayName()}. Unequipped because that slot is occupied; ownership and upgrades are retained.");
|
||||
continue;
|
||||
}
|
||||
equipped[package.Slot] = package.Id;
|
||||
if (package.Slot != slotEntry.slot)
|
||||
MigrationNotices.Add($"{distroId}: {package.DisplayName} moved to {package.Slot.DisplayName()}.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_equippedByDistro.Clear();
|
||||
MigrationNotices.Clear();
|
||||
}
|
||||
|
||||
private void AddIfEquipped(string distroId, PackageSlot slot, List<PackageDefinition> packages)
|
||||
|
||||
@@ -1,17 +1,36 @@
|
||||
using System;
|
||||
using KernelPanic.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KernelPanic.Meta
|
||||
{
|
||||
public static class PackageTuning
|
||||
{
|
||||
public const int MaxPackageLevel = 5;
|
||||
// Serialization ceiling; each definition owns its actual upgrade cap.
|
||||
public const int MaxPackageLevel = 8;
|
||||
public const float RefundFraction = 1f;
|
||||
public const float RarityCostMultiplier = 1f;
|
||||
|
||||
private static readonly int[] CachePerRarityValues = { 5, 12, 30, 80, 200 };
|
||||
private static readonly int[] UpgradeCacheCostValues = { 10, 25, 50, 90, 150 };
|
||||
private static readonly int[] UpgradeBandwidthCostValues = { 20, 50, 100, 180, 300 };
|
||||
private static readonly int[] UpgradeCacheCostValues = { 10, 25, 50, 90, 150, 230, 330, 450 };
|
||||
private static readonly int[] UpgradeBandwidthCostValues = { 20, 50, 100, 180, 300, 460, 660, 900 };
|
||||
|
||||
public static void ReconcileUpgradeCaps(SaveData save, PackageDatabase database)
|
||||
{
|
||||
if (save?.ownedPackages == null || database == null) return;
|
||||
foreach (var entry in save.ownedPackages)
|
||||
{
|
||||
var definition = database.FindById(entry?.id);
|
||||
if (definition == null || entry.upgradeLevel <= definition.MaxUpgradeLevel) continue;
|
||||
int previous = entry.upgradeLevel;
|
||||
int current = definition.MaxUpgradeLevel;
|
||||
int cache = GetInvestedCache(previous, definition.Rarity) - GetInvestedCache(current, definition.Rarity);
|
||||
int bandwidth = GetInvestedBandwidth(previous, definition.Rarity) - GetInvestedBandwidth(current, definition.Rarity);
|
||||
save.cacheBalance = (int)Math.Min(int.MaxValue, (long)save.cacheBalance + cache);
|
||||
save.bandwidthBalance = (int)Math.Min(int.MaxValue, (long)save.bandwidthBalance + bandwidth);
|
||||
entry.upgradeLevel = current; // Same save transaction as the refund; safe to retry loading.
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCacheForRarity(int rarity)
|
||||
{
|
||||
|
||||
@@ -36,13 +36,13 @@ namespace KernelPanic.Meta
|
||||
|
||||
public static PackageUpgradeResult TryUpgrade(OwnedPackageInstance packageInstance, SaveData wallet)
|
||||
{
|
||||
if (packageInstance == null || wallet == null)
|
||||
if (packageInstance?.Definition == null || wallet == null)
|
||||
{
|
||||
return new PackageUpgradeResult(false, PackageUpgradeFailureReason.NotOwned, 0, 0, 0);
|
||||
}
|
||||
|
||||
int currentLevel = Math.Max(0, packageInstance.UpgradeLevel);
|
||||
if (currentLevel >= PackageTuning.MaxPackageLevel)
|
||||
if (currentLevel >= packageInstance.MaxUpgradeLevel)
|
||||
{
|
||||
return new PackageUpgradeResult(false, PackageUpgradeFailureReason.MaxLevel, 0, 0, currentLevel);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user