-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from EugeneWWolf/RPGSAGA
RPGSAGA [Completed] + tests
- Loading branch information
Showing
60 changed files
with
2,645 additions
and
182 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,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; | ||
} | ||
} |
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,4 @@ | ||
export enum AttackType { | ||
attack, | ||
spell, | ||
} |
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,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); | ||
} | ||
} | ||
} |
Oops, something went wrong.