Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercicios/entregas/exemplo-mariana-seidel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
50 changes: 50 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Equipment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class Equipments {
equipments = [];

choseEquipments() {
this.equipments = [];
this.handEquipments = [];
}

addHandsEquipment(equipment) {
if (this.equipments.length < 2) {
this.handEquipments.push(equipment)
return `Você pegou ${equipment}!`
} else {
'Suas mãos estão cheias!'
}
}

reduceEquipment(equipment) {
for (let i = this.totalInjuries; i < 3; i++) {
equipments = this.equipments.filter(item => item != equipment);
this.equipments = equipments;
}

if (this.equipments.length > 7) {
const diference = this.equipments.length - 7;
return `Você possui mais equipamentos do que sua capacidade de armanezamento! Descarte ${diference} itens.`
}
}
}

class CombateItems extends Equipments {
combate = [
'bastão de baseball',
'frigideira',
'machado',
'pistola'
];
}

class UtilitarianItems extends Equipments {
utilitarian = [
'garrafa de água',
'comida',
'kit de primeiros socorros'
];
}

module.exports = { Equipments }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mariana do céu, estou aplaudindo o seu código. Genial sua sacada de criar uma classe equipamentos e duas classes de tipos específicos de equipamentos herdando da genérica, uau!!


30 changes: 30 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
let { Survivor } = require('./Survivor')

class Level {
level;
experience;

constructor(survivor) {
this.level = survivor.level;
if (!survivor.level === 'Blue') {
survivor.level === this.level
}
this.experience = survivor.experience;
}

changeLevel() {
if (this.experience >= 42) {
this.level = 'Red'
return `Seu nível é: ${this.level}.`
} else if (this.experience >= 18 && this.experience < 42) {
this.level = 'Orange'
return `Seu nível é: ${this.level}.`
} else if (this.experience >= 6) {
this.level = 'Yellow'
return `Seu nível é: ${this.level}.`
}
}
}

module.exports = { Level }

26 changes: 26 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Level.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
let { Level } = require('./Level');
let { Survivor } = require('./Survivor');

describe('verify level class', () => {

let level, survivor;

beforeEach(() => {
level = new Level(survivor);
survivor = new Survivor();
})

it('should check the experience when de surviver begings the match', () => {
expect(survivor.experience).toBe(0);
});

it('should check the level when de surviver begings the match', () => {
expect(survivor.level).toBe('Blue');
});

it('should check the function changeLevel', () => {
survivor.experience = 19;
expect(level.changeLevel()).toBe('Seu nível é: Orange.');
});

})
43 changes: 43 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Match.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
let { Survivor } = require('./Survivor')

class Match {
survivors;
level;

constructor() {
this.survivors = Survivor.allSurvivors.length
if (this.survivors === 0) {
return `Fim do jogo!`
}

const filterLevel = Survivor.allSurvivors.filter((element) => {
if (element === 'Red') {
return element.level
} else if (element === 'Orange') {
return element.level
} else if (element.level === 'Yellow') {
return element.level
} else {
return element.level
}
})

this.level = filterLevel;
}

addSurvivors(newPlayers) {
if (!(newPlayers instanceof Survivor)) {
return 'Insira um jogador válido.'
}
return Survivor.allSurvivors
}
}

module.exports = { Match }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adorei essa classe!! Seu código está super limpo e fácil de entender!!







26 changes: 26 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Match.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { Match } = require('./Match');
const { Survivor } = require('./Survivor');

describe('verify match class', () => {

let match1;

beforeEach(() => {
match1 = new Match();
})

it('should check a match when there is not survivers', () => {
expect(match1).toBe('Fim do jogo!');
});

it('should check add players when the parameter is not a survivor object', () => {
const player1 = 'player1';
expect(match1.addSurvivors(player1)).toBe('Insira um jogador válido.');
});

it('should check add players', () => {
const player1 = new Survivor('player1');
match1.addSurvivors(player1);
expect(match1.survivors).toBe(1);
});
})
33 changes: 33 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Skill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
let { Level } = require('./Level')

class Skill {
skillTree;
potencialSkills = ['+1 Dano',
'Tesouro escondido',
'+1 Ação de Movimento',
'+1 equipamento em mãos',
'+1 vida'];
unlockedSkills = ['+1 Ação'];

skills() {
switch (this.level) {
case 'Yellow':
this.skillTree = 1;
break;
case 'Orange':
this.skillTree = 2;
break;
case 'Red':
this.skillTree = 3;
break;
}
}

unlockedSkills() {
if (this.level === 'Yellow') {
this.skillTree.push(unlockedSkills[0]);
}
}
}

module.exports = { Skill }
41 changes: 41 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Survivor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Survivor {
name;
totalInjuries;
actions = 3;
equipment = {};
level = 'Blue';
experience = 0;
skillTree = [];

static allSurvivors = [];

constructor(name) {
this.name = name;
this.totalInjuries = 0;
this.constructor.allSurvivors.push({ survivor: this });
}

injuries() {
this.totalInjuries++;

if (this.totalInjuries >= 3) {
return 'Fim do jogo. Você morreu!'
} else {
return `Cuidado, você possui o total de ${this.totalInjuries} ferimento(s)!`
}
}

killZumbi() {
this.experience += 1;
return 'Zumbi morto!'
}

endGame(){
if(this.experience === 150){
return `Fim do jogo!`
}
}
}

module.exports = { Survivor }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ficou muito bom o seu código, a lógica está clara e sua classe tá sensacional. Estou com vergonha da minha classe depois que vi a sua kkkk parabéns, está muito bom mesmo!!

53 changes: 53 additions & 0 deletions exercicios/entregas/exemplo-mariana-seidel/Survivor.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const { Survivor } = require('./Survivor')

describe('verify survivor class', () => {

let survivor1, survivor2;

beforeEach(() => {
survivor1 = new Survivor();
survivor2 = new Survivor();
})

it('should check when the survivor suffers an injury', () => {
expect(survivor1.injuries()).toBe('Cuidado, você possui o total de 1 ferimento(s)!');
})

it('should check when the survivor suffers 03 injuries and die', () => {
survivor1.injuries();
survivor1.injuries();
expect(survivor1.injuries()).toBe('Fim do jogo. Você morreu!');
})

it('should check when the survivor kill a zumbi', () => {
expect(survivor1.killZumbi()).toBe('Zumbi morto!');
expect(survivor1.experience).toBe(1);
})

it('should check a list of survivors with the static variable', () => {
survivor1.name = 'Ellie';
survivor2.name = 'Joel';
expect(Survivor.allSurvivors).toBe(`[{
survivor: Survivor {
name: 'Ellie',
totalInjuries: 0,
actions: 3,
equipment: {},
level: 'blue',
experience: 0,
skillTree: []
}
},
{
survivor: Survivor {
name: 'Joel',
totalInjuries: 0,
actions: 3,
equipment: {},
level: 'blue',
experience: 0,
skillTree: []
}
}]`);
})
})
Loading