-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a8697e
commit a9247e9
Showing
18 changed files
with
1,202 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { Player } from '../laba3CreatingPlayer'; | ||
import { Logs } from '../laba3Logs'; | ||
|
||
export class Archer extends Player { | ||
abilities: string[] = ['Огненные стрелы', 'Ледяные стрелы']; | ||
private fireArrowsUsed: boolean = false; | ||
private iceArrowsUsed: number = 0; | ||
private fireArrowsDuration: number = 0; | ||
private iceArrowsDuration: number = 0; | ||
|
||
constructor(name: string, strength: number, health: number) { | ||
super(name, strength, health); | ||
} | ||
|
||
// Метод для сброса состояния огненных стрел | ||
public resetFireArrowsUsed(): void { | ||
this.fireArrowsUsed = false; | ||
this.fireArrowsDuration = 0; | ||
} | ||
|
||
// Метод для сброса состояния ледяных стрел | ||
public resetIceArrowsUsed(): void { | ||
this.iceArrowsUsed = 0; | ||
this.iceArrowsDuration = 0; | ||
} | ||
|
||
useAbility(target: Player, logs: Logs): void { | ||
const ability = this.getSelectedAbility(); | ||
if (!ability) return; | ||
|
||
const baseDamage = this.getStrength(); | ||
target.takeDamage(baseDamage); | ||
|
||
logs.logAbility( | ||
this, | ||
ability, | ||
target, | ||
`и наносит ${baseDamage} основного урона. ${target.getName()} теряет 3 единицы жизни следующие 2 хода`, | ||
); | ||
|
||
if (ability === 'Огненные стрелы' && !this.fireArrowsUsed) { | ||
this.fireArrowsUsed = true; | ||
this.fireArrowsDuration = 3; | ||
} else if (ability === 'Ледяные стрелы' && this.iceArrowsUsed < 2) { | ||
this.iceArrowsUsed++; | ||
this.iceArrowsDuration = 3; | ||
} | ||
} | ||
|
||
applyAbilityEffects(target: Player, logs: Logs): void { | ||
this.applyArrowEffect(target, logs, 'Огненные стрелы', this.fireArrowsUsed, this.fireArrowsDuration); | ||
this.applyArrowEffect(target, logs, 'Ледяные стрелы', this.iceArrowsUsed > 0, this.iceArrowsDuration); | ||
|
||
if (this.fireArrowsDuration > 0) this.fireArrowsDuration--; | ||
if (this.iceArrowsDuration > 0) this.iceArrowsDuration--; | ||
} | ||
|
||
private applyArrowEffect(target: Player, logs: Logs, arrowType: string, isUsed: boolean, duration: number): void { | ||
if (isUsed && duration > 0) { | ||
const damage = 3; | ||
target.takeDamage(damage); | ||
logs.logDamageOverTime(target, damage, arrowType); | ||
} | ||
} | ||
|
||
public setStrength(strength: number): void { | ||
if (strength >= 15 && strength <= 70) { | ||
super.setStrength(strength); | ||
} else { | ||
throw new Error('Strength for Archer must be between 15 and 70'); | ||
} | ||
} | ||
|
||
public setHealth(health: number): void { | ||
if (health >= 60 && health <= 180) { | ||
super.setHealth(health); | ||
} else { | ||
throw new Error('Health for Archer must be between 60 and 180'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Player } from '../laba3CreatingPlayer'; | ||
import { Logs } from '../laba3Logs'; | ||
|
||
export class Knight extends Player { | ||
abilities: string[] = ['Короночка']; | ||
private abilityUsed: boolean = false; | ||
|
||
public resetAbilityUsed(): void { | ||
this.abilityUsed = false; | ||
} | ||
|
||
useAbility(target: Player, logs: Logs): void { | ||
const ability = this.getSelectedAbility(); | ||
if (!ability) return; | ||
|
||
if (ability === 'Короночка' && !this.abilityUsed) { | ||
const damage = Math.round(this.getStrength() * 1.5); | ||
target.takeDamage(damage); | ||
this.abilityUsed = true; | ||
logs.logAbility(this, ability, target, `который получает ${damage} урона`); | ||
this.setSelectedAbility(null); // Сбрасываем выбранную способность | ||
} | ||
} | ||
public setStrength(strength: number): void { | ||
if (strength >= 20 && strength <= 100) { | ||
super.setStrength(strength); | ||
} else { | ||
throw new Error('Strength for Knight must be between 20 and 100'); | ||
} | ||
} | ||
public setHealth(health: number): void { | ||
if (health >= 80 && health <= 200) { | ||
super.setHealth(health); | ||
} else { | ||
throw new Error('Health for Knight must be between 80 and 200'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Player } from '../laba3CreatingPlayer'; | ||
import { Logs } from '../laba3Logs'; | ||
|
||
export class Mage extends Player { | ||
abilities: string[] = ['Оглушение', 'Лечение']; | ||
private abilityUsed: boolean = false; | ||
|
||
public resetAbilityUsed(): void { | ||
this.abilityUsed = false; | ||
} | ||
|
||
useAbility(target: Player, logs: Logs): void { | ||
const ability = this.getSelectedAbility(); // Используем выбранную способность | ||
if (!ability) return; | ||
|
||
if (ability === 'Оглушение' && !this.abilityUsed) { | ||
target.setStunDuration(2); // Устанавливаем длительность оглушения на 2 хода | ||
target.setIsStunned(true); // Применяем оглушение | ||
this.abilityUsed = true; | ||
logs.logAbility(this, ability, target, 'будет оглушен на 2 хода'); | ||
|
||
// Маг сразу атакует после применения оглушения | ||
this.attack(target, logs); | ||
} else if (ability === 'Лечение') { | ||
const healAmount = 20; | ||
this.setHealth(this.getHealth() + healAmount); | ||
logs.logHeal(this, healAmount); // Логируем лечение | ||
} | ||
} | ||
|
||
takeDamage(damage: number): void { | ||
super.takeDamage(damage); // Всегда наносим урон, независимо от оглушения | ||
} | ||
|
||
public setStrength(strength: number): void { | ||
if (strength >= 10 && strength <= 50) { | ||
super.setStrength(strength); | ||
} else { | ||
throw new Error('Strength for Mage must be between 10 and 50'); | ||
} | ||
} | ||
|
||
public setHealth(health: number): void { | ||
if (health >= 50 && health <= 150) { | ||
super.setHealth(health); | ||
} else { | ||
throw new Error('Health for Mage must be between 50 and 150'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.