/
Pilot.js
35 lines (27 loc) · 798 Bytes
/
Pilot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {Model, attr, fk} from "redux-orm";
export default class Pilot extends Model {
static modelName = "Pilot";
static fields = {
id : attr(),
name : attr(),
rank : attr(),
gunnery : attr(),
piloting : attr(),
age : attr(),
mech : fk("Mech")
}
static parse(pilotData) {
// We could do useful stuff in here with relations,
// but since we have no relations yet, all we need
// to do is pass the pilot data on to create()
// Note that in a static class method, `this` is the
// class itself, not an instance
return this.create(pilotData);
}
toJSON() {
return {...this.ref};
}
updateFrom(otherPilot) {
this.update(otherPilot.ref);
}
}