当前位置: 首页>>代码示例>>C++>>正文


C++ Spy类代码示例

本文整理汇总了C++中Spy的典型用法代码示例。如果您正苦于以下问题:C++ Spy类的具体用法?C++ Spy怎么用?C++ Spy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Spy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ai_spy_town_rebel

//--------- Begin of function SpyArray::ai_spy_town_rebel ----------//
//
// Tell the AI spies in the town that a rebellion is happening.
//
// When a rebellion happens, all the AI spies in the town will mobilize
// and turn its cloak back to a nation that is not at war with the enemy
// (and notification flag should be off.) and move to a safe place
// (near to one of your towns). Then the spy reaches thedestination, it will
// become idle and then the AI processing function on idle spy will be
// called and handle the spy.
//
// <int> townRecno - recno of the town with rebellion happening.
//
void SpyArray::ai_spy_town_rebel(int townRecno)
{
	int  spyCount=size();
	Spy* spyPtr;

	for( int i=1 ; i<=spyCount ; i++ )
	{
		if( spy_array.is_deleted(i) )
			continue;

		spyPtr = spy_array[i];

		if( spyPtr->spy_place==SPY_TOWN &&
			 spyPtr->spy_place_para==townRecno &&
			 nation_array[spyPtr->true_nation_recno]->is_ai() )
		{
			//-------- mobilize the spy ----------//

			int unitRecno = spyPtr->mobilize_town_spy();

			//----- think new action for the spy ------//

			if( unitRecno )
				spyPtr->think_mobile_spy_new_action();
		}
	}
}
开发者ID:mecirt,项目名称:7k2,代码行数:40,代码来源:ospya.cpp

示例2: size

//--------- Begin of function SpyArray::next_day ----------//
//
void SpyArray::next_day()
{
	int  spyCount = size();
	Spy* spyPtr;

	for( int i=1 ; i<=spyCount ; i++ )
	{
		if( spy_array.is_deleted(i) )
			continue;

		spyPtr = spy_array[i];

		spyPtr->next_day();

		if( spy_array.is_deleted(i) )
			continue;

		if( nation_array[spyPtr->true_nation_recno]->is_ai() )
			spyPtr->process_ai();
	}

	//---------- update Firm::sabotage_level ----------//

	if( info.game_date%15==0 )
		process_sabotage();
}
开发者ID:mecirt,项目名称:7k2,代码行数:28,代码来源:ospya.cpp

示例3: change_cloaked_nation

//--------- Begin of function SpyArray::change_cloaked_nation ---------//
//
// Change the cloak of all the spies in the specific place.
//
// This function is called when a firm or town change nation.
//
// <int> spyPlace        - spy place
// <int> spyPlacePara    - spy place para
// <int> fromNationRecno - change any spies in the place whose cloaked_nation_recno
// <int> toNationRecno     is fromNationRecno to toNationRecno.
//
void SpyArray::change_cloaked_nation(int spyPlace, int spyPlacePara, int fromNationRecno, int toNationRecno)
{
	Spy* spyPtr;

	for( int i=spy_array.size() ; i>0 ; i-- )
	{
		if( spy_array.is_deleted(i) )
			continue;

		spyPtr = spy_array[i];

		if( spyPtr->cloaked_nation_recno != fromNationRecno )
			continue;

		if( spyPtr->spy_place != spyPlace )
			continue;

		//--- check if the spy is in the specific firm or town ---//

		if( spyPlace == SPY_FIRM || spyPlace == SPY_TOWN )  // only check spy_place_para when spyPlace is SPY_TOWN or SPY_FIRM
		{
			if( spyPtr->spy_place_para != spyPlacePara )
				continue;
		}

		if(spyPlace==spyPtr->spy_place && spyPlacePara==spyPtr->spy_place_para &&
			spyPtr->true_nation_recno==toNationRecno)
			spyPtr->set_action_mode(SPY_IDLE);

		//----- if the spy is associated with a unit (mobile or firm overseer), we call Unit::spy_chnage_nation() ---//

		if( spyPlace == SPY_FIRM )
		{
			FirmCamp *firmCamp = firm_array[spyPtr->spy_place_para]->cast_to_FirmCamp();
			if( firmCamp )
			{
				int firmOverseerRecno = firmCamp->overseer_recno;

				if( firmOverseerRecno && unit_array[firmOverseerRecno]->spy_recno == i )
				{
					unit_array[firmOverseerRecno]->spy_change_nation(toNationRecno, COMMAND_AUTO);
					continue;
				}
			}
		}
		else if( spyPlace == SPY_MOBILE )
		{
			unit_array[spyPtr->spy_place_para]->spy_change_nation(toNationRecno, COMMAND_AUTO);
			continue;
		}

		//---- otherwise, just change the spy cloak ----//

		spyPtr->cloaked_nation_recno = toNationRecno;
	}
}
开发者ID:mecirt,项目名称:7k2,代码行数:67,代码来源:ospya.cpp

示例4: put_spy_rec

//-------- Begin of static function put_spy_rec --------//
//
static void put_spy_rec(int recNo, int x, int y, int refreshFlag)
{
	int x2 = x+browse_spy.rec_width-1;

	//-------- display icon of the spy unit -----//

	Spy* spyPtr = spy_array[ spy_filter(recNo) ];

	//-------- get the rank of the spy --------//

	int unitId = race_res[spyPtr->race_id]->basic_unit_id;
	int rankId = RANK_SOLDIER;

	if( spyPtr->spy_place == SPY_FIRM )
	{
		int unitRecno = firm_array[spyPtr->spy_place_para]->overseer_recno;

		if( unitRecno && unit_array[unitRecno]->spy_recno == spyPtr->spy_recno )
			rankId = RANK_GENERAL;
	}

	//---------- display unit icon ---------//

	if( refreshFlag == INFO_REPAINT )
	{
		vga.d3_panel_down(x+1, y+1, x+UNIT_SMALL_ICON_WIDTH+4, y+UNIT_SMALL_ICON_HEIGHT+4 );

		vga_front.put_bitmap(x+3, y+3, unit_res[unitId]->get_small_icon_ptr(rankId) );
	}

	//--------- set help parameters --------//

	if( mouse.in_area(x+1, y+1, x+RACE_ICON_WIDTH+4, y+RACE_ICON_HEIGHT+4) )
	{
		help.set_unit_help( unitId, rankId, x+1, y+1, x+RACE_ICON_WIDTH+4, y+RACE_ICON_HEIGHT+4 );
	}

	//-------- display spy skill -------//

	font_san.put( x+40, y+6, spyPtr->spy_skill, 1, x+66 );

	//-------- display spy loyalty -------//

	font_san.put( x+67, y+6, spyPtr->spy_loyalty, 1, x+94 );

	//------ display the action mode of the spy ------//

	vga.blt_buf( x+95, y+6, x2, y+5+font_san.height(), 0 );

   font_san.use_max_height();
	font_san.center_put( x+95, y+6, x2, y+5+font_san.height(), spyPtr->action_str() );
	font_san.use_std_height();
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:55,代码来源:OFIRMIF2.cpp

示例5: main

int main(int argc, char *argv[])
{

  KAboutData aboutData( "spy", I18N_NOOP("Spy"),
    VERSION, description, KAboutData::License_GPL,
    "(c) 2001, Richard Moore", 0, 0, "[email protected]");
  aboutData.addAuthor("Richard Moore",0, "[email protected]");
  KCmdLineArgs::init( argc, argv, &aboutData );
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  KApplication a;
  Spy *spy = new Spy();
  a.setMainWidget(spy);

  spy->show();

  return a.exec();
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:18,代码来源:main.cpp

示例6: spy_filter

//--------- Begin of function Info::detect_spy ---------//
//
void Info::detect_spy()
{
	//------- detect the spy browser -------//

	if( browse_spy.detect() )
	{
		browse_spy_recno = browse_spy.recno();

		if( browse_spy.double_click )
		{
			Spy* spyPtr = spy_array[ spy_filter(browse_spy_recno) ];
			int  xLoc, yLoc;

			if( spyPtr->get_loc(xLoc, yLoc) )
				world.go_loc( xLoc, yLoc, 1 );
		}
	}
}
开发者ID:Stummi,项目名称:7kaa,代码行数:20,代码来源:OR_SPY.cpp

示例7: set_action_mode

//--------- Begin of function SpyArray::set_action_mode ----------//
//
// Set all spies in the given place to the specific action mode.
//
void SpyArray::set_action_mode(int spyPlace, int spyPlacePara, int actionMode)
{
	int  spyCount=size();
	Spy* spyPtr;

	for( int i=1 ; i<=spyCount ; i++ )
	{
		if( spy_array.is_deleted(i) )
			continue;

		spyPtr = spy_array[i];

		if( spyPtr->spy_place==spyPlace &&
			 spyPtr->spy_place_para==spyPlacePara )
		{
			spyPtr->set_action_mode(actionMode);
		}
	}
}
开发者ID:mecirt,项目名称:7k2,代码行数:23,代码来源:ospya.cpp

示例8:

void Level3::contact_level(b2Contact* contact)
{
	Spy *spyA = spymanager->getChildByBody(contact->GetFixtureA()->GetBody());
	Spy *spyB = spymanager->getChildByBody(contact->GetFixtureB()->GetBody());
	if (spyA != nullptr && spyB != nullptr)
	{
		if (((spyA->getTag() == "dan") && (spyB->getTag() == "goal")))
		{
			b2JointEdge *joint = spyB->getBody()->GetJointList();
			if (joint != nullptr || joint != NULL)
			{
				b2Joint *joint_e = joint->joint;
				for (; joint_e != NULL; joint_e = joint_e->GetNext())
				{
					if (joint_e->GetUserData() == "pig_rope")
					{
						spyA->getSprite()->runAction(CallFuncN::create(CC_CALLBACK_0(Level3::doCallback, this, joint_e)));
						break;
					}
				}
			}
		}
		if ((spyB->getTag() == "dan") && (spyA->getTag() == "goal"))
		{
			b2JointEdge *joint = spyA->getBody()->GetJointList();
			if (joint != nullptr || joint != NULL)
			{
				b2Joint *joint_e = joint->joint;
				for (; joint_e != NULL; joint_e = joint_e->GetNext())
				{
					if (joint_e->GetUserData() == "pig_rope")
					{
						spyB->getSprite()->runAction(CallFuncN::create(CC_CALLBACK_0(Level3::doCallback, this, joint_e)));
						break;
					}
				}
			}
		}
	}

}
开发者ID:phanngoc,项目名称:bombay1,代码行数:41,代码来源:Level3.cpp

示例9: mobilize_all_spy

//--------- Begin of function SpyArray::mobilize_all_spy ----------//
//
// Mobilize all spies of the specific nation in the specific place.
//
// <int> spyPlace     - place id. of the spy
// <int> spyPlacePara - town or firm recno of the spy's staying
// <int> nationRecno	 - recno of the nation which the spy should
//							   be mobilized.
//
void SpyArray::mobilize_all_spy(int spyPlace, int spyPlacePara, int nationRecno)
{
	Spy* spyPtr;

	for( int i=size() ; i>0 ; i-- )
	{
		if( spy_array.is_deleted(i) )
			continue;

		spyPtr = spy_array[i];

		if( spyPtr->spy_place == spyPlace &&
			 spyPtr->spy_place_para == spyPlacePara &&
			 spyPtr->true_nation_recno == nationRecno )
		{
			if( spyPtr->spy_place == SPY_TOWN )
				spyPtr->mobilize_town_spy();

			else if( spyPtr->spy_place == SPY_FIRM )
				spyPtr->mobilize_firm_spy();
		}
	}
}
开发者ID:mecirt,项目名称:7k2,代码行数:32,代码来源:ospya.cpp

示例10: process_viewing_spy

void Info::process_viewing_spy()
{
	//---- check if the viewing spy is still valid ----//

	int isValid=1;

	if( spy_array.is_deleted(viewing_spy_recno) )	// the spy is dead
	{
		isValid = 0;
	}
	else
	{
		Spy* spyPtr = spy_array[viewing_spy_recno];

		//-- check if the spy still stay in the same place --//

		if( spyPtr->spy_place_nation_recno() != info.viewing_nation_recno )
		{
			isValid = 0;
		}
		else
		{
		/*
			//--- on average, a spy will get caught in 5 to 15 days when viewing the secret of its enemy ---//

			if( misc2.random(5+spyPtr->spy_skill/5) ) // use m2 to avoid multiplayer sync problem
			{
				spyPtr->set_exposed(COMMAND_PLAYER);
				isValid = 0;
			}
		*/
		}
	}

	if( !isValid )		//-- if not valid, set the mode back to normal viewing mode
		sys.set_view_mode(MODE_NORMAL);
}
开发者ID:ArseniyShestakov,项目名称:7kaa,代码行数:37,代码来源:OINFO.cpp

示例11: ai_find_spy

//--------- Begin of function Nation::ai_assign_spy --------//
//
// Try to locate an existing spy for use.
//
// <int> targetXLoc, targetYLoc - the target location
// [int] spyRaceId			  - if specified, only spies of this race
//											 will be located. (default:0)
// [int] mobileOnly 				  - get mobile spies only. (default:0)
//
int Nation::ai_assign_spy(int targetXLoc, int targetYLoc, int spyRaceId, int mobileOnly)
{
	int unitRecno=0;

	//---- try to find an existing spy ----//

	Spy* spyPtr = ai_find_spy( targetXLoc, targetYLoc, spyRaceId, mobileOnly );

	if( spyPtr )
		unitRecno = spyPtr->mobilize_spy();

	//--- if not successful, then try to hire one ---//

	if( !unitRecno )
		unitRecno = hire_unit(SKILL_SPYING, spyRaceId, targetXLoc, targetYLoc);

	//--- if cannot hire one, try to train one ----//

	int trainTownRecno=0;

	if( !unitRecno )
		unitRecno = train_unit(SKILL_SPYING, spyRaceId, targetXLoc, targetYLoc, trainTownRecno);

	if( !unitRecno )
		return 0;

	//------ get the spy object of the unit ------//

	Unit* unitPtr = unit_array[unitRecno];

	err_when( !unitPtr->spy_recno );

	spyPtr = spy_array[unitPtr->spy_recno];

	//------- get the nation of the assign destination -----//

	Location* locPtr = world.get_loc(targetXLoc, targetYLoc);
	int 		 cloakedNationRecno;

	if( locPtr->is_firm() )
	{
		Firm* firmPtr = firm_array[locPtr->firm_recno()];

		err_when( firmPtr->nation_recno==0 );		// cannot assign to a monster firm

		cloakedNationRecno = firmPtr->nation_recno;
	}
	else if( locPtr->is_town() )
	{
		Town* townPtr = town_array[locPtr->town_recno()];

		cloakedNationRecno = townPtr->nation_recno;
	}
	else
	{
		return 0;		// the original firm or town has been destroyed or sold
	}

	//------- Add the assign spy action --------//

	int actionRecno = add_action( targetXLoc, targetYLoc,
							-1, -1, ACTION_AI_ASSIGN_SPY, cloakedNationRecno, 1, unitRecno );

	if( !actionRecno )
		return 0;

	//------ if the unit is under training ------//

	if( trainTownRecno )
		town_array[trainTownRecno]->train_unit_action_id = get_action(actionRecno)->action_id;

	return 1;
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:82,代码来源:OAI_SPY.cpp

示例12: detect_unit_list

//--------- Begin of function FirmInn::detect_info ---------//
//
void FirmInn::detect_info()
{
//	firm_inn_ptr = this;

	Firm::detect_info();

//	if( detect_basic_info() )
//		return;

	if( !should_show_info() )
		return;

	detect_unit_list();

	// ------ detect hire button -------//

	// since button_hire and button_spy_mobilize share the same place
	// if one is not visible, do not call detect() to avoid incorrect help text displayed

	if( button_hire_visible && button_hire.detect() 
		&& selected_unit_id > 0 && selected_unit_id <= inn_unit_count )
	{
		InnUnit *innUnit = inn_unit_array + selected_unit_id - 1;

		se_ctrl.immediate_sound("TAXGRANT");

		se_res.far_sound(center_x, center_y, 1, 'S', 
			unit_res[innUnit->unit_id]->sprite_id,
			"RDY" );
		if(remote.is_enable())
		{
			// packet structure : <firm recno>, <hire Id> <nation no> <spy escape>
			short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_INN_HIRE, 4*sizeof(short));
			shortPtr[0] = firm_recno;
			shortPtr[1] = selected_unit_id;
			shortPtr[2] = nation_recno;
			// ###### begin Gilbert 13/2 #######//
			shortPtr[3] = 0;
			// ###### end Gilbert 13/2 #######//
		}
		else
		{
			hire(selected_unit_id, 0);
		}

		// ------ clear selected_unit_id ------//

		selected_unit_id = 0;
	}
	else if( button_spy_mobilize_visible && button_spy_mobilize.detect() 
		&& selected_unit_id > 0 && selected_unit_id <= inn_unit_count )
	{
		se_res.far_sound(center_x, center_y, 1, 'S', 
			unit_res[inn_unit_array[selected_unit_id-1].unit_id]->sprite_id,
			"RDY" );

		err_when( spy_array.is_deleted(inn_unit_array[selected_unit_id-1].spy_recno) );
		Spy *spyPtr = spy_array[inn_unit_array[selected_unit_id-1].spy_recno];
		if( !remote.is_enable() )
		{
			if( spyPtr->mobilize_firm_spy() )
			{
				spyPtr->notify_cloaked_nation_flag = 0;		// reset it so the player can control it
			}
		}
		else
		{
			// packet structure <spy recno>
			short *shortPtr = (short *)remote.new_send_queue_msg(MSG_SPY_LEAVE_FIRM, sizeof(short) );
			*shortPtr = spyPtr->spy_recno;
		}

		// ------ clear selected_unit_id ------//

		selected_unit_id = 0;
	}

	// -------- detect buy item ------//

	if( selected_unit_id > 0 && selected_unit_id <= inn_unit_count )
	{
		InnUnit *innUnit = inn_unit_array + selected_unit_id - 1;

		if( button_buy_item.detect() )
		{
			se_ctrl.immediate_sound("TAXGRANT");

			if( !remote.is_enable() )
			{
				buy_item( selected_unit_id, 0 );
			}
			else
			{
				short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_INN_BUY_ITEM, 2*sizeof(short));
				// packet structure : <firm recno>, <inn unid id>
				shortPtr[0] = firm_recno;
				shortPtr[1] = selected_unit_id;
			}
//.........这里部分代码省略.........
开发者ID:mecirt,项目名称:7k2,代码行数:101,代码来源:of_inni.cpp

示例13: err_when

//-------- Begin of function FirmInn::transfer_inn_unit --------//
//
int FirmInn::transfer_inn_unit(int recNo)
{
	err_when( recNo < 1 );
	
	if( recNo > inn_unit_count )
		return 0;

	InnUnit *innUnit = inn_unit_array+recNo-1;

	if( !innUnit->spy_recno )
		return 0;					// only spy considers transfer

	Spy *spyPtr = NULL;
	if( innUnit->spy_recno && !spy_array.is_deleted(innUnit->spy_recno) )
		spyPtr = spy_array[innUnit->spy_recno];

	// -------- scan any inn firm in world ----------//

	int ownFirmRecno = 0;
	int anyOwnInn = 0;
	int firmRecno = 1+misc.random(firm_array.size());

	int firmCount;
	for( firmCount = firm_array.size(); firmCount > 0; --firmCount, ++firmRecno )
	{
		if( firmRecno > firm_array.size() )
			firmRecno -= firm_array.size();
		err_when(firmRecno < 1 || firmRecno > firm_array.size());

		if( firm_array.is_deleted(firmRecno) )
			continue;

		FirmInn *firmInn = firm_array[firmRecno]->cast_to_FirmInn();

		if( !firmInn )
			continue;

		if( spyPtr && firmInn->nation_recno == spyPtr->true_nation_recno )
		{
			if( !anyOwnInn )
				anyOwnInn = firmRecno;
		}

		if( firmRecno == firm_recno )		// never go back to the same inn
			continue;

		if( firmInn->inn_unit_count >= MAX_INN_UNIT )
			continue;

		if( spyPtr && firmInn->nation_recno == spyPtr->true_nation_recno )
		{
			if( !ownFirmRecno )
				ownFirmRecno = firmRecno;
			continue;							// spy tend not to go back to own firmInn, unless no other choice
		}

		break;
	}

	if( firmCount <= 0 )				// if no other firm found, go back to own firm
		firmRecno = ownFirmRecno;

	if( firmRecno )					// if no any firm to go return false
	{
		// ------ transfer inn unit -------//

		FirmInn *firmInn = firm_array[firmRecno]->cast_to_FirmInn();		
		err_when( !firmInn );
		InnUnit *newInnUnit = firmInn->inn_unit_array + firmInn->inn_unit_count;
		firmInn->inn_unit_count++;
		*newInnUnit = *innUnit;

		// ------- generate new stay count ------//

		newInnUnit->stay_count = 10 + misc.random(5);
		newInnUnit->set_hire_cost();

		// ------ trasfer Spy ------- //

		if( spyPtr )
			spyPtr->set_place(SPY_FIRM, firmRecno);
		innUnit->spy_recno = 0;					// prevent del_inn_unit call spy_array.del_spy

		// ------ delete inn unit of current inn ------//

		del_inn_unit(recNo);
		innUnit = newInnUnit;			// set innUnit to the transferred place for later use
	}
	else if( (firmRecno = anyOwnInn) )
	{
		// mobilize in another any own inn

		hire( recNo, 1, firmRecno );
		innUnit = NULL;
	}

	return firmRecno;
}
开发者ID:112212,项目名称:7k2,代码行数:100,代码来源:of_inn.cpp

示例14: put_spy_rec

//-------- Begin of static function put_spy_rec --------//
//
static void put_spy_rec(int recNo, int x, int y, int refreshFlag)
{
	int  spyRecno = spy_filter(recNo);
	Spy* spyPtr   = spy_array[spyRecno];

	x+=3;
	y+=5;

	//------ display rank/skill icon -------//

	int 	 cloakedRankId  = spyPtr->cloaked_rank_id();
	int 	 cloakedSkillId = spyPtr->cloaked_skill_id();
	String str;

	switch( cloakedRankId )
	{
		case RANK_KING:
			str = "U_KING";
			break;

		case RANK_GENERAL:
			str = "U_GENE";
			break;

		case RANK_SOLDIER:
			if( cloakedSkillId )
			{
				str  = "U_";
				str += Skill::skill_code_array[cloakedSkillId-1];
			}
			else
			{
				str = "";
			}
			break;
	}

	if( str.len() > 0 )
		image_icon.put_back(x, y+1, str);

	//------ display race icon -------------//

	vga_back.put_bitmap( x+13, y-4, race_res[spyPtr->race_id]->icon_bitmap_ptr );

	//----------- display name -----------//

	font_san.put( x+39, y, race_res[spyPtr->race_id]->get_name(spyPtr->name_id), 0, 185 );

	//------- display cloaked nation color ------//

	int tx = x+170;

	if( spyPtr->cloaked_nation_recno==0 )		// independent nation
	{
		vga_back.bar( tx, y, tx+12, y+12, V_WHITE );
		vga_back.rect( tx, y, tx+12, y+12, 1, VGA_GRAY+8 );
	}
	else
	{
		nation_array[spyPtr->cloaked_nation_recno]->disp_nation_color(tx, y+2);
	}

	//---------- display other info ----------//

	switch( spyPtr->spy_place )
	{
		case SPY_FIRM:
			str = firm_res[firm_array[spyPtr->spy_place_para]->firm_id]->name;
			break;

		case SPY_TOWN:
			str = town_array[spyPtr->spy_place_para]->town_name();
			break;

		case SPY_MOBILE:
		{
			Unit* unitPtr = unit_array[spyPtr->spy_place_para];

			switch( unitPtr->unit_mode )
			{
				case UNIT_MODE_CONSTRUCT:
					str = firm_res[firm_array[unitPtr->unit_mode_para]->firm_id]->name;
					break;

				case UNIT_MODE_ON_SHIP:
					str = "On Ship";
					break;

				default:
					str = "Mobile";
			}
			break;
		}

		default:
			str = "";
	}

//.........这里部分代码省略.........
开发者ID:Stummi,项目名称:7kaa,代码行数:101,代码来源:OR_SPY.cpp

示例15: if

//-------- Begin of function SpyArray::catch_spy ------//
//
// <int> spyPlace - either SPY_TOWN or SPY_FIRM
// <int> spyPlacePara - town_recno or firm_recno
//
int SpyArray::catch_spy(int spyPlace, int spyPlacePara)
{
	int nationRecno, totalPop;

	if( spyPlace == SPY_TOWN )
	{
		Town* townPtr = town_array[spyPlacePara];

		nationRecno = townPtr->nation_recno;
		totalPop    = townPtr->population;
	}
	else if( spyPlace == SPY_FIRM )
	{
		Firm* firmPtr = firm_array[spyPlacePara];

		nationRecno = firmPtr->nation_recno;
		if( firmPtr->cast_to_FirmCamp() )
		{
			FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp();
			totalPop    = firmCamp->soldier_count + (firmCamp->overseer_recno>0);
		}
		else if( firmPtr->cast_to_FirmWork() )
		{
			FirmWork *firmWork = firmPtr->cast_to_FirmWork();
			totalPop    = firmWork->worker_count;
		}
		else if( firmPtr->cast_to_FirmTrain() )
		{
			totalPop = firmPtr->cast_to_FirmTrain()->trainee_count;
			return 0;		// don't catch spy
		}
		else if( firmPtr->cast_to_FirmInn() )
		{
			totalPop = firmPtr->cast_to_FirmInn()->inn_unit_count;
			return 0;		// don't catch spy
		}
		else if( firmPtr->cast_to_FirmMarket() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmMonsterTrain() )
		{
			totalPop = firmPtr->cast_to_FirmMonsterTrain()->trainee_count;
			return 0;		// don't catch spy
		}
		else if( firmPtr->cast_to_FirmMonsterAlchemy() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmLishorr() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmMonsterFortress() )
		{
			FirmMonsterFortress *firmMonsterFortress = firmPtr->cast_to_FirmMonsterFortress();
			totalPop = firmMonsterFortress->archer_count + firmMonsterFortress->extra_builder_count;
		}
		else if( firmPtr->cast_to_FirmAnimal() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmIncubator() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmMagic() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmOffensive() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmOffensive2() )
		{
			totalPop = 0;
			return 0;
		}
		else
		{
			err_here();
			totalPop = 0;
		}
	}
	else
		err_here();

//.........这里部分代码省略.........
开发者ID:mecirt,项目名称:7k2,代码行数:101,代码来源:ospya.cpp


注:本文中的Spy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。