本文整理汇总了C++中Town类的典型用法代码示例。如果您正苦于以下问题:C++ Town类的具体用法?C++ Town怎么用?C++ Town使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Town类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: deinit_unit_mode
//--------- Begin of function Unit::deinit_unit_mode ---------//
//
void Unit::deinit_unit_mode()
{
if( sys.signal_exit_flag )
return;
//----- this unit was defending the town before it gets killed ----//
if(unit_mode==UNIT_MODE_TOWN_DEFENDER)
{
if(!town_array.is_deleted(unit_mode_para))
{
Town *townPtr = town_array[unit_mode_para];
if(nation_recno == townPtr->nation_recno)
townPtr->reduce_defender_count();
}
set_mode(0); // reset mode
}
// ###### begin Gilbert 30/4 #########//
else if( unit_mode == UNIT_MODE_CAMP_DEFENDER )
{
// no extra action needed other than reset mode
// if(!firm_array.is_deleted(unit_mode_para))
// {
// Firm *firmPtr = firm_array[unit_mode_para];
// if(nation_recno == firmPtr->nation_recno)
// firmPtr->reduce_defender_count();
// }
set_mode(0); // reset mode
}
// ###### end Gilbert 30/4 #########//
/*
//----- this is a monster unit defending its town ------//
else if( unit_mode==UNIT_MODE_MONSTER && unit_mode_para )
{
if(((UnitMonster*)this)->monster_action_mode!=MONSTER_ACTION_DEFENSE)
return;
FirmMonster* firmMonster = (FirmMonster*) firm_array[unit_mode_para];
err_when( firmMonster->firm_id != FIRM_MONSTER );
firmMonster->reduce_defender_count(rank_id);
}
*/
}
开发者ID:112212,项目名称:7k2,代码行数:53,代码来源:oun_init.cpp
示例2: majority_race
//------- Begin of function Town::think_ai_migrate_to_town --------//
//
// Think about the town to migrate to.
//
int Town::think_ai_migrate_to_town()
{
//------ think about which town to migrate to ------//
Nation* nationPtr = nation_array[nation_recno];
int curRating, bestRating=0, bestTownRecno=0;
short *aiTownPtr = nationPtr->ai_town_array;
int majorityRace = majority_race();
Town *townPtr;
for(int i=0; i<nationPtr->ai_town_count; i++, aiTownPtr++)
{
if( town_recno == *aiTownPtr )
continue;
townPtr = town_array[*aiTownPtr];
err_when( townPtr->nation_recno != nation_recno );
if( !townPtr->is_base_town ) // only migrate to base towns
continue;
if( townPtr->region_id != region_id )
continue;
if( population > MAX_TOWN_POPULATION-townPtr->population ) // if the town does not have enough space for the migration
continue;
//--------- compare the ratings ---------//
curRating = 1000 * townPtr->race_pop_array[majorityRace-1] / townPtr->population; // *1000 so that this will have a much bigger weight than the distance rating
curRating += world.distance_rating( center_x, center_y, townPtr->center_x, townPtr->center_y );
if( curRating > bestRating )
{
//--- if there is a considerable population of this race, then must migrate to a town with the same race ---//
if( race_pop_array[majorityRace-1] >= 6 )
{
if( townPtr->majority_race() != majorityRace ) // must be commented out otherwise low population town will never be optimized
continue;
}
bestRating = curRating;
bestTownRecno = townPtr->town_recno;
}
}
return bestTownRecno;
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:55,代码来源:OTOWNAI.cpp
示例3:
// -----------------------------------------------------------------
// Name : findTown
// -----------------------------------------------------------------
Town * Map::findTown(u32 uTownId)
{
// Loop through map
for (int x = 0; x < m_iWidth; x++)
{
for (int y = 0; y < m_iHeight; y++)
{
Town * pTown = (Town*) (m_pTiles[x][y])->getFirstMapObject(GOTYPE_TOWN);
if (pTown != NULL && pTown->getId() == uTownId)
return pTown;
}
}
return NULL;
}
开发者ID:jotak,项目名称:shahnarman,代码行数:17,代码来源:Map.cpp
示例4: ai_assign_spy_to_town
//--------- Begin of function Nation::ai_assign_spy_to_town --------//
//
// Think about sending spies to the specific town.
//
// <int> townRecno - recno of the town
// [int] raceId - race id. of the spy
// (default: majority_race() of the tonw)
//
// return: <int> 1 - a spy is assigned successfully.
// 0 - failure.
//
int Nation::ai_assign_spy_to_town(int townRecno, int raceId)
{
Town* townPtr = town_array[townRecno];
if( townPtr->population >= MAX_TOWN_POPULATION )
return 0;
if( !raceId )
raceId = townPtr->majority_race();
int mobileOnly = townPtr->nation_recno == nation_recno; // if assign to own towns/firms, only get mobile spies, don't get spies from existing towns/firms as that will result in a loop effect
return ai_assign_spy( townPtr->loc_x1, townPtr->loc_y1, raceId, mobileOnly );
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:25,代码来源:OAI_SPY.cpp
示例5: payRent
bool Houses::payRent(Player* player, House* house, uint32_t bid, time_t _time/* = 0*/)
{
if(rentPeriod == RENTPERIOD_NEVER || !house->getOwner() ||
house->getPaidUntil() > _time || !house->getRent() ||
player->hasCustomFlag(PlayerCustomFlag_IgnoreHouseRent))
return true;
Town* town = server.towns().getTown(house->getTownId());
if(!town)
return false;
bool paid = false;
uint32_t amount = house->getRent() + bid;
if(server.configManager().getBool(ConfigManager::BANK_SYSTEM) && player->balance >= amount)
{
player->balance -= amount;
paid = true;
}
else if(Depot* depot = player->getDepot(town->getID(), true))
paid = server.game().removeMoney(depot, amount, FLAG_NOLIMIT);
if(!paid)
return false;
if(!_time)
_time = time(nullptr);
uint32_t paidUntil = _time;
switch(rentPeriod)
{
case RENTPERIOD_DAILY:
paidUntil += 86400;
break;
case RENTPERIOD_WEEKLY:
paidUntil += 7 * 86400;
break;
case RENTPERIOD_MONTHLY:
paidUntil += 30 * 86400;
break;
case RENTPERIOD_YEARLY:
paidUntil += 365 * 86400;
break;
default:
break;
}
house->setPaidUntil(paidUntil);
return true;
}
开发者ID:novasdream,项目名称:tyano-core,代码行数:49,代码来源:house.cpp
示例6: mobilize_capturer
//-------- Begin of function Nation::mobilize_capturer ------//
//
// Mobilize the capturer unit if he isn't mobilized yet.
//
int Nation::mobilize_capturer(int unitRecno)
{
//--- if the picked unit is an overseer of an existng camp ---//
Unit* unitPtr = unit_array[unitRecno];
if( unitPtr->unit_mode == UNIT_MODE_OVERSEE )
{
Firm* firmPtr = firm_array[unitPtr->unit_mode_para];
Town* townPtr;
//-- can recruit from either a command base or seat of power --//
//-- train a villager with leadership to replace current overseer --//
int i;
for( i=0 ; i<firmPtr->linked_town_count ; i++ )
{
townPtr = town_array[ firmPtr->linked_town_array[i] ];
if( townPtr->nation_recno != nation_recno )
continue;
//--- first try to train a unit who is racially homogenous to the commander ---//
int unitRecno = townPtr->recruit( SKILL_LEADING, firmPtr->majority_race(), COMMAND_AI );
//--- if unsucessful, then try to train a unit whose race is the same as the majority of the town ---//
if( !unitRecno )
unitRecno = townPtr->recruit( SKILL_LEADING, townPtr->majority_race(), COMMAND_AI );
if( unitRecno )
{
add_action(townPtr->loc_x1, townPtr->loc_y1, -1, -1, ACTION_AI_ASSIGN_OVERSEER, FIRM_CAMP);
break;
}
}
if( i==firmPtr->linked_town_count ) // unsuccessful
return 0;
//------- mobilize the current overseer --------//
firmPtr->mobilize_overseer();
}
return 1;
}
开发者ID:MicroVirus,项目名称:7kaa,代码行数:53,代码来源:OAI_CAPT.cpp
示例7: add_town
//----- Begin of function TownArray::add_town -------//
//
// <int> nationRecno - the nation recno
// <int> raceId - the race of the majority of the town poulation
// <int> xLoc, yLoc - location of the town
//
int TownArray::add_town(int nationRecno, int raceId, int xLoc, int yLoc)
{
Town* townPtr;
townPtr = new Town;
linkin(&townPtr);
townPtr->town_recno = recno();
townPtr->init(nationRecno, raceId, xLoc, yLoc);
nation_array.update_statistic(); // update largest_town_recno
return recno();
}
开发者ID:brianV,项目名称:7kaa,代码行数:21,代码来源:OTOWNA.cpp
示例8: create
static Target create( const Option& o )
{
Town* town = new Town( &o );
TargetValue* THIS = new TargetValue( town );
town->setTHIS(THIS);
Target target = THIS;
town->build(o);
//l.addFeature( target );
return Target(target);
}
开发者ID:anylonen,项目名称:abura-tan,代码行数:15,代码来源:features.hpp
示例9: main
int main()
{
int i,j;
/*Strategy * a;
for(i=0;i<1000;i++)
{
a= new Strategy(5);
a->getScore();
a->getBar(20);
a->updateScore(1);
delete a;
}
cout<<"strat"<<endl;
int c[]={1,0,1,1,0,1,0,1,1,0};
Agent * b;
for(i=0;i<1000;i++)
{
b= new Agent(10,0,0);
b->isGoingToBar(20);
b->tellWins(c,40);
b->isDead();
delete b;
}
cout<<"Agent"<<endl;
Group * d;
for(i=0;i<1000;i++)
{
d=new Group(4,5,0,0);
d->isGoingToBar(20);
d->getNumPeeps();
d->isEmpty();
delete d;
}
cout<<"Group"<<endl;*/
int g[]={1,2,3,4,5};
Town * t;
for(i=0;i<1000;i++)
{
t=new Town(5,100,g,true,3,50,50);
for(j=0;j<1000;j++)
{
//cout<<i<<" "<<j<<endl;
t->turn();
}
delete t;
}
cout<<"Town"<<endl;
}
开发者ID:ZeroVirus,项目名称:Software-Eng.,代码行数:48,代码来源:Test.cpp
示例10: refToTown
State_TownMenu::State_TownMenu(Town& town, Ship& ship)
: refToTown(town), refToShip(ship)
{
int potenwidth = 14 + town.getName().size();
potenwidth = potenwidth > 18 ? potenwidth : 18;
console = new TCODConsole(potenwidth, 9);
}
开发者ID:GalenEvil,项目名称:ChartedWaters,代码行数:7,代码来源:State_townmenu.cpp
示例11: tmp
StatusType RectangleLand::AddNeighborhood(Shore side, int location, int population){
if ( (location < 0) || (population <= 0) ) {
return INVALID_INPUT;
}
try{
Town tmp(location);
Town* T = Shores[side].find(&tmp);
if (T == NULL) {
return FAILURE;
}
if (T->AddNeighborhood(population) == T->TownSuccess) {
return SUCCESS;
}
} catch (std::bad_alloc&) {
}
return FAILURE;
}
开发者ID:tzafrir,项目名称:mivni2,代码行数:18,代码来源:RectangleLand.cpp
示例12: teleportToTown
void Commands::teleportToTown(Player* player, const std::string& cmd, const std::string& param)
{
Town* town = Towns::getInstance().getTown(param);
if (town) {
Position oldPosition = player->getPosition();
Position newPosition = g_game.getClosestFreeTile(player, 0, town->getTemplePosition(), true);
if (oldPosition != newPosition) {
if (newPosition.x == 0) {
player->sendCancel("You can not teleport there.");
} else if (g_game.internalTeleport(player, newPosition) == RET_NOERROR) {
g_game.addMagicEffect(oldPosition, NM_ME_POFF, player->isInGhostMode());
g_game.addMagicEffect(newPosition, NM_ME_TELEPORT, player->isInGhostMode());
}
}
} else {
player->sendCancel("Could not find the town.");
}
}
开发者ID:KnightLogini,项目名称:forgottenserver,代码行数:18,代码来源:commands.cpp
示例13: float
//------ Begin of function FirmWork::process_independent_town_worker -----//
//
// Process workers from independent towns.
//
// When workers work for a foreign firm, the overall resistance of
// the worker's town towards that nation decreases.
//
void FirmWork::process_independent_town_worker()
{
#define RESISTANCE_DECREASE_PER_WORKER float(0.2) // resistance decrease per month every 15 days
Town* townPtr;
for( int i=0 ; i<worker_count ; i++ )
{
err_when( !worker_array[i].town_recno );
townPtr = town_array[ worker_array[i].town_recno ];
if( townPtr->nation_recno==0 ) // if it's an independent town
{
townPtr->change_resistance( nation_recno, -RESISTANCE_DECREASE_PER_WORKER );
}
}
}
开发者ID:112212,项目名称:7k2,代码行数:25,代码来源:of_work.cpp
示例14: put_town_rec
//-------- Begin of static function put_town_rec --------//
//
static void put_town_rec(int recNo, int x, int y, int refreshFlag)
{
int townRecno = town_filter(recNo);
Town* townPtr = town_array[townRecno];
//---------- display info ----------//
x+=3;
y+=3;
font_san.put( x , y, townPtr->town_name() );
font_san.put( x+175, y, townPtr->population );
font_san.put( x+241, y, townPtr->jobless_population );
font_san.put( x+309, y, townPtr->average_loyalty() );
//------- display race icons -------//
x += 350;
int i;
int iconSpacing = RACE_ICON_WIDTH+2;
#if(MAX_RACE > 7)
int raceCount = 0;
for( i=0 ; i<MAX_RACE ; i++ )
{
if( townPtr->race_pop_array[i] > 0 )
{
++raceCount;
}
}
if( raceCount > 7 )
{
iconSpacing = 7 * iconSpacing / raceCount;
}
#endif
for( i=0 ; i<MAX_RACE ; i++ )
{
if( townPtr->race_pop_array[i] > 0 )
{
vga_back.put_bitmap( x, y-2, race_res[i+1]->icon_bitmap_ptr );
x += iconSpacing;
}
}
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:46,代码来源:OR_TOWN.cpp
示例15: setLastErrorString
bool IOMap::parseTowns(OTB::Loader& loader, const OTB::Node& townsNode, Map& map)
{
for (auto& townNode : townsNode.children) {
PropStream propStream;
if (townNode.type != OTBM_TOWN) {
setLastErrorString("Unknown town node.");
return false;
}
if (!loader.getProps(townNode, propStream)) {
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townId;
if (!propStream.read<uint32_t>(townId)) {
setLastErrorString("Could not read town id.");
return false;
}
Town* town = map.towns.getTown(townId);
if (!town) {
town = new Town(townId);
map.towns.addTown(townId, town);
}
std::string townName;
if (!propStream.readString(townName)) {
setLastErrorString("Could not read town name.");
return false;
}
town->setName(townName);
OTBM_Destination_coords town_coords;
if (!propStream.read(town_coords)) {
setLastErrorString("Could not read town coordinates.");
return false;
}
town->setTemplePos(Position(town_coords.x, town_coords.y, town_coords.z));
}
return true;
}
开发者ID:LuisPro,项目名称:forgottenserver,代码行数:44,代码来源:iomap.cpp
示例16: start_capture
//--------- Begin of function Nation::start_capture --------//
//
int Nation::start_capture(int townRecno, int captureUnitRecno)
{
//--- find the two races with most population in the town ---//
Town* townPtr = town_array[townRecno];
int majorityRace=0;
//--- if it's an independent town, the race of the commander must match with the race of the town ---//
if( townPtr->nation_recno == 0 )
{
majorityRace = townPtr->majority_race();
}
//---- see if we have generals in the most populated race, if so build a camp next to the town ----//
return capture_build_camp(townRecno, majorityRace, captureUnitRecno);
}
开发者ID:MicroVirus,项目名称:7kaa,代码行数:21,代码来源:OAI_CAPT.cpp
示例17: commander_power
//--------- Begin of function Unit::commander_power ---------//
//
// A commander's power is determined:
//
// -Population of the towns he controls
// -The employment rate of the towns he controls, the higher the
// employment rate, the higher his power is
// -If there are any other commanders controls the towns at the same time.
// -the no. of soldiers led by the commander and their combat levels.
//
int Unit::commander_power()
{
//---- if the commander is in a military camp -----//
int commanderPower=0;
if( unit_mode == UNIT_MODE_OVERSEE )
{
Firm* firmPtr = firm_array[unit_mode_para];
if( firmPtr->cast_to_FirmCamp() )
{
Town* townPtr;
for( int i=firmPtr->linked_town_count-1 ; i>=0 ; i-- )
{
if( firmPtr->linked_town_enable_array[i] == LINK_EE )
{
townPtr = town_array[firmPtr->linked_town_array[i]];
int linkedCampCount = townPtr->linked_camp_count(true);
if( linkedCampCount > 0 )
commanderPower += townPtr->population / linkedCampCount;
}
}
commanderPower += firmPtr->cast_to_FirmCamp()->soldier_count*3; // 0 to 24
}
else if( firmPtr->firm_id == FIRM_BASE )
{
commanderPower = 60;
}
}
else
{
commanderPower = team_info->member_count*3; // 0 to 24
}
return commanderPower;
}
开发者ID:mecirt,项目名称:7k2,代码行数:51,代码来源:oun_info.cpp
示例18: update_influence
//--------- Begin of function FirmCamp::update_influence ---------//
//
// Update this camp's influence on neighbor towns.
//
void FirmCamp::update_influence()
{
int i;
Town* townPtr;
for( i=0 ; i<linked_town_count ; i++ )
{
if(town_array.is_deleted(linked_town_array[i]))
continue;
townPtr = town_array[linked_town_array[i]];
if( linked_town_enable_array[i] == LINK_EE )
{
if( townPtr->nation_recno )
townPtr->update_target_loyalty();
else
townPtr->update_target_resistance();
}
}
}
开发者ID:mecirt,项目名称:7k2,代码行数:25,代码来源:of_camp.cpp
示例19: teleportToTown
bool Commands::teleportToTown(Creature* creature, const std::string& cmd, const std::string& param)
{
std::string tmp = param;
Player* player = creature->getPlayer();
if(!player){
return false;
}
Town* town = Towns::getInstance().getTown(tmp);
if(town){
if(g_game.internalTeleport(creature, town->getTemplePosition()) == RET_NOERROR) {
g_game.addMagicEffect(town->getTemplePosition(), NM_ME_ENERGY_AREA);
return true;
}
}
player->sendCancel("Could not find the town.");
return false;
}
开发者ID:ChubNtuck,项目名称:avesta74,代码行数:21,代码来源:commands.cpp
示例20: House
void HousePalettePanel::OnClickAddHouse(wxCommandEvent& event)
{
if(map == nullptr)
return;
House* new_house = newd House(*map);
new_house->id = map->houses.getEmptyID();
std::ostringstream os;
os << "Unnamed House #" << new_house->id;
new_house->name = os.str();
Town* town = reinterpret_cast<Town*>(town_choice->GetClientData(town_choice->GetSelection()));
ASSERT(town);
new_house->townid = town->getID();
map->houses.addHouse(new_house);
house_list->Append(wxstr(new_house->getDescription()), new_house);
SelectHouse(house_list->FindString(wxstr(new_house->getDescription())));
gui.SelectBrush();
refresh_timer.Start(300, true);
}
开发者ID:Codex-NG,项目名称:rme,代码行数:22,代码来源:palette_house.cpp
注:本文中的Town类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论