mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
feat: strip Colors (#469)
This commit is contained in:
parent
0a3338320e
commit
5ae12dd494
11 changed files with 47 additions and 38 deletions
|
|
@ -60,6 +60,6 @@ export default class armagetron extends Core {
|
|||
}
|
||||
|
||||
stripColorCodes (str) {
|
||||
return str.replace(/0x[0-9a-f]{6}/g, '')
|
||||
return this.options.stripColors ? str.replace(/0x[0-9a-f]{6}/g, '') : str
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,6 @@ export default class doom3 extends Core {
|
|||
|
||||
stripColors (str) {
|
||||
// uses quake 3 color codes
|
||||
return str.replace(/\^(X.{6}|.)/g, '')
|
||||
return this.options.stripColors ? str.replace(/\^(X.{6}|.)/g, '') : str
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export default class gamespy2 extends Core {
|
|||
if (state.raw.gamename === 'armygame') {
|
||||
const stripColor = (str) => {
|
||||
// uses unreal 2 color codes
|
||||
return str.replace(/\x1b...|[\x00-\x1a]/g, '')
|
||||
return this.options.stripColors ? str.replace(/\x1b...|[\x00-\x1a]/g, '') : str
|
||||
}
|
||||
state.name = stripColor(state.name)
|
||||
state.map = stripColor(state.map)
|
||||
|
|
|
|||
|
|
@ -81,6 +81,6 @@ export default class nadeo extends Core {
|
|||
}
|
||||
|
||||
stripColors (str) {
|
||||
return str.replace(/\$([0-9a-f]{3}|[a-z])/gi, '')
|
||||
return this.options.stripColors ? str.replace(/\$([0-9a-f]{3}|[a-z])/gi, '') : str
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,12 @@ export default class quake3 extends quake2 {
|
|||
for (const player of state.players) {
|
||||
player.name = this.stripColors(player.name)
|
||||
}
|
||||
for (const bot of state.bots) {
|
||||
bot.name = this.stripColors(bot.name)
|
||||
}
|
||||
}
|
||||
|
||||
stripColors (str) {
|
||||
return str.replace(/\^(X.{6}|.)/g, '')
|
||||
return this.options.stripColors ? str.replace(/\^(X.{6}|.)/g, '') : str
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ export default class savage2 extends Core {
|
|||
}
|
||||
|
||||
stripColorCodes (str) {
|
||||
return str.replace(/\^./g, '')
|
||||
return this.options.stripColors ? str.replace(/\^./g, '') : str
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export default class unreal2 extends Core {
|
|||
out = out.substring(0, out.length - 1)
|
||||
}
|
||||
|
||||
if (stripColor) {
|
||||
if (stripColor && this.options.stripColors) {
|
||||
out = out.replace(/\x1b...|[\x00-\x1a]/gus, '')
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue