donsol-js/sources/scripts/gage.shield.js
2020-04-16 19:53:23 +09:00

25 lines
809 B
JavaScript

'use strict'
function Gage_Shield (name, limit, color) {
Gage.call(this, name, limit, color)
this.break_limit = null
this.update = function () {
if (this.is_damaged() === true) {
this.value_element.innerHTML = `${this.break_limit - 1}/${this.value} <span class='unit'>DP</span>`
this.progress.update(this.value < this.break_limit ? this.value : this.break_limit - 1, 11)
} else if (this.value == 0) {
this.value_element.innerHTML = "0 <span class='unit'>DP</span>"
this.progress.update(0, 11)
} else {
this.value_element.innerHTML = '<span>' + this.value + "</span> <span class='unit'>DP</span>"
this.progress.update(this.value, 11)
}
}
this.is_damaged = function () {
if (this.break_limit === null) { return false }
return true
}
}