package panzer.commands;

import panzer.contracts.BattleOperator;
import panzer.contracts.Manager;
import panzer.contracts.Vehicle;
import panzer.factories.PartFactory;
import panzer.factories.VehicleFactory;

import java.math.BigDecimal;
import java.util.List;

public class VehicleCommand extends Command {
public VehicleCommand(BattleOperator battleOperator, Manager manager, PartFactory partFactory, VehicleFactory vehicleFactory, List arguments) {
super(battleOperator, manager, partFactory, vehicleFactory, arguments);
}

@Override
public String execute() {
String vehicleType = super.getArguments().get(1);
String vehicleModel = super.getArguments().get(2);
double vehicleWeight = Double.parseDouble(super.getArguments().get(3));
BigDecimal vehiclePrice = new BigDecimal(super.getArguments().get(4));
int vehicleAttack = Integer.parseInt(super.getArguments().get(5));
int vehicleDefense = Integer.parseInt(super.getArguments().get(6));
int vehicleHitPoints = Integer.parseInt(super.getArguments().get(7));

Vehicle vehicle = super.getVehicleFactory().createVehicle(vehicleType, vehicleModel,
vehicleWeight, vehiclePrice, vehicleAttack, vehicleDefense, vehicleHitPoints);
super.getManager().addVehicle(vehicle);

return String.format(“Created %s Vehicle – %s”, vehicleType, vehicleModel);
}
}