Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
PlayerEntity(ContractsPrivate) Category Reference

Instance Methods

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

Detailed Description

Definition at line 53 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 1998 of file PlayerEntityContracts.m.

1101 :(NSArray *) contracts_array forCargo:(BOOL) forCargo forParcels:(BOOL)forParcels
1102{
1103 // check contracts
1104 NSMutableArray *result = [NSMutableArray arrayWithCapacity:5];
1105 NSString *formatString = (forCargo||forParcels) ? @"oolite-manifest-item-delivery" : @"oolite-manifest-person-travelling";
1106 unsigned i;
1107 for (i = 0; i < [contracts_array count]; i++)
1108 {
1109 NSDictionary* contract_info = (NSDictionary *)[contracts_array objectAtIndex:i];
1110 NSString* label = [contract_info oo_stringForKey:forCargo ? CARGO_KEY_DESCRIPTION : PASSENGER_KEY_NAME];
1111 // the system name can change via script. The following PASSENGER_KEYs are identical to the corresponding CONTRACT_KEYs
1112 NSString* destination = [UNIVERSE getSystemName: [contract_info oo_intForKey:CONTRACT_KEY_DESTINATION]];
1113 int dest_eta = [contract_info oo_doubleForKey:CONTRACT_KEY_ARRIVAL_TIME] - ship_clock;
1114 NSString *deadline = [UNIVERSE shortTimeDescription:dest_eta];
1115
1116 OOCreditsQuantity fee = [contract_info oo_intForKey:CONTRACT_KEY_FEE];
1117 NSString *feeDesc = OOIntCredits(fee);
1118
1119 [result addObject:OOExpandKey(formatString, label, destination, deadline, feeDesc)];
1120
1121 }
1122
1123 return result;
1124}
OOINLINE NSString * OOIntCredits(OOCreditsQuantity integerCredits)
uint64_t OOCreditsQuantity
Definition OOTypes.h:182

◆ tradeInValue

- (OOCreditsQuantity) tradeInValue

Extends class PlayerEntity.

Definition at line 1443 of file PlayerEntityContracts.m.

1706{
1707 // returns down to ship_trade_in_factor% of the full credit value of your ship
1708
1709 /* FIXME: the trade-in value can be more than the sale value, and
1710 ship_trade_in_factor starts at 100%, so it can be profitable to sit
1711 and buy the same ship over and over again. This bug predates Oolite
1712 1.65.
1713 Partial fix: make effective trade-in value 75% * ship_trade_in_factor%
1714 of the "raw" trade-in value. This still allows profitability! A better
1715 solution would be to unify the price calculation for trade-in and
1716 for-sale ships.
1717 -- Ahruman 20070707, fix applied 20070708
1718 */
1719 unsigned long long value = [UNIVERSE tradeInValueForCommanderDictionary:[self commanderDataDictionary]];
1720 value -= value * 0.006 * [self missingSubEntitiesAdjustment]; // TODO: 0.006 might need rethinking.
1721 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.
1722 return value * 10;
1723}
return self
double cunningFee(double value, double precision)

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