-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#115-AddPlayerPanel-styling
- Loading branch information
Showing
50 changed files
with
837 additions
and
380 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
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,37 @@ | ||
import { AnimalNames } from '../Enums/AnimalNamesEnum'; | ||
import { AnimalRoles } from '../Enums/AnimalRolesEnum'; | ||
import { AttackHerdInterface } from '../Interfaces/AttackHerdInterface'; | ||
import { Animal } from './Animal'; | ||
|
||
export class Predator extends Animal implements AttackHerdInterface { | ||
protected _kills: AnimalNames[]; | ||
protected _isChasedAwayBy: AnimalNames; | ||
protected _exclamation: string; | ||
constructor( | ||
name: AnimalNames, | ||
imagePath: string, | ||
roles: AnimalRoles = AnimalRoles.PREDATOR, | ||
kills: AnimalNames[], | ||
isChasedAwayBy: AnimalNames, | ||
exclamation: string, | ||
) { | ||
super(name, imagePath, undefined, roles); | ||
this._kills = kills; | ||
this._isChasedAwayBy = isChasedAwayBy; | ||
this._exclamation = exclamation; | ||
} | ||
|
||
get kills(): AnimalNames[] { | ||
return this._kills; | ||
} | ||
get isChasedAwayBy(): AnimalNames { | ||
return this._isChasedAwayBy; | ||
} | ||
get exclamation(): string { | ||
return this._exclamation; | ||
} | ||
|
||
attackHerd(): string { | ||
return this._exclamation; | ||
} | ||
} |
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,37 @@ | ||
import { AnimalNames } from '../Enums/AnimalNamesEnum'; | ||
import { AnimalRoles } from '../Enums/AnimalRolesEnum'; | ||
import { ProtectHerdInterface } from '../Interfaces/ProtectHerdInterface'; | ||
import { Animal, Value } from './Animal'; | ||
|
||
export class Protector | ||
extends Animal | ||
implements ProtectHerdInterface { | ||
protected _chasesAway: AnimalNames; | ||
protected _exclamation: string; | ||
constructor( | ||
name: AnimalNames, | ||
imagePath: string, | ||
role: AnimalRoles = AnimalRoles.PREDATOR, | ||
value: Value, | ||
chasesAway: AnimalNames, | ||
exclamation: string, | ||
) { | ||
super(name, imagePath, value, role); | ||
this._chasesAway = chasesAway; | ||
this._exclamation = exclamation; | ||
} | ||
|
||
get chasesAway(): AnimalNames { | ||
if (!this._chasesAway) throw new Error('nothing to chase away'); | ||
return this._chasesAway; | ||
} | ||
get exclamation(): string { | ||
if (!this._exclamation) return ''; | ||
return this._exclamation; | ||
} | ||
|
||
protectHerd(): string { | ||
if (!this._exclamation) return ''; | ||
return this._exclamation; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface AttackHerdInterface { | ||
// TODO: tweak when herd is ready | ||
// TODO: DEFINE THE ACTION FOR ATTACK | ||
attackHerd(): string; | ||
} |
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
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
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import { AnimalRoles } from '../Enums/AnimalRolesEnum'; | ||
import { AnimalNames } from '../Enums/AnimalNamesEnum'; | ||
|
||
export interface PredatorsConfigInterface { | ||
name: AnimalNames; | ||
path: string; | ||
roles: AnimalRoles; | ||
kills: AnimalNames[]; | ||
isChasedAwayBy: AnimalNames[]; | ||
isChasedAwayBy: AnimalNames; | ||
exclamation: string; | ||
dice?: { diceNumber: number; probability: number }[]; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/Interfaces/DiceInterface.ts → src/Interfaces/RandomAnimalInterface.ts
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AnimalNames } from '../Enums/AnimalNamesEnum'; | ||
|
||
export interface GetRandomValue { | ||
export interface RandomAnimalInterface { | ||
getRandomValue(): AnimalNames; | ||
} |
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
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
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 |
---|---|---|
@@ -1,10 +1,28 @@ | ||
import { GetRandomValue } from '../Interfaces/DiceInterface'; | ||
import { RandomAnimalInterface } from '../Interfaces/RandomAnimalInterface'; | ||
import { AnimalNames } from '../Enums/AnimalNamesEnum'; | ||
import { sample } from 'lodash'; | ||
import { sample, shuffle } from 'lodash'; | ||
|
||
export class Dice implements GetRandomValue { | ||
constructor(private diceSides: AnimalNames[]) {} | ||
export class Dice implements RandomAnimalInterface { | ||
private dice: AnimalNames[] = []; | ||
|
||
/** | ||
* adds animals names to dice sides in quantity of probability | ||
* @param animal accepts AnimalNames with desired animal on side | ||
* @param probability accepts number with number of sides with this animal | ||
*/ | ||
addSide(animal: AnimalNames, probability: number): void { | ||
if (probability === 0) { | ||
return; | ||
} | ||
this.dice.push(animal); | ||
this.addSide(animal, probability - 1); | ||
} | ||
|
||
/** | ||
* Returns random animal | ||
*/ | ||
getRandomValue(): AnimalNames { | ||
return sample(this.diceSides) as AnimalNames; | ||
this.dice = shuffle(this.dice); | ||
return sample(this.dice) as AnimalNames; | ||
} | ||
} |
Oops, something went wrong.