'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { homeworldCard } from '@/game/homeworld-cards'; import { HomeworldFace } from './homeworld-cards'; import { Button } from './ui/button'; import { Input } from './ui/input'; type Props = { game: GameView; act: (action: Action) => void; busy: boolean }; type Offer = NonNullable; export function HomeworldOccupiedPercentage({ game, act, busy }: Props) { const offer = game.homeworldOccupiedPercentage; if (!offer) return null; const authorized = game.decision?.kind === 'homeworldOccupiedPercentage' && game.decision.player === game.me && game.decision.event === offer.event && offer.owner === game.me; if (!authorized && !offer.blocked) return null; return ; } function PercentageChoice({ offer, game, act, busy }: Props & { offer: Offer }) { const [ownAmount, setOwnAmount] = useState(offer.maxOwnAmount); const valid = Number.isSafeInteger(ownAmount) && ownAmount >= offer.minOwnAmount && ownAmount <= offer.maxOwnAmount; const source = game.homeworlds?.worlds?.find((world) => world.id === offer.world); const card = source ? homeworldCard(source.card) : undefined; return (

{offer.name} · occupied percentage income

Allocate {offer.amount} spice from the actual completed payment or Collection income. {offer.allyName ? ` Keep it or immediately share any portion with ${offer.allyName}.` : ' You have no reciprocal ally to share with.'}

This is the actual occupied portion, not a printed Bank icon award or a bribe from your personal spice. The printed Homeworld effect cannot be canceled by Karama; ordinary native advantages remain separate.

Development preview · Advanced occupation benefits are retained until your last occupying force leaves. Basic lifecycle and unresolved competing-owner cases remain guarded. Not complete or certified Homeworld rules.

{card && (
Inspect {offer.name} source card
)} {offer.blocked ? {offer.blocked} : (
{ event.preventDefault(); if (!busy && valid) act({ type: 'decision', event: offer.event, ownAmount }); }}> {offer.ally && ( <>
)} {valid ? `Credits: ${offer.ownerName} ${ownAmount}${offer.allyName ? ` · ${offer.allyName} ${offer.amount - ownAmount}` : ''}. Total ${offer.amount}.` : `Keep a whole number from ${offer.minOwnAmount} through ${offer.maxOwnAmount}.`}
)}
); }