Skip to content

Commit

Permalink
remove current quests and items
Browse files Browse the repository at this point in the history
  • Loading branch information
amcolash committed Jul 13, 2024
1 parent 32ec6cf commit 11fa624
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 93 deletions.
Binary file removed screenshot.png
Binary file not shown.
4 changes: 2 additions & 2 deletions src/classes/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Player } from './Player';
import { InteractResult, Interactive, ItemType } from './types';

export const ItemData = {
[ItemType.Book]: { x: 1500, y: 875, image: 'book' },
[ItemType.Map]: { x: 3500, y: 810, image: 'map' },
[ItemType.Wrench]: { x: 0, y: 0, image: 'wrench' },
[ItemType.Gear]: { x: 3500, y: 810, image: 'gear' },
};

export class Item extends Phaser.Physics.Arcade.Sprite implements Interactive {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/NPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class NPC extends Phaser.Physics.Arcade.Sprite implements Interactive {
} else {
this.player.message.setMessage();
if (dialog.onCompleted) {
dialog.onCompleted(this.player);
dialog.onCompleted(this.player, this);
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/classes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ export enum WarpType {
}

export enum ItemType {
Book,
Map,
Wrench,
Gear,
}

export enum QuestType {
InventorBook,
StrangerMap,
ClockGear1,
ClockGear2,
ClockGear3,
}

export enum NPCType {
Expand Down
7 changes: 2 additions & 5 deletions src/scenes/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Game extends Scene {
this.createBackgrounds();

// game objects
this.player = new Player(this, 400, 650);
this.player = new Player(this);

const walls = new Walls(this);
const warpers = this.createWarpers();
Expand Down Expand Up @@ -106,10 +106,7 @@ export class Game extends Scene {
}

createItems(): Item[] {
const book = new Item(this, ItemType.Book, this.player);
const ring = new Item(this, ItemType.Map, this.player);

return [book, ring];
return [];
}

createEventListeners() {
Expand Down
16 changes: 8 additions & 8 deletions src/scenes/Preloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export class Preloader extends Scene {
this.load.image('watch', 'watch.png');

// items
this.load.image('book', 'items/book.png');
this.load.image('candle', 'items/candle.png');
this.load.image('dagger', 'items/dagger.png');
this.load.image('gear', 'items/gear.png');
this.load.image('journal', 'items/journal.png');
this.load.image('lantern', 'items/lantern.png');
this.load.image('letter', 'items/letter.png');
this.load.image('lockpick', 'items/lockpick.png');
this.load.image('map', 'items/map.png');
this.load.image('wrench', 'items/wrench.png');
// this.load.image('book', 'items/book.png');
// this.load.image('candle', 'items/candle.png');
// this.load.image('dagger', 'items/dagger.png');
// this.load.image('journal', 'items/journal.png');
// this.load.image('lantern', 'items/lantern.png');
// this.load.image('letter', 'items/letter.png');
// this.load.image('lockpick', 'items/lockpick.png');
// this.load.image('wrench', 'items/wrench.png');

// characters
this.load.spritesheet('character', 'characters/player.png', { frameWidth: 24, frameHeight: 36 });
Expand Down
79 changes: 6 additions & 73 deletions src/utils/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NPC } from '../classes/NPC';
import { Player } from '../classes/Player';
import { ItemType, JournalEntry, NPCType, Quest, QuestType } from '../classes/types';

Expand All @@ -11,95 +12,27 @@ export interface NPCDialog {
or?: boolean;
};
messages: string[];
onCompleted?: (player: Player) => void;
onCompleted?: (player: Player, npc?: NPC) => void;
}

const npcDialogs: Record<NPCType, NPCDialog[]> = {
[NPCType.Inventor]: [
{
messages: ['I am working on a new invention.'],
conditions: {
completedQuest: QuestType.InventorBook,
journalEntry: JournalEntry.InventorBookFound,
},
},
{
messages: ['You found my book! Thank you!', 'I heard that the stranger might need some help.'],
conditions: {
activeQuest: QuestType.InventorBook,
hasItem: ItemType.Book,
},
onCompleted: (player) => {
player.quests.updateExistingQuest(QuestType.InventorBook, true);
player.inventory.removeItem(ItemType.Book);
player.journal.addEntry(JournalEntry.InventorBookFound);
},
},
{
messages: ['Did you find my book yet?'],
conditions: {
activeQuest: QuestType.InventorBook,
},
},
{
messages: [
'My name is Johan and I am an inventor.',
'I wonder what I did with that book of mine...',
'Could you find it for me?',
],
conditions: {
noJournalEntry: JournalEntry.InventorBookFound,
},
onCompleted: (player) => {
player.quests.addQuest({ id: QuestType.InventorBook, name: 'Find the inventors book', completed: false });
},
},
{
messages: ['My name is Johan and I am an inventor.'],
},
],
[NPCType.Stranger]: [
{
messages: ['I saw her this morning in the forest.'],
conditions: {
completedQuest: QuestType.StrangerMap,
},
},
{
messages: ['You found my map! Thank you!', 'I heard a rumor about the mayor making shady deals in the forest...'],
conditions: {
activeQuest: QuestType.StrangerMap,
hasItem: ItemType.Map,
},
onCompleted: (player) => {
player.quests.updateExistingQuest(QuestType.StrangerMap, true);
player.inventory.removeItem(ItemType.Map);
player.journal.addEntry(JournalEntry.StrangerMapFound);
},
},
{
messages: ['Did you find my map?'],
conditions: {
activeQuest: QuestType.StrangerMap,
},
},
{
messages: ['You helped the inventor?', 'Can you find my map for me?'],
conditions: {
journalEntry: JournalEntry.InventorBookFound,
},
onCompleted: (player) => {
player.quests.addQuest({ id: QuestType.StrangerMap, name: 'Find the strangers map', completed: false });
},
},
{
messages: ['Who am I?', 'Eventually, you will learn.'],
},
],
// TODO: Should the clock tower be a different type than NPC?
[NPCType.ClockTower]: [
{
messages: ["This dusty clock tower hasn't worked in many years."],
messages: [
"This dusty clock tower hasn't told the correct time in many years.",
'It appears to be missing some gears.',
],
},
],
};
Expand Down

0 comments on commit 11fa624

Please sign in to comment.