How to use StatusUpdater method in Karma

Best JavaScript code snippet using karma

Run Karma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

skills.js

Source: skills.js Github

copy
1import statusUpdater from "./statusUpdater";
2import store from "../store";
3export default {
4  extraHeart: {
5    name: "extraHeart",
6    text: "Extra Heart",
7    desc: "Increase HP by 30% per level",
8    cost: 3,
9    max: 3,
10    prerequisites: false,
11    aquire(){
12      store.player.hp.extraHeartMultiplier += 0.3;
13      statusUpdater.updateHp();
14    },
15    remove(){
16      store.player.hp.extraHeartMultiplier = 0;
17      statusUpdater.updateHp();
18    }
19  },
20  extraBeef: {
21    name: "extraBeef",
22    text: "Extra Beef",
23    desc: "Increase Attack by 10% per level",
24    cost: 1,
25    max: 5,
26    prerequisites: ["extraHeart"],
27    aquire(){
28      store.player.attack.extraBeefMultiplier += 0.1;
29      statusUpdater.updateAttack();
30    },
31    remove(){
32      store.player.attack.extraBeefMultiplier = 0;
33      statusUpdater.updateAttack();
34    }
35  },
36  longerLegs: {
37    name: "longerLegs",
38    text: "Longer Legs",
39    desc: "Increase speed by 1 - ATB fills up one tick sooner. Base is 25 ticks.",
40    cost: 4,
41    max: 3,
42    prerequisites: false,
43    aquire(){
44      store.player.atb.longerLegs += 1;
45      statusUpdater.updateSpeed();
46    },
47    remove(){
48      store.player.atb.longerLegs = 0;
49      statusUpdater.updateSpeed();
50    },
51  },
52  superiorVision: {
53    name: "superiorVision",
54    text: "Superior Vision",
55    desc: "Increase explore speed by 5 - ATB fills up 5 ticks sooner. Base is 100 ticks.",
56    cost: 1,
57    max: 10,
58    prerequisites: false,
59    aquire(){
60      store.player.exploreSpeed += 5;
61      statusUpdater.updateExploreSpeed();
62    },
63    remove(){
64      store.player.exploreSpeed = 0;
65      statusUpdater.updateExploreSpeed();
66    },
67  },
68  centepedeForcipules:{
69    name: "centepedeForcipules",
70    text: "Centepede Forcipules",
71    desc: "Base posion damage up 1 per level - by default poison has a 5% chance of hitting",
72    cost: 4,
73    max: 3,
74    prerequisites: false,
75    aquire(){
76      store.player.poisonAttack.centepedeForcipules += 1;
77      statusUpdater.updatePoisonAttack();
78    }, 
79    remove(){
80      store.player.poisonAttack.centepedeForcipules = 0;
81      statusUpdater.updatePoisonAttack();
82    }, 
83  },
84  anaphylaxis:{
85    name: "anaphylaxis",
86    text: "Anaphylaxis",
87    desc: "Posion chance is 20% greater - multiplier - it's multiplied by 20%, not 20% more!",
88    cost: 2,
89    max: 5,
90    prerequisites: false,
91    aquire(){
92      store.player.poisonAttack.anaphylaxis += 20;
93      statusUpdater.updatePoisonAttackChance();
94    },
95    remove(){
96      store.player.poisonAttack.anaphylaxis = 0;
97      statusUpdater.updatePoisonAttackChance();
98    },      
99  },
100  formicAcid:{
101    name: "formicAcid",
102    text: "Formic Acid",
103    desc: "Posion chance base is 1% greater - additive - it's 1% more!",
104    cost: 2,
105    max: 10,
106    prerequisites: false,
107    aquire(){
108      store.player.poisonAttack.formicAcid += 1;
109      statusUpdater.updatePoisonAttackChance();
110    },
111    remove(){
112      store.player.poisonAttack.formicAcid = 0;
113      statusUpdater.updatePoisonAttackChance();
114    },      
115  },
116  fangs:{
117    name: "fangs",
118    text: "Fangs",
119    desc: "Your poison attack percentage will directly multiply your damage",
120    cost: 20,
121    max: 1,
122    prerequisites: false,
123    aquire(){
124      store.player.attack.fangsMultiplier = store.player.poisonAttack.chance/100;
125      statusUpdater.updateAttack();
126    },
127    remove(){
128      store.player.attack.fangsMultiplier = 0;
129      statusUpdater.updateAttack();
130    },    
131  },
132  lobsterGreed:{
133    name: "lobsterGreed",
134    text: "Lobster Greed",
135    desc: "These greedy lobster instincts will compell you to find 10% more gold per level.",
136    cost: 2,
137    max: 10,
138    prerequisites: false,
139    aquire(){
140      store.player.goldGain.lobsterGreed += 0.1;
141      statusUpdater.updateGoldGain();
142    },
143    remove(){
144      store.player.goldGain.lobsterGreed = 0;
145      statusUpdater.updateGoldGain();
146    },    
147  },
148  shrimpWisdom:{
149    name: "shrimpWisdom",
150    text: "Shrimp Wisdom",
151    desc: "You could learn alot from shrimps you know? Gain 10% more experience per level.",
152    cost: 2,
153    max: 10,
154    prerequisites: false,
155    aquire(){
156      store.player.expGain.shrimpWisdom += 0.1;
157      statusUpdater.updateExpGain();
158    },
159    remove(){
160      store.player.expGain.shrimpWisdom = 0;
161      statusUpdater.updateExpGain();
162    },
163  },
164  necrosis:{
165    name: "necrosis",
166    text: "Necrosis",
167    desc: "Attacks are 10% more powerfull against poisoned foes.",
168    cost: 2,
169    max: 5,
170    prerequisites: false,
171    aquire(){
172      store.player.toxin.necrosis += 0.1;
173      statusUpdater.updateToxin();
174    },
175    remove(){
176      store.player.toxin.necrosis = 0;
177      statusUpdater.updateToxin();
178    },      
179  },
180  antigens:{
181    name: "antigens",
182    text: "Antigens",
183    desc: "You negate one poison per level.",
184    cost: 3,
185    max: 3,
186    prerequisites: false,
187    aquire(){
188      store.player.poisonDefence.antigens += 1;
189      statusUpdater.updatePoisonDefence();
190    },
191    remove(){
192      store.player.poisonDefence.antigens = 0;
193      statusUpdater.updatePoisonDefence();
194    }
195  },
196  joust: {
197    name: "joust",
198    text: "Joust",
199    desc: "Every fourth attack will do 70% more damage per level.",
200    cost: 4,
201    max: 3,
202    prerequisites: false,
203    aquire(){
204      store.player.strongFourth.joust += 0.7
205      statusUpdater.updateStrongFourthVal();
206    },
207    remove(){
208      store.player.strongFourth.joust = 0;
209      statusUpdater.updateStrongFourthVal();
210    }      
211  },
212  antiJoust: {
213    name: "antiJoust",
214    text: "Anti-Joust",
215    desc: "You block an extra 2 damage per level - but only only every fourth time your attacked.",
216    cost: 3,
217    max: 3,
218    prerequisites: false,
219    aquire(){
220      store.player.fourthDefence.antiJoust += 2;
221      statusUpdater.updateFourthDefenceFlat();
222    },
223    remove(){
224      store.player.fourthDefence.antiJoust = 0;
225      statusUpdater.updateFourthDefenceFlat();
226    }     
227  }
228
229}
230
231
232
233
234
235
Full Screen

artifacts.js

Source: artifacts.js Github

copy
1import store from "../store";
2import statusUpdater from "./statusUpdater";
3export default {
4  dodgyTicker:{
5    name:"dodgyTicker",
6    text: "The Dodgy Ticker",
7    desc: "Beep Beep Beep BONG. Your fourth attack is greater so your other attacks are nerfed.",
8    equip(){
9      store.artifacts.dodgyTicker.equipped = true;
10      store.player.attack.dodgyTicker += 1;
11      store.player.strongFourth.dodgyTicker += 3;
12      statusUpdater.updateAttack();
13      statusUpdater.updateStrongFourthVal();
14    },
15    unequip(){
16      store.artifacts.dodgyTicker.equipped = false;
17      store.player.attack.dodgyTicker -= 1;
18      store.player.strongFourth.dodgyTicker -= 3;
19      statusUpdater.updateAttack();
20      statusUpdater.updateStrongFourthVal();
21    }
22  },
23  experimentalVaccine:{
24    name:"experimentalVaccine",
25    text: "Experimental Vaccine",
26    desc: "You will become more immune to poison, your long term heath will suffer",
27    equip(){
28      store.artifacts.experimentalVaccine.equipped = true;
29      store.player.hp.experimentalVaccine += 1;
30      store.player.poisonDefence.experimentalVaccine += 2;
31      statusUpdater.updateHp();
32      statusUpdater.updatePoisonDefence();
33    },
34    unequip(){
35      store.artifacts.experimentalVaccine.equipped = false;
36      store.player.hp.experimentalVaccine -= 1;
37      store.player.poisonDefence.experimentalVaccine -= 2;
38      statusUpdater.updateHp();
39      statusUpdater.updatePoisonDefence();
40    }
41  },
42  pillow:{
43    name:"pillow",
44    text: "The Pillow",
45    desc: "Life just got more comfortable - you will rely less on violence.",
46    equip(){
47      store.artifacts.pillow.equipped = true;
48      store.player.hp.pillow += 0.3;
49      store.player.attack.pillow += 1;
50      statusUpdater.updateHp();
51      statusUpdater.updateAttack();
52    },
53    unequip(){
54      store.artifacts.pillow.equipped = false;
55      store.player.hp.pillow -= 0.3;
56      store.player.attack.pillow -= 1;
57      statusUpdater.updateHp();
58      statusUpdater.updateAttack();
59    }
60  },
61  plusSign:{
62    name:"plusSign",
63    text: "A Plus Sign",
64    desc: "Yay, no drabacks.",
65    equip(){
66      store.artifacts.plusSign.equipped = true;
67      store.player.hp.plusSign += 13;
68      store.player.attack.plusSign += 3;
69      statusUpdater.updateHp();
70      statusUpdater.updateAttack();
71    },
72    unequip(){
73      store.artifacts.plusSign.equipped = false;
74      store.player.hp.plusSign -= 13;
75      store.player.attack.plusSign -= 3;
76      statusUpdater.updateHp();
77      statusUpdater.updateAttack();
78    },
79  },
80
81
82}
Full Screen

index.js

Source: index.js Github

copy
1let config    = require(__base + 'config'),
2masterConfig  = require(__base + 'components/db-master/master-configs'),
3rp            = require('request-promise'),
4statusUpdater   = require(__base +
5  'components/core/helper/status-updater')({}),
6tableOperations   = require(__base +
7    'components/db-master/table-operations')({}),
8pushUpdate   = require(__base +
9        'components/core/push-update')({}),
10isJSON      = require('is-valid-json'),
11isReachable = require('is-reachable'),
12logger      = require(__base + 'components/logger').log(),
13logFormat   = require(__base + 'components/logger').format;
14
15module.exports = (params) => {
16  return {
17    proceedCSM: (data) => {
18      console.log('================ proceedCSM data');
19      masterConfig.getConfigValue('core', 'cloud_his_url', (err, row) => {
20        console.log('================ proceedCSM' + row);
21        if(row) {
22          let cloudUrl = row.config_val;
23          console.log('================ proceedCSM' + cloudUrl);
24          isReachable(cloudUrl).then(reachable => {
25            console.log('================ IS REACHABLE');
26            let d = {
27              state: 4,
28              syncRequestsId: data.sync_requests_id,
29              remoteSyncRequestId: data.relative_sync_requests_id,
30              hotelId: data.hotel_id
31            };
32            console.log('================ PRINTING DATA PACKET TO UPDATE');
33            console.log(d);
34            statusUpdater.updateStatus(d, (err, response) => {
35              console.log('================ REPONSE FROM UPDATE');
36              if(err) {
37                let d = {
38                  state: 2,
39                  syncRequestsId: data.sync_requests_id,
40                  remoteSyncRequestId: data.relative_sync_requests_id,
41                  hotelId: data.hotel_id
42                };
43                statusUpdater.updateStatus(d, (err, response) => {
44                  //return true;
45                });
46              }
47            });
48          });
49        }
50      });
51    },
52    backupData: (data, callback) => {
53      let d = {
54        state: 7,
55        syncRequestsId: data.sync_requests_id,
56        remoteSyncRequestId: data.relative_sync_requests_id,
57        hotelId: data.hotel_id
58      };
59      statusUpdater.updateStatus(d, (err, response) => {
60        if(response) {
61          console.log('STATUS = 7 UPDATED @ CLOUD AND INPREMISE :: CLOUD AND INPREMISE');
62          tableOperations.tablesBackup(data, (err, tablesBackupRes) => {
63            if(tablesBackupRes) {
64              let d = {
65                state: 8,
66                syncRequestsId: data.sync_requests_id,
67                remoteSyncRequestId: data.relative_sync_requests_id,
68                hotelId: data.hotel_id
69              };
70              statusUpdater.updateStatus(d, (err, response) => {
71                if(response) {
72                  // need to write logger functions
73                } else {
74                  // need to write logger functions
75                }
76              });
77            } else {
78              let d = {
79                state: 6,
80                syncRequestsId: data.sync_requests_id,
81                remoteSyncRequestId: data.relative_sync_requests_id,
82                hotelId: data.hotel_id
83              };
84
85              statusUpdater.updateStatus(d, (err, response) => {
86                if(response) {
87                  // need to write logger functions
88                } else {
89                  // need to write logger functions
90                }
91              });
92            }
93          });
94        } else {
95          let d = {
96            state: 6,
97            syncRequestsId: data.sync_requests_id,
98            remoteSyncRequestId: data.relative_sync_requests_id,
99            hotelId: data.hotel_id
100          };
101          statusUpdater.updateStatus(d, (err, response) => {
102            if(response) {
103              // need to write logger functions
104            } else {
105              // need to write logger functions
106            }
107          });
108        }
109      });
110    },
111    truncateTables: (data, callback) => {
112      let d = {
113        state: 9,
114        syncRequestsId: data.sync_requests_id,
115        remoteSyncRequestId: data.relative_sync_requests_id,
116        hotelId: data.hotel_id
117      };
118      statusUpdater.updateStatus(d, (err, response) => {
119        if(response) {
120          tableOperations.truncateTables(data, (err, truncateDataRes) => {
121            console.log('RESPONSE FROM truncateTables :: CLOUD TO INPREMISE - HEAD START');
122            console.log(truncateDataRes);
123            console.log('RESPONSE FROM truncateTables :: CLOUD TO INPREMISE - HEAD END');
124            if(truncateDataRes) {
125              console.log('ENTED IN IF CONDITION truncateTables');
126              let d = {
127                state: 10,
128                syncRequestsId: data.sync_requests_id,
129                remoteSyncRequestId: data.relative_sync_requests_id,
130                hotelId: data.hotel_id
131              };
132
133              statusUpdater.updateStatus(d, (err, response) => {
134                if(response) {
135                  // need to write logger functions
136                } else {
137                  // need to write logger functions
138                }
139              });
140            } else {
141              let d = {
142                state: 8,
143                syncRequestsId: data.sync_requests_id,
144                remoteSyncRequestId: data.relative_sync_requests_id,
145                hotelId: data.hotel_id
146              };
147
148              statusUpdater.updateStatus(d, (err, response) => {
149                if(response) {
150                  // need to write logger functions
151                } else {
152                  // need to write logger functions
153                }
154              });
155            }
156          });
157        } else {
158          let d = {
159            state: 8,
160            syncRequestsId: data.sync_requests_id,
161            remoteSyncRequestId: data.relative_sync_requests_id,
162            hotelId: data.hotel_id
163          };
164
165          statusUpdater.updateStatus(d, (err, response) => {
166            if(response) {
167              // need to write logger functions
168            } else {
169              // need to write logger functions
170            }
171          });
172        }
173      });
174    },
175    importTables: (data, callback) => {
176      let d = {
177        state: 11,
178        syncRequestsId: data.sync_requests_id,
179        remoteSyncRequestId: data.relative_sync_requests_id,
180        hotelId: data.hotel_id
181      };
182      statusUpdater.updateStatus(d, (err, response) => {
183        if(response) {
184          tableOperations.importTables(data, (err, importDataRes) => {
185            if(importDataRes) {
186              let stateValue = 12;
187
188              if(data.generate_sqlite==0 && data.generate_push==0) {
189                stateValue = 16;
190              } else if(data.generate_sqlite==0 && data.generate_push==1) {
191                stateValue = 14;
192              }
193              console.log('REQUEST FROM importTables Fn');
194              console.log('WRITING TO CLOUD and IN-PREMISE');
195              let d = {
196                state: stateValue,
197                syncRequestsId: data.sync_requests_id,
198                remoteSyncRequestId: data.relative_sync_requests_id,
199                hotelId: data.hotel_id
200              };
201
202              statusUpdater.updateStatus(d, (err, response) => {
203                if(response) {
204                  return true;
205                } else {
206                  return false;
207                }
208              });
209            }
210          });
211        } else {
212          let d = {
213            state: 8,
214            syncRequestsId: data.sync_requests_id,
215            remoteSyncRequestId: data.relative_sync_requests_id,
216            hotelId: data.hotel_id
217          };
218
219          statusUpdater.updateStatus(d, (err, response) => {
220            if(response) {
221              // need to write logger functions
222            } else {
223              // need to write logger functions
224            }
225          });
226        }
227      });
228    },
229    generateSQLITE: (data, callback) => {
230      let d = {
231        state: 13,
232        syncRequestsId: data.sync_requests_id,
233        remoteSyncRequestId: data.relative_sync_requests_id,
234        hotelId: data.hotel_id
235      };
236      statusUpdater.updateStatus(d, (err, response) => {
237        if(response) {
238          masterConfig.getConfigValue('core', 'inpremise_his_url', (err, row) => {
239            let generateSqliteUrl =
240              config.inpremise.syncManager.url.generateSqlite;
241              console.log(generateSqliteUrl);
242              let options = {
243                method: 'POST',
244                uri: generateSqliteUrl,
245                headers: {
246                  'Content-Type': config.inpremise.headers.contentType,
247                  'Access-Token': process.env.access_token
248                },
249                body: JSON.stringify({
250                  files: data.module_name,
251                  hotel_id: data.hotel_id
252                }),
253                rejectUnauthorized: config.server.rejectUnauthorized
254              };
255
256              rp(options)
257                .then((getSqliteRes) => {
258                  console.log(getSqliteRes);
259                  if(isJSON(getSqliteRes)) {
260                    console.log(getSqliteRes);
261                    let parsedRes = JSON.parse(getSqliteRes);
262
263                    if(parsedRes.status) {
264                      let stateValue = 14;
265
266                      if(data.generate_push==0) {
267                        stateValue = 16;
268                      }
269
270                      let d = {
271                        state: stateValue,
272                        syncRequestsId: data.sync_requests_id,
273                        remoteSyncRequestId: data.relative_sync_requests_id,
274                        hotelId: data.hotel_id
275                      };
276
277                      statusUpdater.updateStatus(d, (err, response) => {
278                        if(response) {
279                          // need to write logger functions
280                        } else {
281                          // need to write logger functions
282                        }
283                      });
284                    } else {
285                      let d = {
286                        state: 12,
287                        syncRequestsId: data.sync_requests_id,
288                        remoteSyncRequestId: data.relative_sync_requests_id,
289                        hotelId: data.hotel_id
290                      };
291
292                      statusUpdater.updateStatus(d, (err, response) => {
293                        if(response) {
294                          // need to write logger functions
295                        } else {
296                          // need to write logger functions
297                        }
298                      });
299                    }
300                  } else {
301                    console.log('not a valid JSON');
302                  }
303                })
304                .catch((err) => {
305                  console.log(err);
306                  let d = {
307                    state: 12,
308                    syncRequestsId: data.sync_requests_id,
309                    remoteSyncRequestId: data.relative_sync_requests_id,
310                    hotelId: data.hotel_id
311                  };
312                  statusUpdater.updateStatus(d, (err, response) => {
313                    if(response) {
314                      // need to write logger functions
315                    } else {
316                      // need to write logger functions
317                    }
318                  });
319                });
320          });
321        } else {
322          // need to write logger functions
323        }
324      });
325    }
326  };
327}
328
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Karma on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)