From 3131e8889df820e2e82b05f1d9bf42862dd579a8 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Thu, 15 Oct 2020 14:59:31 -0400 Subject: [PATCH] Add a way to recruit allies; fix self-selection bug in combat Eating an ally would wind up causing both the left and right selections to be yourself, which caused duplicate keys and broke the interface. Pair actions are now only checked if the left and right selections are distinct. --- src/components/Combat.vue | 8 ++++---- src/game/maps/town.ts | 18 +++++++++++++++++- src/game/world.ts | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/components/Combat.vue b/src/components/Combat.vue index c29d61f..85741db 100644 --- a/src/components/Combat.vue +++ b/src/components/Combat.vue @@ -21,8 +21,8 @@
- - + +
@@ -34,8 +34,8 @@
- - + +
diff --git a/src/game/maps/town.ts b/src/game/maps/town.ts index 4089774..ce9c3b1 100644 --- a/src/game/maps/town.ts +++ b/src/game/maps/town.ts @@ -286,7 +286,7 @@ export const Town = (): Place => { name: "Fight some tasty nerd", intro: () => new LogLine(`You find some nerd to fight.`) }, - [world.player, enemy] + [world.player, enemy].concat(world.party) ) world.encounter = encounter return nilLog @@ -294,6 +294,22 @@ export const Town = (): Place => { ) ) + westAve.choices.push( + new Choice( + "Recruit someone", + "Not ow", + (world) => { + const ally = new Creatures.Human(new ProperNoun("Ally"), TheyPronouns) + ally.side = Side.Heroes + ally.ai = new VoreAI() + ally.equip(new Items.Sword(), Items.EquipmentSlot.MainHand) + world.party.push(ally) + + return new LogLine(`You recruit a nerd`) + } + ) + ) + square.choices.push( new Choice( "Fight Geta", diff --git a/src/game/world.ts b/src/game/world.ts index 3134b42..1d950ec 100644 --- a/src/game/world.ts +++ b/src/game/world.ts @@ -92,6 +92,7 @@ export class World { time: Moment creatures: Creature[] = [] encounter: Encounter|null = null + party: Creature[] = [] constructor (public player: Creature) { this.time = moment.utc([500, 1, 1, 9, 0, 0, 0])