starfleet-ui
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#6 · main · 2 min 01 s
0Étoiles
0Forks
0Issues
| 1 | <script lang="ts"> |
| 2 | import type { TradeRoute } from '$lib/game/trade'; |
| 3 | import { untilLabel } from '$lib/time'; |
| 4 | import Button from '$lib/ui/Button.svelte'; |
| 5 | |
| 6 | interface Props { |
| 7 | routes: TradeRoute[]; |
| 8 | loading: boolean; |
| 9 | known: number; |
| 10 | onShow: (route: TradeRoute) => void; |
| 11 | onRefresh: () => void; |
| 12 | } |
| 13 | |
| 14 | let { routes, loading, known, onShow, onRefresh }: Props = $props(); |
| 15 | |
| 16 | const dur = (s: number) => untilLabel(new Date(Date.now() + s * 1000).toISOString()); |
| 17 | const cr = (n: number) => n.toLocaleString('en-US'); |
| 18 | </script> |
| 19 | |
| 20 | <div class="space-y-2"> |
| 21 | <div class="flex items-center justify-between text-xs text-slate-400"> |
| 22 | <span>From {known} known markets · best profit per minute first</span> |
| 23 | <Button size="sm" variant="ghost" busy={loading} onclick={onRefresh}>Refresh</Button> |
| 24 | </div> |
| 25 | {#each routes as r, i (`${r.good}:${r.from}:${r.to}`)} |
| 26 | <button |
| 27 | onclick={() => onShow(r)} |
| 28 | class="block w-full rounded-lg border border-slate-700/70 bg-slate-950/50 p-3 text-left transition hover:border-cyan-400/50" |
| 29 | > |
| 30 | <div class="flex items-baseline justify-between gap-2"> |
| 31 | <span class="font-mono text-sm"> |
| 32 | <span class="text-slate-500">{i + 1}.</span> |
| 33 | <span class="font-bold text-amber-200">{r.units} {r.good}</span> |
| 34 | </span> |
| 35 | <span class="font-mono text-base font-bold text-emerald-300">+{cr(r.profit)} cr</span> |
| 36 | </div> |
| 37 | <div class="mt-1 font-mono text-xs text-slate-300">{r.from} → {r.to}</div> |
| 38 | <div class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-slate-400"> |
| 39 | <span>~{dur(r.seconds)}</span> |
| 40 | <span>{Math.round(r.profitPerMinute)} cr/min</span> |
| 41 | <span>buy {cr(r.cost)} · sell {cr(r.revenue)}{r.fuelCost ? ` · fuel ${cr(r.fuelCost)}` : ''}</span> |
| 42 | {#if r.loaded.jumps}<span>{r.loaded.jumps} jump{r.loaded.jumps > 1 ? 's' : ''}</span>{/if} |
| 43 | {#if r.loaded.nebula || r.toBuy.nebula}<span class="text-fuchsia-300">nebula: slower</span>{/if} |
| 44 | {#if !r.fuelOk}<span class="text-red-300">fuel short</span>{/if} |
| 45 | {#if r.stale}<span class="text-amber-300">old prices</span>{/if} |
| 46 | </div> |
| 47 | </button> |
| 48 | {:else} |
| 49 | <p class="text-sm text-slate-500 italic"> |
| 50 | {loading ? 'Reading markets…' : 'No profitable run found from the markets we know.'} |
| 51 | </p> |
| 52 | {/each} |
| 53 | <p class="text-[11px] leading-snug text-slate-500"> |
| 54 | Estimates: each unit traded moves the price, and trip times ignore nebulae. Preview a trip before you commit. |
| 55 | </p> |
| 56 | </div> |