2023-10-07 20:08:33 +00:00
|
|
|
import BattleScene from "../battle-scene";
|
2024-01-13 17:24:24 +00:00
|
|
|
import { TrainerType } from "../data/enums/trainer-type";
|
2024-03-21 04:57:28 +00:00
|
|
|
import Trainer, { TrainerVariant } from "../field/trainer";
|
2023-10-07 20:08:33 +00:00
|
|
|
|
|
|
|
export default class TrainerData {
|
|
|
|
public trainerType: TrainerType;
|
2024-03-21 04:57:28 +00:00
|
|
|
public variant: TrainerVariant;
|
2023-10-18 22:01:15 +00:00
|
|
|
public partyTemplateIndex: integer;
|
2024-03-21 04:57:28 +00:00
|
|
|
public name: string;
|
|
|
|
public partnerName: string;
|
2023-10-07 20:08:33 +00:00
|
|
|
|
|
|
|
constructor(source: Trainer | any) {
|
|
|
|
const sourceTrainer = source instanceof Trainer ? source as Trainer : null;
|
|
|
|
this.trainerType = sourceTrainer ? sourceTrainer.config.trainerType : source.trainerType;
|
2024-03-21 04:57:28 +00:00
|
|
|
this.variant = source.hasOwnProperty('variant') ? source.variant : source.female ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT;
|
2023-10-18 22:01:15 +00:00
|
|
|
this.partyTemplateIndex = source.partyMemberTemplateIndex;
|
2024-03-21 04:57:28 +00:00
|
|
|
this.name = source.name;
|
|
|
|
this.partnerName = source.partnerName;
|
2023-10-07 20:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
toTrainer(scene: BattleScene): Trainer {
|
2024-03-21 04:57:28 +00:00
|
|
|
return new Trainer(scene, this.trainerType, this.variant, this.partyTemplateIndex);
|
2023-10-07 20:08:33 +00:00
|
|
|
}
|
|
|
|
}
|