package MpmasInvestmentsAttachedToLand;

use strict;
use warnings;
use Exporter;
use Storable qw(dclone);
use Data::Dumper;
use MpmasInputfile;
use MpmasInputBlock;
our @ISA = qw(MpmasInputfile);

sub filename {
	return "InvestmentsAttachedToLand";
}
sub required {
	my ($self) = @_;
	return ($self->config_entry("MULTIPERIOD")  || ($self->config_entry("LANDMARKET_MODEL") == 4 && scalar (@{$self->config_entry("LM_assets_with_land")}) > 0)); 
}


sub prepare_special {
	my ($self) = @_;	
	my @AttachedAssets = @{$self->config_entry("LM_assets_with_land")};
	my $block = MpmasInputBlock->new(3,10);
	$block->add_row("THE 'INVESTMENTS ATTACHED TO LAND' FILE");
	$block->add_row("1","INVESTMENTS THAT ARE ATTACHED TO LAND","","");
	$block->add_row("","1.1", "Number of plot capacity layers", $self->config_entry("NUM_PLOT_CAPACITY_LAYERS") || 0);
	$block->add_row("","1.2", "Number of assets", scalar(@AttachedAssets));
	$block->add_empty_rows(1);
	$block->add_comment_row("","","AssetID","ObjectID","Plot capacity layer", "Plot capacity used", "Can be attached to rented land");
	for my $k (@AttachedAssets)
	{
		$block->add_row("", "", $k->id, $k->oid(), $k->attr("plot_capacity_layer"), $k->attr("plot_capacity_used"), $k->attr("can_be_attached_to_rented_land"), $k->attr("compensation_when_returning_with_rented_land") );
	}
	$self->add_block($block);
}
1;
