Call the bank: ask for a loan from the Bank window

With a rating of A or better, five amount buttons in the Bank window make an
immediate offer. The terms follow from the rating alone (bank, APR, conditions
and limit in CALL_TERMS), so calling again gets nothing better and rolls no
dice. The limit is a multiple of monthly revenue less current debt. An offer
goes through the existing card and takeLoan, and a new call replaces an earlier
called offer.

Fixes #251
This commit is contained in:
Christopher Hawker 2026-11-04 23:40:46 +11:00
parent ac5ce7fa05
commit ae70e8e750
13 changed files with 194 additions and 2 deletions

View file

@ -39,6 +39,7 @@ const API_DOMAINS={
opsTplKey:{kind:'enum',values:()=>OPS_TPL.slice()},
// The specialist's offers: a seat on a consortium cable, the charter, a vendor demo.
seatPairs:{kind:'enum',values:()=>SEAT_N.slice()},
callAmount:{kind:'enum',values:()=>CALL_AMTS.slice()},
charterKey:{table:'CHARTERS',kind:'key'},
// The link metric editor: a factor or an exact weight (metricMode, metricSet).
metricKind:{kind:'enum',values:['f','w']},

View file

@ -240,6 +240,8 @@ const API_CMD={
/* ---------- money ---------- */
takeLoan:{args:[['id','entityId']],
doc:'Accept a loan offer. Terms vary wildly by bank; the crypto one pays out 55-135% of face value. Equity banks take a share of the company.'},
callBank:{args:[['amount','callAmount']],watch:['loanOffers'],
doc:'Call a bank for a loan offer of this size, with a credit rating of A or better. The terms follow from the rating, and the amount must fit the limit of a few months of revenue less current debt. Nothing is borrowed until you take the offer.'},
declineLoan:{args:[['id','entityId']],
doc:'Throw a loan offer away.'},
repayLoan:{args:[['id','entityId']],confirm:'double',

View file

@ -78,6 +78,16 @@ function spawnLoanOffer(emergency){
S.loanOffers.push(o);
toast(tr('banks.bank_would_like_to_lend_you',{bank:esc(B.name),amount:fmt$(amount)})+'<br>'+(emergency?tr('banks.they_heard_you_might_be_in'):tr('banks.terms_apply_several_terms')),emergency?'bad':'goal',[{l:tr('common.open_bank'),act:'bank',args:{}}]);
}
/* Good credit can pick up the phone (#251). The terms follow from the rating alone, so calling again gets nothing better and
rolls no dice. What you owe already uses up the limit, and the limit replaces the revenue share of a BIG_LOAN. */
const CALL_AMTS=[1e5,5e5,1e6,5e6,1e7],CALL_MONTHS=36;
const CALL_TERMS={A:{bank:'jpm',apr:.09,x:4,covs:['uptime','logo']},AA:{bank:'gs',apr:.075,x:6,covs:['golf','continents2']},AAA:{bank:'gs',apr:.06,x:8,covs:['golf']}};
const loanDebt=()=>S.loans.reduce((a,l)=>a+(BANKS[l.bank].equity?0:l.bal),0);
const callLimit=T=>Math.max(0,(R.revMo||0)*T.x-loanDebt());
// The new offer replaces an earlier called one; offers that came by themselves stay.
function callOffer(amount){const T=CALL_TERMS[rating()];if(!T||!CALL_AMTS.includes(amount)||S.cash>=RICH_NO_LOANS||amount>callLimit(T))return null;
const o={id:uid(),bank:T.bank,amount,exp:S.day+25,covs:T.covs.slice(),apr:T.apr,term:CALL_MONTHS,pay:Math.round(annuity(amount,T.apr,CALL_MONTHS)),call:1};
S.loanOffers=S.loanOffers.filter(x=>!x.call);S.loanOffers.push(o);return o;}
// Best Effort has no game over: deep in the red, the Ministry of Tubes lends what it takes to be back in the black,
// cheap, over five years, no conditions. The repayments are still yours.
const RESCUE_APR=0.02,RESCUE_TERM=60;

View file

@ -15,6 +15,7 @@ const ACT={
S.cash+=got;S.loanOffers=S.loanOffers.filter(x=>x!==o);
S.loans.push({id:o.id,bank:o.bank,start:S.day,amount:o.amount,got,bal:o.model==='transit'?o.owe:o.amount,apr:o.apr||0,apr0:o.apr||0,pay:o.pay||0,left:o.term||0,term:o.term||0,share:o.share||0,model:o.model,cut:o.cut,covs:o.covs,base:{sub:S.links.filter(x=>x.sub).length}});
track('loan_taken');toast(`<b>${tr('interface.amt_from_bank_has_landed',{amt:fmt$(got),bank:esc(B.name)})}</b><br>${B.equity?tr('interface.they_now_own_p_of_your',{p:pct(o.share)}):loanSummary(o)}${note}`,'good');sfx('coin');after();renderBank();},
callBank:({amount})=>{if(!callOffer(amount))return;track('loan_called');sfx('click');renderBank();renderHUD();save();},
declineLoan:({id})=>{S.loanOffers=S.loanOffers.filter(x=>x.id!==id);sfx('click');renderBank();renderHUD();save();},
repayLoan:({id})=>{const l=S.loans.find(x=>x.id===id);if(!l)return;const B=BANKS[l.bank];const cost=repayCost(l,B);
if(UI.confirm!==id){UI.confirm=id;renderBank();return;}UI.confirm=null;if(!spend(cost)){renderBank();return;}S.loans=S.loans.filter(x=>x!==l);track('loan_repaid');

View file

@ -15,8 +15,11 @@ function renderBank(){
<div class="dgrid"><div class="tile"><div class="lbl">${tr('common.cash')}</div><div class="val" style="color:${S.cash<0?'var(--bad)':'inherit'}">${fmt$(S.cash)}</div><div class="sub">${S.cash<0?tr('bank.bankrupt_at_100k'):tr('bank.in_the_vault')}</div></div>
<div class="tile"><div class="lbl">${tr('dashboard.monthly_p_l')}</div><div class="val" style="color:${net>=0?'var(--eye)':'var(--bad)'}">${net>=0?'+':''}${fmt$(net)}</div><div class="sub">${tr('bank.after_loan_payments')}</div></div>
<div class="tile"><div class="lbl">${tr('common.credit_rating')}</div><div class="val">${rt}</div><div class="sub">${rIdx(rt)>=5?tr('bank.bankers_return_your_calls'):rIdx(rt)>=3?tr('bank.bankers_return_your_emails'):tr('bank.bankers_pretend_to_be_out')}</div></div>
<div class="tile"><div class="lbl">${tr('common.debt')}</div><div class="val">${fmt$(S.loans.reduce((a,l)=>a+(BANKS[l.bank].equity?0:l.bal),0))}</div><div class="sub">${trn('bank.n_loan',S.loans.length)}</div></div></div>`;
h+=`<h3 style="font-size:18px;margin-top:6px">${tr('common.offers')}</h3>`;
<div class="tile"><div class="lbl">${tr('common.debt')}</div><div class="val">${fmt$(loanDebt())}</div><div class="sub">${trn('bank.n_loan',S.loans.length)}</div></div></div>`;
const CT=CALL_TERMS[rt];
if(S.cash<RICH_NO_LOANS){const lim=CT?callLimit(CT):0;h+=`<h3 style="font-size:18px;margin-top:6px">${tr('bank.call_the_bank')}</h3>`;
h+=CT?`<div class="meta">${tr('bank.bank_picks_up_apr_apr_over',{bank:esc(BANKS[CT.bank].name),apr:(CT.apr*100).toFixed(1),n:CALL_MONTHS,limit:fmt$(lim)})}</div><div class="btns" style="margin-top:6px">${CALL_AMTS.map(a=>btn(fmt$(a),'callBank',{amount:a},'sm',a>lim)).join('')}</div>`:`<p class="empty">${tr('bank.get_to_an_a_rating_and')}</p>`;}
h+=`<h3 style="font-size:18px;margin-top:14px">${tr('common.offers')}</h3>`;
if(!S.loanOffers.length)h+=`<p class="empty">${tr('bank.no_offers_right_now_banks_get')}</p>`;
for(const o of S.loanOffers){const B=BANKS[o.bank];h+=`<div class="loan"><span class="logo" style="--c:${B.col}">${initials(B)}</span><div class="grow"><div class="nm">${tr('bank.bank_offers_amount',{bank:esc(B.name),amount:fmt$(o.amount)})}</div><div class="meta">${esc(B.blurb)} · ${tr('bank.offer_ends_in_n_d',{n:o.exp-S.day})}</div><div class="terms">${terms(o)}</div>${covList({covs:o.covs,start:S.day,base:{sub:S.links.filter(x=>x.sub).length}})}<div class="btns" style="margin-top:6px">${btn(tr('bank.take_the_money'),'takeLoan',{id:o.id},'pink')}${btn(tr('common.no_thanks'),'declineLoan',{id:o.id},'ghost sm')}</div></div></div>`;}
h+=`<h3 style="font-size:18px;margin-top:14px">${tr('common.your_loans')}</h3>`;

View file

@ -245,14 +245,17 @@
"bank.after_loan_payments":"after loan payments",
"bank.apr_apr":"{apr}% APR",
"bank.bank_offers_amount":"{bank} offers <b>{amount}</b>",
"bank.bank_picks_up_apr_apr_over":"{bank} picks up: {apr}% APR over {n} months, and up to {limit} more on your tab. You see the offer before you take it.",
"bank.bankers_pretend_to_be_out":"Bankers pretend to be out",
"bank.bankers_return_your_calls":"Bankers return your calls",
"bank.bankers_return_your_emails":"Bankers return your emails",
"bank.bankrupt_at_100k":"Bankrupt at −$100k",
"bank.buy_out_price":"Buy-out {price}",
"bank.buy_them_out_price":"Buy them out <small>{price}</small>",
"bank.call_the_bank":"Call the bank",
"bank.condition_broken_for_n_day":{"one":"Condition broken for {n} day.","other":"Condition broken for {n} days."},
"bank.debt_free_your_accountant_is":"Debt-free. Your accountant is suspicious.",
"bank.get_to_an_a_rating_and":"Get to an A rating and bankers will take your call. Right now they are in a meeting.",
"bank.in_the_vault":"in the vault",
"bank.n_loan":{"one":"{n} loan","other":"{n} loans"},
"bank.n_months":"{n} months",