Oolite
Loading...
Searching...
No Matches
PlayerEntity(ContractsPrivate) Category Reference

Instance Methods

(OOCreditsQuantity) - tradeInValue
(NSArray *) - contractsListFromArray:forCargo:forParcels:

Detailed Description

Definition at line 52 of file PlayerEntityContracts.m.

Method Documentation

◆ contractsListFromArray:forCargo:forParcels:

- (NSArray *) contractsListFromArray: (NSArray *) contracts_array
forCargo: (BOOL) forCargo
forParcels: (BOOL) forParcels 

Extends class PlayerEntity.

Definition at line 960 of file PlayerEntityContracts.m.

960 :(NSArray*)contracts_array forCargo:(BOOL)forCargo forParcels:(BOOL)forParcels
961{
962 // check contracts
963 NSMutableArray* result = [NSMutableArray arrayWithCapacity:5];
964 NSString* formatString = (forCargo || forParcels) ? @"oolite-manifest-item-delivery" : @"oolite-manifest-person-travelling";
965 unsigned i;
966 for (i = 0; i < [contracts_array count]; i++) {
967 NSDictionary* contract_info = (NSDictionary*)[contracts_array objectAtIndex:i];
968 NSString* label = [contract_info oo_stringForKey:forCargo ? CARGO_KEY_DESCRIPTION : PASSENGER_KEY_NAME];
969 // the system name can change via script. The following PASSENGER_KEYs are identical to the corresponding CONTRACT_KEYs
970 NSString* destination = [UNIVERSE getSystemName:[contract_info oo_intForKey:CONTRACT_KEY_DESTINATION]];
971 int dest_eta = [contract_info oo_doubleForKey:CONTRACT_KEY_ARRIVAL_TIME] - ship_clock;
972 NSString* deadline = [UNIVERSE shortTimeDescription:dest_eta];
973
974 OOCreditsQuantity fee = [contract_info oo_intForKey:CONTRACT_KEY_FEE];
975 NSString* feeDesc = OOIntCredits(fee);
976
977 [result addObject:OOExpandKey(formatString, label, destination, deadline, feeDesc)];
978 }
979
980 return result;
981}
OOINLINE NSString * OOIntCredits(OOCreditsQuantity integerCredits)
uint64_t OOCreditsQuantity
Definition OOTypes.h:160

References OOIntCredits().

Referenced by PlayerEntity(Contracts)::contractList, PlayerEntity(Contracts)::parcelList, and PlayerEntity(Contracts)::passengerList.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tradeInValue

- (OOCreditsQuantity) tradeInValue

Extends class PlayerEntity.

Definition at line 1490 of file PlayerEntityContracts.m.

1491{
1492 // returns down to ship_trade_in_factor% of the full credit value of your ship
1493
1494 /* FIXME: the trade-in value can be more than the sale value, and
1495 ship_trade_in_factor starts at 100%, so it can be profitable to sit
1496 and buy the same ship over and over again. This bug predates Oolite
1497 1.65.
1498 Partial fix: make effective trade-in value 75% * ship_trade_in_factor%
1499 of the "raw" trade-in value. This still allows profitability! A better
1500 solution would be to unify the price calculation for trade-in and
1501 for-sale ships.
1502 -- Ahruman 20070707, fix applied 20070708
1503 */
1504 unsigned long long value = [UNIVERSE tradeInValueForCommanderDictionary:[self commanderDataDictionary]];
1505 value -= value * 0.006 * [self missingSubEntitiesAdjustment]; // TODO: 0.006 might need rethinking.
1506 value = cunningFee(((value * 75 * ship_trade_in_factor) + 5000) / 10000, 0.005); // Multiply by two percentages, divide by 100*100. The +5000 is to get normal rounding.
1507 return value * 10;
1508}
return self
double cunningFee(double value, double precision)

References PlayerEntity::commanderDataDictionary, cunningFee(), PlayerEntity::missingSubEntitiesAdjustment, and tradeInValue.

Referenced by PlayerEntity(Contracts)::buySelectedShip, PlayerEntity(Contracts)::showTradeInInformationFooter, and tradeInValue.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following file: