/// Eine bestellte Ware konnte doch nicht kommen
void nobHarborBuilding::WareLost(Ware * ware)
{
	// ggf. neue Waren für Expedition bestellen
	if(expedition.active && (ware->type == GD_BOARDS || ware->type == GD_STONES))
		OrderExpeditionWares();
	RemoveDependentWare(ware);
}
示例#2
0
/// Startet eine Expedition oder stoppt sie, wenn bereits eine stattfindet
void nobHarborBuilding::StartExpedition()
{
    // Schon eine Expedition gestartet?
    if(expedition.active)
    {
        StopExpedition();
        return;
    }

    // Initialisierung
    expedition.active = true;

    // In unseren Warenbestand gucken und die erforderlichen Bretter und Steine sowie den
    // Bauarbeiter holen, falls vorhanden
    expedition.boards = std::min(unsigned(BUILDING_COSTS[nation][BLD_HARBORBUILDING].boards), inventory[GD_BOARDS]);
    expedition.stones = std::min(unsigned(BUILDING_COSTS[nation][BLD_HARBORBUILDING].stones), inventory[GD_STONES]);
    inventory.Remove(GD_BOARDS, expedition.boards);
    inventory.Remove(GD_STONES, expedition.stones);

    if(inventory[JOB_BUILDER])
    {
        expedition.builder = true;
        inventory.Remove(JOB_BUILDER);
    }
    else
    {
        bool convert = true;
        expedition.builder = false;
        //got a builder in ANY storehouse?
        GameClientPlayer& owner = gwg->GetPlayer(player);
        for(std::list<nobBaseWarehouse*>::const_iterator it = owner.GetStorehouses().begin(); it != owner.GetStorehouses().end(); ++it)
        {
            if((*it)->GetRealFiguresCount(JOB_BUILDER))
            {
                convert = false;
                break;
            }
        }
        if(convert && inventory[GD_HAMMER] && inventory[JOB_HELPER] > 1) //maybe have a hammer & helper to create our own builder?
        {
            inventory.Remove(GD_HAMMER);
            owner.DecreaseInventoryWare(GD_HAMMER, 1);
            inventory.Remove(JOB_HELPER);
            owner.DecreaseInventoryJob(JOB_HELPER, 1);

            owner.IncreaseInventoryJob(JOB_BUILDER, 1);
            expedition.builder = true;
        }
        // not in harbor, and didnt have to or couldnt convert so order a builder
        if(!expedition.builder)
            owner.AddJobWanted(JOB_BUILDER, this);
    }

    // Ggf. Waren bestellen, die noch fehlen
    OrderExpeditionWares();

    // Ggf. ist jetzt alles benötigte schon da
    // Dann Schiff rufen
    CheckExpeditionReady();
}
示例#3
0
/// Eine bestellte Ware konnte doch nicht kommen
void nobHarborBuilding::WareLost(Ware* ware)
{
    RTTR_Assert(!IsBeingDestroyedNow());
    // ggf. neue Waren für Expedition bestellen
    if(expedition.active && (ware->type == GD_BOARDS || ware->type == GD_STONES))
        OrderExpeditionWares();
    nobBaseWarehouse::WareLost(ware);
}
/// Startet eine Expedition oder stoppt sie, wenn bereits eine stattfindet
void nobHarborBuilding::StartExpedition()
{
	// Schon eine Expedition gestartet?
	if(expedition.active)
	{
		// Dann diese stoppen
		expedition.active = false;

		// Waren zurücktransferieren
		real_goods.goods[GD_BOARDS] += expedition.boards;
		goods.goods[GD_BOARDS] += expedition.boards;
		real_goods.goods[GD_STONES] += expedition.stones;
		goods.goods[GD_STONES] += expedition.stones;

		if(expedition.builder)
		{
			++real_goods.people[JOB_BUILDER];
			++goods.people[JOB_BUILDER];
			// Evtl. Abnehmer für die Figur wieder finden
			gwg->GetPlayer(player)->FindWarehouseForAllJobs(JOB_BUILDER);
		}

		return;
	}

	// Initialisierung
	expedition.active = true;
	
	// In unseren Warenbestand gucken und die erforderlichen Bretter und Steine sowie den 
	// Bauarbeiter holen, falls vorhanden
	expedition.boards = min(unsigned(BUILDING_COSTS[nation][BLD_HARBORBUILDING].boards), real_goods.goods[GD_BOARDS]);
	expedition.stones = min(unsigned(BUILDING_COSTS[nation][BLD_HARBORBUILDING].stones), real_goods.goods[GD_STONES]);
	real_goods.goods[GD_BOARDS] -= expedition.boards;
	goods.goods[GD_BOARDS] -= expedition.boards;
	real_goods.goods[GD_STONES] -= expedition.stones;
	goods.goods[GD_STONES] -= expedition.stones;

	if(real_goods.people[JOB_BUILDER])
	{
		expedition.builder = true;
		--real_goods.people[JOB_BUILDER];
		--goods.people[JOB_BUILDER];
	}
	else
	{
		expedition.builder = false;
		// Bauarbeiter bestellen
		gwg->GetPlayer(player)->AddJobWanted(JOB_BUILDER,this);
	}

	// Ggf. Waren bestellen, die noch fehlen
	OrderExpeditionWares();
	
	// Ggf. ist jetzt alles benötigte schon da
	// Dann Schiff rufen
	CheckExpeditionReady();

}
void nobHarborBuilding::HandleEvent(const unsigned int id)
{
	switch(id)
	{
	// Waren-Bestell-Event
	case 10:
		{
			this->orderware_ev = NULL;
			// Mal wieder schauen, ob es Waren für unsere Expedition gibt
			OrderExpeditionWares();
		} break;
	default: HandleBaseEvent(id);
	}
}