| @@ -113,24 +113,27 @@ export default class Combat extends Vue { | |||
| writeLog (entry: LogEntry, cls = "") { | |||
| const log = this.$el.querySelector(".log") | |||
| if (log !== null) { | |||
| const before = log.querySelector("div.log-entry") | |||
| const holder = document.createElement("div") | |||
| holder.classList.add("log-entry") | |||
| const elements = entry.render() | |||
| if (elements.length > 0) { | |||
| const before = log.querySelector("div.log-entry") | |||
| const holder = document.createElement("div") | |||
| holder.classList.add("log-entry") | |||
| entry.render().forEach(element => { | |||
| holder.appendChild(element) | |||
| }) | |||
| if (cls !== "") { | |||
| holder.classList.add(cls) | |||
| } | |||
| entry.render().forEach(element => { | |||
| holder.appendChild(element) | |||
| }) | |||
| const hline = document.createElement("div") | |||
| hline.classList.add("log-separator") | |||
| log.insertBefore(hline, before) | |||
| log.insertBefore(holder, hline) | |||
| if (cls !== "") { | |||
| holder.classList.add(cls) | |||
| log.scrollTo({ top: 0, left: 0 }) | |||
| } | |||
| const hline = document.createElement("div") | |||
| hline.classList.add("log-separator") | |||
| log.insertBefore(hline, before) | |||
| log.insertBefore(holder, hline) | |||
| log.scrollTo({ top: 0, left: 0 }) | |||
| } | |||
| } | |||
| @@ -556,8 +556,11 @@ export class Encounter { | |||
| const effectResults = this.currentMove.effects.map(effect => effect.preTurn(this.currentMove)).filter(effect => effect.prevented) | |||
| if (effectResults.some(result => result.prevented)) { | |||
| const parts = effectResults.map(result => result.log).concat([this.nextMove()]) | |||
| console.log(parts) | |||
| return new LogLines( | |||
| ...effectResults.map(result => result.log).concat([this.nextMove()]) | |||
| ...parts | |||
| ) | |||
| } | |||
| } | |||
| @@ -135,3 +135,22 @@ export class DazzlingEffect extends StatusEffect { | |||
| } | |||
| } | |||
| } | |||
| export class SurrenderEffect extends StatusEffect { | |||
| constructor () { | |||
| super('Surrendered', 'This creature has given up', 'fas fa-flag') | |||
| } | |||
| onApply (creature: Creature): LogEntry { | |||
| return new LogLine( | |||
| `${creature.name.capital} ${creature.name.conjugate(new Verb('surrender'))}!` | |||
| ) | |||
| } | |||
| preTurn (creature: Creature): { prevented: boolean; log: LogEntry } { | |||
| return { | |||
| prevented: true, | |||
| log: nilLog | |||
| } | |||
| } | |||
| } | |||
| @@ -1,7 +1,9 @@ | |||
| import { Creature } from "../creature" | |||
| import { Vigor, Stats, Vigors } from '../combat' | |||
| import { Vigor, Stats, Vigors, CompositionAction } from '../combat' | |||
| import { Noun, Pronoun, ImproperNoun } from '../language' | |||
| import { VoreType } from '../vore' | |||
| import { StatusConsequence } from '../combat/consequences' | |||
| import { SurrenderEffect } from '../combat/effects' | |||
| export class Human extends Creature { | |||
| constructor (name: Noun, pronouns: Pronoun, options: { | |||
| @@ -22,5 +24,17 @@ export class Human extends Creature { | |||
| this.title = "Snack" | |||
| this.desc = "Definitely going on an adventure" | |||
| this.actions.push(new CompositionAction( | |||
| "Surrender", | |||
| "uwu", | |||
| { | |||
| consequences: [ | |||
| new StatusConsequence( | |||
| () => new SurrenderEffect() | |||
| ) | |||
| ] | |||
| } | |||
| )) | |||
| } | |||
| } | |||
| @@ -30,6 +30,7 @@ export class LogLines implements LogEntry { | |||
| } | |||
| render (): HTMLElement[] { | |||
| let nonEmpty = false | |||
| const div = document.createElement("div") | |||
| this.parts.forEach(part => { | |||
| @@ -37,16 +38,18 @@ export class LogLines implements LogEntry { | |||
| const partDiv = document.createElement("div") | |||
| partDiv.innerText = part | |||
| div.appendChild(partDiv) | |||
| nonEmpty = true | |||
| } else if (part !== nilLog) { | |||
| (part as LogEntry).render().forEach(logPart => { | |||
| const partDiv = document.createElement("div") | |||
| partDiv.appendChild(logPart) | |||
| div.appendChild(partDiv) | |||
| nonEmpty = true | |||
| }) | |||
| } | |||
| }) | |||
| return [div] | |||
| return nonEmpty ? [div] : [] | |||
| } | |||
| } | |||
| @@ -105,6 +108,7 @@ export class LogLine implements LogEntry { | |||
| } | |||
| render (): HTMLElement[] { | |||
| let nonEmpty = false | |||
| const div = document.createElement("span") | |||
| this.parts.forEach(part => { | |||
| @@ -112,14 +116,16 @@ export class LogLine implements LogEntry { | |||
| const partSpan = document.createElement("span") | |||
| partSpan.innerText = part | |||
| div.appendChild(partSpan) | |||
| nonEmpty = true | |||
| } else if (part !== nilLog) { | |||
| (part as LogEntry).render().forEach(logPart => { | |||
| div.appendChild(logPart) | |||
| nonEmpty = true | |||
| }) | |||
| } | |||
| }) | |||
| return [div] | |||
| return nonEmpty ? [div] : [] | |||
| } | |||
| } | |||