Keep Guild routes selectable before scheduled boarding
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m6s
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m6s
This commit is contained in:
parent
e5845b120c
commit
633cb376e9
2 changed files with 22 additions and 2 deletions
|
|
@ -57,7 +57,7 @@ export function createGuildService(bank,{authority,resolve,allowArrakis=async()=
|
|||
const ready=await readyForTravel(user,uuid),open=[],catalog=[];
|
||||
for(const world of TRADE_WORLDS){
|
||||
const t=await tariff(user,uuid,world.id,bank),journey=await allowJourney(sourceWorld,world.id,bank,false),source=ready&&journey&&t.fareMinor>0?await funds(bank,user,t.fareMinor):null;
|
||||
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':tradeWorld(sourceWorld)!=='lobby'?'Board ordinary passages from the Guild Lobby.':!journey?'The Spacing Guild has embargoed this route.':!boardingOpen(clock())?'Boarding opens at :00, :20 and :40 for five minutes.':t.fareMinor>0&&!source?'Not enough available Dunemarks.':'';
|
||||
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':tradeWorld(sourceWorld)!=='lobby'?'Board ordinary passages from the Guild Lobby.':!journey?'The Spacing Guild has embargoed this route.':t.fareMinor>0&&!source?'Not enough available Dunemarks.':'';
|
||||
if(!reason)open.push(world.id);
|
||||
catalog.push({server:world.id,name:world.name,available:!reason,reason,fareMinor:t.fareMinor,free:t.free,...(t.free?{freeReason:t.reason}:{bountyMinor:t.bountyMinor,reduced:t.reduced,trip:t.trip})});
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ export function createGuildService(bank,{authority,resolve,allowArrakis=async()=
|
|||
await expire();const user=await resolve(uuid);if(!user||!routes[user.faction])fail('Link your active website account and choose your House first.',403);
|
||||
const ready=await readyForTravel(user,uuid),{price,offer}=await quotedFare(user),source=ready?await funds(bank,user,price):null,open=[],catalog=[];
|
||||
for(const world of TRADE_WORLDS){const lawful=await allowed(user,world.id),journey=lawful&&await allowJourney(sourceWorld,world.id,bank,false);if(ready&&journey)open.push(world.id);
|
||||
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':!lawful?'Your House has no Imperial passage for this destination.':!journey?'The Spacing Guild has embargoed this route.':!boardingOpen(clock())?'Boarding opens at :00, :20 and :40 for five minutes.':!source?'Not enough available Dunemarks.':'';
|
||||
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':!lawful?'Your House has no Imperial passage for this destination.':!journey?'The Spacing Guild has embargoed this route.':!source?'Not enough available Dunemarks.':'';
|
||||
catalog.push({server:world.id,name:world.name,available:!reason,reason,fareMinor:price});
|
||||
}
|
||||
return {ok:true,destination:routes[user.faction],destinations:[...new Set([routes[user.faction],...open])].filter(w=>open.includes(w)),routes:catalog,fareMinor:price,...(offer?{subsidyMinor:offer.amount}:{}),affordable:!!source,account:source?.account_number||null,...(!ready?{prologueRequired:true}:{})};
|
||||
|
|
|
|||
|
|
@ -180,3 +180,23 @@ test('concurrent native reports cannot post the same bounty twice',async()=>{
|
|||
assert.equal((await f.db.first("SELECT COUNT(*) n FROM pb_orders WHERE memo LIKE 'Travel bounty%'")).n,1);
|
||||
}finally{f.db.close();}
|
||||
});
|
||||
|
||||
test('all five worlds can be picked before departure, but boarding stays timed and paid fares still rise',async()=>{
|
||||
const f=await fixture();try{
|
||||
const open=(await f.service.quote(f.traveller.uuid,'lobby')).destinations;
|
||||
assert.equal(open.length,5);
|
||||
for(let minute=0;minute<60;minute++){
|
||||
f.setTime(minute*60000);
|
||||
const quote=await f.service.quote(f.traveller.uuid,'lobby');
|
||||
assert.deepEqual(quote.destinations,open);
|
||||
assert(quote.routes.every(route=>route.available));
|
||||
}
|
||||
f.setTime(19*60000);
|
||||
await assert.rejects(f.service.board(f.input('giedi_prime',15000)),/Boarding opens/);
|
||||
f.setTime(20*60000);
|
||||
await f.service.board(f.input('giedi_prime',15000));
|
||||
await f.service.arrive(f.traveller.uuid,'giedi_prime');
|
||||
f.setTime(25*60000);
|
||||
assert.equal((await f.route('giedi_prime')).fareMinor,16500);
|
||||
}finally{f.db.close();}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff