| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
export const REACH = 46; |
| 12 |
|
| 13 |
const secs = (n) => Math.max(0, Math.ceil(n)); |
| 14 |
|
| 15 |
export function choosePrompt(snap, world = {}) { |
| 16 |
if (!snap) return ""; |
| 17 |
const me = snap.me; |
| 18 |
const spike = snap.spike; |
| 19 |
const onSite = world.onSite === true; |
| 20 |
const nearSpike = world.nearSpike === true; |
| 21 |
|
| 22 |
|
| 23 |
const buyWith = world.input === "keys" ? "Press b and buy a gun you can afford." : "Click a gun you can afford."; |
| 24 |
|
| 25 |
if (snap.phase === "over") return snap.result ? `Match over — ${snap.result}` : "Match over"; |
| 26 |
if (me.blind > 0.05) return "You are blind — back off until it clears"; |
| 27 |
if (!me.alive) |
| 28 |
return snap.phase === "buy" |
| 29 |
? "Buy phase — you are back next round" |
| 30 |
: "Waiting for the next round — you're in it"; |
| 31 |
if (snap.phase === "end") return snap.result ? `${snap.result} — next round in ${secs(snap.clock)}s` : "Round over"; |
| 32 |
if (snap.phase === "buy") return `Buy phase — ${secs(snap.clock)}s left. ${buyWith}`; |
| 33 |
|
| 34 |
if (me.planting > 0) return `Planting — hold F for ${secs(4 - me.planting)}s more`; |
| 35 |
if (spike.planted) { |
| 36 |
if (me.side === "def") { |
| 37 |
if (spike.defuse > 0) return `Defusing — keep holding F, ${secs(7 - spike.defuse)}s`; |
| 38 |
return nearSpike |
| 39 |
? `Spike down, ${secs(spike.fuse)}s — hold F to defuse` |
| 40 |
: `Spike down, ${secs(spike.fuse)}s — get to it and hold F`; |
| 41 |
} |
| 42 |
return `Spike down, ${secs(spike.fuse)}s — keep them off it`; |
| 43 |
} |
| 44 |
|
| 45 |
if (me.side === "atk") { |
| 46 |
if (me.spike) return onSite ? "Hold F to plant" : "You have the spike — get to site A or B"; |
| 47 |
if (spike.carried) return "Your team has the spike — go with them and take a site"; |
| 48 |
if (nearSpike) return "Walk onto the spike to pick it up"; |
| 49 |
return "Somebody has to carry the spike — it is on the ground"; |
| 50 |
} |
| 51 |
return `Defending — hold A and B, ${secs(snap.clock)}s`; |
| 52 |
} |