| @@ -64,14 +64,13 @@ export default class App extends Vue { | |||||
| } | } | ||||
| created () { | created () { | ||||
| const player = new Creatures.Wolf() | |||||
| const player = new Creatures.Player() | |||||
| player.perspective = POV.Second | player.perspective = POV.Second | ||||
| player.side = Side.Heroes | player.side = Side.Heroes | ||||
| player.equipment.set(Items.EquipmentSlot.MainHand, new Items.Sword()) | player.equipment.set(Items.EquipmentSlot.MainHand, new Items.Sword()) | ||||
| player.items.push(new Items.Sword()) | |||||
| player.equipment.set(Items.EquipmentSlot.Head, new Items.Helmet()) | |||||
| player.items.push(new Items.Mace()) | player.items.push(new Items.Mace()) | ||||
| player.items.push(new Items.Dagger()) | player.items.push(new Items.Dagger()) | ||||
| player.items.push(new Items.Sword()) | |||||
| this.$data.world = new World(player) | this.$data.world = new World(player) | ||||
| player.location = Town() | player.location = Town() | ||||
| @@ -74,7 +74,7 @@ export class DamageTypeResistanceEffect extends StatusEffect { | |||||
| modResistance (type: DamageType, factor: number) { | modResistance (type: DamageType, factor: number) { | ||||
| if (this.damageTypes.includes(type)) { | if (this.damageTypes.includes(type)) { | ||||
| return factor * (1 - this.amount) | |||||
| return factor * this.amount | |||||
| } else { | } else { | ||||
| return factor | return factor | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| import { Damage, Combatant, Stats, Action, Vigor, Side, GroupAction, VisibleStatus, ImplicitStatus, StatusEffect, DamageType } from './combat' | |||||
| import { Damage, Combatant, Stats, Action, Vigor, Side, GroupAction, VisibleStatus, ImplicitStatus, StatusEffect, DamageType, Effective } from './combat' | |||||
| import { Noun, Pronoun } from './language' | import { Noun, Pronoun } from './language' | ||||
| import { LogEntry, LogLines } from './interface' | import { LogEntry, LogLines } from './interface' | ||||
| import { Vore, VoreContainer, VoreType } from './vore' | import { Vore, VoreContainer, VoreType } from './vore' | ||||
| @@ -10,7 +10,16 @@ export class Creature extends Vore implements Combatant { | |||||
| actions: Array<Action> = []; | actions: Array<Action> = []; | ||||
| containedIn: VoreContainer | null = null; | containedIn: VoreContainer | null = null; | ||||
| desc = "Some creature"; | desc = "Some creature"; | ||||
| effects: Array<StatusEffect> = []; | |||||
| get effects (): Array<Effective> { | |||||
| return (this.statusEffects as Effective[]).concat( | |||||
| Array.from(this.equipment.values()).flatMap( | |||||
| item => item.effects | |||||
| ) | |||||
| ) | |||||
| } | |||||
| statusEffects: Array<StatusEffect> = []; | |||||
| groupActions: Array<GroupAction> = []; | groupActions: Array<GroupAction> = []; | ||||
| items: Array<Item> = []; | items: Array<Item> = []; | ||||
| otherActions: Array<Action> = []; | otherActions: Array<Action> = []; | ||||
| @@ -35,7 +44,7 @@ export class Creature extends Vore implements Combatant { | |||||
| * Determines how much damage an attack would do | * Determines how much damage an attack would do | ||||
| */ | */ | ||||
| effectiveDamage (damage: Damage): Damage { | effectiveDamage (damage: Damage): Damage { | ||||
| const preDamage = this.effects.reduce((modifiedDamage: Damage, effect: StatusEffect) => { | |||||
| const preDamage = this.effects.reduce((modifiedDamage: Damage, effect: Effective) => { | |||||
| return effect.preDamage(this, modifiedDamage) | return effect.preDamage(this, modifiedDamage) | ||||
| }, damage) | }, damage) | ||||
| return super.effectiveDamage(preDamage) | return super.effectiveDamage(preDamage) | ||||
| @@ -61,7 +70,7 @@ export class Creature extends Vore implements Combatant { | |||||
| } | } | ||||
| removeEffect (effect: StatusEffect): LogEntry { | removeEffect (effect: StatusEffect): LogEntry { | ||||
| this.effects = this.effects.filter(eff => eff !== effect) | |||||
| this.statusEffects = this.statusEffects.filter(eff => eff !== effect) | |||||
| return effect.onRemove(this) | return effect.onRemove(this) | ||||
| } | } | ||||
| @@ -81,7 +90,7 @@ export class Creature extends Vore implements Combatant { | |||||
| results.push(new ImplicitStatus('Eaten', 'Devoured by ' + this.containedIn.owner.name, 'fas fa-drumstick-bite')) | results.push(new ImplicitStatus('Eaten', 'Devoured by ' + this.containedIn.owner.name, 'fas fa-drumstick-bite')) | ||||
| } | } | ||||
| this.effects.forEach(effect => { | |||||
| this.statusEffects.forEach(effect => { | |||||
| results.push(effect) | results.push(effect) | ||||
| }) | }) | ||||
| return results | return results | ||||
| @@ -1,12 +1,20 @@ | |||||
| import { Creature } from "../creature" | import { Creature } from "../creature" | ||||
| import { ProperNoun, TheyPronouns, ImproperNoun, POV } from '../language' | import { ProperNoun, TheyPronouns, ImproperNoun, POV } from '../language' | ||||
| import { Damage, DamageType, Vigor, ConstantDamageFormula } from '../combat' | import { Damage, DamageType, Vigor, ConstantDamageFormula } from '../combat' | ||||
| import { Stomach, Bowels, VoreType } from '../vore' | |||||
| import { Stomach, Bowels, VoreType, anyVore } from '../vore' | |||||
| import { AttackAction } from '../combat/actions' | import { AttackAction } from '../combat/actions' | ||||
| export class Player extends Creature { | export class Player extends Creature { | ||||
| constructor () { | constructor () { | ||||
| super(new ProperNoun('The Dude'), new ImproperNoun('player', 'players'), TheyPronouns, { Toughness: 20, Power: 20, Speed: 20, Willpower: 20, Charm: 20 }, new Set([VoreType.Oral, VoreType.Anal]), new Set([VoreType.Oral, VoreType.Anal]), 50) | |||||
| super( | |||||
| new ProperNoun('Player'), | |||||
| new ImproperNoun('player', 'players'), | |||||
| TheyPronouns, | |||||
| { Toughness: 25, Power: 25, Speed: 25, Willpower: 25, Charm: 25 }, | |||||
| anyVore, | |||||
| anyVore, | |||||
| 50 | |||||
| ) | |||||
| this.actions.push(new AttackAction(new ConstantDamageFormula(new Damage({ type: DamageType.Pierce, amount: 20, target: Vigor.Health }, { type: DamageType.Pierce, amount: 20, target: Vigor.Stamina })))) | this.actions.push(new AttackAction(new ConstantDamageFormula(new Damage({ type: DamageType.Pierce, amount: 20, target: Vigor.Health }, { type: DamageType.Pierce, amount: 20, target: Vigor.Stamina })))) | ||||
| @@ -1,6 +1,8 @@ | |||||
| import { TextLike, LiveText, DynText, Word, ImproperNoun, Verb } from './language' | import { TextLike, LiveText, DynText, Word, ImproperNoun, Verb } from './language' | ||||
| import { Actionable, Action, DamageFormula, ConstantDamageFormula, Damage, DamageType, Vigor, StatDamageFormula, Stat } from './combat' | |||||
| import { Actionable, Action, DamageFormula, ConstantDamageFormula, Damage, DamageType, Vigor, StatDamageFormula, Stat, Effective } from './combat' | |||||
| import { AttackAction } from './combat/actions' | import { AttackAction } from './combat/actions' | ||||
| import { Resistances } from './entity' | |||||
| import { DamageTypeResistanceEffect } from './combat/effects' | |||||
| export enum ItemKind { | export enum ItemKind { | ||||
| Key = "Key Item", | Key = "Key Item", | ||||
| @@ -15,9 +17,10 @@ export const ItemKindIcons: {[key in ItemKind]: string} = { | |||||
| } | } | ||||
| export abstract class Item implements Actionable { | export abstract class Item implements Actionable { | ||||
| abstract kind: ItemKind; | |||||
| abstract actions: Array<Action>; | |||||
| actions: Array<Action> = [] | |||||
| effects: Array<Effective> = [] | |||||
| abstract kind: ItemKind | |||||
| constructor (public name: Word, public desc: TextLike) { | constructor (public name: Word, public desc: TextLike) { | ||||
| } | } | ||||
| @@ -105,3 +108,34 @@ export class Mace extends Weapon { | |||||
| ) | ) | ||||
| } | } | ||||
| } | } | ||||
| export abstract class Armor extends Equipment { | |||||
| constructor (name: Word, desc: TextLike, public slot: EquipmentSlot, resistances: Partial<Resistances>) { | |||||
| super(name, desc) | |||||
| Object.entries(resistances).forEach(([damageType, value]) => { | |||||
| if (value !== undefined) { | |||||
| this.effects.push( | |||||
| new DamageTypeResistanceEffect( | |||||
| [damageType as DamageType], | |||||
| value | |||||
| ) | |||||
| ) | |||||
| } | |||||
| }) | |||||
| } | |||||
| } | |||||
| export class Helmet extends Armor { | |||||
| constructor () { | |||||
| super( | |||||
| new ImproperNoun('helmet'), | |||||
| 'A helmet', | |||||
| EquipmentSlot.Head, | |||||
| { | |||||
| Slash: 0.75, | |||||
| Pierce: 0.5, | |||||
| Crush: 0.9 | |||||
| } | |||||
| ) | |||||
| } | |||||
| } | |||||