MCPcopy Create free account
hub / github.com/JKPotato-Computer/SignMaker / Shield

Class Shield

js/Shield.js:1–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Shield {
2 /**
3 * Creates anew a route shield.
4 * @param {string} [type="I-"] - Type of shield.
5 * @param {number} [routeNumber="1"] - Route number to display on shield.
6 * @param {boolean} [to=false] - Whether or not the shield should be signed as "TO".
7 * @param {string} [bannerType] - Directional banner to display.
8 * @param {string} [bannerPosition] - Where to place the directional banner relative to the shield.
9 */
10 constructor({
11 type = "I",
12 routeNumber = "1",
13 to = false,
14 indentFirstLetter = true,
15 fontSize = "1.4rem",
16 specialBannerType,
17 bannerType,
18 bannerType2,
19 bannerPosition
20 } = {}
21 ) {
22 if (Object.keys(this.types).includes(type)) {
23 this.type = type;
24 } else {
25 this.type = "I";
26 }
27 this.type = type;
28 this.routeNumber = routeNumber;
29 this.to = to;
30 this.indentFirstLetter = indentFirstLetter;
31 this.fontSize = fontSize;
32
33 if (this.bannerTypes.includes(bannerType)) {
34 this.bannerType = bannerType;
35 } else {
36 this.bannerType = this.bannerTypes[0];
37 }
38 if (this.bannerTypes.includes(bannerType2)) {
39 this.bannerType2 = bannerType2;
40 } else {
41 this.bannerType2 = this.bannerTypes[0];
42 }
43
44 if (this.bannerPositions.includes(bannerPosition)) {
45 this.bannerPosition = bannerPosition;
46 } else {
47 this.bannerPosition = this.bannerPositions[0];
48 }
49
50 let selectedSpecialBannerType = this.specialBannerTypes[type][specialBannerType];
51
52 if (selectedSpecialBannerType == undefined) {
53 this.specialBannerType = this.bannerTypes[0];
54 } else {
55 if (routeNumber.length >= selectedSpecialBannerType) {
56 this.specialBannerType = specialBannerType;
57 } else {
58 this.specialBannerType = this.bannerTypes[0];
59 }
60 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected