| @@ -113,24 +113,27 @@ export default class Combat extends Vue { | |||||
| writeLog (entry: LogEntry, cls = "") { | writeLog (entry: LogEntry, cls = "") { | ||||
| const log = this.$el.querySelector(".log") | const log = this.$el.querySelector(".log") | ||||
| if (log !== null) { | 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) | const effectResults = this.currentMove.effects.map(effect => effect.preTurn(this.currentMove)).filter(effect => effect.prevented) | ||||
| if (effectResults.some(result => result.prevented)) { | if (effectResults.some(result => result.prevented)) { | ||||
| const parts = effectResults.map(result => result.log).concat([this.nextMove()]) | |||||
| console.log(parts) | |||||
| return new LogLines( | 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 { Creature } from "../creature" | ||||
| import { Vigor, Stats, Vigors } from '../combat' | |||||
| import { Vigor, Stats, Vigors, CompositionAction } from '../combat' | |||||
| import { Noun, Pronoun, ImproperNoun } from '../language' | import { Noun, Pronoun, ImproperNoun } from '../language' | ||||
| import { VoreType } from '../vore' | import { VoreType } from '../vore' | ||||
| import { StatusConsequence } from '../combat/consequences' | |||||
| import { SurrenderEffect } from '../combat/effects' | |||||
| export class Human extends Creature { | export class Human extends Creature { | ||||
| constructor (name: Noun, pronouns: Pronoun, options: { | constructor (name: Noun, pronouns: Pronoun, options: { | ||||
| @@ -22,5 +24,17 @@ export class Human extends Creature { | |||||
| this.title = "Snack" | this.title = "Snack" | ||||
| this.desc = "Definitely going on an adventure" | 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[] { | render (): HTMLElement[] { | ||||
| let nonEmpty = false | |||||
| const div = document.createElement("div") | const div = document.createElement("div") | ||||
| this.parts.forEach(part => { | this.parts.forEach(part => { | ||||
| @@ -37,16 +38,18 @@ export class LogLines implements LogEntry { | |||||
| const partDiv = document.createElement("div") | const partDiv = document.createElement("div") | ||||
| partDiv.innerText = part | partDiv.innerText = part | ||||
| div.appendChild(partDiv) | div.appendChild(partDiv) | ||||
| nonEmpty = true | |||||
| } else if (part !== nilLog) { | } else if (part !== nilLog) { | ||||
| (part as LogEntry).render().forEach(logPart => { | (part as LogEntry).render().forEach(logPart => { | ||||
| const partDiv = document.createElement("div") | const partDiv = document.createElement("div") | ||||
| partDiv.appendChild(logPart) | partDiv.appendChild(logPart) | ||||
| div.appendChild(partDiv) | div.appendChild(partDiv) | ||||
| nonEmpty = true | |||||
| }) | }) | ||||
| } | } | ||||
| }) | }) | ||||
| return [div] | |||||
| return nonEmpty ? [div] : [] | |||||
| } | } | ||||
| } | } | ||||
| @@ -105,6 +108,7 @@ export class LogLine implements LogEntry { | |||||
| } | } | ||||
| render (): HTMLElement[] { | render (): HTMLElement[] { | ||||
| let nonEmpty = false | |||||
| const div = document.createElement("span") | const div = document.createElement("span") | ||||
| this.parts.forEach(part => { | this.parts.forEach(part => { | ||||
| @@ -112,14 +116,16 @@ export class LogLine implements LogEntry { | |||||
| const partSpan = document.createElement("span") | const partSpan = document.createElement("span") | ||||
| partSpan.innerText = part | partSpan.innerText = part | ||||
| div.appendChild(partSpan) | div.appendChild(partSpan) | ||||
| nonEmpty = true | |||||
| } else if (part !== nilLog) { | } else if (part !== nilLog) { | ||||
| (part as LogEntry).render().forEach(logPart => { | (part as LogEntry).render().forEach(logPart => { | ||||
| div.appendChild(logPart) | div.appendChild(logPart) | ||||
| nonEmpty = true | |||||
| }) | }) | ||||
| } | } | ||||
| }) | }) | ||||
| return [div] | |||||
| return nonEmpty ? [div] : [] | |||||
| } | } | ||||
| } | } | ||||