-
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.
- Loading branch information
1 parent
c4d769c
commit 0ee8d8e
Showing
15 changed files
with
239 additions
and
9 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
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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../saga/src/spell_system/spell/fireArrow.ts → ...c/spell_system/activeEffects/fireArrow.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
2 changes: 1 addition & 1 deletion
2
...ga/src/spell_system/spell/knightAttack.ts → ...pell_system/activeEffects/knightAttack.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
2 changes: 1 addition & 1 deletion
2
rpgsaga/saga/src/spell_system/spell/stun.ts → ...ga/src/spell_system/activeEffects/stun.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
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,55 @@ | ||
import { Character } from '../src/character'; | ||
import { CharacterClass } from '../src/characterClasses'; | ||
import { Spell } from '../src/spell_system/spell/spell'; | ||
import { Stun } from '../src/spell_system/activeEffects/stun'; | ||
import { StunEffect } from '../src/spell_system/statusEffect/stunEffect'; | ||
|
||
describe('Testing Character class', () => { | ||
it('Constructor tests', () => { | ||
const character = new Character( | ||
'Linda', | ||
CharacterClass.mage, | ||
105, | ||
new Spell('Freeze', new Stun(2, 0), new StunEffect('Stun', 1)), | ||
); | ||
|
||
expect(character.name).toBe('Linda'); | ||
expect(character.class).toBe(CharacterClass.mage); | ||
expect(character.healthPoints).toBe(105); | ||
expect(character.spell).toBeInstanceOf(Spell); | ||
}); | ||
it('Testing receiveDamage method', () => { | ||
const character = new Character( | ||
'Linda', | ||
CharacterClass.mage, | ||
105, | ||
new Spell('Freeze', new Stun(2, 0), new StunEffect('Stun', 1)), | ||
); | ||
|
||
character.receiveDamage(5); | ||
|
||
expect(character.healthPoints).toBe(100); | ||
}); | ||
it('Testing getAttackPoints method', () => { | ||
const character = new Character( | ||
'Linda', | ||
CharacterClass.mage, | ||
105, | ||
new Spell('Freeze', new Stun(2, 0), new StunEffect('Stun', 1)), | ||
); | ||
|
||
character.strengthModificator = 5.0; | ||
|
||
expect(character.getAttackPoints()).toBe(25); | ||
}); | ||
it('Testing toString method', () => { | ||
const character = new Character( | ||
'Linda', | ||
CharacterClass.mage, | ||
105, | ||
new Spell('Freeze', new Stun(2, 0), new StunEffect('Stun', 1)), | ||
); | ||
|
||
expect(character.toString()).toBe('Linda (mage) [105/105]'); | ||
}); | ||
}); |
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,87 @@ | ||
import { DoublyLinkedList } from '../src/doublyLinkedList/doublyLinkedList'; | ||
import { FireArrowEffect } from '../src/spell_system/statusEffect/fireArrowEffect'; | ||
import { StunEffect } from '../src/spell_system/statusEffect/stunEffect'; | ||
import { IStatusEffect } from '../src/spell_system/statusEffect/IStatusEffect'; | ||
|
||
describe('Testing DoublyLinkedList constructor', () => { | ||
it('Should initialise properly', () => { | ||
const linkedList = new DoublyLinkedList(); | ||
expect(linkedList.head).toBe(null); | ||
expect(linkedList.tail).toBe(null); | ||
expect(linkedList.size).toBe(0); | ||
}); | ||
}); | ||
|
||
describe('Testing addLast method', () => { | ||
it('Should add an element into the empty doubly linked list', () => { | ||
const linkedList = new DoublyLinkedList(); | ||
linkedList.addLast(new FireArrowEffect('Burning', 3)); | ||
|
||
expect(linkedList.head.value).toBeInstanceOf(FireArrowEffect); | ||
expect(linkedList.tail).toBe(null); | ||
expect(linkedList.size).toBe(1); | ||
}); | ||
it('Should add an element into the non-empty doubly linked list', () => { | ||
const linkedList = new DoublyLinkedList(); | ||
linkedList.addLast(new FireArrowEffect('Burning', 3)); | ||
linkedList.addLast(new FireArrowEffect('Blue Fire', 1)); | ||
linkedList.addLast(new StunEffect('Stun', 1)); | ||
|
||
expect(linkedList.head.value).toBeInstanceOf(FireArrowEffect); | ||
expect(linkedList.head.next.value).toBeInstanceOf(FireArrowEffect); | ||
expect(linkedList.head.next.next.value).toBeInstanceOf(StunEffect); | ||
expect(linkedList.tail.value).toBeInstanceOf(StunEffect); | ||
expect(linkedList.size).toBe(3); | ||
}); | ||
}); | ||
|
||
describe('Testing contains method', () => { | ||
it('Should result in true if element is in the linked list', () => { | ||
const linkedList = new DoublyLinkedList(); | ||
const statusEffect: IStatusEffect = new FireArrowEffect('Burning', 3); | ||
|
||
linkedList.addLast(statusEffect); | ||
|
||
expect(linkedList.contains(statusEffect)).toBe(true); | ||
}); | ||
it('Should result in false if linked list is empty', () => { | ||
const linkedList = new DoublyLinkedList(); | ||
const statusEffect: IStatusEffect = new FireArrowEffect('Burning', 3); | ||
|
||
expect(linkedList.contains(statusEffect)).toBe(false); | ||
}); | ||
it("Should result in false if element isn't in the linked list", () => { | ||
const linkedList = new DoublyLinkedList(); | ||
const statusEffect: IStatusEffect = new FireArrowEffect('Burning', 3); | ||
const anotherStatusEffect: IStatusEffect = new FireArrowEffect('Blue Fire', 1); | ||
|
||
linkedList.addLast(statusEffect); | ||
|
||
expect(linkedList.contains(anotherStatusEffect)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('Testing remove method', () => { | ||
it('Should work without errors if linked list is empty', () => { | ||
const linkedList = new DoublyLinkedList(); | ||
const statusEffect: IStatusEffect = new FireArrowEffect('Blue Fire', 1); | ||
|
||
expect(() => { | ||
linkedList.remove(statusEffect); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('Should remove an element from non-empty linked list', () => { | ||
const linkedList = new DoublyLinkedList(); | ||
const statusEffect: IStatusEffect = new FireArrowEffect('Blue Fire', 1); | ||
const anotherStatusEffect: IStatusEffect = new FireArrowEffect('Burning', 3); | ||
|
||
linkedList.addLast(statusEffect); | ||
linkedList.addLast(anotherStatusEffect); | ||
|
||
linkedList.remove(statusEffect); | ||
|
||
expect(linkedList.size).toBe(1); | ||
expect(linkedList.head.value).toBe(anotherStatusEffect); | ||
}); | ||
}); |
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,32 @@ | ||
import { Character } from '../src/character'; | ||
import { CharacterClass } from '../src/characterClasses'; | ||
import { Message } from '../src/message'; | ||
import { KnightAttack } from '../src/spell_system/activeEffects/knightAttack'; | ||
import { Spell } from '../src/spell_system/spell/spell'; | ||
|
||
describe('Testing Message class', () => { | ||
it('Testing Message constructor', () => { | ||
const dummyCharacter = new Character( | ||
'Korsika', | ||
CharacterClass.knight, | ||
150, | ||
new Spell('Mighty Slash', new KnightAttack(2, 5), null), | ||
); | ||
|
||
const message = new Message( | ||
dummyCharacter, | ||
dummyCharacter.toString(), | ||
dummyCharacter, | ||
dummyCharacter.toString(), | ||
dummyCharacter.getAttackPoints(), | ||
dummyCharacter.spell, | ||
); | ||
|
||
expect(message.attacker).toBe(dummyCharacter); | ||
expect(message.attackerInfo).toBe(dummyCharacter.toString()); | ||
expect(message.target).toBe(dummyCharacter); | ||
expect(message.targetInfo).toBe(dummyCharacter.toString()); | ||
expect(message.damagePoints).toBe(dummyCharacter.getAttackPoints()); | ||
expect(message.spell).toBe(dummyCharacter.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,46 @@ | ||
import { Character } from '../../src/character'; | ||
import { CharacterClass } from '../../src/characterClasses'; | ||
import { FireArrow } from '../../src/spell_system/activeEffects/fireArrow'; | ||
import { Spell } from '../../src/spell_system/spell/spell'; | ||
import { FireArrowEffect } from '../../src/spell_system/statusEffect/fireArrowEffect'; | ||
|
||
describe('Testing Spell class constructor', () => { | ||
it('Should result in correct values', () => { | ||
const spell = new Spell('Fire arrow', new FireArrow(2, 7), new FireArrowEffect('Burning', 3)); | ||
|
||
expect(spell.name).toBe('Fire arrow'); | ||
expect(spell.activeEffect).toBeInstanceOf(FireArrow); | ||
expect(spell.statusEffect).toBeInstanceOf(FireArrowEffect); | ||
}); | ||
it("Status effect in constructor should result to null if it's not passed as a parameter", () => { | ||
const spell = new Spell('Fire arrow', new FireArrow(2, 7)); | ||
|
||
expect(spell.name).toBe('Fire arrow'); | ||
expect(spell.activeEffect).toBeInstanceOf(FireArrow); | ||
expect(spell.statusEffect).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('Testing canExecute method', () => { | ||
it('Should result in true if spell can be casted', () => { | ||
const spell = new Spell('Fire arrow', new FireArrow(2, 7), new FireArrowEffect('Burning', 3)); | ||
expect(spell.canExecute()).toBe(true); | ||
}); | ||
it('Should result in false if spell cannot be casted', () => { | ||
const spell = new Spell('Fire arrow', new FireArrow(0, 7), new FireArrowEffect('Burning', 3)); | ||
expect(spell.canExecute()).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('Testing execute method', () => { | ||
it('Should result in true if spell casted successfully', () => { | ||
const spell = new Spell('Fire arrow', new FireArrow(1, 7), new FireArrowEffect('Burning', 3)); | ||
const dummyTarget = new Character('Lilian', CharacterClass.mage, 100, spell); | ||
expect(spell.execute(dummyTarget)).toBe(true); | ||
}); | ||
it('Should result in true if spell has not been casted', () => { | ||
const spell = new Spell('Fire arrow', new FireArrow(0, 7), new FireArrowEffect('Burning', 3)); | ||
const dummyTarget = new Character('Lilian', CharacterClass.mage, 100, spell); | ||
expect(spell.execute(dummyTarget)).toBe(false); | ||
}); | ||
}); |