Skip to content

Commit

Permalink
Merge pull request #37 from EugeneWWolf/RPGSAGA
Browse files Browse the repository at this point in the history
RPGSAGA [Completed] + tests
  • Loading branch information
jskonst authored Feb 10, 2024
2 parents 4dc7129 + a78a18e commit 1fd5bdd
Show file tree
Hide file tree
Showing 60 changed files with 2,645 additions and 182 deletions.
5 changes: 5 additions & 0 deletions rpgsaga/saga/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ module.exports = {
selector: 'typeProperty',
format: ['snake_case', 'camelCase'],
},
{
selector: 'classProperty',
format: ['camelCase'],
leadingUnderscore: 'allow',
}
],
},
settings: {
Expand Down
3 changes: 2 additions & 1 deletion rpgsaga/saga/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"request": "launch",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${workspaceFolder}/src/index.ts"],
"outputCapture": "std"
"outputCapture": "std",
"console": "integratedTerminal",
},
{
"type": "node",
Expand Down
104 changes: 91 additions & 13 deletions rpgsaga/saga/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions rpgsaga/saga/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
},
"author": "",
"license": "ISC",
"dependencies": {},
"dependencies": {
"lodash": "^4.17.21",
"prompt-sync": "^4.2.0"
},
"devDependencies": {
"@types/jest": "^27.0.3",
"@types/jest": "^27.5.2",
"@types/lodash": "^4.14.202",
"@types/node": "^16.11.0",
"@types/prompt-sync": "^4.2.3",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^7.28.0",
Expand All @@ -23,9 +28,9 @@
"eslint-plugin-prettier": "^3.4.0",
"jest": "^27.2.5",
"prettier": "^2.4.1",
"ts-jest": "^27.1.2",
"ts-node": "^10.3.0",
"typescript": "^4.4.4",
"ts-jest": "^27.1.2"
"typescript": "^4.4.4"
},
"jest": {
"preset": "ts-jest"
Expand Down
27 changes: 27 additions & 0 deletions rpgsaga/saga/src/arrayItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Character } from './character';

export class ArrayItem {
private _player: Character;
private _index: number;

get player() {
return this._player;
}

set player(value: Character) {
this._player = value;
}

get index() {
return this._index;
}

set index(value: number) {
this._index = value;
}

constructor(player: Character, index: number) {
this._player = player;
this._index = index;
}
}
4 changes: 4 additions & 0 deletions rpgsaga/saga/src/attackType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum AttackType {
attack,
spell,
}
59 changes: 59 additions & 0 deletions rpgsaga/saga/src/bina.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Character } from './character';
import { DoublyLinkedListNode } from './doublyLinkedList/doublyLinkedListNode';
import { Message } from './message';
import { IStatusEffect } from './spell_system/statusEffect/IStatusEffect';

export class Bina {
private _message: Message;

get message() {
return this._message;
}

public receiveMessage(message: Message) {
this._message = message;
}

public performAttack() {
this._message.target.receiveDamage(this._message.damagePoints);

console.log(
`${this._message.attackerInfo} has dealt ${this._message.damagePoints} damage to ${this._message.targetInfo}!`,
);
}

public performSpell(): boolean {
const isSuccessful = this._message.spell.execute(this._message.target);

if (isSuccessful) {
console.log(
`${this._message.attackerInfo} has casted a spell ${this._message.spell.describe()} on ${
this._message.targetInfo
}!`,
);

if (this._message.spell.hasStatusEffect()) {
this.sendStatusEffect(this._message.target, this._message.spell.getStatusEffect());
}
return true;
} else {
console.log(`${this._message.attackerInfo} has failed to cast a spell!`);
return false;
}
}

private sendStatusEffect(target: Character, statusEffect: IStatusEffect) {
if (target.statusEffects.contains(statusEffect)) {
const node: DoublyLinkedListNode = target.statusEffects.head;
while (node !== null) {
if (node.value.describe() === statusEffect.describe()) {
node.value.refresh();
return;
}
}
} else {
statusEffect.refresh();
target.statusEffects.addLast(statusEffect);
}
}
}
Loading

0 comments on commit 1fd5bdd

Please sign in to comment.