You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
module.exports = class {
|
|
onCreate(input) {
|
|
this.state = {
|
|
characters: input.characters,
|
|
modal: null,
|
|
}
|
|
}
|
|
|
|
open(modal) {
|
|
this.state.modal = modal
|
|
}
|
|
|
|
close() {
|
|
this.state.modal = null
|
|
}
|
|
|
|
characterRemoved({id}) {
|
|
this.state.characters = this.state.characters.filter(c => c.id !== id)
|
|
}
|
|
|
|
characterEdited(character, patch) {
|
|
const characters = this.state.characters.slice()
|
|
const index = characters.findIndex(c => c.id === character.id)
|
|
if (index === -1) {
|
|
return
|
|
}
|
|
|
|
characters[index] = Object.assign(characters[index], patch)
|
|
|
|
this.state.characters = characters
|
|
}
|
|
|
|
characterAdded(character) {
|
|
this.state.characters = this.state.characters.concat(character)
|
|
}
|
|
|
|
characterNicksChanged(character, nicks) {
|
|
const characters = this.state.characters.slice()
|
|
const index = characters.findIndex(c => c.id === character.id)
|
|
if (index === -1) {
|
|
return
|
|
}
|
|
|
|
characters[index] = Object.assign(characters[index], {nicks: nicks.slice(), nick: (nicks[0] || "")})
|
|
|
|
this.state.characters = characters
|
|
}
|
|
}
|