1
1

PersonStat.ts 713 B

12345678910111213141516171819
  1. class PersonStat {
  2. public id : string;
  3. protected description : string | Say | ((value : number) => string | Say);
  4. public defaultValue : number = 0;
  5. public maxValue : number = 10;
  6. public constructor (id : string, description? : string | Say | ((value : number) => string | Say)) {
  7. this.id = id;
  8. this.description = description == undefined ? "Not defined" : description;
  9. }
  10. public getDescription (value : number) : Say | string | ((value : number) => (string | Say)) {
  11. if (typeof this.description == "string" || this.description instanceof Say) {
  12. return this.description;
  13. } else {
  14. return this.description(value);
  15. }
  16. }
  17. }