Selaa lähdekoodia

Add armor

vintage
Fen Dweller 5 vuotta sitten
vanhempi
commit
6d8af38985
5 muutettua tiedostoa jossa 64 lisäystä ja 14 poistoa
  1. +2
    -3
      src/App.vue
  2. +1
    -1
      src/game/combat/effects.ts
  3. +14
    -5
      src/game/creature.ts
  4. +10
    -2
      src/game/creatures/player.ts
  5. +37
    -3
      src/game/items.ts

+ 2
- 3
src/App.vue Näytä tiedosto

@@ -64,14 +64,13 @@ export default class App extends Vue {
}

created () {
const player = new Creatures.Wolf()
const player = new Creatures.Player()
player.perspective = POV.Second
player.side = Side.Heroes
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.Dagger())
player.items.push(new Items.Sword())
this.$data.world = new World(player)

player.location = Town()


+ 1
- 1
src/game/combat/effects.ts Näytä tiedosto

@@ -74,7 +74,7 @@ export class DamageTypeResistanceEffect extends StatusEffect {

modResistance (type: DamageType, factor: number) {
if (this.damageTypes.includes(type)) {
return factor * (1 - this.amount)
return factor * this.amount
} else {
return factor
}


+ 14
- 5
src/game/creature.ts Näytä tiedosto

@@ -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 { LogEntry, LogLines } from './interface'
import { Vore, VoreContainer, VoreType } from './vore'
@@ -10,7 +10,16 @@ export class Creature extends Vore implements Combatant {
actions: Array<Action> = [];
containedIn: VoreContainer | null = null;
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> = [];
items: Array<Item> = [];
otherActions: Array<Action> = [];
@@ -35,7 +44,7 @@ export class Creature extends Vore implements Combatant {
* Determines how much damage an attack would do
*/
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)
}, damage)
return super.effectiveDamage(preDamage)
@@ -61,7 +70,7 @@ export class Creature extends Vore implements Combatant {
}

removeEffect (effect: StatusEffect): LogEntry {
this.effects = this.effects.filter(eff => eff !== effect)
this.statusEffects = this.statusEffects.filter(eff => eff !== effect)
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'))
}

this.effects.forEach(effect => {
this.statusEffects.forEach(effect => {
results.push(effect)
})
return results


+ 10
- 2
src/game/creatures/player.ts Näytä tiedosto

@@ -1,12 +1,20 @@
import { Creature } from "../creature"
import { ProperNoun, TheyPronouns, ImproperNoun, POV } from '../language'
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'

export class Player extends Creature {
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 }))))



+ 37
- 3
src/game/items.ts Näytä tiedosto

@@ -1,6 +1,8 @@
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 { Resistances } from './entity'
import { DamageTypeResistanceEffect } from './combat/effects'

export enum ItemKind {
Key = "Key Item",
@@ -15,9 +17,10 @@ export const ItemKindIcons: {[key in ItemKind]: string} = {
}

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) {

}
@@ -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
}
)
}
}

Loading…
Peruuta
Tallenna