//------- Begin of function FirmMine::ai_has_excess_worker -------// // // Return whether this firm has any excessive workers or not. // int FirmMine::ai_has_excess_worker() { //--- if the actual production is lower than the productivity, than the firm must be under-capacity. if( worker_count > 4 ) // at least keep 4 workers { return stock_qty > max_stock_qty * (float) 0.9 && production_30days() < productivity*25; // take 25 days instead of 30 days so there will be small chance of errors. } else if( worker_count > 1 ) { return reserve_qty < worker_count*200; } else // don't leave if there is only one miner there { return 0; } }
//--------- Begin of function FirmFactory::disp_factory_info ---------// // void FirmFactory::disp_factory_info(int dispY1, int refreshFlag) { //---------------- paint the panel --------------// if( refreshFlag == INFO_REPAINT ) vga_util.d3_panel_up( INFO_X1, dispY1, INFO_X2, dispY1+70); //---------- display production info -------------// int x=INFO_X1+4, y=dispY1+4; vga_front.put_bitmap_trans( x+1, y+1, raw_res.small_product_icon(product_raw_id) ); String str; // TRANSLATORS: Producing <Clay/Copper/Iron> Products snprintf( str, MAX_STR_LEN+1, _("Producing %s Products"), _(raw_res[product_raw_id]->name) ); font_san.use_max_height(); // make sure the old text is replaced completely #if(defined(FRENCH) || defined(SPANISH)) font_san.disp( x+15, y, str, INFO_X2-1); #else font_san.disp( x+20, y, str, INFO_X2-2); #endif font_san.use_std_height(); y+=16; font_san.field( x, y, _("Monthly Production"), x+133, (int) production_30days(), 1, INFO_X2-2, refreshFlag, "FC_PROD" ); y+=16; str = (int) raw_stock_qty; str += " / "; str += (int) max_raw_stock_qty; font_san.field( x, y, _("Raw Material Stock"), x+133, str, INFO_X2-2, refreshFlag, "FC_RAW" ); y+=16; str = (int) stock_qty; str += " / "; str += (int) max_stock_qty; font_san.field( x, y, _("Product Stock"), x+133, str, INFO_X2-2, refreshFlag, "FC_PROD"); }
//--------- Begin of function FirmMine::disp_mine_info ---------// // void FirmMine::disp_mine_info(int dispY1, int refreshFlag) { //---------------- paint the panel --------------// if( refreshFlag == INFO_REPAINT ) vga_util.d3_panel_up( INFO_X1, dispY1, INFO_X2, dispY1+70); //------ if there is no natural resource on this location ------// if( !raw_id ) { font_san.center_put( INFO_X1, dispY1, INFO_X2, dispY1+70, "No Natural Resources" ); return; } //-------------- display mining info -----------// int x=INFO_X1+4, y=dispY1+4; raw_res.put_small_raw_icon( x+1, y+1, raw_id ); String str; str = translate.process("Mining "); str += raw_res[raw_id]->name; font_san.disp( x+20, y, str, INFO_X2-2); y+=16; font_san.field( x, y, "Monthly Production", x+126, (int) production_30days(), 1, INFO_X2-2, refreshFlag, "MN_PROD"); y+=16; str = (int) stock_qty; str += " / "; str += (int) max_stock_qty; font_san.field( x, y, "Mined Stock", x+126, str, INFO_X2-2, refreshFlag, "MN_STOCK"); y+=16; font_san.field( x, y, "Untapped Reserve", x+126, (int) reserve_qty, 1, INFO_X2-2, refreshFlag, "MN_UNTAP"); }
//------- Begin of function FirmMine::think_inc_productivity -------// // int FirmMine::think_inc_productivity() { //----------------------------------------------// // // If this factory has a medium to high level of stock, // this means the bottleneck is not at the factories, // building more factories won't solve the problem. // //----------------------------------------------// if( stock_qty > max_stock_qty * 0.1 && production_30days() > 30 ) return 0; if( reserve_qty < MAX_RAW_RESERVE_QTY/10 ) return 0; //------ try to get skilled workers from inns and other firms ------// // return think_hire_inn_unit(); return 0; }
//------- Begin of function FirmMine::think_adjust_workforcez -------// // // Think about adjusting the workforce by increasing or decreasing // needed_worker_count. // int FirmMine::think_adjust_workforce() { //------ think about decreasing work force -------// //-- the more full the stock is, the less worker we needed ----// int optimizedWorker = 3 + MAX_WORKER - MAX_WORKER * (int) stock_qty / (int) max_stock_qty; if( needed_worker_count > optimizedWorker ) { int decCount = (needed_worker_count-optimizedWorker)/3; set_needed_worker_count( needed_worker_count - MAX(1, decCount), COMMAND_AI ); return 1; } //------- think about increasing work force -------// if( stock_qty > max_stock_qty * 0.1 && production_30days() > 30 ) return 0; if( reserve_qty < MAX_RAW_RESERVE_QTY/10 ) return 0; if( needed_worker_count < MAX_WORKER ) { if( stock_qty > max_stock_qty * 0.05 ) set_needed_worker_count( needed_worker_count+1, COMMAND_AI ); else set_needed_worker_count( needed_worker_count+2, COMMAND_AI ); return 1; } return 0; }
// -------- begin of function FirmMine::disp_firm_info --------// // void FirmMine::disp_firm_info(int dispY1, int refreshFlag) { //---------- display production info -------------// // String str; //, str2; if (raw_id == 0) { // str = "No Natural Resources near !! You cannot mine in here."; font_snds.put_paragraph( INFO_X1+20, INFO_Y1+38, INFO_X2-5, INFO_Y2-5, text_firm.str_mine_no_raw() ); } else { // font_snds.center_put( INFO_X1+10, INFO_Y1+5, INFO_X1+96, INFO_Y1+30, // "Unmined Raw", 0, 1 ); font_snds.put( INFO_X1+14, INFO_Y1+12, text_firm.str_unmined_raw(), 0, -1, 1 ); // font_snds.center_put( INFO_X2-86+12, INFO_Y1+5, INFO_X2, INFO_Y1+30, // text_firm.str_mined_raw(), // "Mined Raw", // 0, 1 ); font_snds.right_put( INFO_X2-10, INFO_Y1+12, text_firm.str_mined_raw(), 0, 1 ); font_snds.center_put( INFO_X1+10, INFO_Y1+20, INFO_X1+96, INFO_Y1+45, raw_res[raw_id]->name, 0, 1 ); font_snds.center_put( INFO_X2-86+12, INFO_Y1+20, INFO_X2, INFO_Y1+45, raw_res[raw_id]->name, 0, 1 ); // str = (int) stock_qty; // str += " / "; // str += (int) max_stock_qty; if (stock_qty >= max_stock_qty) vga.active_buf->put_bitmap( INFO_X2-64+6, INFO_Y1+40+15, image_icon.read("FULLVILL") ); font_snds.center_put( INFO_X2-86+12, INFO_Y1+40, INFO_X2, INFO_Y1+55, misc.format((int) stock_qty) ); // str ); // str = (int) reserve_qty; // if ( reserve_qty <= 0 ) // vga.active_buf->put_bitmap( INFO_X1+33, INFO_Y1+40+15, image_icon.read("FULLVILL") ); font_snds.center_put( INFO_X1+10, INFO_Y1+40, INFO_X1+96, INFO_Y1+55, misc.format((int) reserve_qty) ); // str ); if ( (int) production_30days() > 0 ) // if ( is_operating() ) { char animate[] = "PICK-0"; if ( animate_seqno >0 ) animate[5] = '2'; if ( animate_seqno >1 ) animate[5] = '1'; if (config.frame_speed != 0) animate_seqno ++; int limit; if ( (int) production_30days() > 0 && (int) production_30days() <= 20 ) limit = 7; if ( (int) production_30days() > 20 && (int) production_30days() <= 50 ) limit = 6; if ( (int) production_30days() > 50 && (int) production_30days() <= 90 ) limit = 5; if ( (int) production_30days() > 90 && (int) production_30days() <=140 ) limit = 4; if ( (int) production_30days() >140 && (int) production_30days() <=200 ) limit = 3; if ( (int) production_30days() >200 ) limit = 2; if ( animate_seqno >limit ) animate_seqno = 1; vga.active_buf->put_bitmap( INFO_X1+93, INFO_Y1+36, image_icon.read( animate ) ); } else vga.active_buf->put_bitmap( INFO_X1+93, INFO_Y1+36, image_icon.read( "PICK-1" ) ); if (raw_id == RAW_CLAY) { vga.active_buf->put_bitmap( INFO_X1+20, INFO_Y1+88, image_icon.read( "CLY-RW_L" ) ); vga.active_buf->put_bitmap_trans( INFO_X1+164, INFO_Y1+83, image_icon.read( "CLY-RW_R" ) ); } else if (raw_id == RAW_COPPER) { vga.active_buf->put_bitmap( INFO_X1+20, INFO_Y1+88, image_icon.read( "COP-RW_L" ) ); vga.active_buf->put_bitmap_trans( INFO_X1+164, INFO_Y1+83, image_icon.read( "COP-RW_R" ) ); } else if (raw_id == RAW_IRON) { vga.active_buf->put_bitmap( INFO_X1+20, INFO_Y1+88, image_icon.read( "IRN-RW_L" ) ); vga.active_buf->put_bitmap_trans( INFO_X1+164, INFO_Y1+83, image_icon.read( "IRN-RW_R" ) ); } else err_here(); // str = "Monthly"; // font_snds.center_put( INFO_X1+17, INFO_Y1+90, INFO_X2, INFO_Y1+115, str ); // str = "Production"; // font_snds.center_put( INFO_X1+17, INFO_Y1+106, INFO_X2, INFO_Y1+121, str ); font_snds.center_put_paragraph( INFO_X1+72, INFO_Y1+85, INFO_X1+169, INFO_Y1+121, text_firm.str_monthly_production(), 0, 0, 0 ); // str = (int) production_30days(); // font_snds.center_put( INFO_X1+17, INFO_Y1+117, INFO_X2, INFO_Y1+137, str ); font_snds.center_put( INFO_X1+17, INFO_Y1+117, INFO_X2, INFO_Y1+137, misc.format((int) production_30days()) ); } }