Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/workshop/BaseCharacter.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
import { CharacterClassName, ICharacter, ICharacterActionDecision } from "../off-limits/ICharacter";
import { CharacterClassName, equip, ICharacter, ICharacterActionDecision } from "../off-limits/ICharacter";
import { IWeapon, IItem } from "../off-limits/IWeapons";
import { Feet } from "./Characters";
import { AwesomeAmulet } from "./Weapons";

//todo: use this base class somehow in Characters.tsx
export class Character implements ICharacter {
name: string = '';
health: number = 5;
position: number = 10;
weapons: IWeapon[] = [];
item?: IItem;

name: string;
characterClass: CharacterClassName = "Cleric";
feet = new Feet(this);
constructor(public nameInit: string, public key: number, equipItem: IItem|undefined) {
this.name = nameInit;
equip(equipItem, this);
}
classname(): CharacterClassName {
throw new Error("Method not implemented.");
return this.characterClass;
}
move(){
throw new Error("Method not implemented.");
this.feet.move();
}
chooseAction(): ICharacterActionDecision{
throw new Error("Method not implemented.");
if (this.health<5) return {
use: this.item || new AwesomeAmulet()
}
return {
attack: this.weapons[0]
}
}
getASCIIStatus(): string {
throw new Error("Method not implemented.");
if (this.health>0) return this.characterClass.charAt(0);
return "X";
}
}
96 changes: 12 additions & 84 deletions src/workshop/Characters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,103 +12,31 @@ import {
//todo: customize the chooseAction() to better fight the dragon
//todo: update the `getASCIIStatus` function(s) to return X when dead and a unique character per class

export class Warrior implements ICharacter {
health: number = 5;
position: number = 10;
weapons: IWeapon[] = [];
item?: IItem;
feet = new Feet(this);
classname(): CharacterClassName {
return 'Warrior';
}
move(){
this.feet.move();
}
export class Warrior extends Character implements ICharacter {
constructor(public name: string, public key: number) {
equip(WarriorStartItem, this);
}
chooseAction(): ICharacterActionDecision {
return {
attack: this.weapons[0]
}
}
getASCIIStatus(): string {
return "@";
super(name,key, WarriorStartItem);
this.characterClass = 'Warrior';
}
}

export class Cleric implements ICharacter{
health: number = 5;
position: number = 10;
weapons: IWeapon[] = [];
item?: IItem;
feet = new Feet(this);
classname(): CharacterClassName {
return 'Cleric';
}
move(){
this.feet.move();
}
export class Cleric extends Character implements ICharacter{
constructor(public name: string, public key: number) {
equip(ClericStartItem, this);
}
chooseAction(): ICharacterActionDecision {
return {
attack: this.weapons[0]
}
}
getASCIIStatus(): string {
return "@";
super(name,key, ClericStartItem);
this.characterClass = 'Cleric';
}
}

export class Mage implements ICharacter {
health: number = 5;
position: number = 10;
weapons: IWeapon[] = [];
item?: IItem;
feet = new Feet(this);
classname(): CharacterClassName {
return 'Mage';
}
export class Mage extends Character implements ICharacter {
constructor(public name: string, public key: number) {
equip(MageStartItem, this);
}
move(){
this.feet.move();
}
chooseAction(): ICharacterActionDecision {
return {
attack: this.weapons[0]
}
}
getASCIIStatus(): string {
return "@";
super(name,key, MageStartItem);
this.characterClass = 'Mage';
}
}

export class Thief implements ICharacter {
health: number = 5;
position: number = 10;
weapons: IWeapon[] = [];
item?: IItem;
feet = new Feet(this);
move(){
this.feet.move();
}
classname(): CharacterClassName {
return 'Thief';
}
export class Thief extends Character implements ICharacter {
constructor(public name: string, public key: number) {
equip(ThiefStartItem, this);
}
chooseAction(): ICharacterActionDecision {
return {
attack: this.weapons[0]
}
}
getASCIIStatus(): string {
return "@";
super(name,key, ThiefStartItem);
this.characterClass = 'Thief';
}
}

Expand Down
36 changes: 29 additions & 7 deletions src/workshop/Weapons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,49 @@ export class Club implements IMeleeWeapon {
meleeRange = 1;
}

export class Excaliber implements IMeleeWeapon {
name = 'Excaliber';
damage = 100;
meleeRange = 1;
}

export class Crossbow implements IRangedWeapon<Arrow> {
damage: 0 = 0;
name = 'Crossbow';
meleeRange = 50;
projectiles = [new Arrow()];
}

export class Arrow implements IWeapon {
name = 'Arrow';
damage = 100;
}

// ITEM VAULT
// todo: add more and better items!
export class UselessAmulet implements IItem {
name = 'Useless Amulet';
}

export class AwesomeAmulet implements IConsumableItem {
name = 'Awesome Amulet';
healthBonus = 5;
}

// ITEM ASSIGNMENTS
// todo: assign starting items
export const WarriorStartItem: IItem|undefined = new Club();
export const ClericStartItem: IItem|undefined = new Club();
export const WarriorStartItem: IItem|undefined = new Excaliber();
export const ClericStartItem: IItem|undefined = new Excaliber();
export const MageStartItem: IItem|undefined = undefined;
export const ThiefStartItem: IItem|undefined = new Club();
export const ThiefStartItem: IItem|undefined = new Excaliber();

// TREASURE ASSIGNMENTS
// todo: assign treasure from chests
export function GetItemsInTreasureChests(): IItem[]{
return [
new UselessAmulet(), //this will be found by the warrior
new UselessAmulet(), //this will be found by the cleric
new UselessAmulet(), //this will be found by the mage
new UselessAmulet(), //this will be found by the thief
new AwesomeAmulet(), //this will be found by the warrior
new AwesomeAmulet(), //this will be found by the cleric
new AwesomeAmulet(), //this will be found by the mage
new AwesomeAmulet(), //this will be found by the thief
];
}