Ejemplo n.º 1
0
void UpgradeWork::finish(Island* island, const Event& e) {
	Tiles* tiles = island->getTiles();
	tiles->clear_state(e.tile_x,e.tile_y,TS_ACTIVE);
	Tile& t = tiles->get(e.tile_x, e.tile_y);
	++t.level;
	// remove old regular work
	island->removeWork(PT_REGULAR,e.tile_x, e.tile_y);
	// create new
	island->calculateMaxResources();
	Resources tmp;
	if (gContext->price_registry.get(PT_REGULAR, 0, t.building_id, t.level, &tmp)) {
		island->createWork(PT_REGULAR, e.tile_x, e.tile_y, t.building_id, t.level);
	}
}
Ejemplo n.º 2
0
Archivo: vis.cpp Proyecto: amecky/space
	// ------------------------------------------------------
	// describe building
	// ------------------------------------------------------
	bool describe_building(Island* island,int x, int y) {
		Tiles* tiles = island->getTiles();
		int idx = x + y * tiles->width;
		if (tiles->getBuildingID(idx) == -1) {
			gContext->messages.report_error("There is no building at %d %d", x, y);
			return false;
		}
		const Tile& t = tiles->get(x, y);
		printf("Building: %s\n", gContext->building_definitions.getName(t.building_id));
		printf("   Level: %d\n", t.level);
		Resources tmp;
		if (gContext->price_registry.get(PT_REGULAR, 2, t.building_id, t.level, &tmp)) {
			printf("Regular income:\n");
			printf("Duration: %d\n", gContext->price_registry.getDuration(PT_REGULAR, t.building_id, t.level));
			res::show_resources(gContext->resource_registry, tmp, false);
		}
		printf("Available work:\n");
		for (int i = 1; i <= t.level; ++i) {
			if (gContext->price_registry.get(PT_WORK, 0, t.building_id, i, &tmp)) {
				printf(" Level %d\n", i);
				printf("Duration: %d\n", gContext->price_registry.getDuration(PT_WORK, t.building_id, i));
				printf("Costs:\n");
				res::show_resources(gContext->resource_registry, tmp, false);
			}
			if (gContext->price_registry.get(PT_WORK, 1, t.building_id, i, &tmp)) {
				printf("Income:\n");
				Resources collect;
				if (gContext->price_registry.get(PT_WORK, 2, t.building_id, i, &collect)) {
					tmp.add(collect);

				}
				res::show_resources(gContext->resource_registry, tmp, false);
			}
		}
		// FIXME: list start options
		return true;
	}