Add a bank with loans
Tap the cash chip to open the bank. Lenders make loan offers now and then, and much more often while you are in the red, so a bad hour no longer has to end in bankruptcy. - Eleven lenders with their own rates, terms and odd conditions, from Goldman Sacks (A rating and up) to the Loan Shark (always open, sends "reminders" when you are late). - Conditions are checked daily: 15 days of grace, a warning, then a penalty added to the balance every 30 days while broken. - Credit rating from revenue, profit, cash and payment burden decides which banks will talk to you. - Crypto Bros pay out in a volatile TubeCoin; Venture Vultures take a share of revenue instead of repayments and can be bought out. - Repay early for a 2% fee. Payments show up in costs and the NOC dashboard. Closes #1 Closes #2
This commit is contained in:
parent
d2aebbd507
commit
b52d20e536
3 changed files with 176 additions and 10 deletions
|
|
@ -133,3 +133,40 @@ test('Stuttgart has only the Spätzle-IX: no transit, no PNIs', () => {
|
|||
ev('ACT.start({})');
|
||||
assert.ok(ev("ixMembers('stg').length") > 0, 'networks still peer at the exchange');
|
||||
});
|
||||
|
||||
test('bank: offers arrive, loans pay out, cost money monthly and get paid off', () => {
|
||||
const { ev, errors } = load();
|
||||
seed(ev, 5);
|
||||
ev("ACT.start({});ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1})");
|
||||
ev("S.loanOffers=[];spawnLoanOffer(false)");
|
||||
assert.equal(ev('S.loanOffers.length'), 1);
|
||||
ev("S.loanOffers[0]={id:'x1',bank:'db',amount:100000,exp:S.day+20,covs:['fax'],apr:0.12,term:6,pay:Math.round(annuity(100000,0.12,6))}");
|
||||
const c0 = ev('S.cash');
|
||||
ev("ACT.takeLoan({id:'x1'})");
|
||||
assert.equal(ev('S.cash') - c0 >= 100000 - 1, true, 'cash paid out');
|
||||
assert.ok(ev('R.cost.loans') > 17000, 'monthly payment shows up in costs');
|
||||
for (let d = 0; d < 200; d++) ev('dayTick()');
|
||||
assert.equal(ev("S.loans.filter(l=>l.id==='x1').length"), 0, 'six-month loan is paid off');
|
||||
ev('ACT.bank({})');
|
||||
assert.match(ev("document.getElementById('bankCard').textContent"), /Credit rating/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('bank: broke players get emergency offers, broken conditions cost a penalty', () => {
|
||||
const { ev } = load();
|
||||
seed(ev, 9);
|
||||
ev("ACT.start({});S.cash=-20000");
|
||||
for (let d = 0; d < 20; d++) ev('loanTick(S.day)');
|
||||
assert.ok(ev('S.loanOffers.length') >= 1, 'someone offers money when you are broke');
|
||||
ev("S.cash=500000;S.loans.push({id:'c1',bank:'db',start:S.day-40,amount:100000,bal:100000,apr:0.1,pay:5000,left:24,term:24,share:0,covs:['gen'],base:{sub:0}})");
|
||||
for (let d = 0; d < 10; d++) ev('S.day++;loanTick(S.day)');
|
||||
assert.ok(ev("S.loans.find(l=>l.id==='c1').bal") > 100000, 'penalty added after 10 days of breach');
|
||||
});
|
||||
|
||||
test('bank: the venture vultures take a share of revenue instead of payments', () => {
|
||||
const { ev } = load();
|
||||
ev("ACT.start({});ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});for(let i=0;i<30;i++)dayTick()");
|
||||
ev("S.loanOffers.push({id:'v1',bank:'vult',amount:500000,exp:S.day+20,covs:['blitz'],share:0.1});ACT.takeLoan({id:'v1'})");
|
||||
assert.equal(ev('R.cost.loans'), 0);
|
||||
assert.ok(Math.abs(ev('R.cost.revshare') - ev('R.revMo') * 0.1) < 1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue