int race(int count, const char * horses) { int i = 0, races = 0; //const char * top_horses; int sub_races = count % 5 == 0 ? count/5 : count/5 + 1; int top_race_size = (count/5) * 3 + count % 5; std::vector<int> top_horses; for ( int i = 0; i < count; i++) { //get the next 5 or whatever's left int subrace_size = i > 5 ? i - 5 : i; std::vector<int> subrace(subrace_size); for ( int j = 0; j < subrace_size; j++ ) subrace[j] = horses[i+j]; //get the top 3 horses and add to the top horse list sort(subrace_size, subrace); for ( int j = 0; j < 3 && j < subrace_size; j++ ) top_horses.push_back(subrace[j]); races ++; } //race the top horses races += race(top_count, top_horses); return races; }
Wargear* WargearList::resolveWargear(const QString& id) { Wargear *ret = getWargear(id); if(!ret) ret = const_cast<Game*>(race().game())->getBaseWargear(id); return ret; }
BlueprintDefs::BlueprintDefs() { RaceType races[] = { RaceType::Human, RaceType::Eridani, RaceType::Planta, RaceType::Orion }; for (auto r : races) { Race race(r); for (auto s : PlayerShipTypesRange()) m_map.insert(std::make_pair(BlueprintID(r, s), race.GetBlueprintDef(s))); } }
void AIWizard::Update(double timeElapsed) { m_dTimeSinceLastFrame = timeElapsed; m_vSteeringForce.ZERO; m_pStateMachine->Update(); translateEntity(timeElapsed); separateEntity(timeElapsed); MessageSystem::getSingletonPtr()->DispatchMessageGraphUnit(this->ID(), this->ID(), SMSG_AISystemToGraphSystem, this->getPosition(), this->getOrientation(), timeElapsed, this->m_iType, race(), getAnimation(), this->getActualHealth()); }
void AIHall::Update(double timeElapsed) { // El update de AIHall va a la máquina de estados y según en el que esté calcula un steering behavior. // Si queremos un update cada cierto tiempo la unidad tiene que seguir moviendose en ese plazo, por lo que debe haber 2 updates. // 1 se debería llamar cada frame y el otro 5 veces cada 60 frames. Necesitamos la dirección anterior. // reset the steering force m_pStateMachine->Update(); //int receiver = FactoryGraphics::getSingletonPtr()->GetGraphEntityFromID(this->ID()); MessageSystem::getSingletonPtr()->DispatchMessageGraphUnit(this->ID(), this->ID(), SMSG_AISystemToGraphSystem, this->getPosition(), this->getOrientation(), timeElapsed, this->m_iType, race(), getAnimation(), m_dActualHealth); }
void ForcesWindow::RefreshWindow() { HWND hWnd = getHandle(); GuiMapPtr map = chkd.maps.curr; if ( map != nullptr ) { for ( int force=0; force<4; force++ ) { ChkdString forceName; bool allied = false, vision = false, random = false, av = false; map->getForceString(forceName, force); map->getForceInfo(force, allied, vision, random, av); SetWindowText(GetDlgItem(hWnd, EDIT_F1NAME+force), forceName.c_str()); if ( allied ) SendMessage(GetDlgItem(hWnd, CHECK_F1ALLIED+force), BM_SETCHECK, BST_CHECKED , 0); else SendMessage(GetDlgItem(hWnd, CHECK_F1ALLIED+force), BM_SETCHECK, BST_UNCHECKED, 0); if ( vision ) SendMessage(GetDlgItem(hWnd, CHECK_F1VISION+force), BM_SETCHECK, BST_CHECKED , 0); else SendMessage(GetDlgItem(hWnd, CHECK_F1VISION+force), BM_SETCHECK, BST_UNCHECKED, 0); if ( random ) SendMessage(GetDlgItem(hWnd, CHECK_F1RANDOM+force), BM_SETCHECK, BST_CHECKED , 0); else SendMessage(GetDlgItem(hWnd, CHECK_F1RANDOM+force), BM_SETCHECK, BST_UNCHECKED, 0); if ( av ) SendMessage(GetDlgItem(hWnd, CHECK_F1AV +force), BM_SETCHECK, BST_CHECKED , 0); else SendMessage(GetDlgItem(hWnd, CHECK_F1AV +force), BM_SETCHECK, BST_UNCHECKED, 0); } for ( int i=0; i<4; i++ ) { HWND hListBox = GetDlgItem(hWnd, LB_F1PLAYERS+i); if ( hListBox != NULL ) while ( SendMessage(hListBox, LB_DELETESTRING, 0, 0) != LB_ERR ); } for ( int player=0; player<8; player++ ) { u8 force(0), color(0), race(0), displayOwner(map->getDisplayOwner(player)); if ( map->getPlayerForce(player, force) ) { map->getPlayerColor(player, color); map->getPlayerRace(player, race); std::stringstream ssplayer; ssplayer << "Player " << player+1 << " - " << playerColors.at(color) << " - " << playerRaces.at(race) << " (" << playerOwners.at(displayOwner) << ")"; HWND hListBox = GetDlgItem(hWnd, LB_F1PLAYERS+force); if ( hListBox != NULL ) SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)ssplayer.str().c_str()); } } } }
void MapPropertiesWindow::RefreshWindow() { refreshing = true; if ( CM != nullptr ) { ChkdString mapTitle, mapDescription; CM->getMapTitle(mapTitle); CM->getMapDescription(mapDescription); u16 tileset = CM->getTileset(), currWidth = CM->XSize(), currHeight = CM->YSize(); std::string sCurrWidth(std::to_string(currWidth)); std::string sCurrHeight(std::to_string(currHeight)); editMapTitle.SetText(mapTitle.c_str()); editMapDescription.SetText(mapDescription.c_str()); possibleTitleUpdate = false; possibleDescriptionUpdate = false; dropMapTileset.SetSel(tileset); dropMapTileset.ClearEditSel(); dropNewMapTerrain.SetSel(0); dropNewMapTerrain.ClearEditSel(); editMapWidth.SetText(sCurrWidth.c_str()); editMapHeight.SetText(sCurrHeight.c_str()); for ( int player=0; player<12; player++ ) { u8 displayOwner(CM->GetPlayerOwnerStringIndex(player)), race(0), color(0); CM->getPlayerRace(player, race); dropPlayerOwner[player].SetSel(displayOwner); dropPlayerOwner[player].ClearEditSel(); dropPlayerRaces[player].SetSel(race); dropPlayerRaces[player].ClearEditSel(); if ( player < 8 ) { CM->getPlayerColor(player, color); dropPlayerColor[player].SetSel(0); dropPlayerColor[player].ClearEditSel(); } } } refreshing = false; }
void TeamState::InitHex(const Team& team, const MapPos& pos, int rotation, Map& map) { Race race(team.GetRace()); Hex& hex = map.AddHex(HexPtr(new Hex(race.GetStartSector(team.GetColour()), pos, rotation))); hex.SetColour(team.GetColour()); m_infTrack.RemoveDiscs(1); for (Square* pSquare : hex.GetAvailableSquares(team)) { m_popTrack.Remove(SquareTypeToResource(pSquare->GetType()), 1); pSquare->SetOccupied(true); } ShipType ship = race.GetStartShip(); hex.AddShip(ship, team.GetColour()); RemoveShips(ship, 1); }
void WargearList::fromXml(const QDomElement& ele) throw(XmlParseException) { QDomNodeList list = ele.childNodes(); int len = list.length(); QDomElement current; for(int i = 0; i < len; i++) { current = list.item(i).toElement(); if(!current.isNull()) { if(current.nodeName() == "wargear") { Wargear wg(current, race()); m_wargears.insert(wg.id(), wg); } else throw XmlParseException("invalid wargear list node", current); } } }
int main(int argc, char** argv) { (void) argc; (void) argv; sf::Font MyFont; //MyFont.LoadFromFile("data/Polsku.ttf"); MyFont.LoadFromFile("data/Junicode-Bold.ttf"); // Create main window sf::RenderWindow App(sf::VideoMode(SCREEN_W, SCREEN_H), "DDcar", sf::Style::Fullscreen); App.UseVerticalSync(true); App.SetFramerateLimit(60); //const sf::Input& Input = App.GetInput(); //main menu ? Menu menu(&App,&MyFont); menu.create(); bool quit_game=false; while (!quit_game) { if (menu.show()) { quit_game=true;continue; } //Race race(&App,"data/track2.xml",15); Race race(&App,&MyFont,menu.get_track(),menu.get_rule(),menu.get_nbr_cars()); if (race.run()) { quit_game=true; } } App.Close(); return 0; }
void TeamState::Init(const Team& team, const MapPos& pos, int rotation, Map& map, const std::vector<int>& repTiles) { Race race(team.GetRace()); m_storage = race.GetStartStorage(); m_infTrack.AddDiscs(race.GetStartInfluenceDiscs()); for (TechType t : race.GetStartTechnologies()) m_techTrack.Add(t); for (int i : repTiles) m_repTrack.AddReputationTile(i); for (auto shipType : PlayerShipTypesRange()) m_blueprints[(int)shipType].reset(new Blueprint(team.GetRace(), shipType)); AddShips(ShipType::Interceptor, 8); AddShips(ShipType::Cruiser, 4); AddShips(ShipType::Dreadnought, 2); AddShips(ShipType::Starbase, 4); InitHex(team, pos, rotation, map); }
//les proccessus sont tous lancés en meme temps int main(int argc, char *argv[]){ race(); return 0; }