Skip to content

Commit

Permalink
Add enemies
Browse files Browse the repository at this point in the history
  • Loading branch information
andredarcie committed Jun 20, 2021
1 parent 08c3e2d commit 7bd81ae
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 30 deletions.
32 changes: 32 additions & 0 deletions src/entities/Enemy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Difficulties } from "../enums/Difficulties";
import { EnemyTypes } from "../seeds/EnemySeeds";

export class Enemy {
private _name: string;
private _type: EnemyTypes;
private _attack: Difficulties;
private _runAway: Difficulties;
private _timesThatAppears: number;
private _imageUrl: string;

constructor(name: string, type: EnemyTypes, attack: Difficulties, runAway: Difficulties, timesThatAppears: number, imageUrl: string = '') {
this._name = name;
this._type = type;
this._attack = attack;
this._runAway = runAway;
this._timesThatAppears = timesThatAppears;
this._imageUrl = imageUrl;
}

get name(): string {
return this._name;
}

get attack(): Difficulties {
return this._attack;
}

get runAway(): Difficulties {
return this._runAway;
}
}
55 changes: 55 additions & 0 deletions src/seeds/EnemySeeds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Enemy } from '../entities/Enemy';
import { Difficulties } from '../enums/Difficulties';

export enum EnemyTypes {
WildAnimal,
Human,
Supernatural
}

export class EnemySeeds {
public static enemies: Enemy[] = [
// Wild Animals
new Enemy('Angry dog', EnemyTypes.WildAnimal, Difficulties.CHALLENGING, Difficulties.VERY_HARD, 3, 'https://pixabay.com/photos/dog-angry-aggressive-white-black-5287546/'),
new Enemy('Wild dog', EnemyTypes.WildAnimal, Difficulties.MEDIUM, Difficulties.CHALLENGING, 3, 'https://pixabay.com/photos/dog-angry-rage-violent-furious-486550/'),
new Enemy('Hungry wild wolf', EnemyTypes.WildAnimal, Difficulties.VERY_HARD, Difficulties.CHALLENGING, 1, 'https://pixabay.com/photos/wolf-predator-hunter-canis-lupus-635063/'),
new Enemy('Swarm of bees', EnemyTypes.WildAnimal, Difficulties.IMPOSSIBILE, Difficulties.CHALLENGING, 1, 'https://pixabay.com/photos/bees-insects-macro-honey-bees-276190/'),
new Enemy('Cloud of insects', EnemyTypes.WildAnimal, Difficulties.IMPOSSIBILE, Difficulties.MEDIUM, 1),
new Enemy('Hungry fox', EnemyTypes.WildAnimal, Difficulties.CHALLENGING, Difficulties.MEDIUM, 1),
new Enemy('Brown bear', EnemyTypes.WildAnimal, Difficulties.VERY_HARD, Difficulties.VERY_HARD, 1),
new Enemy('Amur tiger', EnemyTypes.WildAnimal, Difficulties.IMPOSSIBILE, Difficulties.VERY_HARD, 1, 'https://pixabay.com/photos/tiger-animal-roar-fangs-angry-5946115/'),
new Enemy('Grey wolf', EnemyTypes.WildAnimal, Difficulties.VERY_HARD, Difficulties.CHALLENGING, 1),
new Enemy('White bear', EnemyTypes.WildAnimal, Difficulties.VERY_HARD, Difficulties.CHALLENGING, 1),
new Enemy('Wild boar', EnemyTypes.WildAnimal, Difficulties.MEDIUM, Difficulties.EASY, 1),
new Enemy('Northern viper', EnemyTypes.WildAnimal, Difficulties.MEDIUM, Difficulties.EASY, 1),
new Enemy('Eurasian Lynx', EnemyTypes.WildAnimal, Difficulties.CHALLENGING, Difficulties.MEDIUM, 1),
new Enemy('Deer', EnemyTypes.WildAnimal, Difficulties.MEDIUM, Difficulties.EASY, 3),
new Enemy('Siberian Tiger', EnemyTypes.WildAnimal, Difficulties.IMPOSSIBILE, Difficulties.VERY_HARD, 1),
new Enemy('Wild Boar', EnemyTypes.WildAnimal, Difficulties.VERY_HARD, Difficulties.MEDIUM, 3),
new Enemy('Deformed rats', EnemyTypes.WildAnimal, Difficulties.MEDIUM, Difficulties.EASY, 3),
new Enemy('Flock of crows', EnemyTypes.WildAnimal, Difficulties.VERY_HARD, Difficulties.EASY, 2),
new Enemy('Locust cloud', EnemyTypes.WildAnimal, Difficulties.IMPOSSIBILE, Difficulties.TRIVIAL, 2),
new Enemy('Swarm of flies', EnemyTypes.WildAnimal, Difficulties.IMPOSSIBILE, Difficulties.MEDIUM, 2),
new Enemy('Pigs with worms in the body', EnemyTypes.WildAnimal, Difficulties.VERY_HARD, Difficulties.CHALLENGING, 1),
// Humans
new Enemy('Sick human', EnemyTypes.Human, Difficulties.MEDIUM, Difficulties.EASY, 3),
new Enemy('Thief with ax', EnemyTypes.Human, Difficulties.VERY_HARD, Difficulties.CHALLENGING, 1),
new Enemy('Militia hunter', EnemyTypes.Human, Difficulties.IMPOSSIBILE, Difficulties.CHALLENGING, 1),
new Enemy('Man crawling with a knife', EnemyTypes.Human, Difficulties.VERY_HARD, Difficulties.MEDIUM, 1),
new Enemy('Two militia hunters', EnemyTypes.Human, Difficulties.IMPOSSIBILE, Difficulties.VERY_HARD, 1),
// Supernatural
new Enemy('Dark figure', EnemyTypes.Supernatural, Difficulties.IMPOSSIBILE, Difficulties.TRIVIAL, 2),
new Enemy('Woman with two faces', EnemyTypes.Supernatural, Difficulties.VERY_HARD, Difficulties.CHALLENGING, 1),
new Enemy('Eyeless creature', EnemyTypes.Supernatural, Difficulties.IMPOSSIBILE, Difficulties.MEDIUM, 1),
new Enemy('Anomaly', EnemyTypes.Supernatural, Difficulties.IMPOSSIBILE, Difficulties.MEDIUM, 3),
new Enemy('Ghost', EnemyTypes.Supernatural, Difficulties.IMPOSSIBILE, Difficulties.EASY, 4),
];

public static getOneRandomEnemy(): Enemy {
return EnemySeeds.enemies[EnemySeeds.getRandomArbitrary(0, EnemySeeds.enemies.length)];
}

private static getRandomArbitrary(min: number, max: number) {
return Math.floor(Math.random() * (max - min) + min);
}
}
38 changes: 8 additions & 30 deletions src/seeds/EventSeeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Game } from '../Game';
import { LogType } from '../managers/LogManager';
import { Skills } from '../enums/Skills';
import { Difficulties } from '../enums/Difficulties';
import { EnemySeeds } from './EnemySeeds';
import { Enemy } from '../entities/Enemy';

export class EventSeeds {
private _events: Event[];
Expand Down Expand Up @@ -206,31 +208,7 @@ export class EventSeeds {
}

public getCombatEvent() {
const possibleEnemies = [
'Mad Dog',
'Wild dog',
'Pack of hounds',
'Hungry wild wolf',
'Swarm of bees',
'Cloud of insects',
'Sick human',
'Hungry fox',
'Dark figure',
'Woman with two faces',
'Thief with ax',
'Militia hunter',
'Two militia hunters',
'Deformed rats',
'Flock of crows',
'Pack of wolves',
'Locust cloud',
'Swarm of flies',
'Pigs with worms in the body',
'Eyeless creature',
'Man crawling with a knife'
];

const enemy = possibleEnemies[Math.floor(Math.random() * possibleEnemies.length)];
const enemy: Enemy = EnemySeeds.getOneRandomEnemy();

const possibleQuotes = [
'Approaches more and more with an aggressive posture.',
Expand All @@ -244,20 +222,20 @@ export class EventSeeds {
const quote = possibleQuotes[Math.floor(Math.random() * possibleQuotes.length)];

return new Event(
enemy,
enemy.name,
'Conflict',
quote,
'2',
[{
buttonText: 'Attack',
skillCheck: true,
skillCheckFields: {
difficulty: this._game.getRandomArbitrary(6),
difficulty: enemy.attack,
skillToCheck: Skills.STRENGTH,
canGiveItems: false,
resultPath: {
success: () => {
this._game.log.addTempLog('You managed to scare the ' + enemy.toLowerCase() + ' and run away.', LogType.Result);
this._game.log.addTempLog('You managed to scare the ' + enemy.name.toLowerCase() + ' and run away.', LogType.Result);
},
failure: () => {
this._game.characterManager.decreasesTheHealthOfSomeoneInTheGroup();
Expand All @@ -272,7 +250,7 @@ export class EventSeeds {
buttonText: 'Run away',
skillCheck: true,
skillCheckFields: {
difficulty: this._game.getRandomArbitrary(6),
difficulty: enemy.runAway,
skillToCheck: Skills.STRENGTH,
canGiveItems: false,
resultPath: {
Expand All @@ -282,7 +260,7 @@ export class EventSeeds {
failure: () => {
this._game.characterManager.decreasesTheHealthOfSomeoneInTheGroup();
this._game.characterManager.makeSomeoneInTheGroupGetStatus('Fear');
this._game.log.addTempLog('You escaped but got hurt by the ' + enemy.toLowerCase(), LogType.Result);
this._game.log.addTempLog('You escaped but got hurt by the ' + enemy.name.toLowerCase(), LogType.Result);
},
}
},
Expand Down

0 comments on commit 7bd81ae

Please sign in to comment.