Example #1
0
File: land.c Project: mchelen/naev
static int commodity_canSell( char *name )
{
   int failure;

   failure = 0;

   if (pilot_cargoOwned( player.p, name ) == 0) {
      land_errDialogueBuild("You can't sell something you don't have!");
      failure = 1;
   }

   return !failure;
}
Example #2
0
/**
 * @brief Makes sure it's sane to buy a ship, trading the old one in simultaneously.
 *    @param shipname Ship being bought.
 */
int shipyard_canTrade( char* shipname )
{
    int failure = 0;
    Ship* ship;
    ship = ship_get( shipname );

    /* Must have the necessary license, enough credits, and be able to swap ships. */
    if (!player_hasLicense(ship->license)) {
        land_errDialogueBuild( "You lack the %s.", ship->license );
        failure = 1;
    }
    if (!player_hasCredits( ship->price - player_shipPrice(player.p->name))) {
        credits_t creditdifference = ship->price - (player_shipPrice(player.p->name) + player.p->credits);
        char buf[ECON_CRED_STRLEN];
        credits2str( buf, creditdifference, 2 );
        land_errDialogueBuild( "You need %s more credits.", buf);
        failure = 1;
    }
    if (!can_swap( shipname ))
        failure = 1;
    return !failure;
}
Example #3
0
/**
 * @brief Makes sure it's sane to buy a ship.
 *    @param shipname Ship being bought.
 */
int shipyard_canBuy ( char *shipname, Planet *planet )
{
   Ship* ship;
   ship = ship_get( shipname );
   int failure = 0;
   credits_t price;

   price = ship_buyPrice(ship);

   /* Must have enough credits and the necessary license. */
   if ((!player_hasLicense(ship->license)) &&
         ((planet == NULL) || (!planet_isBlackMarket(planet)))) {
      land_errDialogueBuild( "You lack the %s.", ship->license );
      failure = 1;
   }
   if (!player_hasCredits( price )) {
      char buf[ECON_CRED_STRLEN];
      credits2str( buf, price - player.p->credits, 2 );
      land_errDialogueBuild( "You need %s more credits.", buf);
      failure = 1;
   }
   return !failure;
}
Example #4
0
static int commodity_canBuy( char *name )
{
   int failure;
   unsigned int q, price;
   Commodity *com;
   char buf[ECON_CRED_STRLEN];

   failure = 0;
   q = commodity_getMod();
   com = commodity_get( name );
   price = planet_commodityPrice( land_planet, com ) * q;

   if (!player_hasCredits( price )) {
      credits2str( buf, price - player.p->credits, 2 );
      land_errDialogueBuild("You need %s more credits.", buf );
      failure = 1;
   }
   if (pilot_cargoFree(player.p) <= 0) {
      land_errDialogueBuild("No cargo space available!");
      failure = 1;
   }

   return !failure;
}