|
- import { Place, Choice, Direction, World } from '@/game/world'
- import { ProperNoun, ImproperNoun, MalePronouns, FemalePronouns, TheyPronouns } from '@/game/language'
- import { Encounter, Stat, Damage, DamageType, Vigor, Side } from '@/game/combat'
- import * as Items from '@/game/items'
- import { LogLine, nilLog, LogLines } from '@/game/interface'
- import { Creature } from '@/game/creature'
- import { DevourAction } from '@/game/combat/actions'
- import { InstantDigestionEffect, SurrenderEffect } from '@/game/combat/effects'
- import moment from 'moment'
- import { VoreAI } from '@/game/ai'
- import { DeliciousPerk } from '@/game/combat/perks'
- import Inazuma from '../creatures/characters/inazuma'
- import Samuel from '../creatures/characters/Samuel'
- import Human from '../creatures/human'
- import Slime from '../creatures/monsters/slime'
-
- function makeParty (): Creature[] {
- const fighter = new Human(new ProperNoun("Redgar"), MalePronouns, {
- stats: {
- Toughness: 20,
- Power: 20,
- Reflexes: 15,
- Agility: 15,
- Willpower: 15,
- Charm: 10
- }
- })
- fighter.title = "Lv. 6 Fighter"
- fighter.equip(new Items.Sword(), Items.EquipmentSlot.MainHand)
- const rogue = new Human(new ProperNoun('Lidda'), FemalePronouns, {
- stats: {
- Toughness: 10,
- Power: 15,
- Reflexes: 20,
- Agility: 20,
- Willpower: 15,
- Charm: 20
- }
- })
- rogue.title = "Lv. 5 Rogue"
- rogue.equip(new Items.Dagger(), Items.EquipmentSlot.MainHand)
- const wizard = new Human(new ProperNoun('Mialee'), FemalePronouns, {
- stats: {
- Toughness: 10,
- Power: 10,
- Reflexes: 15,
- Agility: 15,
- Willpower: 20,
- Charm: 25
- }
- })
- wizard.title = "Lv. 6 Wizard"
- wizard.equip(new Items.Wand(), Items.EquipmentSlot.MainHand)
- const cleric = new Human(new ProperNoun('Jozan'), MalePronouns, {
- stats: {
- Toughness: 15,
- Power: 15,
- Reflexes: 10,
- Agility: 10,
- Willpower: 20,
- Charm: 15
- }
- })
- cleric.title = "Lv. 5 Cleric"
- cleric.equip(new Items.Mace(), Items.EquipmentSlot.MainHand)
-
- return [fighter, cleric, rogue, wizard]
- }
-
- export const Newtown = (): Place => {
- const home = new Place(
- new ProperNoun("Home"),
- "A place you can rest after long adventures"
- )
-
- const debug = new Place(
- new ProperNoun("Debug Room"),
- "Where weird stuff happens"
- )
-
- const southTownStreet = new Place(
- new ProperNoun("South Town Street"),
- "Town street south of the Town square"
- )
-
- const northTownStreet = new Place(
- new ProperNoun("North Town Street"),
- "Town street north of the Town square"
- )
-
- const northTownShop = new Place(
- new ProperNoun("North Town Shop"),
- "A shop for your impulsive buying needs"
- )
-
- const eastTownStreet = new Place(
- new ProperNoun("East Town Street"),
- "Town street east of the Town square"
- )
-
- const westTownStreet = new Place(
- new ProperNoun("West Town Street"),
- "Town street west of the Town square"
- )
-
- const townSquare = new Place(
- new ProperNoun("Town Square"),
- "The central-most part of town, and a hub of bustling activity"
- )
-
- const eastGate = new Place(
- new ProperNoun("East Gate"),
- "The towns gate, leading out into the wilderness"
- )
- const woods = new Place(
- new ProperNoun("The Woods"),
- "A scary part of the forest where monsters hide"
- )
- const deepwoods = new Place(
- new ProperNoun("Deep Woods"),
- "Extra scary"
- )
- deepwoods.choices.push(
- new Choice(
- "Fight Inazuma",
- "Go fight Inazuma!",
- (world, executor) => {
- const enemy = new Inazuma()
- const encounter = new Encounter(
- {
- name: "Fight some tough nerd",
- intro: () => new LogLine(`Inazuma Approaches!`)
- },
- [world.player, enemy].concat(world.party)
- )
- world.encounter = encounter
- return nilLog
- }
- )
- )
- const bossEncounters = [
- new Encounter(
- { name: "Inazuma", intro: () => nilLog },
- makeParty().concat([new Inazuma()])
- )
- ]
-
- home.choices.push(
- new Choice(
- "Nap",
- "Zzzzzz",
- (world) => {
- return new LogLines(
- `You lie down for a nice nap...`,
- world.advance(moment.duration(1, "hour"))
- )
- }
- )
- )
-
- home.choices.push(
- new Choice(
- "Heal",
- "Become not dead and/or eaten",
- (world, executor) => {
- Object.keys(Vigor).forEach(vigor => {
- executor.vigors[vigor as Vigor] = executor.maxVigors[vigor as Vigor]
- })
- if (executor.containedIn !== null) {
- executor.containedIn.release(executor)
- }
- executor.statusEffects.forEach(effect => {
- executor.removeEffect(effect)
- })
- executor.destroyed = false
- return new LogLine(`You're healthy again`)
- }
- )
- )
-
- home.choices.push(
- new Choice(
- "Grab potions",
- "Grab some potions",
- (world, executor) => {
- executor.items.push(new Items.HealthPotion())
- executor.items.push(new Items.AcidPotion())
- executor.items.push(new Items.ShrinkPotion())
- executor.items.push(new Items.StrengthPotion())
- return new LogLine("You grab some potions")
- }
- )
- )
-
- townSquare.choices.push(
- new Choice(
- "Eat someone",
- "Slurp",
- (world, executor) => {
- const snack = new Human(new ProperNoun(["Snack", "Treat", "Tasty", "Dinner", "Appetizer"][Math.floor(Math.random() * 5)]), [MalePronouns, FemalePronouns, TheyPronouns][Math.floor(Math.random() * 3)])
- snack.applyEffect(new SurrenderEffect())
- const options = executor.validActions(snack).filter(action => action instanceof DevourAction)
- return options[Math.floor(options.length * Math.random())].execute(executor, snack)
- }
- )
- )
-
- townSquare.choices.push(
- new Choice(
- "Fight someone",
- "Ow",
- (world) => {
- const enemy = new Human(new ProperNoun("Nerd"), TheyPronouns)
- enemy.side = Side.Monsters
- enemy.ai = new VoreAI(enemy)
- enemy.equip(new Items.Sword(), Items.EquipmentSlot.MainHand)
- enemy.addPerk(new DeliciousPerk())
- const encounter = new Encounter(
- {
- name: "Fight some tasty nerd",
- intro: () => new LogLine(`You find some nerd to fight.`)
- },
- [world.player, enemy].concat(world.party)
- )
- world.encounter = encounter
- return nilLog
- }
- )
- )
-
- townSquare.choices.push(
- new Choice(
- "Recruit someone",
- "Not ow",
- (world) => {
- const ally = new Human(new ProperNoun("Ally"), TheyPronouns)
- ally.side = Side.Heroes
- ally.ai = new VoreAI(ally)
- ally.equip(new Items.Sword(), Items.EquipmentSlot.MainHand)
- world.party.push(ally)
-
- return new LogLine(`You recruit a nerd`)
- }
- )
- )
-
- northTownShop.choices.push(
- new Choice(
- "Buy a shiny rock",
- "This rock has no use.",
- (world, executor) => {
- if (executor.wallet.Gold >= 500) {
- executor.wallet.Gold -= 500
- executor.items.push(
- new Items.KeyItem(new ProperNoun("Shiny Rock"), "Very shiny")
- )
-
- return new LogLine(`You buy a shiny rock`)
- } else {
- return new LogLine(`Shiny rocks are 500 gold coins, loser!`)
- }
- }
- )
- )
- northTownShop.choices.push(
- new Choice(
- "Buy a health potion",
- "50 Gold",
- (world, executor) => {
- if (executor.wallet.Gold >= 50) {
- executor.wallet.Gold -= 50
- executor.items.push(
- new Items.HealthPotion()
- )
-
- return new LogLine(`You buy a health potion.`)
- } else {
- return new LogLine(`Health potions are 50 gold coins.`)
- }
- }
- )
- )
-
- northTownShop.choices.push(
- new Choice(
- "Buy a strength potion",
- "40 Gold",
- (world, executor) => {
- if (executor.wallet.Gold >= 40) {
- executor.wallet.Gold -= 40
- executor.items.push(
- new Items.StrengthPotion()
- )
-
- return new LogLine(`You buy a strength potion.`)
- } else {
- return new LogLine(`Strength potions are 40 gold coins.`)
- }
- }
- )
- )
-
- northTownShop.choices.push(
- new Choice(
- "Buy an acid potion",
- "25 Gold",
- (world, executor) => {
- if (executor.wallet.Gold >= 25) {
- executor.wallet.Gold -= 25
- executor.items.push(
- new Items.AcidPotion()
- )
-
- return new LogLine(`You buy an acid potion.`)
- } else {
- return new LogLine(`Acid potions are 25 gold coins.`)
- }
- }
- )
- )
-
- northTownShop.choices.push(
- new Choice(
- "Buy a shrink potion",
- "10 Gold",
- (world, executor) => {
- if (executor.wallet.Gold >= 10) {
- executor.wallet.Gold -= 10
- executor.items.push(
- new Items.ShrinkPotion()
- )
-
- return new LogLine(`You buy a shrink potion.`)
- } else {
- return new LogLine(`Shrink potions are 10 gold coins.`)
- }
- }
- )
- )
-
- debug.choices.push(
- new Choice(
- "Cut stats",
- "Make your stats less good-er",
- (world, executor) => {
- Object.keys(Stat).forEach(stat => {
- executor.baseStats[stat as Stat] -= 5
- executor.takeDamage(new Damage(
- { amount: 5, target: (stat as Stat), type: DamageType.Pure }
- ))
- })
- return new LogLine(`You're weaker now`)
- }
- )
- )
-
- debug.choices.push(
- new Choice(
- "Boost stats",
- "Make your stats more good-er",
- (world, executor) => {
- Object.keys(Stat).forEach(stat => {
- executor.baseStats[stat as Stat] += 5
- executor.takeDamage(new Damage(
- { amount: 5, target: (stat as Stat), type: DamageType.Heal }
- ))
- })
- return new LogLine(`You're stronger now`)
- }
- )
- )
-
- debug.choices.push(
- new Choice(
- "Grow",
- "Make yourself larger",
- (world, executor) => {
- executor.voreStats.Mass *= 1.5
- return new LogLine(`You're larger now`)
- }
- )
- )
-
- debug.choices.push(
- new Choice(
- "Shrink",
- "Make yourself smaller",
- (world, executor) => {
- executor.voreStats.Mass /= 1.5
- return new LogLine(`You're smaller now`)
- }
- )
- )
-
- debug.choices.push(
- new Choice(
- "Instant Digestion",
- "Make your stomach REALLY powerful",
- (world, executor) => {
- executor.applyEffect(new InstantDigestionEffect())
- return new LogLine(`You're really gonna melt people now.`)
- }
- )
- )
-
- debug.choices.push(
- new Choice(
- "Set Name",
- "Set your name",
- (world, executor) => {
- const input = prompt("Enter a name")
- if (input !== null) {
- executor.baseName = new ProperNoun(input)
- return new LogLine(`Your new name is ${executor.baseName}.`)
- } else {
- return new LogLine(`nvm`)
- }
- }
- )
- )
-
- debug.choices.push(
- new Choice(
- "Add money",
- "Get some money",
- (world, executor) => {
- executor.wallet.Gold += 1000
- return new LogLine(`$$$$$$$$$$$$$$$$$`)
- }
- )
- )
- woods.choices.push(
- new Choice(
- "Fight a slime",
- "Go fight a slime",
- (world, executor) => {
- const enemy = new Slime()
- const encounter = new Encounter(
- {
- name: "Fight some tasty nerd",
- intro: () => new LogLine(`A slime draws near!`)
- },
- [world.player, enemy].concat(world.party)
- )
- world.encounter = encounter
- return nilLog
- }
- )
- )
-
- woods.choices.push(
- new Choice(
- "Fight Samuel",
- "Go fight a poor little wolf!",
- (world, executor) => {
- const enemy = new Samuel()
- const encounter = new Encounter(
- {
- name: "Fight some tasty nerd",
- intro: () => new LogLine(`Samuel pokes his head out from the bushes!`)
- },
- [world.player, enemy].concat(world.party)
- )
- world.encounter = encounter
- return nilLog
- }
- )
- )
-
- const bosses = new Place(
- new ProperNoun("BOSS ZONE"),
- "Extra scary"
- )
-
- bossEncounters.forEach(encounter => {
- bosses.choices.push(
- new Choice(
- encounter.desc.name,
- "Boss fight!",
- (world) => {
- world.encounter = encounter
- return nilLog
- }
- )
- )
- })
-
- home.biconnect(Direction.South, debug, "Walk", "Enter the debug room", "Leave", "Exit the debug room")
- home.biconnect(Direction.Northeast, townSquare, "Leave", "Go outside", "Enter", "Enter your home")
- townSquare.biconnect(Direction.North, northTownStreet, "Walk", "Go that way", "Walk", "Go that way")
- townSquare.biconnect(Direction.East, eastTownStreet, "Walk", "Go that way", "Walk", "Go that way")
- townSquare.biconnect(Direction.South, southTownStreet, "Walk", "Go that way", "Walk", "Go that way")
- townSquare.biconnect(Direction.West, westTownStreet, "Walk", "Go that way", "Walk", "Go that way")
- northTownShop.biconnect(Direction.West, northTownStreet, "Exit", "Leave the shop", "Enter", "Enter the shop")
- debug.biconnect(Direction.South, bosses, "Enter", "Boss Fight!", "Leave", "Go back to the debug room")
- eastTownStreet.biconnect(Direction.East, eastGate, "Walk", "Go that way", "Walk", "Go that way")
- eastGate.biconnect(Direction.East, woods, "Walk", "Enter the woods", "Approach", "Enter the city gates")
- woods.biconnect(Direction.North, deepwoods, "Walk", "Go deeper", "Walk", "Leave the deep woods")
-
- return home
- }
|