Pārlūkot izejas kodu

Filter out nilLogs

master
Fen Dweller pirms 5 gadiem
vecāks
revīzija
36c5f03a24
2 mainītis faili ar 14 papildinājumiem un 14 dzēšanām
  1. +3
    -3
      src/game/combat/actions.ts
  2. +11
    -11
      src/game/interface.ts

+ 3
- 3
src/game/combat/actions.ts Parādīt failu

@@ -3,7 +3,7 @@ import { DynText, LiveText, TextLike, Verb, PairLine, PairLineArgs } from '../la
import { Entity } from '../entity'
import { Creature } from "../creature"
import { Damage, DamageFormula, Stat, Vigor, Action } from '../combat'
import { LogLine, LogLines, LogEntry, CompositeLog, nilLog } from '../interface'
import { LogLine, LogLines, LogEntry, nilLog } from '../interface'
import { VoreContainer, Container } from '../vore'
import { CapableCondition, UserDrainedVigorCondition, TogetherCondition, EnemyCondition, SoloCondition, PairCondition, ContainsCondition, ContainedByCondition } from './conditions'

@@ -43,7 +43,7 @@ export class AttackAction extends Action {
const damage = this.damage.calc(user, target)
const targetResult = target.takeDamage(damage)
const ownResult = this.successLine(user, target, { damage: damage })
return new CompositeLog(ownResult, targetResult)
return new LogLines(ownResult, targetResult)
} else {
return this.failLine(user, target)
}
@@ -217,7 +217,7 @@ export class DigestAction extends Action {

execute (user: Creature, target: Creature): LogEntry {
const results = this.container.tick(60)
return new CompositeLog(results)
return new LogLines(results)
}

describe (user: Creature, target: Creature): LogEntry {


+ 11
- 11
src/game/interface.ts Parādīt failu

@@ -8,6 +8,15 @@ export interface LogEntry {
render: () => HTMLElement[];
}

/**
* Represents nothing. Other elements should filter this out if they don't want blank spaces
*/
export const nilLog = {
render (): HTMLElement[] {
return []
}
}

/**
* Takes zero or more strings or [[LogEntry]] objects
*
@@ -28,7 +37,7 @@ export class LogLines implements LogEntry {
const partDiv = document.createElement("div")
partDiv.innerText = part
div.appendChild(partDiv)
} else {
} else if (part !== nilLog) {
(part as LogEntry).render().forEach(logPart => {
const partDiv = document.createElement("div")
partDiv.appendChild(logPart)
@@ -103,7 +112,7 @@ export class LogLine implements LogEntry {
const partSpan = document.createElement("span")
partSpan.innerText = part
div.appendChild(partSpan)
} else {
} else if (part !== nilLog) {
(part as LogEntry).render().forEach(logPart => {
div.appendChild(logPart)
})
@@ -230,12 +239,3 @@ export class CompositeLog implements LogEntry {
return this.entries.flatMap(e => e.render())
}
}

/**
* Represents nothing. Other elements should filter this out if they don't want blank spaces
*/
export const nilLog = {
render (): HTMLElement[] {
return []
}
}

Notiek ielāde…
Atcelt
Saglabāt