/// Prüft, ob eine Expedition von den Waren her vollständig ist und ruft ggf. das Schiff void nobHarborBuilding::CheckExpeditionReady() { // Alles da? // Dann bestellen wir mal das Schiff if(IsExpeditionReady()) OrderShip(); }
/// Fügt einen Schiffs-Angreifer zum Hafen hinzu void nobHarborBuilding::AddSeaAttacker(nofAttacker * attacker) { unsigned best_distance = 0xffffffff; unsigned best_harbor_point = 0xffffffff; std::vector<unsigned> harbor_points; gwg->GetHarborPointsAroundMilitaryBuilding(attacker->GetAttackedGoal()->GetX(),attacker->GetAttackedGoal()->GetY(), &harbor_points); for(unsigned i = 0;i<harbor_points.size();++i) { unsigned tmp_distance = gwg->CalcHarborDistance(this->GetHarborPosID(),harbor_points[i]); if(tmp_distance < best_distance) { best_distance = tmp_distance; best_harbor_point = harbor_points[i]; } } // no harbor point found? tell attacker that the goal has been destroyed. if (best_harbor_point == 0xffffffff) { // TODO: true or false? AddFigure(attacker, false); attacker->AttackedGoalDestroyed(); return; } SoldierForShip sfs = { attacker, gwg->GetHarborPoint(best_harbor_point) }; soldiers_for_ships.push_back(sfs); OrderShip(); ++goods.people[attacker->GetJobType()]; }
/// Fügt einen Schiffs-Angreifer zum Hafen hinzu void nobHarborBuilding::AddSeaAttacker(nofAttacker* attacker) { unsigned best_distance = 0xffffffff; unsigned best_harbor_point = 0xffffffff; RTTR_Assert(attacker->GetAttackedGoal()); std::vector<unsigned> harbor_points = gwg->GetHarborPointsAroundMilitaryBuilding(attacker->GetAttackedGoal()->GetPos()); for(unsigned i = 0; i < harbor_points.size(); ++i) { unsigned tmp_distance = gwg->CalcHarborDistance(this->GetHarborPosID(), harbor_points[i]); if(tmp_distance < best_distance) { best_distance = tmp_distance; best_harbor_point = harbor_points[i]; } } // no harbor to target (should not happen) or no target (might happen very very rarely not sure) if (best_harbor_point == 0xffffffff) { // notify target about noShow, notify home that soldier wont return, add to inventory attacker->SeaAttackFailedBeforeLaunch(); //set state, remove target & home RTTR_Assert(!attacker->GetAttackedGoal()); RTTR_Assert(attacker->HasNoHome()); RTTR_Assert(attacker->HasNoGoal()); AddFigure(attacker, true); return; } SoldierForShip sfs = { attacker, gwg->GetHarborPoint(best_harbor_point) }; soldiers_for_ships.push_back(sfs); inventory.visual.Add(attacker->GetJobType()); OrderShip(); }
/// Fügt einen Mensch hinzu, der mit dem Schiff irgendwo hin fahren will void nobHarborBuilding::AddFigureForShip(noFigure * fig, Point<MapCoord> dest) { FigureForShip ffs = { fig, dest }; figures_for_ships.push_back(ffs); OrderShip(); // Anzahl visuell erhöhen ++goods.people[fig->GetJobType()]; }
/// Fügt eine Ware hinzu, die mit dem Schiff verschickt werden soll void nobHarborBuilding::AddWareForShip(Ware * ware) { wares_for_ships.push_back(ware); // Anzahl visuell erhöhen ++goods.goods[ConvertShields(ware->type)]; ware->WaitForShip(this); OrderShip(); }
/// Fügt einen Mensch hinzu, der mit dem Schiff irgendwo hin fahren will void nobHarborBuilding::AddFigureForShip(noFigure* fig, MapPoint dest) { RTTR_Assert(!helpers::contains(gwg->GetFigures(fig->GetPos()), fig)); // Figure is in the harbor, so it cannot be outside FigureForShip ffs = { fig, dest }; figures_for_ships.push_back(ffs); // Anzahl visuell erhöhen inventory.visual.Add(fig->GetJobType()); OrderShip(); }
/// Fügt eine Ware hinzu, die mit dem Schiff verschickt werden soll void nobHarborBuilding::AddWareForShip(Ware*& ware) { wares_for_ships.push_back(ware); // Anzahl visuell erhöhen inventory.visual.Add(ConvertShields(ware->type)); ware->WaitForShip(this); OrderShip(); // Take ownership ware = NULL; }
/// Prüft, ob eine Expedition von den Spähern her vollständig ist und ruft ggf. das Schiff void nobHarborBuilding::CheckExplorationExpeditionReady() { if ((exploration_expedition.scouts < SCOUTS_EXPLORATION_EXPEDITION) && (exploration_expedition.scouts + real_goods.people[JOB_SCOUT] >= SCOUTS_EXPLORATION_EXPEDITION)) { real_goods.people[JOB_SCOUT] -= SCOUTS_EXPLORATION_EXPEDITION - exploration_expedition.scouts; exploration_expedition.scouts = SCOUTS_EXPLORATION_EXPEDITION; } // Alles da? // Dann bestellen wir mal das Schiff if(IsExplorationExpeditionReady()) OrderShip(); }
/// Schiff konnte nicht mehr kommen void nobHarborBuilding::ShipLost(noShip * ship) { // Neues Schiff bestellen OrderShip(); }