Exemple #1
0
END_TURN enter_location(PLAYER *player, LOCATION *location) {
    
    END_TURN end_turn = YES;
    display_player_profile(player);
    display_location_actions_menu(location);
    
    char choice = '\0';
    char *valid_choices = VALID_LOCATION_ACTIONS;
    
    while (!strpbrk(valid_choices, &choice)) {
        choice = getchar();
        choice = toupper(choice);
    }
    
    switch (choice) {
        case 'A':
            end_turn = buy_goods(player, location, LUMBER);
            break;
        case 'B':
            end_turn = buy_goods(player, location, STONE);
            break;
        case 'C':
            end_turn = buy_goods(player, location, SILK);
            break;
        case 'D':
            end_turn = buy_goods(player, location, ORE);
            break;
        case 'E':
            end_turn = buy_goods(player, location, GEM);
            break;
        case 'F':
            end_turn = sell_goods(player, location, LUMBER);
            break;
        case 'G':
            end_turn = sell_goods(player, location, STONE);
            break;
        case 'H':
            end_turn = sell_goods(player, location, SILK);
            break;
        case 'I':
            end_turn = sell_goods(player, location, ORE);
            break;
        case 'J':
            end_turn = sell_goods(player, location, GEM);
            break;
        case 'M':
            end_turn = NO;
            break;
    }
    pickpocket_attempt(player);
    return end_turn;
}
Exemple #2
0
//--------- Begin of function FirmMarket::next_day ---------//
//
void FirmMarket::next_day()
{
	//----- call next_day() of the base class -----//

	Firm::next_day();

	//---- update trade link to harbors to towns -----//

	update_trade_link();

	//-------- input goods ----------//

	if( info.game_date%PROCESS_GOODS_INTERVAL == firm_recno%PROCESS_GOODS_INTERVAL )
	{
		input_goods(50);								// input maximum 50 qty of goods per day
		set_next_output_firm();						// set next output firm
	}

	//-------- sell goods --------//

	sell_goods();

	//------- free up unused slots -------//

	//### begin alex 24/10 ###//
	//if( info.game_date%30 == firm_recno%30 )
	//	free_unused_slot();
	//#### end alex 24/10 ####//
}
/* Trade with a transport.
 * Port is at x/y, transport at u/v. */
static void
trade_connection( const int x, const int y, const int u, const int v, int* ic_ptr, int* et_ptr )
{
  if (u >= 0 && v>=0 && (MP_INFO( u, v).flags
              & FLAG_IS_TRANSPORT) != 0)
  {
      //printf("Port %i/%i trading with transport %i/%i\n", x,y,u,v);
      int i, flags;
      int ic = 0;
      int et = 0;
      flags = MP_INFO(x,y).flags;
      if ((flags & FLAG_MB_FOOD) != 0)
      {
          i = buy_food ( u, v);
          ic += i;
          MP_INFO(x + 1,y).int_3 += i;
      }
      if ((flags & FLAG_MS_FOOD) != 0)
      {
          i = sell_food ( u, v);
          et += i;
          MP_INFO(x + 2,y).int_3 += i;
      }
      if ((flags & FLAG_MB_COAL) != 0)
      {
          i = buy_coal ( u, v);
          ic += i;
          MP_INFO(x + 1,y).int_4 += i;
      }
      if ((flags & FLAG_MS_COAL) != 0)
      {
          i = sell_coal ( u, v);
          et += i;
          MP_INFO(x + 2,y).int_4 += i;
      }
      if ((flags & FLAG_MB_ORE) != 0)
      {
          i = buy_ore ( u, v);
          ic += i;
          MP_INFO(x + 1,y).int_5 += i;
      }
      if ((flags & FLAG_MS_ORE) != 0)
      {
          i = sell_ore ( u, v);
          et += i;
          MP_INFO(x + 2,y).int_5 += i;
      }
      if ((flags & FLAG_MB_GOODS) != 0)
      {
          i = buy_goods ( u, v);
          ic += i;
          MP_INFO(x + 1,y).int_6 += i;
      }
      if ((flags & FLAG_MS_GOODS) != 0)
      {
          i = sell_goods ( u, v);
          et += i;
          MP_INFO(x + 2,y).int_6 += i;
      }
      if ((flags & FLAG_MB_STEEL) != 0)
      {
          i = buy_steel ( u, v);
          ic += i;
          MP_INFO(x + 1,y).int_7 += i;
      }
      if ((flags & FLAG_MS_STEEL) != 0)
      {
          i = sell_steel ( u, v);
          et += i;
          MP_INFO(x + 2,y).int_7 += i;
      }
      *ic_ptr += ic;
      *et_ptr += et;
  }
}
void
do_port (int x, int y)
{
  /*
     // int_1 is the money made so far this month
     // int_2 is the money made last month
     // int_3 holds the 'pence/pennies/bits' to add next time round.
     // int_4 is the import costs so far this month
     // int_5 is the import costs for last month
     // Use int_3 to int_7 of (x+1,y) to hold the individual buy values
     //                       (x,y+1) is last month's
     // Use int_3 to int_7 of (x+2,y) to hold the individual sell values
     //                       (x,y+2) is last month's
   */
  int i, et = 0, ic = 0, flags, *b1, *b2, *s1, *s2;
  /* left connection first */
  flags = MP_INFO(x,y).flags;
  if (x > 0 && (MP_INFO(x - 1,y).flags
		& FLAG_IS_TRANSPORT) != 0)
    {
      if ((flags & FLAG_MB_FOOD) != 0)
	{
	  i = buy_food (x - 1, y);
	  ic += i;
	  MP_INFO(x + 1,y).int_3 += i;
	}
      if ((flags & FLAG_MS_FOOD) != 0)
	{
	  i = sell_food (x - 1, y);
	  et += i;
	  MP_INFO(x + 2,y).int_3 += i;
	}
      if ((flags & FLAG_MB_COAL) != 0)
	{
	  i = buy_coal (x - 1, y);
	  ic += i;
	  MP_INFO(x + 1,y).int_4 += i;
	}
      if ((flags & FLAG_MS_COAL) != 0)
	{
	  i = sell_coal (x - 1, y);
	  et += i;
	  MP_INFO(x + 2,y).int_4 += i;
	}
      if ((flags & FLAG_MB_ORE) != 0)
	{
	  i = buy_ore (x - 1, y);
	  ic += i;
	  MP_INFO(x + 1,y).int_5 += i;
	}
      if ((flags & FLAG_MS_ORE) != 0)
	{
	  i = sell_ore (x - 1, y);
	  et += i;
	  MP_INFO(x + 2,y).int_5 += i;
	}
      if ((flags & FLAG_MB_GOODS) != 0)
	{
	  i = buy_goods (x - 1, y);
	  ic += i;
	  MP_INFO(x + 1,y).int_6 += i;
	}
      if ((flags & FLAG_MS_GOODS) != 0)
	{
	  i = sell_goods (x - 1, y);
	  et += i;
	  MP_INFO(x + 2,y).int_6 += i;
	}
      if ((flags & FLAG_MB_STEEL) != 0)
	{
	  i = buy_steel (x - 1, y);
	  ic += i;
	  MP_INFO(x + 1,y).int_7 += i;
	}
      if ((flags & FLAG_MS_STEEL) != 0)
	{
	  i = sell_steel (x - 1, y);
	  et += i;
	  MP_INFO(x + 2,y).int_7 += i;
	}
    }
  /* upper gate next */
  if (y > 0 && (MP_INFO(x,y - 1).flags
		& FLAG_IS_TRANSPORT) != 0)
    {
      if ((flags & FLAG_MB_FOOD) != 0)
	{
	  i = buy_food (x, y - 1);
	  ic += i;
	  MP_INFO(x + 1,y).int_3 += i;
	}
      if ((flags & FLAG_MS_FOOD) != 0)
	{
	  i = sell_food (x, y - 1);
	  et += i;
	  MP_INFO(x + 2,y).int_3 += i;
	}
      if ((flags & FLAG_MB_COAL) != 0)
	{
	  i = buy_coal (x, y - 1);
	  ic += i;
	  MP_INFO(x + 1,y).int_4 += i;
	}
      if ((flags & FLAG_MS_COAL) != 0)
	{
	  i = sell_coal (x, y - 1);
	  et += i;
	  MP_INFO(x + 2,y).int_4 += i;
	}
      if ((flags & FLAG_MB_ORE) != 0)
	{
	  i = buy_ore (x, y - 1);
	  ic += i;
	  MP_INFO(x + 1,y).int_5 += i;
	}
      if ((flags & FLAG_MS_ORE) != 0)
	{
	  i = sell_ore (x, y - 1);
	  et += i;
	  MP_INFO(x + 2,y).int_5 += i;
	}
      if ((flags & FLAG_MB_GOODS) != 0)
	{
	  i = buy_goods (x, y - 1);
	  ic += i;
	  MP_INFO(x + 1,y).int_6 += i;
	}
      if ((flags & FLAG_MS_GOODS) != 0)
	{
	  i = sell_goods (x, y - 1);
	  et += i;
	  MP_INFO(x + 2,y).int_6 += i;
	}
      if ((flags & FLAG_MB_STEEL) != 0)
	{
	  i = buy_steel (x, y - 1);
	  ic += i;
	  MP_INFO(x + 1,y).int_7 += i;
	}
      if ((flags & FLAG_MS_STEEL) != 0)
	{
	  i = sell_steel (x, y - 1);
	  et += i;
	  MP_INFO(x + 2,y).int_7 += i;
	}
    }
  MP_INFO(x,y).int_1 += et;
  MP_INFO(x,y).int_4 += ic;
  if (total_time % 100 == 0)
    {
      MP_INFO(x,y).int_2 = MP_INFO(x,y).int_1;
      MP_INFO(x,y).int_1 = 0;
      MP_INFO(x,y).int_5 = MP_INFO(x,y).int_4;
      MP_INFO(x,y).int_4 = 0;
      b1 = &(MP_INFO(x + 1,y).int_3);
      s1 = &(MP_INFO(x + 2,y).int_3);
      b2 = &(MP_INFO(x,y + 1).int_3);
      s2 = &(MP_INFO(x,y + 2).int_3);
      /* GCS FIX -- This obfuscation is unnecessary. */
      for (i = 0; i < 5; i++)
	{
	  *(b2++) = *b1;
	  *(s2++) = *s1;
	  *(b1++) = 0;
	  *(s1++) = 0;
	}
    }
  if (et > 0)
    {
      sust_port_flag = 0;
      tech_level++;
    }
  if (ic > 0)
    {
      sust_port_flag = 0;
      tech_level++;
    }
  et += MP_INFO(x,y).int_3;	/* int_3 holds the 'pence' */

  export_tax += et / 100;
  MP_INFO(x,y).int_3 = et % 100;
  import_cost += ic;
}