Skip to content

Commit

Permalink
Switch between more vehicle types in desktop client
Browse files Browse the repository at this point in the history
  • Loading branch information
daveajlee committed Oct 31, 2023
1 parent 9a5d119 commit 123b7f3
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions desktop/src/app/vehicleshowroom/vehicleshowroom.component.ts
Expand Up @@ -3,6 +3,7 @@ import {VehicleModel} from "../vehicles/vehiclemodel.model";
import {GameService} from "../shared/game.service";
import {Router} from "@angular/router";
import {DatePipe} from "@angular/common";
import {Vehicle} from "../vehicles/vehicle.model";

@Component({
selector: 'app-vehicleshowroom',
Expand All @@ -25,7 +26,10 @@ export class VehicleshowroomComponent {
*/
constructor(private gameService2: GameService, public router: Router, private datePipe: DatePipe) {
this.gameService = gameService2;
this.models = [new VehicleModel('MyBus Single Decker', 44, 36, 85000.0, 'assets/Bus.jpg')];
this.models = [new VehicleModel('MyBus Single Decker', 'Single Decker Bus', 44, 36, 85000.0, 'assets/singledecker-bus-pixabay.png'),
new VehicleModel('MyBus Double Decker', 'Double Decker Bus', 78, 25,160000, 'assets/doubledecker-bus-pixabay.png' ),
new VehicleModel('MyBus Bendy', 'Bendy Bus', 48, 97, 190000, 'assets/bendybus-albertstoynov-unsplash.jpg'),
new VehicleModel('MyTram Tram 1', 'Tram',104, 83, 280000, 'assets/tram-pixabay.png')];
this.currentDisplay = 0;
this.quantity = 1;
this.currentDate = new Date();
Expand Down Expand Up @@ -65,7 +69,23 @@ export class VehicleshowroomComponent {
}

onPurchaseVehicle(): void {
alert('Coming Soon!');
// First we determine the next fleet number,
var vehicles = this.gameService.getGame().vehicles;
var highestFleetNumberSoFar = 0;
for ( var i = 0; i < vehicles.length; i++ ) {
if ( parseInt(vehicles[i].fleetNumber) > highestFleetNumberSoFar ) {
highestFleetNumberSoFar = parseInt(vehicles[i].fleetNumber);
}
}
const additionalProps = new Map<string, string>();
additionalProps.set('Model', this.getVehicleType());
additionalProps.set('Age', '0 months');
additionalProps.set('Standing Capacity', '' + this.getVehicleStandingCapacity());
additionalProps.set('Seating Capacity', '' + this.getVehicleSeatingCapacity());
additionalProps.set('Value', '' + this.getVehiclePurchasePrice());
this.gameService.getGame().addVehicle(new Vehicle('' + (highestFleetNumberSoFar+1), this.models[this.currentDisplay].modelType, '',
'', '', 0, additionalProps));
this.router.navigate(['management']);
}

backToManagementScreen(): void {
Expand All @@ -80,4 +100,11 @@ export class VehicleshowroomComponent {
return (this.currentDisplay + 1) >= this.models.length;
}

moveToPreviousVehicleType(): void {
this.currentDisplay -= 1;
}
moveToNextVehicleType(): void {
this.currentDisplay += 1;
}

}

0 comments on commit 123b7f3

Please sign in to comment.