30 lines
543 B
TypeScript
30 lines
543 B
TypeScript
export const BarcoTipo = Object.freeze({
|
|
FRAGATA: 1,
|
|
DESTRUCTOR: 2,
|
|
ACORAZADO: 3,
|
|
PORTAAVIONES: 4,
|
|
});
|
|
|
|
export default class Barco {
|
|
constructor(
|
|
public id: number,
|
|
public x: number,
|
|
public y: number,
|
|
public longitud: number,
|
|
public orientacion: string,
|
|
public impactos: number = 0,
|
|
public destruido = false,
|
|
) {}
|
|
|
|
recibirImpacto() {
|
|
this.impactos++;
|
|
if (this.impactos >= this.longitud) {
|
|
this.destruido = true;
|
|
}
|
|
}
|
|
|
|
haSidoDestruido(): boolean {
|
|
return this.destruido;
|
|
}
|
|
}
|