@xmobitea/gn-server 2.6.9 → 2.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1379,7 +1379,7 @@ class AnalyticsService {
1379
1379
  // },
1380
1380
  // {
1381
1381
  // $group: {
1382
- // _id: { eventName: "$eventName", E: "$operationResponse.parameters.E" },
1382
+ // _id: { eventName: "$eventName", errorCode: "$operationResponse.parameters.errorCode" },
1383
1383
  // count: { $sum: 1 } // Đếm số lần xuất hiện
1384
1384
  // }
1385
1385
  // },
@@ -1388,7 +1388,7 @@ class AnalyticsService {
1388
1388
  // _id: "$_id.eventName",
1389
1389
  // results: {
1390
1390
  // $push: {
1391
- // errorCode: "$_id.E",
1391
+ // errorCode: "$_id.errorCode",
1392
1392
  // count: "$count"
1393
1393
  // }
1394
1394
  // }
@@ -1464,7 +1464,7 @@ class AnalyticsService {
1464
1464
  };
1465
1465
  this.currentRequestComplete.push(thisCurrentRequestComplete);
1466
1466
  }
1467
- let errorCode = operationResponse?.parameters?.E;
1467
+ let errorCode = operationResponse?.parameters?.errorCode;
1468
1468
  if (errorCode) {
1469
1469
  let thisCurrentRequestCompleteErrorCode = thisCurrentRequestComplete.results.find(x => x.errorCode == errorCode);
1470
1470
  if (thisCurrentRequestCompleteErrorCode == null) {
@@ -6917,6 +6917,12 @@ class MongoObject {
6917
6917
  this.updateFilter.$inc = {};
6918
6918
  this.updateFilter.$inc[field] = value;
6919
6919
  }
6920
+ removeInc(field) {
6921
+ if (this.updateFilter != null && this.updateFilter.$inc != null) {
6922
+ if (this.updateFilter.$inc[field])
6923
+ delete this.updateFilter.$inc[field];
6924
+ }
6925
+ }
6920
6926
  min(field, value) {
6921
6927
  if (this.updateFilter == null)
6922
6928
  this.updateFilter = {};
@@ -7347,7 +7353,6 @@ class DataObjectBase extends MongoObject {
7347
7353
  }
7348
7354
  setCustomData(key, value) {
7349
7355
  this.customDatas.set(key, value);
7350
- this.removeSet(DataObjectBase._customDatas);
7351
7356
  this.set(DataObjectBase._customDatas + DataObjectBase.DOT + key, value);
7352
7357
  }
7353
7358
  removeCustomData(key) {
@@ -7394,7 +7399,6 @@ class DataObjectBase extends MongoObject {
7394
7399
  }
7395
7400
  setTag(key, value) {
7396
7401
  this.tags.set(key, value);
7397
- this.removeSet(DataObjectBase._tags);
7398
7402
  this.set(DataObjectBase._tags + DataObjectBase.DOT + key, value);
7399
7403
  }
7400
7404
  removeTag(key) {
@@ -7486,12 +7490,22 @@ class PlayerBase extends DataObjectBase {
7486
7490
  getPlayerCurrency(key) {
7487
7491
  return this.playerCurrencies.get(key);
7488
7492
  }
7489
- changePlayerCurrency(key, value) {
7493
+ changePlayerCurrency(key, amount) {
7494
+ const thisPlayerCurrency = this.playerCurrencies.get(key);
7495
+ this.playerCurrencies.set(key, {
7496
+ value: thisPlayerCurrency != null ? (thisPlayerCurrency.value + amount) : amount,
7497
+ });
7498
+ const field = PlayerBase._playerCurrencies + DataObjectBase.DOT + key;
7499
+ this.removeSet(field);
7500
+ this.inc(field + DataObjectBase.DOT + "value", amount);
7501
+ }
7502
+ setPlayerCurrency(key, value) {
7490
7503
  this.playerCurrencies.set(key, {
7491
7504
  value: value
7492
7505
  });
7493
- this.removeSet(PlayerBase._playerCurrencies);
7494
- this.set(PlayerBase._playerCurrencies + DataObjectBase.DOT + key, {
7506
+ const field = PlayerBase._playerCurrencies + DataObjectBase.DOT + key;
7507
+ this.removeInc(field + DataObjectBase.DOT + "value");
7508
+ this.set(field, {
7495
7509
  value: value
7496
7510
  });
7497
7511
  }
@@ -7511,13 +7525,26 @@ class PlayerBase extends DataObjectBase {
7511
7525
  getPlayerStatistics(key) {
7512
7526
  return this.playerStatistics.get(key);
7513
7527
  }
7514
- changePlayerStatistics(key, value, tsLastUpdate) {
7528
+ changePlayerStatistics(key, amount, tsLastUpdate) {
7529
+ const thisPlayerStatistics = this.playerStatistics.get(key);
7530
+ this.playerStatistics.set(key, {
7531
+ value: thisPlayerStatistics != null ? (thisPlayerStatistics.value + amount) : amount,
7532
+ tsLastUpdate: tsLastUpdate,
7533
+ });
7534
+ const field = PlayerBase._playerStatistics + DataObjectBase.DOT + key;
7535
+ this.removeSet(field);
7536
+ this.inc(field + DataObjectBase.DOT + "value", amount);
7537
+ this.set(field + DataObjectBase.DOT + "tsLastUpdate", tsLastUpdate);
7538
+ }
7539
+ setPlayerStatistics(key, value, tsLastUpdate) {
7515
7540
  this.playerStatistics.set(key, {
7516
7541
  value: value,
7517
7542
  tsLastUpdate: tsLastUpdate
7518
7543
  });
7519
- this.removeSet(PlayerBase._playerStatistics);
7520
- this.set(PlayerBase._playerStatistics + DataObjectBase.DOT + key, {
7544
+ const field = PlayerBase._playerStatistics + DataObjectBase.DOT + key;
7545
+ this.removeInc(field + DataObjectBase.DOT + "value");
7546
+ this.removeSet(field + DataObjectBase.DOT + "tsLastUpdate");
7547
+ this.set(field, {
7521
7548
  value: value,
7522
7549
  tsLastUpdate: tsLastUpdate
7523
7550
  });
@@ -7965,12 +7992,22 @@ class Group extends DataObjectBase {
7965
7992
  getGroupCurrency(key) {
7966
7993
  return this.groupCurrencies.get(key);
7967
7994
  }
7968
- changeGroupCurrency(key, value) {
7995
+ changeGroupCurrency(key, amount) {
7996
+ const thisGroupCurrency = this.groupCurrencies.get(key);
7997
+ this.groupCurrencies.set(key, {
7998
+ value: thisGroupCurrency != null ? (thisGroupCurrency.value + amount) : amount
7999
+ });
8000
+ const field = Group._groupCurrencies + DataObjectBase.DOT + key;
8001
+ this.removeSet(field);
8002
+ this.inc(field + DataObjectBase.DOT + "value", amount);
8003
+ }
8004
+ setGroupCurrency(key, value) {
7969
8005
  this.groupCurrencies.set(key, {
7970
8006
  value: value
7971
8007
  });
7972
- this.removeSet(Group._groupCurrencies);
7973
- this.set(Group._groupCurrencies + DataObjectBase.DOT + key, {
8008
+ const field = Group._groupCurrencies + DataObjectBase.DOT + key;
8009
+ this.removeInc(field + DataObjectBase.DOT + "value");
8010
+ this.set(field, {
7974
8011
  value: value
7975
8012
  });
7976
8013
  }
@@ -8024,15 +8061,28 @@ class Group extends DataObjectBase {
8024
8061
  getGroupStatistics(key) {
8025
8062
  return this.groupStatistics.get(key);
8026
8063
  }
8027
- changeGroupStatistics(key, value, tsLastUpdate) {
8064
+ changeGroupStatistics(key, amount, tsLastUpdate) {
8065
+ const thisGroupStatistics = this.groupStatistics.get(key);
8028
8066
  this.groupStatistics.set(key, {
8067
+ value: thisGroupStatistics != null ? (thisGroupStatistics.value + amount) : amount,
8029
8068
  tsLastUpdate: tsLastUpdate,
8030
- value: value
8031
8069
  });
8032
- this.removeSet(Group._groupStatistics);
8033
- this.set(Group._groupStatistics + DataObjectBase.DOT + key, {
8070
+ const field = Group._groupStatistics + DataObjectBase.DOT + key;
8071
+ this.removeSet(field);
8072
+ this.inc(field + DataObjectBase.DOT + "value", amount);
8073
+ this.set(field + DataObjectBase.DOT + "tsLastUpdate", tsLastUpdate);
8074
+ }
8075
+ setGroupStatistics(key, value, tsLastUpdate) {
8076
+ this.groupStatistics.set(key, {
8077
+ value: value,
8078
+ tsLastUpdate: tsLastUpdate,
8079
+ });
8080
+ const field = Group._groupStatistics + DataObjectBase.DOT + key;
8081
+ this.removeInc(field + DataObjectBase.DOT + "value");
8082
+ this.removeSet(field + DataObjectBase.DOT + "tsLastUpdate");
8083
+ this.set(field, {
8084
+ value: value,
8034
8085
  tsLastUpdate: tsLastUpdate,
8035
- value: value
8036
8086
  });
8037
8087
  }
8038
8088
  removeGroupStatistics(key) {
@@ -8198,16 +8248,29 @@ class Inventory extends DataObjectBase {
8198
8248
  getItemStatistics(key) {
8199
8249
  return this.itemStatistics.get(key);
8200
8250
  }
8201
- changeItemStatistics(key, value, tsLastUpdate) {
8251
+ changeItemStatistics(key, amount, tsLastUpdate) {
8252
+ const thisItemStatistics = this.itemStatistics.get(key);
8202
8253
  this.itemStatistics.set(key, {
8254
+ value: thisItemStatistics != null ? (thisItemStatistics.value + amount) : amount,
8203
8255
  tsLastUpdate: tsLastUpdate,
8204
- value: value
8205
8256
  });
8206
- this.removeSet(Inventory._itemStatistics);
8207
- this.set(Inventory._itemStatistics + DataObjectBase.DOT + key, {
8257
+ const field = Inventory._itemStatistics + DataObjectBase.DOT + key;
8258
+ this.removeSet(field);
8259
+ this.inc(field + DataObjectBase.DOT + "value", amount);
8260
+ this.set(field + DataObjectBase.DOT + "tsLastUpdate", tsLastUpdate);
8261
+ }
8262
+ setItemStatistics(key, value, tsLastUpdate) {
8263
+ this.itemStatistics.set(key, {
8208
8264
  tsLastUpdate: tsLastUpdate,
8209
8265
  value: value
8210
8266
  });
8267
+ const field = Inventory._itemStatistics + DataObjectBase.DOT + key;
8268
+ this.removeInc(field + DataObjectBase.DOT + "value");
8269
+ this.removeSet(field + DataObjectBase.DOT + "tsLastUpdate");
8270
+ this.set(field, {
8271
+ value: value,
8272
+ tsLastUpdate: tsLastUpdate,
8273
+ });
8211
8274
  }
8212
8275
  removeItemStatistics(key) {
8213
8276
  if (this.itemStatistics.has(key)) {
@@ -8818,15 +8881,28 @@ class TradeInventory extends DataObjectBase {
8818
8881
  getItemStatistics(key) {
8819
8882
  return this.itemStatistics.get(key);
8820
8883
  }
8821
- changeItemStatistics(key, value, tsLastUpdate) {
8884
+ changeItemStatistics(key, amount, tsLastUpdate) {
8885
+ const thisItemStatistics = this.itemStatistics.get(key);
8822
8886
  this.itemStatistics.set(key, {
8887
+ value: (thisItemStatistics != null) ? (thisItemStatistics.value + amount) : amount,
8823
8888
  tsLastUpdate: tsLastUpdate,
8824
- value: value
8825
8889
  });
8826
- this.removeSet(TradeInventory._itemStatistics);
8827
- this.set(TradeInventory._itemStatistics + DataObjectBase.DOT + key, {
8890
+ const field = TradeInventory._itemStatistics + DataObjectBase.DOT + key;
8891
+ this.removeSet(field);
8892
+ this.inc(field + DataObjectBase.DOT + "value", amount);
8893
+ this.set(field + DataObjectBase.DOT + "tsLastUpdate", tsLastUpdate);
8894
+ }
8895
+ setItemStatistics(key, value, tsLastUpdate) {
8896
+ this.itemStatistics.set(key, {
8897
+ value: value,
8898
+ tsLastUpdate: tsLastUpdate,
8899
+ });
8900
+ const field = TradeInventory._itemStatistics + DataObjectBase.DOT + key;
8901
+ this.removeInc(field + DataObjectBase.DOT + "value");
8902
+ this.removeSet(field + DataObjectBase.DOT + "tsLastUpdate");
8903
+ this.set(field, {
8904
+ value: value,
8828
8905
  tsLastUpdate: tsLastUpdate,
8829
- value: value
8830
8906
  });
8831
8907
  }
8832
8908
  removeItemStatistics(key) {
@@ -8859,7 +8935,6 @@ class TradeInventory extends DataObjectBase {
8859
8935
  this.prices.set(key, {
8860
8936
  value: value
8861
8937
  });
8862
- this.removeSet(TradeInventory._prices);
8863
8938
  this.set(TradeInventory._prices + DataObjectBase.DOT + key, {
8864
8939
  value: value
8865
8940
  });
@@ -8987,6 +9062,9 @@ class xDatabase {
8987
9062
  }
8988
9063
  }
8989
9064
  run(onMongoRunSuccess, onMongoRunError) {
9065
+ if (this.logClient != null && this.logClient != this.client) {
9066
+ this.logClient.connect();
9067
+ }
8990
9068
  this.client.connect().then(result => {
8991
9069
  if (onMongoRunSuccess != null)
8992
9070
  onMongoRunSuccess();
@@ -9169,7 +9247,7 @@ class xDatabase {
9169
9247
  let collection = this.systemCollection("MasterPlayer");
9170
9248
  let $sort = {};
9171
9249
  $sort["playerStatistics." + key + ".value"] = direction;
9172
- $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9250
+ // $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9173
9251
  let results = await collection.find({}, {
9174
9252
  projection: this.getFindOptions(masterPlayerFindOptions)
9175
9253
  }).sort($sort).skip(skip).limit(limit);
@@ -9181,7 +9259,7 @@ class xDatabase {
9181
9259
  $filter["playerStatistics." + key + ".value"] = { $ne: null };
9182
9260
  let $sort = {};
9183
9261
  $sort["playerStatistics." + key + ".value"] = direction;
9184
- $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9262
+ // $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9185
9263
  let results = await collection.find($filter, {
9186
9264
  projection: this.getFindOptions(masterPlayerFindOptions)
9187
9265
  }).sort($sort);
@@ -9231,20 +9309,20 @@ class xDatabase {
9231
9309
  }
9232
9310
  let $filter = {};
9233
9311
  if (direction == -1) {
9234
- let condition1 = {};
9235
- let condition2 = {};
9236
- condition1["playerStatistics." + key + ".value"] = { $gt: score };
9237
- condition2["playerStatistics." + key + ".value"] = score;
9238
- condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9239
- $filter.$or = [condition1, condition2];
9312
+ // let condition1 = {} as any;
9313
+ // let condition2 = {} as any;
9314
+ $filter["playerStatistics." + key + ".value"] = { $gt: score };
9315
+ // condition2["playerStatistics." + key + ".value"] = score;
9316
+ // condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9317
+ // $filter.$or = [condition1, condition2];
9240
9318
  }
9241
9319
  else {
9242
- let condition1 = {};
9243
- let condition2 = {};
9244
- condition1["playerStatistics." + key + ".value"] = { $lt: score };
9245
- condition2["playerStatistics." + key + ".value"] = score;
9246
- condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9247
- $filter.$or = [condition1, condition2];
9320
+ // let condition1 = {} as any;
9321
+ // let condition2 = {} as any;
9322
+ $filter["playerStatistics." + key + ".value"] = { $lt: score };
9323
+ // condition2["playerStatistics." + key + ".value"] = score;
9324
+ // condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9325
+ // $filter.$or = [condition1, condition2];
9248
9326
  }
9249
9327
  return await collection.countDocuments($filter);
9250
9328
  }
@@ -9499,7 +9577,7 @@ class xDatabase {
9499
9577
  let collection = this.systemGameCollection("GamePlayer", gameId);
9500
9578
  let $sort = {};
9501
9579
  $sort["playerStatistics." + key + ".value"] = direction;
9502
- $sort["playerStatistics." + key + ".tsLastUpdate"] = direction;
9580
+ // $sort["playerStatistics." + key + ".tsLastUpdate"] = direction;
9503
9581
  let results = await collection.find({}, {
9504
9582
  projection: this.getFindOptions(gamePlayerFindOptions)
9505
9583
  }).sort($sort).skip(skip).limit(limit);
@@ -9511,7 +9589,7 @@ class xDatabase {
9511
9589
  $filter["playerStatistics." + key + ".value"] = { $ne: null };
9512
9590
  let $sort = {};
9513
9591
  $sort["playerStatistics." + key + ".value"] = direction;
9514
- $sort["playerStatistics." + key + ".tsLastUpdate"] = direction;
9592
+ // $sort["playerStatistics." + key + ".tsLastUpdate"] = direction;
9515
9593
  let results = await collection.find($filter, {
9516
9594
  projection: this.getFindOptions(gamePlayerFindOptions)
9517
9595
  }).sort($sort);
@@ -9573,20 +9651,20 @@ class xDatabase {
9573
9651
  }
9574
9652
  let $filter = {};
9575
9653
  if (direction == -1) {
9576
- let condition1 = {};
9577
- let condition2 = {};
9578
- condition1["playerStatistics." + key + ".value"] = { $gt: score };
9579
- condition2["playerStatistics." + key + ".value"] = score;
9580
- condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9581
- $filter.$or = [condition1, condition2];
9654
+ // let condition1 = {} as any;
9655
+ // let condition2 = {} as any;
9656
+ $filter["playerStatistics." + key + ".value"] = { $gt: score };
9657
+ // condition2["playerStatistics." + key + ".value"] = score;
9658
+ // condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9659
+ // $filter.$or = [condition1, condition2];
9582
9660
  }
9583
9661
  else {
9584
- let condition1 = {};
9585
- let condition2 = {};
9586
- condition1["playerStatistics." + key + ".value"] = { $lt: score };
9587
- condition2["playerStatistics." + key + ".value"] = score;
9588
- condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9589
- $filter.$or = [condition1, condition2];
9662
+ // let condition1 = {} as any;
9663
+ // let condition2 = {} as any;
9664
+ $filter["playerStatistics." + key + ".value"] = { $lt: score };
9665
+ // condition2["playerStatistics." + key + ".value"] = score;
9666
+ // condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9667
+ // $filter.$or = [condition1, condition2];
9590
9668
  }
9591
9669
  return await collection.countDocuments($filter);
9592
9670
  }
@@ -9750,7 +9828,7 @@ class xDatabase {
9750
9828
  let collection = this.systemGameCollection("CharacterPlayer", gameId);
9751
9829
  let $sort = {};
9752
9830
  $sort["playerStatistics." + key + ".value"] = direction;
9753
- $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9831
+ // $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9754
9832
  let $filter = {};
9755
9833
  if (catalogId) {
9756
9834
  $filter["catalogId"] = catalogId;
@@ -9768,7 +9846,7 @@ class xDatabase {
9768
9846
  $filter["catalogId"] = catalogId;
9769
9847
  let $sort = {};
9770
9848
  $sort["playerStatistics." + key + ".value"] = direction;
9771
- $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9849
+ // $sort["playerStatistics." + key + ".tsLastUpdate"] = 1;
9772
9850
  let results = await collection.find($filter, {
9773
9851
  projection: this.getFindOptions(characterPlayerFindOptions)
9774
9852
  }).sort($sort);
@@ -9828,20 +9906,20 @@ class xDatabase {
9828
9906
  $filter["catalogId"] = catalogId;
9829
9907
  }
9830
9908
  if (direction == -1) {
9831
- let condition1 = {};
9832
- let condition2 = {};
9833
- condition1["playerStatistics." + key + ".value"] = { $gt: score };
9834
- condition2["playerStatistics." + key + ".value"] = score;
9835
- condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9836
- $filter.$or = [condition1, condition2];
9909
+ // let condition1 = {} as any;
9910
+ // let condition2 = {} as any;
9911
+ $filter["playerStatistics." + key + ".value"] = { $gt: score };
9912
+ // condition2["playerStatistics." + key + ".value"] = score;
9913
+ // condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9914
+ // $filter.$or = [condition1, condition2];
9837
9915
  }
9838
9916
  else {
9839
- let condition1 = {};
9840
- let condition2 = {};
9841
- condition1["playerStatistics." + key + ".value"] = { $lt: score };
9842
- condition2["playerStatistics." + key + ".value"] = score;
9843
- condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9844
- $filter.$or = [condition1, condition2];
9917
+ // let condition1 = {} as any;
9918
+ // let condition2 = {} as any;
9919
+ $filter["playerStatistics." + key + ".value"] = { $lt: score };
9920
+ // condition2["playerStatistics." + key + ".value"] = score;
9921
+ // condition2["playerStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
9922
+ // $filter.$or = [condition1, condition2];
9845
9923
  }
9846
9924
  return await collection.countDocuments($filter);
9847
9925
  }
@@ -10007,7 +10085,7 @@ class xDatabase {
10007
10085
  let collection = this.systemGameCollection("Group", gameId);
10008
10086
  let $sort = {};
10009
10087
  $sort["groupStatistics." + key + ".value"] = direction;
10010
- $sort["groupStatistics." + key + ".tsLastUpdate"] = 1;
10088
+ // $sort["groupStatistics." + key + ".tsLastUpdate"] = 1;
10011
10089
  let $filter = {};
10012
10090
  if (catalogId)
10013
10091
  $filter["catalogId"] = catalogId;
@@ -10024,7 +10102,7 @@ class xDatabase {
10024
10102
  $filter["catalogId"] = catalogId;
10025
10103
  let $sort = {};
10026
10104
  $sort["groupStatistics." + key + ".value"] = direction;
10027
- $sort["groupStatistics." + key + ".tsLastUpdate"] = 1;
10105
+ // $sort["groupStatistics." + key + ".tsLastUpdate"] = 1;
10028
10106
  let results = await collection.find($filter, {
10029
10107
  projection: this.getFindOptions(groupFindOptions)
10030
10108
  }).sort($sort);
@@ -10073,20 +10151,20 @@ class xDatabase {
10073
10151
  if (catalogId)
10074
10152
  $filter["catalogId"] = catalogId;
10075
10153
  if (direction == -1) {
10076
- let condition1 = {};
10077
- let condition2 = {};
10078
- condition1["groupStatistics." + key + ".value"] = { $gt: score };
10079
- condition2["groupStatistics." + key + ".value"] = score;
10080
- condition2["groupStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10081
- $filter.$or = [condition1, condition2];
10154
+ // let condition1 = {} as any;
10155
+ // let condition2 = {} as any;
10156
+ $filter["groupStatistics." + key + ".value"] = { $gt: score };
10157
+ // condition2["groupStatistics." + key + ".value"] = score;
10158
+ // condition2["groupStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10159
+ // $filter.$or = [condition1, condition2];
10082
10160
  }
10083
10161
  else {
10084
- let condition1 = {};
10085
- let condition2 = {};
10086
- condition1["groupStatistics." + key + ".value"] = { $lt: score };
10087
- condition2["groupStatistics." + key + ".value"] = score;
10088
- condition2["groupStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10089
- $filter.$or = [condition1, condition2];
10162
+ // let condition1 = {} as any;
10163
+ // let condition2 = {} as any;
10164
+ $filter["groupStatistics." + key + ".value"] = { $lt: score };
10165
+ // condition2["groupStatistics." + key + ".value"] = score;
10166
+ // condition2["groupStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10167
+ // $filter.$or = [condition1, condition2];
10090
10168
  }
10091
10169
  return await collection.countDocuments($filter);
10092
10170
  }
@@ -10178,7 +10256,7 @@ class xDatabase {
10178
10256
  let collection = this.systemGameCollection("Inventory", gameId);
10179
10257
  let $sort = {};
10180
10258
  $sort["itemStatistics." + key + ".value"] = direction;
10181
- $sort["itemStatistics." + key + ".tsLastUpdate"] = 1;
10259
+ // $sort["itemStatistics." + key + ".tsLastUpdate"] = 1;
10182
10260
  let $filter = {};
10183
10261
  $filter["catalogId"] = catalogId;
10184
10262
  let results = await collection.find($filter, {
@@ -10194,7 +10272,7 @@ class xDatabase {
10194
10272
  $filter["catalogId"] = catalogId;
10195
10273
  let $sort = {};
10196
10274
  $sort["itemStatistics." + key + ".value"] = direction;
10197
- $sort["itemStatistics." + key + ".tsLastUpdate"] = 1;
10275
+ // $sort["itemStatistics." + key + ".tsLastUpdate"] = 1;
10198
10276
  let results = await collection.find({}, {
10199
10277
  projection: this.getFindOptions(inventoryFindOptions)
10200
10278
  }).sort($sort);
@@ -10231,20 +10309,20 @@ class xDatabase {
10231
10309
  if (catalogId)
10232
10310
  $filter["catalogId"] = catalogId;
10233
10311
  if (direction == -1) {
10234
- let condition1 = {};
10235
- let condition2 = {};
10236
- condition1["itemStatistics." + key + ".value"] = { $gt: score };
10237
- condition2["itemStatistics." + key + ".value"] = score;
10238
- condition2["itemStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10239
- $filter.$or = [condition1, condition2];
10312
+ // let condition1 = {} as any;
10313
+ // let condition2 = {} as any;
10314
+ $filter["itemStatistics." + key + ".value"] = { $gt: score };
10315
+ // condition2["itemStatistics." + key + ".value"] = score;
10316
+ // condition2["itemStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10317
+ // $filter.$or = [condition1, condition2];
10240
10318
  }
10241
10319
  else {
10242
- let condition1 = {};
10243
- let condition2 = {};
10244
- condition1["itemStatistics." + key + ".value"] = { $lt: score };
10245
- condition2["itemStatistics." + key + ".value"] = score;
10246
- condition2["itemStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10247
- $filter.$or = [condition1, condition2];
10320
+ // let condition1 = {} as any;
10321
+ // let condition2 = {} as any;
10322
+ $filter["itemStatistics." + key + ".value"] = { $lt: score };
10323
+ // condition2["itemStatistics." + key + ".value"] = score;
10324
+ // condition2["itemStatistics." + key + ".tsLastUpdate"] = { $lt: tsLastUpdate };
10325
+ // $filter.$or = [condition1, condition2];
10248
10326
  }
10249
10327
  return await collection.countDocuments($filter);
10250
10328
  }
@@ -30139,7 +30217,9 @@ class ChangePlayerCurrencyRequestHandler extends MasterPlayerBaseRequestHandler
30139
30217
  let initialValue = playerCurrenciesSettingsItem.initialValue;
30140
30218
  let amount = playerCurrencyParam.amount;
30141
30219
  let serverValue = 0;
30220
+ let useSetPlayerCurrency = false;
30142
30221
  if (!masterPlayer.hasPlayerCurrency(key)) {
30222
+ useSetPlayerCurrency = true;
30143
30223
  serverValue = initialValue;
30144
30224
  }
30145
30225
  else {
@@ -30156,7 +30236,12 @@ class ChangePlayerCurrencyRequestHandler extends MasterPlayerBaseRequestHandler
30156
30236
  gnPlayerCurrency.add(ParameterCode.Key, key);
30157
30237
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
30158
30238
  gnPlayerCurrencies.add(gnPlayerCurrency);
30159
- masterPlayer.changePlayerCurrency(key, serverValue);
30239
+ if (useSetPlayerCurrency) {
30240
+ masterPlayer.setPlayerCurrency(key, serverValue);
30241
+ }
30242
+ else {
30243
+ masterPlayer.changePlayerCurrency(key, amount);
30244
+ }
30160
30245
  }
30161
30246
  masterPlayer.saveAsync();
30162
30247
  gnInfoResponseParameters.add(ParameterCode.PlayerCurrencies, gnPlayerCurrencies);
@@ -30481,22 +30566,34 @@ class ChangePlayerStatisticsRequestHandler extends MasterPlayerBaseRequestHandle
30481
30566
  let value = playerStatisticsParam.value;
30482
30567
  let gnPlayerStatistic = new GNHashtable();
30483
30568
  gnPlayerStatistic.add(ParameterCode.Key, key);
30484
- if (!masterPlayer.hasPlayerStatistics(key))
30485
- masterPlayer.changePlayerStatistics(key, playerStatisticsSettingsItem.initialValue, currentMilliseconds);
30569
+ let useSetPlayerStatistics = false;
30570
+ if (!masterPlayer.hasPlayerStatistics(key)) {
30571
+ useSetPlayerStatistics = true;
30572
+ masterPlayer.setPlayerStatistics(key, playerStatisticsSettingsItem.initialValue, currentMilliseconds);
30573
+ }
30486
30574
  let playerStatistics = masterPlayer.getPlayerStatistics(key);
30487
30575
  let oldValue = playerStatistics.value;
30488
30576
  let statisticsAggregationMethod = playerStatisticsSettingsItem.statisticsAggregationMethod;
30489
30577
  if (statisticsAggregationMethod == xStatisticsAggregationMethod.Sum) {
30490
30578
  let newValue = value + playerStatistics.value;
30491
30579
  if (playerStatisticsSettingsItem.maximumValue != null) {
30492
- if (value > playerStatisticsSettingsItem.maximumValue)
30493
- value = playerStatisticsSettingsItem.maximumValue;
30580
+ if (newValue > playerStatisticsSettingsItem.maximumValue) {
30581
+ useSetPlayerStatistics = true;
30582
+ newValue = playerStatisticsSettingsItem.maximumValue;
30583
+ }
30494
30584
  }
30495
30585
  if (playerStatisticsSettingsItem.minimumValue != null) {
30496
- if (value < playerStatisticsSettingsItem.minimumValue)
30497
- value = playerStatisticsSettingsItem.minimumValue;
30586
+ if (newValue < playerStatisticsSettingsItem.minimumValue) {
30587
+ useSetPlayerStatistics = true;
30588
+ newValue = playerStatisticsSettingsItem.minimumValue;
30589
+ }
30590
+ }
30591
+ if (useSetPlayerStatistics) {
30592
+ masterPlayer.setPlayerStatistics(key, newValue, currentMilliseconds);
30593
+ }
30594
+ else {
30595
+ masterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
30498
30596
  }
30499
- masterPlayer.changePlayerStatistics(key, newValue, currentMilliseconds);
30500
30597
  gnPlayerStatistic.add(ParameterCode.Value, newValue);
30501
30598
  this.gnServer.getDatabase().insertMasterPlayerStatisticsLogAsync(request.userId, key, playerStatisticsParam.value, oldValue, newValue, request.log);
30502
30599
  }
@@ -30510,7 +30607,7 @@ class ChangePlayerStatisticsRequestHandler extends MasterPlayerBaseRequestHandle
30510
30607
  if (value < playerStatisticsSettingsItem.minimumValue)
30511
30608
  value = playerStatisticsSettingsItem.minimumValue;
30512
30609
  }
30513
- masterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
30610
+ masterPlayer.setPlayerStatistics(key, value, currentMilliseconds);
30514
30611
  gnPlayerStatistic.add(ParameterCode.Value, value);
30515
30612
  this.gnServer.getDatabase().insertMasterPlayerStatisticsLogAsync(request.userId, key, playerStatisticsParam.value, oldValue, value, request.log);
30516
30613
  }
@@ -30518,13 +30615,13 @@ class ChangePlayerStatisticsRequestHandler extends MasterPlayerBaseRequestHandle
30518
30615
  if (playerStatisticsSettingsItem.maximumValue != null) {
30519
30616
  if (playerStatistics.value > playerStatisticsSettingsItem.maximumValue) {
30520
30617
  playerStatistics.value = playerStatisticsSettingsItem.maximumValue;
30521
- masterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30618
+ masterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30522
30619
  }
30523
30620
  }
30524
30621
  if (playerStatisticsSettingsItem.minimumValue != null) {
30525
30622
  if (playerStatistics.value < playerStatisticsSettingsItem.minimumValue) {
30526
30623
  playerStatistics.value = playerStatisticsSettingsItem.minimumValue;
30527
- masterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30624
+ masterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30528
30625
  }
30529
30626
  }
30530
30627
  gnPlayerStatistic.add(ParameterCode.Value, playerStatistics.value);
@@ -30541,7 +30638,7 @@ class ChangePlayerStatisticsRequestHandler extends MasterPlayerBaseRequestHandle
30541
30638
  if (value < playerStatisticsSettingsItem.minimumValue)
30542
30639
  value = playerStatisticsSettingsItem.minimumValue;
30543
30640
  }
30544
- masterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
30641
+ masterPlayer.setPlayerStatistics(key, value, currentMilliseconds);
30545
30642
  gnPlayerStatistic.add(ParameterCode.Value, value);
30546
30643
  this.gnServer.getDatabase().insertMasterPlayerStatisticsLogAsync(request.userId, key, playerStatisticsParam.value, oldValue, value, request.log);
30547
30644
  }
@@ -30549,13 +30646,13 @@ class ChangePlayerStatisticsRequestHandler extends MasterPlayerBaseRequestHandle
30549
30646
  if (playerStatisticsSettingsItem.maximumValue != null) {
30550
30647
  if (playerStatistics.value > playerStatisticsSettingsItem.maximumValue) {
30551
30648
  playerStatistics.value = playerStatisticsSettingsItem.maximumValue;
30552
- masterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30649
+ masterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30553
30650
  }
30554
30651
  }
30555
30652
  if (playerStatisticsSettingsItem.minimumValue != null) {
30556
30653
  if (playerStatistics.value < playerStatisticsSettingsItem.minimumValue) {
30557
30654
  playerStatistics.value = playerStatisticsSettingsItem.minimumValue;
30558
- masterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30655
+ masterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
30559
30656
  }
30560
30657
  }
30561
30658
  gnPlayerStatistic.add(ParameterCode.Value, playerStatistics.value);
@@ -30571,7 +30668,7 @@ class ChangePlayerStatisticsRequestHandler extends MasterPlayerBaseRequestHandle
30571
30668
  if (value < playerStatisticsSettingsItem.minimumValue)
30572
30669
  value = playerStatisticsSettingsItem.minimumValue;
30573
30670
  }
30574
- masterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
30671
+ masterPlayer.setPlayerStatistics(key, value, currentMilliseconds);
30575
30672
  gnPlayerStatistic.add(ParameterCode.Value, value);
30576
30673
  this.gnServer.getDatabase().insertMasterPlayerStatisticsLogAsync(request.userId, key, playerStatisticsParam.value, oldValue, value, request.log);
30577
30674
  }
@@ -38247,7 +38344,9 @@ class ChangePlayerCurrencyRequestHandler_ChangePlayerCurrencyRequestHandler exte
38247
38344
  continue;
38248
38345
  let amount = playerCurrencyParam.amount;
38249
38346
  let serverValue = 0;
38347
+ let useSetPlayerCurrency = false;
38250
38348
  if (!characterPlayer.hasPlayerCurrency(key)) {
38349
+ useSetPlayerCurrency = true;
38251
38350
  serverValue = playerCurrenciesSettingsItem.initialValue;
38252
38351
  }
38253
38352
  else {
@@ -38264,7 +38363,12 @@ class ChangePlayerCurrencyRequestHandler_ChangePlayerCurrencyRequestHandler exte
38264
38363
  gnPlayerCurrency.add(ParameterCode.Key, key);
38265
38364
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
38266
38365
  gnPlayerCurrencies.add(gnPlayerCurrency);
38267
- characterPlayer.changePlayerCurrency(key, serverValue);
38366
+ if (useSetPlayerCurrency) {
38367
+ characterPlayer.setPlayerCurrency(key, serverValue);
38368
+ }
38369
+ else {
38370
+ characterPlayer.changePlayerCurrency(key, amount);
38371
+ }
38268
38372
  }
38269
38373
  characterPlayer.saveAsync();
38270
38374
  gnInfoResponseParameters.add(ParameterCode.PlayerCurrencies, gnPlayerCurrencies);
@@ -38557,22 +38661,34 @@ class ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequestHandler
38557
38661
  let value = playerStatisticsParam.value;
38558
38662
  let gnPlayerStatistic = new GNHashtable();
38559
38663
  gnPlayerStatistic.add(ParameterCode.Key, key);
38560
- if (!characterPlayer.hasPlayerStatistics(key))
38561
- characterPlayer.changePlayerStatistics(key, playerStatisticsSettingsItem.initialValue, currentMilliseconds);
38664
+ let useSetPlayerStatistics = false;
38665
+ if (!characterPlayer.hasPlayerStatistics(key)) {
38666
+ useSetPlayerStatistics = true;
38667
+ characterPlayer.setPlayerStatistics(key, playerStatisticsSettingsItem.initialValue, currentMilliseconds);
38668
+ }
38562
38669
  let playerStatistics = characterPlayer.getPlayerStatistics(key);
38563
38670
  let oldValue = playerStatistics.value;
38564
38671
  let statisticsAggregationMethod = playerStatisticsSettingsItem.statisticsAggregationMethod;
38565
38672
  if (statisticsAggregationMethod == xStatisticsAggregationMethod.Sum) {
38566
38673
  let newValue = value + playerStatistics.value;
38567
38674
  if (playerStatisticsSettingsItem.maximumValue != null) {
38568
- if (value > playerStatisticsSettingsItem.maximumValue)
38569
- value = playerStatisticsSettingsItem.maximumValue;
38675
+ if (newValue > playerStatisticsSettingsItem.maximumValue) {
38676
+ useSetPlayerStatistics = true;
38677
+ newValue = playerStatisticsSettingsItem.maximumValue;
38678
+ }
38570
38679
  }
38571
38680
  if (playerStatisticsSettingsItem.minimumValue != null) {
38572
- if (value < playerStatisticsSettingsItem.minimumValue)
38573
- value = playerStatisticsSettingsItem.minimumValue;
38681
+ if (newValue < playerStatisticsSettingsItem.minimumValue) {
38682
+ useSetPlayerStatistics = true;
38683
+ newValue = playerStatisticsSettingsItem.minimumValue;
38684
+ }
38685
+ }
38686
+ if (useSetPlayerStatistics) {
38687
+ characterPlayer.setPlayerStatistics(key, newValue, currentMilliseconds);
38688
+ }
38689
+ else {
38690
+ characterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
38574
38691
  }
38575
- characterPlayer.changePlayerStatistics(key, newValue, currentMilliseconds);
38576
38692
  gnPlayerStatistic.add(ParameterCode.Value, newValue);
38577
38693
  this.gnServer.getDatabase().insertCharacterPlayerStatisticsLogAsync(request.characterId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, newValue, request.log);
38578
38694
  }
@@ -38586,7 +38702,7 @@ class ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequestHandler
38586
38702
  if (value < playerStatisticsSettingsItem.minimumValue)
38587
38703
  value = playerStatisticsSettingsItem.minimumValue;
38588
38704
  }
38589
- characterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
38705
+ characterPlayer.setPlayerStatistics(key, value, currentMilliseconds);
38590
38706
  gnPlayerStatistic.add(ParameterCode.Value, value);
38591
38707
  this.gnServer.getDatabase().insertCharacterPlayerStatisticsLogAsync(request.characterId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, value, request.log);
38592
38708
  }
@@ -38594,13 +38710,13 @@ class ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequestHandler
38594
38710
  if (playerStatisticsSettingsItem.maximumValue != null) {
38595
38711
  if (playerStatistics.value > playerStatisticsSettingsItem.maximumValue) {
38596
38712
  playerStatistics.value = playerStatisticsSettingsItem.maximumValue;
38597
- characterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38713
+ characterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38598
38714
  }
38599
38715
  }
38600
38716
  if (playerStatisticsSettingsItem.minimumValue != null) {
38601
38717
  if (playerStatistics.value < playerStatisticsSettingsItem.minimumValue) {
38602
38718
  playerStatistics.value = playerStatisticsSettingsItem.minimumValue;
38603
- characterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38719
+ characterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38604
38720
  }
38605
38721
  }
38606
38722
  gnPlayerStatistic.add(ParameterCode.Value, playerStatistics.value);
@@ -38617,7 +38733,7 @@ class ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequestHandler
38617
38733
  if (value < playerStatisticsSettingsItem.minimumValue)
38618
38734
  value = playerStatisticsSettingsItem.minimumValue;
38619
38735
  }
38620
- characterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
38736
+ characterPlayer.setPlayerStatistics(key, value, currentMilliseconds);
38621
38737
  gnPlayerStatistic.add(ParameterCode.Value, value);
38622
38738
  this.gnServer.getDatabase().insertCharacterPlayerStatisticsLogAsync(request.characterId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, value, request.log);
38623
38739
  }
@@ -38625,13 +38741,13 @@ class ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequestHandler
38625
38741
  if (playerStatisticsSettingsItem.maximumValue != null) {
38626
38742
  if (playerStatistics.value > playerStatisticsSettingsItem.maximumValue) {
38627
38743
  playerStatistics.value = playerStatisticsSettingsItem.maximumValue;
38628
- characterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38744
+ characterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38629
38745
  }
38630
38746
  }
38631
38747
  if (playerStatisticsSettingsItem.minimumValue != null) {
38632
38748
  if (playerStatistics.value < playerStatisticsSettingsItem.minimumValue) {
38633
38749
  playerStatistics.value = playerStatisticsSettingsItem.minimumValue;
38634
- characterPlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38750
+ characterPlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
38635
38751
  }
38636
38752
  }
38637
38753
  gnPlayerStatistic.add(ParameterCode.Value, playerStatistics.value);
@@ -38647,7 +38763,7 @@ class ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequestHandler
38647
38763
  if (value < playerStatisticsSettingsItem.minimumValue)
38648
38764
  value = playerStatisticsSettingsItem.minimumValue;
38649
38765
  }
38650
- characterPlayer.changePlayerStatistics(key, value, currentMilliseconds);
38766
+ characterPlayer.setPlayerStatistics(key, value, currentMilliseconds);
38651
38767
  gnPlayerStatistic.add(ParameterCode.Value, value);
38652
38768
  this.gnServer.getDatabase().insertCharacterPlayerStatisticsLogAsync(request.characterId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, value, request.log);
38653
38769
  }
@@ -43213,86 +43329,118 @@ class GetFriendStatisticsLeaderboardRequestHandler extends CharacterPlayerBaseRe
43213
43329
  static quickSort(key, characterPlayers, initialValue) {
43214
43330
  if (characterPlayers.length < 2)
43215
43331
  return characterPlayers;
43216
- let pivotIndex = characterPlayers.length - 1;
43217
- let pivot = characterPlayers[pivotIndex];
43218
- let currentMilliseconds = xDatetime.getCurrentMilliseconds();
43219
- let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
43220
- if (pivotPlayerStatistic == null) {
43221
- pivotPlayerStatistic = {
43222
- tsLastUpdate: currentMilliseconds,
43223
- value: initialValue
43224
- };
43225
- }
43226
- let left = [];
43227
- let right = [];
43228
- let currentItem;
43229
- for (let i = 0; i < pivotIndex; i++) {
43230
- currentItem = characterPlayers[i];
43231
- let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
43232
- if (currentPlayerStatistic == null) {
43233
- currentPlayerStatistic = {
43234
- tsLastUpdate: currentMilliseconds,
43235
- value: initialValue
43236
- };
43237
- }
43238
- if (currentPlayerStatistic.value < pivotPlayerStatistic.value) {
43239
- right.push(currentItem);
43240
- }
43241
- else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
43242
- if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
43243
- right.push(currentItem);
43244
- }
43245
- else {
43246
- left.push(currentItem);
43247
- }
43248
- }
43249
- else {
43250
- left.push(currentItem);
43251
- }
43252
- }
43253
- return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
43332
+ // let pivotIndex = characterPlayers.length - 1;
43333
+ // let pivot = characterPlayers[pivotIndex];
43334
+ // let currentMilliseconds = xDatetime.getCurrentMilliseconds();
43335
+ // let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
43336
+ // if (pivotPlayerStatistic == null) {
43337
+ // pivotPlayerStatistic = {
43338
+ // tsLastUpdate: currentMilliseconds,
43339
+ // value: initialValue
43340
+ // }
43341
+ // }
43342
+ // let left = [];
43343
+ // let right = [];
43344
+ // let currentItem;
43345
+ // for (let i = 0; i < pivotIndex; i++) {
43346
+ // currentItem = characterPlayers[i];
43347
+ // let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
43348
+ // if (currentPlayerStatistic == null) {
43349
+ // currentPlayerStatistic = {
43350
+ // tsLastUpdate: currentMilliseconds,
43351
+ // value: initialValue
43352
+ // }
43353
+ // }
43354
+ // if (currentPlayerStatistic.value < pivotPlayerStatistic.value) {
43355
+ // right.push(currentItem);
43356
+ // }
43357
+ // else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
43358
+ // if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
43359
+ // right.push(currentItem);
43360
+ // }
43361
+ // else {
43362
+ // left.push(currentItem);
43363
+ // }
43364
+ // }
43365
+ // else {
43366
+ // left.push(currentItem);
43367
+ // }
43368
+ // }
43369
+ // return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
43370
+ const currentMilliseconds = xDatetime.getCurrentMilliseconds();
43371
+ return characterPlayers.sort((left, right) => {
43372
+ let leftStat = left.getPlayerStatistics(key);
43373
+ let rightStat = right.getPlayerStatistics(key);
43374
+ if (leftStat == null)
43375
+ leftStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
43376
+ if (rightStat == null)
43377
+ rightStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
43378
+ if (leftStat.value > rightStat.value)
43379
+ return -1;
43380
+ if (leftStat.value < rightStat.value)
43381
+ return 1;
43382
+ // if (leftStat.tsLastUpdate > rightStat.tsLastUpdate) return -1;
43383
+ // if (leftStat.tsLastUpdate < rightStat.tsLastUpdate) return 1;
43384
+ return 0;
43385
+ });
43254
43386
  }
43255
43387
  static quickSortAsc(key, characterPlayers, initialValue) {
43256
43388
  if (characterPlayers.length < 2)
43257
43389
  return characterPlayers;
43258
- let pivotIndex = characterPlayers.length - 1;
43259
- let pivot = characterPlayers[pivotIndex];
43260
- let currentMilliseconds = xDatetime.getCurrentMilliseconds();
43261
- let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
43262
- if (pivotPlayerStatistic == null) {
43263
- pivotPlayerStatistic = {
43264
- tsLastUpdate: currentMilliseconds,
43265
- value: initialValue
43266
- };
43267
- }
43268
- let left = [];
43269
- let right = [];
43270
- let currentItem;
43271
- for (let i = 0; i < pivotIndex; i++) {
43272
- currentItem = characterPlayers[i];
43273
- let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
43274
- if (currentPlayerStatistic == null) {
43275
- currentPlayerStatistic = {
43276
- tsLastUpdate: currentMilliseconds,
43277
- value: initialValue
43278
- };
43279
- }
43280
- if (currentPlayerStatistic.value > pivotPlayerStatistic.value) {
43281
- right.push(currentItem);
43282
- }
43283
- else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
43284
- if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
43285
- right.push(currentItem);
43286
- }
43287
- else {
43288
- left.push(currentItem);
43289
- }
43290
- }
43291
- else {
43292
- left.push(currentItem);
43293
- }
43294
- }
43295
- return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
43390
+ // let pivotIndex = characterPlayers.length - 1;
43391
+ // let pivot = characterPlayers[pivotIndex];
43392
+ // let currentMilliseconds = xDatetime.getCurrentMilliseconds();
43393
+ // let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
43394
+ // if (pivotPlayerStatistic == null) {
43395
+ // pivotPlayerStatistic = {
43396
+ // tsLastUpdate: currentMilliseconds,
43397
+ // value: initialValue
43398
+ // }
43399
+ // }
43400
+ // let left = [];
43401
+ // let right = [];
43402
+ // let currentItem;
43403
+ // for (let i = 0; i < pivotIndex; i++) {
43404
+ // currentItem = characterPlayers[i];
43405
+ // let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
43406
+ // if (currentPlayerStatistic == null) {
43407
+ // currentPlayerStatistic = {
43408
+ // tsLastUpdate: currentMilliseconds,
43409
+ // value: initialValue
43410
+ // }
43411
+ // }
43412
+ // if (currentPlayerStatistic.value > pivotPlayerStatistic.value) {
43413
+ // right.push(currentItem);
43414
+ // }
43415
+ // else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
43416
+ // if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
43417
+ // right.push(currentItem);
43418
+ // }
43419
+ // else {
43420
+ // left.push(currentItem);
43421
+ // }
43422
+ // }
43423
+ // else {
43424
+ // left.push(currentItem);
43425
+ // }
43426
+ // }
43427
+ // return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
43428
+ const currentMilliseconds = xDatetime.getCurrentMilliseconds();
43429
+ return characterPlayers.sort((left, right) => {
43430
+ let leftStat = left.getPlayerStatistics(key);
43431
+ let rightStat = right.getPlayerStatistics(key);
43432
+ if (leftStat == null)
43433
+ leftStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
43434
+ if (rightStat == null)
43435
+ rightStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
43436
+ if (leftStat.value > rightStat.value)
43437
+ return 1;
43438
+ if (leftStat.value < rightStat.value)
43439
+ return -1;
43440
+ // if (leftStat.tsLastUpdate > rightStat.tsLastUpdate) return -1;
43441
+ // if (leftStat.tsLastUpdate < rightStat.tsLastUpdate) return 1;
43442
+ return 0;
43443
+ });
43296
43444
  }
43297
43445
  }
43298
43446
 
@@ -47391,7 +47539,9 @@ class gamePlayer_ChangePlayerCurrencyRequestHandler_ChangePlayerCurrencyRequestH
47391
47539
  let initialValue = playerCurrenciesSettingsItem.initialValue;
47392
47540
  let amount = playerCurrencyParam.amount;
47393
47541
  let serverValue = 0;
47542
+ let useSetPlayerCurrency = false;
47394
47543
  if (!gamePlayer.hasPlayerCurrency(key)) {
47544
+ useSetPlayerCurrency = true;
47395
47545
  serverValue = initialValue;
47396
47546
  }
47397
47547
  else {
@@ -47408,7 +47558,12 @@ class gamePlayer_ChangePlayerCurrencyRequestHandler_ChangePlayerCurrencyRequestH
47408
47558
  gnPlayerCurrency.add(ParameterCode.Key, key);
47409
47559
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
47410
47560
  gnPlayerCurrencies.add(gnPlayerCurrency);
47411
- gamePlayer.changePlayerCurrency(key, serverValue);
47561
+ if (useSetPlayerCurrency) {
47562
+ gamePlayer.setPlayerCurrency(key, serverValue);
47563
+ }
47564
+ else {
47565
+ gamePlayer.changePlayerCurrency(key, amount);
47566
+ }
47412
47567
  }
47413
47568
  gamePlayer.saveAsync();
47414
47569
  gnInfoResponseParameters.add(ParameterCode.PlayerCurrencies, gnPlayerCurrencies);
@@ -47733,22 +47888,34 @@ class gamePlayer_ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequ
47733
47888
  let value = playerStatisticsParam.value;
47734
47889
  let gnPlayerStatistic = new GNHashtable();
47735
47890
  gnPlayerStatistic.add(ParameterCode.Key, key);
47736
- if (!gamePlayer.hasPlayerStatistics(key))
47737
- gamePlayer.changePlayerStatistics(key, playerStatisticsSettingsItem.initialValue, currentMilliseconds);
47891
+ let useSetPlayerStatistics = false;
47892
+ if (!gamePlayer.hasPlayerStatistics(key)) {
47893
+ useSetPlayerStatistics = true;
47894
+ gamePlayer.setPlayerStatistics(key, playerStatisticsSettingsItem.initialValue, currentMilliseconds);
47895
+ }
47738
47896
  let playerStatistics = gamePlayer.getPlayerStatistics(key);
47739
47897
  let oldValue = playerStatistics.value;
47740
47898
  let statisticsAggregationMethod = playerStatisticsSettingsItem.statisticsAggregationMethod;
47741
47899
  if (statisticsAggregationMethod == xStatisticsAggregationMethod.Sum) {
47742
47900
  let newValue = value + playerStatistics.value;
47743
47901
  if (playerStatisticsSettingsItem.maximumValue != null) {
47744
- if (value > playerStatisticsSettingsItem.maximumValue)
47745
- value = playerStatisticsSettingsItem.maximumValue;
47902
+ if (newValue > playerStatisticsSettingsItem.maximumValue) {
47903
+ useSetPlayerStatistics = true;
47904
+ newValue = playerStatisticsSettingsItem.maximumValue;
47905
+ }
47746
47906
  }
47747
47907
  if (playerStatisticsSettingsItem.minimumValue != null) {
47748
- if (value < playerStatisticsSettingsItem.minimumValue)
47749
- value = playerStatisticsSettingsItem.minimumValue;
47908
+ if (newValue < playerStatisticsSettingsItem.minimumValue) {
47909
+ useSetPlayerStatistics = true;
47910
+ newValue = playerStatisticsSettingsItem.minimumValue;
47911
+ }
47912
+ }
47913
+ if (useSetPlayerStatistics) {
47914
+ gamePlayer.setPlayerStatistics(key, newValue, currentMilliseconds);
47915
+ }
47916
+ else {
47917
+ gamePlayer.changePlayerStatistics(key, value, currentMilliseconds);
47750
47918
  }
47751
- gamePlayer.changePlayerStatistics(key, newValue, currentMilliseconds);
47752
47919
  gnPlayerStatistic.add(ParameterCode.Value, newValue);
47753
47920
  this.gnServer.getDatabase().insertGamePlayerStatisticsLogAsync(request.userId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, newValue, request.log);
47754
47921
  }
@@ -47762,7 +47929,7 @@ class gamePlayer_ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequ
47762
47929
  if (value < playerStatisticsSettingsItem.minimumValue)
47763
47930
  value = playerStatisticsSettingsItem.minimumValue;
47764
47931
  }
47765
- gamePlayer.changePlayerStatistics(key, value, currentMilliseconds);
47932
+ gamePlayer.setPlayerStatistics(key, value, currentMilliseconds);
47766
47933
  gnPlayerStatistic.add(ParameterCode.Value, value);
47767
47934
  this.gnServer.getDatabase().insertGamePlayerStatisticsLogAsync(request.userId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, value, request.log);
47768
47935
  }
@@ -47770,13 +47937,13 @@ class gamePlayer_ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequ
47770
47937
  if (playerStatisticsSettingsItem.maximumValue != null) {
47771
47938
  if (playerStatistics.value > playerStatisticsSettingsItem.maximumValue) {
47772
47939
  playerStatistics.value = playerStatisticsSettingsItem.maximumValue;
47773
- gamePlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47940
+ gamePlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47774
47941
  }
47775
47942
  }
47776
47943
  if (playerStatisticsSettingsItem.minimumValue != null) {
47777
47944
  if (playerStatistics.value < playerStatisticsSettingsItem.minimumValue) {
47778
47945
  playerStatistics.value = playerStatisticsSettingsItem.minimumValue;
47779
- gamePlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47946
+ gamePlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47780
47947
  }
47781
47948
  }
47782
47949
  gnPlayerStatistic.add(ParameterCode.Value, playerStatistics.value);
@@ -47793,7 +47960,7 @@ class gamePlayer_ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequ
47793
47960
  if (value < playerStatisticsSettingsItem.minimumValue)
47794
47961
  value = playerStatisticsSettingsItem.minimumValue;
47795
47962
  }
47796
- gamePlayer.changePlayerStatistics(key, value, currentMilliseconds);
47963
+ gamePlayer.setPlayerStatistics(key, value, currentMilliseconds);
47797
47964
  gnPlayerStatistic.add(ParameterCode.Value, value);
47798
47965
  this.gnServer.getDatabase().insertGamePlayerStatisticsLogAsync(request.userId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, value, request.log);
47799
47966
  }
@@ -47801,13 +47968,13 @@ class gamePlayer_ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequ
47801
47968
  if (playerStatisticsSettingsItem.maximumValue != null) {
47802
47969
  if (playerStatistics.value > playerStatisticsSettingsItem.maximumValue) {
47803
47970
  playerStatistics.value = playerStatisticsSettingsItem.maximumValue;
47804
- gamePlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47971
+ gamePlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47805
47972
  }
47806
47973
  }
47807
47974
  if (playerStatisticsSettingsItem.minimumValue != null) {
47808
47975
  if (playerStatistics.value < playerStatisticsSettingsItem.minimumValue) {
47809
47976
  playerStatistics.value = playerStatisticsSettingsItem.minimumValue;
47810
- gamePlayer.changePlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47977
+ gamePlayer.setPlayerStatistics(key, playerStatistics.value, currentMilliseconds);
47811
47978
  }
47812
47979
  }
47813
47980
  gnPlayerStatistic.add(ParameterCode.Value, playerStatistics.value);
@@ -47823,7 +47990,7 @@ class gamePlayer_ChangePlayerStatisticsRequestHandler_ChangePlayerStatisticsRequ
47823
47990
  if (value < playerStatisticsSettingsItem.minimumValue)
47824
47991
  value = playerStatisticsSettingsItem.minimumValue;
47825
47992
  }
47826
- gamePlayer.changePlayerStatistics(key, value, currentMilliseconds);
47993
+ gamePlayer.setPlayerStatistics(key, value, currentMilliseconds);
47827
47994
  gnPlayerStatistic.add(ParameterCode.Value, value);
47828
47995
  this.gnServer.getDatabase().insertGamePlayerStatisticsLogAsync(request.userId, secretInfo.getGameId(), key, playerStatisticsParam.value, oldValue, value, request.log);
47829
47996
  }
@@ -52677,86 +52844,118 @@ class GetFriendStatisticsLeaderboardRequestHandler_GetFriendStatisticsLeaderboar
52677
52844
  static quickSort(key, gamePlayers, initialValue) {
52678
52845
  if (gamePlayers.length < 2)
52679
52846
  return gamePlayers;
52680
- let pivotIndex = gamePlayers.length - 1;
52681
- let pivot = gamePlayers[pivotIndex];
52682
- let currentMilliseconds = xDatetime.getCurrentMilliseconds();
52683
- let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
52684
- if (pivotPlayerStatistic == null) {
52685
- pivotPlayerStatistic = {
52686
- tsLastUpdate: currentMilliseconds,
52687
- value: initialValue
52688
- };
52689
- }
52690
- let left = [];
52691
- let right = [];
52692
- let currentItem;
52693
- for (let i = 0; i < pivotIndex; i++) {
52694
- currentItem = gamePlayers[i];
52695
- let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
52696
- if (currentPlayerStatistic == null) {
52697
- currentPlayerStatistic = {
52698
- tsLastUpdate: currentMilliseconds,
52699
- value: initialValue
52700
- };
52701
- }
52702
- if (currentPlayerStatistic.value < pivotPlayerStatistic.value) {
52703
- right.push(currentItem);
52704
- }
52705
- else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
52706
- if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
52707
- right.push(currentItem);
52708
- }
52709
- else {
52710
- left.push(currentItem);
52711
- }
52712
- }
52713
- else {
52714
- left.push(currentItem);
52715
- }
52716
- }
52717
- return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
52847
+ // let pivotIndex = gamePlayers.length - 1;
52848
+ // let pivot = gamePlayers[pivotIndex];
52849
+ // let currentMilliseconds = xDatetime.getCurrentMilliseconds();
52850
+ // let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
52851
+ // if (pivotPlayerStatistic == null) {
52852
+ // pivotPlayerStatistic = {
52853
+ // tsLastUpdate: currentMilliseconds,
52854
+ // value: initialValue
52855
+ // }
52856
+ // }
52857
+ // let left = [];
52858
+ // let right = [];
52859
+ // let currentItem;
52860
+ // for (let i = 0; i < pivotIndex; i++) {
52861
+ // currentItem = gamePlayers[i];
52862
+ // let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
52863
+ // if (currentPlayerStatistic == null) {
52864
+ // currentPlayerStatistic = {
52865
+ // tsLastUpdate: currentMilliseconds,
52866
+ // value: initialValue
52867
+ // }
52868
+ // }
52869
+ // if (currentPlayerStatistic.value < pivotPlayerStatistic.value) {
52870
+ // right.push(currentItem);
52871
+ // }
52872
+ // else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
52873
+ // if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
52874
+ // right.push(currentItem);
52875
+ // }
52876
+ // else {
52877
+ // left.push(currentItem);
52878
+ // }
52879
+ // }
52880
+ // else {
52881
+ // left.push(currentItem);
52882
+ // }
52883
+ // }
52884
+ // return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
52885
+ const currentMilliseconds = xDatetime.getCurrentMilliseconds();
52886
+ return gamePlayers.sort((left, right) => {
52887
+ let leftStat = left.getPlayerStatistics(key);
52888
+ let rightStat = right.getPlayerStatistics(key);
52889
+ if (leftStat == null)
52890
+ leftStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
52891
+ if (rightStat == null)
52892
+ rightStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
52893
+ if (leftStat.value > rightStat.value)
52894
+ return -1;
52895
+ if (leftStat.value < rightStat.value)
52896
+ return 1;
52897
+ // if (leftStat.tsLastUpdate > rightStat.tsLastUpdate) return -1;
52898
+ // if (leftStat.tsLastUpdate < rightStat.tsLastUpdate) return 1;
52899
+ return 0;
52900
+ });
52718
52901
  }
52719
52902
  static quickSortAsc(key, gamePlayers, initialValue) {
52720
52903
  if (gamePlayers.length < 2)
52721
52904
  return gamePlayers;
52722
- let pivotIndex = gamePlayers.length - 1;
52723
- let pivot = gamePlayers[pivotIndex];
52724
- let currentMilliseconds = xDatetime.getCurrentMilliseconds();
52725
- let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
52726
- if (pivotPlayerStatistic == null) {
52727
- pivotPlayerStatistic = {
52728
- tsLastUpdate: currentMilliseconds,
52729
- value: initialValue
52730
- };
52731
- }
52732
- let left = [];
52733
- let right = [];
52734
- let currentItem;
52735
- for (let i = 0; i < pivotIndex; i++) {
52736
- currentItem = gamePlayers[i];
52737
- let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
52738
- if (currentPlayerStatistic == null) {
52739
- currentPlayerStatistic = {
52740
- tsLastUpdate: currentMilliseconds,
52741
- value: initialValue
52742
- };
52743
- }
52744
- if (currentPlayerStatistic.value > pivotPlayerStatistic.value) {
52745
- right.push(currentItem);
52746
- }
52747
- else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
52748
- if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
52749
- right.push(currentItem);
52750
- }
52751
- else {
52752
- left.push(currentItem);
52753
- }
52754
- }
52755
- else {
52756
- left.push(currentItem);
52757
- }
52758
- }
52759
- return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
52905
+ // let pivotIndex = gamePlayers.length - 1;
52906
+ // let pivot = gamePlayers[pivotIndex];
52907
+ // let currentMilliseconds = xDatetime.getCurrentMilliseconds();
52908
+ // let pivotPlayerStatistic = pivot.getPlayerStatistics(key);
52909
+ // if (pivotPlayerStatistic == null) {
52910
+ // pivotPlayerStatistic = {
52911
+ // tsLastUpdate: currentMilliseconds,
52912
+ // value: initialValue
52913
+ // }
52914
+ // }
52915
+ // let left = [];
52916
+ // let right = [];
52917
+ // let currentItem;
52918
+ // for (let i = 0; i < pivotIndex; i++) {
52919
+ // currentItem = gamePlayers[i];
52920
+ // let currentPlayerStatistic = currentItem.getPlayerStatistics(key);
52921
+ // if (currentPlayerStatistic == null) {
52922
+ // currentPlayerStatistic = {
52923
+ // tsLastUpdate: currentMilliseconds,
52924
+ // value: initialValue
52925
+ // }
52926
+ // }
52927
+ // if (currentPlayerStatistic.value > pivotPlayerStatistic.value) {
52928
+ // right.push(currentItem);
52929
+ // }
52930
+ // else if (currentPlayerStatistic.value == pivotPlayerStatistic.value) {
52931
+ // if (currentPlayerStatistic.tsLastUpdate > pivotPlayerStatistic.tsLastUpdate) {
52932
+ // right.push(currentItem);
52933
+ // }
52934
+ // else {
52935
+ // left.push(currentItem);
52936
+ // }
52937
+ // }
52938
+ // else {
52939
+ // left.push(currentItem);
52940
+ // }
52941
+ // }
52942
+ // return [...this.quickSort(key, right, initialValue), pivot, ...this.quickSort(key, left, initialValue)];
52943
+ const currentMilliseconds = xDatetime.getCurrentMilliseconds();
52944
+ return gamePlayers.sort((left, right) => {
52945
+ let leftStat = left.getPlayerStatistics(key);
52946
+ let rightStat = right.getPlayerStatistics(key);
52947
+ if (leftStat == null)
52948
+ leftStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
52949
+ if (rightStat == null)
52950
+ rightStat = { tsLastUpdate: currentMilliseconds, value: initialValue };
52951
+ if (leftStat.value > rightStat.value)
52952
+ return 1;
52953
+ if (leftStat.value < rightStat.value)
52954
+ return -1;
52955
+ // if (leftStat.tsLastUpdate > rightStat.tsLastUpdate) return -1;
52956
+ // if (leftStat.tsLastUpdate < rightStat.tsLastUpdate) return 1;
52957
+ return 0;
52958
+ });
52760
52959
  }
52761
52960
  }
52762
52961
 
@@ -56820,11 +57019,12 @@ class ChangeGroupCurrencyRequestHandler extends GroupBaseRequestHandler {
56820
57019
  let groupCurrenciesSettingsItem = groupSettings.groupCurrenciesSettings.find(x => x.key == key);
56821
57020
  if (groupCurrenciesSettingsItem == null)
56822
57021
  continue;
56823
- let initialValue = groupCurrenciesSettingsItem.initialValue;
56824
57022
  let amount = groupCurrencyParam.amount;
56825
57023
  let serverValue = 0;
57024
+ let useSetGroupCurrency = false;
56826
57025
  if (!group.hasGroupCurrency(key)) {
56827
- serverValue = initialValue;
57026
+ useSetGroupCurrency = true;
57027
+ serverValue = groupCurrenciesSettingsItem.initialValue;
56828
57028
  }
56829
57029
  else {
56830
57030
  serverValue = group.getGroupCurrency(key).value;
@@ -56838,7 +57038,12 @@ class ChangeGroupCurrencyRequestHandler extends GroupBaseRequestHandler {
56838
57038
  gnGroupCurrency.add(ParameterCode.Key, key);
56839
57039
  gnGroupCurrency.add(ParameterCode.Value, serverValue);
56840
57040
  gnGroupCurrencies.add(gnGroupCurrency);
56841
- group.changeGroupCurrency(key, serverValue);
57041
+ if (useSetGroupCurrency) {
57042
+ group.setGroupCurrency(key, serverValue);
57043
+ }
57044
+ else {
57045
+ group.changeGroupCurrency(key, amount);
57046
+ }
56842
57047
  }
56843
57048
  group.saveAsync();
56844
57049
  gnInfoResponseParameters.add(ParameterCode.GroupCurrencies, gnGroupCurrencies);
@@ -57131,22 +57336,34 @@ class ChangeGroupStatisticsRequestHandler extends GroupBaseRequestHandler {
57131
57336
  let value = groupStatisticsParam.value;
57132
57337
  let gnGroupStatistic = new GNHashtable();
57133
57338
  gnGroupStatistic.add(ParameterCode.Key, key);
57134
- if (!group.hasGroupStatistics(key))
57135
- group.changeGroupStatistics(key, groupStatisticsSettingsItem.initialValue, currentMilliseconds);
57339
+ let useSetGroupStatistics = false;
57340
+ if (!group.hasGroupStatistics(key)) {
57341
+ useSetGroupStatistics = true;
57342
+ group.setGroupStatistics(key, groupStatisticsSettingsItem.initialValue, currentMilliseconds);
57343
+ }
57136
57344
  let groupStatistics = group.getGroupStatistics(key);
57137
57345
  let oldValue = groupStatistics.value;
57138
57346
  let statisticsAggregationMethod = groupStatisticsSettingsItem.statisticsAggregationMethod;
57139
57347
  if (statisticsAggregationMethod == xStatisticsAggregationMethod.Sum) {
57140
57348
  let newValue = value + groupStatistics.value;
57141
57349
  if (groupStatisticsSettingsItem.maximumValue != null) {
57142
- if (value > groupStatisticsSettingsItem.maximumValue)
57143
- value = groupStatisticsSettingsItem.maximumValue;
57350
+ if (newValue > groupStatisticsSettingsItem.maximumValue) {
57351
+ useSetGroupStatistics = true;
57352
+ newValue = groupStatisticsSettingsItem.maximumValue;
57353
+ }
57144
57354
  }
57145
57355
  if (groupStatisticsSettingsItem.minimumValue != null) {
57146
- if (value < groupStatisticsSettingsItem.minimumValue)
57147
- value = groupStatisticsSettingsItem.minimumValue;
57356
+ if (newValue < groupStatisticsSettingsItem.minimumValue) {
57357
+ useSetGroupStatistics = true;
57358
+ newValue = groupStatisticsSettingsItem.minimumValue;
57359
+ }
57360
+ }
57361
+ if (useSetGroupStatistics) {
57362
+ group.setGroupStatistics(key, newValue, currentMilliseconds);
57363
+ }
57364
+ else {
57365
+ group.changeGroupStatistics(key, value, currentMilliseconds);
57148
57366
  }
57149
- group.changeGroupStatistics(key, newValue, currentMilliseconds);
57150
57367
  gnGroupStatistic.add(ParameterCode.Value, newValue);
57151
57368
  this.gnServer.getDatabase().insertGroupStatisticsLogAsync(request.groupId, secretInfo.getGameId(), key, groupStatisticsParam.value, oldValue, newValue, request.log);
57152
57369
  }
@@ -57160,7 +57377,7 @@ class ChangeGroupStatisticsRequestHandler extends GroupBaseRequestHandler {
57160
57377
  if (value < groupStatisticsSettingsItem.minimumValue)
57161
57378
  value = groupStatisticsSettingsItem.minimumValue;
57162
57379
  }
57163
- group.changeGroupStatistics(key, value, currentMilliseconds);
57380
+ group.setGroupStatistics(key, value, currentMilliseconds);
57164
57381
  gnGroupStatistic.add(ParameterCode.Value, value);
57165
57382
  this.gnServer.getDatabase().insertGroupStatisticsLogAsync(request.groupId, secretInfo.getGameId(), key, groupStatisticsParam.value, oldValue, value, request.log);
57166
57383
  }
@@ -57168,13 +57385,13 @@ class ChangeGroupStatisticsRequestHandler extends GroupBaseRequestHandler {
57168
57385
  if (groupStatisticsSettingsItem.maximumValue != null) {
57169
57386
  if (groupStatistics.value > groupStatisticsSettingsItem.maximumValue) {
57170
57387
  groupStatistics.value = groupStatisticsSettingsItem.maximumValue;
57171
- group.changeGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57388
+ group.setGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57172
57389
  }
57173
57390
  }
57174
57391
  if (groupStatisticsSettingsItem.minimumValue != null) {
57175
57392
  if (groupStatistics.value < groupStatisticsSettingsItem.minimumValue) {
57176
57393
  groupStatistics.value = groupStatisticsSettingsItem.minimumValue;
57177
- group.changeGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57394
+ group.setGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57178
57395
  }
57179
57396
  }
57180
57397
  gnGroupStatistic.add(ParameterCode.Value, groupStatistics.value);
@@ -57191,7 +57408,7 @@ class ChangeGroupStatisticsRequestHandler extends GroupBaseRequestHandler {
57191
57408
  if (value < groupStatisticsSettingsItem.minimumValue)
57192
57409
  value = groupStatisticsSettingsItem.minimumValue;
57193
57410
  }
57194
- group.changeGroupStatistics(key, value, currentMilliseconds);
57411
+ group.setGroupStatistics(key, value, currentMilliseconds);
57195
57412
  gnGroupStatistic.add(ParameterCode.Value, value);
57196
57413
  this.gnServer.getDatabase().insertGroupStatisticsLogAsync(request.groupId, secretInfo.getGameId(), key, groupStatisticsParam.value, oldValue, value, request.log);
57197
57414
  }
@@ -57199,13 +57416,13 @@ class ChangeGroupStatisticsRequestHandler extends GroupBaseRequestHandler {
57199
57416
  if (groupStatisticsSettingsItem.maximumValue != null) {
57200
57417
  if (groupStatistics.value > groupStatisticsSettingsItem.maximumValue) {
57201
57418
  groupStatistics.value = groupStatisticsSettingsItem.maximumValue;
57202
- group.changeGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57419
+ group.setGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57203
57420
  }
57204
57421
  }
57205
57422
  if (groupStatisticsSettingsItem.minimumValue != null) {
57206
57423
  if (groupStatistics.value < groupStatisticsSettingsItem.minimumValue) {
57207
57424
  groupStatistics.value = groupStatisticsSettingsItem.minimumValue;
57208
- group.changeGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57425
+ group.setGroupStatistics(key, groupStatistics.value, currentMilliseconds);
57209
57426
  }
57210
57427
  }
57211
57428
  gnGroupStatistic.add(ParameterCode.Value, groupStatistics.value);
@@ -57221,7 +57438,7 @@ class ChangeGroupStatisticsRequestHandler extends GroupBaseRequestHandler {
57221
57438
  if (value < groupStatisticsSettingsItem.minimumValue)
57222
57439
  value = groupStatisticsSettingsItem.minimumValue;
57223
57440
  }
57224
- group.changeGroupStatistics(key, value, currentMilliseconds);
57441
+ group.setGroupStatistics(key, value, currentMilliseconds);
57225
57442
  gnGroupStatistic.add(ParameterCode.Value, value);
57226
57443
  this.gnServer.getDatabase().insertGroupStatisticsLogAsync(request.groupId, secretInfo.getGameId(), key, groupStatisticsParam.value, oldValue, value, request.log);
57227
57444
  }
@@ -63439,22 +63656,34 @@ class ChangeItemStatisticsRequestHandler extends ItemBaseRequestHandler {
63439
63656
  let value = itemStatisticsParam.value;
63440
63657
  let gnItemStatistic = new GNHashtable();
63441
63658
  gnItemStatistic.add(ParameterCode.Key, key);
63442
- if (!inventory.hasItemStatistics(key))
63443
- inventory.changeItemStatistics(key, itemStatisticsSettingsItem.initialValue, currentMilliseconds);
63659
+ let useSetItemStatistics = false;
63660
+ if (!inventory.hasItemStatistics(key)) {
63661
+ useSetItemStatistics = true;
63662
+ inventory.setItemStatistics(key, itemStatisticsSettingsItem.initialValue, currentMilliseconds);
63663
+ }
63444
63664
  let itemStatistics = inventory.getItemStatistics(key);
63445
63665
  let oldValue = itemStatistics.value;
63446
63666
  let statisticsAggregationMethod = itemStatisticsSettingsItem.statisticsAggregationMethod;
63447
63667
  if (statisticsAggregationMethod == xStatisticsAggregationMethod.Sum) {
63448
63668
  let newValue = value + itemStatistics.value;
63449
63669
  if (itemStatisticsSettingsItem.maximumValue != null) {
63450
- if (value > itemStatisticsSettingsItem.maximumValue)
63451
- value = itemStatisticsSettingsItem.maximumValue;
63670
+ if (newValue > itemStatisticsSettingsItem.maximumValue) {
63671
+ useSetItemStatistics = true;
63672
+ newValue = itemStatisticsSettingsItem.maximumValue;
63673
+ }
63452
63674
  }
63453
63675
  if (itemStatisticsSettingsItem.minimumValue != null) {
63454
- if (value < itemStatisticsSettingsItem.minimumValue)
63455
- value = itemStatisticsSettingsItem.minimumValue;
63676
+ if (newValue < itemStatisticsSettingsItem.minimumValue) {
63677
+ useSetItemStatistics = true;
63678
+ newValue = itemStatisticsSettingsItem.minimumValue;
63679
+ }
63680
+ }
63681
+ if (useSetItemStatistics) {
63682
+ inventory.setItemStatistics(key, newValue, currentMilliseconds);
63683
+ }
63684
+ else {
63685
+ inventory.changeItemStatistics(key, value, currentMilliseconds);
63456
63686
  }
63457
- inventory.changeItemStatistics(key, newValue, currentMilliseconds);
63458
63687
  gnItemStatistic.add(ParameterCode.Value, newValue);
63459
63688
  this.gnServer.getDatabase().insertInventoryStatisticsLogAsync(request.itemId, secretInfo.getGameId(), key, itemStatisticsParam.value, oldValue, newValue, request.log);
63460
63689
  }
@@ -63468,7 +63697,7 @@ class ChangeItemStatisticsRequestHandler extends ItemBaseRequestHandler {
63468
63697
  if (value < itemStatisticsSettingsItem.minimumValue)
63469
63698
  value = itemStatisticsSettingsItem.minimumValue;
63470
63699
  }
63471
- inventory.changeItemStatistics(key, value, currentMilliseconds);
63700
+ inventory.setItemStatistics(key, value, currentMilliseconds);
63472
63701
  gnItemStatistic.add(ParameterCode.Value, value);
63473
63702
  this.gnServer.getDatabase().insertInventoryStatisticsLogAsync(request.itemId, secretInfo.getGameId(), key, itemStatisticsParam.value, oldValue, value, request.log);
63474
63703
  }
@@ -63476,13 +63705,13 @@ class ChangeItemStatisticsRequestHandler extends ItemBaseRequestHandler {
63476
63705
  if (itemStatisticsSettingsItem.maximumValue != null) {
63477
63706
  if (itemStatistics.value > itemStatisticsSettingsItem.maximumValue) {
63478
63707
  itemStatistics.value = itemStatisticsSettingsItem.maximumValue;
63479
- inventory.changeItemStatistics(key, itemStatistics.value, currentMilliseconds);
63708
+ inventory.setItemStatistics(key, itemStatistics.value, currentMilliseconds);
63480
63709
  }
63481
63710
  }
63482
63711
  if (itemStatisticsSettingsItem.minimumValue != null) {
63483
63712
  if (itemStatistics.value < itemStatisticsSettingsItem.minimumValue) {
63484
63713
  itemStatistics.value = itemStatisticsSettingsItem.minimumValue;
63485
- inventory.changeItemStatistics(key, itemStatistics.value, currentMilliseconds);
63714
+ inventory.setItemStatistics(key, itemStatistics.value, currentMilliseconds);
63486
63715
  }
63487
63716
  }
63488
63717
  gnItemStatistic.add(ParameterCode.Value, itemStatistics.value);
@@ -63499,7 +63728,7 @@ class ChangeItemStatisticsRequestHandler extends ItemBaseRequestHandler {
63499
63728
  if (value < itemStatisticsSettingsItem.minimumValue)
63500
63729
  value = itemStatisticsSettingsItem.minimumValue;
63501
63730
  }
63502
- inventory.changeItemStatistics(key, value, currentMilliseconds);
63731
+ inventory.setItemStatistics(key, value, currentMilliseconds);
63503
63732
  gnItemStatistic.add(ParameterCode.Value, value);
63504
63733
  this.gnServer.getDatabase().insertInventoryStatisticsLogAsync(request.itemId, secretInfo.getGameId(), key, itemStatisticsParam.value, oldValue, value, request.log);
63505
63734
  }
@@ -63507,13 +63736,13 @@ class ChangeItemStatisticsRequestHandler extends ItemBaseRequestHandler {
63507
63736
  if (itemStatisticsSettingsItem.maximumValue != null) {
63508
63737
  if (itemStatistics.value > itemStatisticsSettingsItem.maximumValue) {
63509
63738
  itemStatistics.value = itemStatisticsSettingsItem.maximumValue;
63510
- inventory.changeItemStatistics(key, itemStatistics.value, currentMilliseconds);
63739
+ inventory.setItemStatistics(key, itemStatistics.value, currentMilliseconds);
63511
63740
  }
63512
63741
  }
63513
63742
  if (itemStatisticsSettingsItem.minimumValue != null) {
63514
63743
  if (itemStatistics.value < itemStatisticsSettingsItem.minimumValue) {
63515
63744
  itemStatistics.value = itemStatisticsSettingsItem.minimumValue;
63516
- inventory.changeItemStatistics(key, itemStatistics.value, currentMilliseconds);
63745
+ inventory.setItemStatistics(key, itemStatistics.value, currentMilliseconds);
63517
63746
  }
63518
63747
  }
63519
63748
  gnItemStatistic.add(ParameterCode.Value, itemStatistics.value);
@@ -63529,7 +63758,7 @@ class ChangeItemStatisticsRequestHandler extends ItemBaseRequestHandler {
63529
63758
  if (value < itemStatisticsSettingsItem.minimumValue)
63530
63759
  value = itemStatisticsSettingsItem.minimumValue;
63531
63760
  }
63532
- inventory.changeItemStatistics(key, value, currentMilliseconds);
63761
+ inventory.setItemStatistics(key, value, currentMilliseconds);
63533
63762
  gnItemStatistic.add(ParameterCode.Value, value);
63534
63763
  this.gnServer.getDatabase().insertInventoryStatisticsLogAsync(request.itemId, secretInfo.getGameId(), key, itemStatisticsParam.value, oldValue, value, request.log);
63535
63764
  }
@@ -67413,16 +67642,25 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67413
67642
  return operationResponse;
67414
67643
  }
67415
67644
  let characterPlayerSettings = this.gnServer.getGNSettings().getCharacterPlayerSettings(secretInfo.getGameId());
67645
+ let useSetPlayerCurrencyLst = [];
67416
67646
  let enoughtCurrency = true;
67417
67647
  for (let i = 0; i < allPriceCurrencies.length; i++) {
67418
67648
  let priceCurrency = allPriceCurrencies[i];
67419
67649
  if (!characterPlayer.hasPlayerCurrency(priceCurrency.key)) {
67650
+ if (!useSetPlayerCurrencyLst.includes(priceCurrency.key))
67651
+ useSetPlayerCurrencyLst.push(priceCurrency.key);
67420
67652
  let playerCurrenciesSettingsItem = characterPlayerSettings.playerCurrenciesSettings.find(x => x.key == priceCurrency.key);
67421
67653
  if (playerCurrenciesSettingsItem != null) {
67422
- characterPlayer.changePlayerCurrency(priceCurrency.key, playerCurrenciesSettingsItem.initialValue);
67654
+ characterPlayer.setPlayerCurrency(priceCurrency.key, playerCurrenciesSettingsItem.initialValue);
67423
67655
  }
67424
67656
  else {
67425
- characterPlayer.changePlayerCurrency(priceCurrency.key, 0);
67657
+ characterPlayer.setPlayerCurrency(priceCurrency.key, 0);
67658
+ }
67659
+ }
67660
+ else {
67661
+ if (allStoreCurrencies.find(x => x.key == priceCurrency.key) != null) {
67662
+ if (!useSetPlayerCurrencyLst.includes(priceCurrency.key))
67663
+ useSetPlayerCurrencyLst.push(priceCurrency.key);
67426
67664
  }
67427
67665
  }
67428
67666
  let playerCurrency = characterPlayer.getPlayerCurrency(priceCurrency.key);
@@ -67452,7 +67690,12 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67452
67690
  let playerCurrency = characterPlayer.getPlayerCurrency(priceCurrency.key);
67453
67691
  let oldValue = playerCurrency.value;
67454
67692
  let serverValue = playerCurrency.value - priceCurrency.value;
67455
- characterPlayer.changePlayerCurrency(priceCurrency.key, serverValue);
67693
+ if (useSetPlayerCurrencyLst.includes(priceCurrency.key)) {
67694
+ characterPlayer.setPlayerCurrency(priceCurrency.key, serverValue);
67695
+ }
67696
+ else {
67697
+ characterPlayer.changePlayerCurrency(priceCurrency.key, -priceCurrency.value);
67698
+ }
67456
67699
  let gnPlayerCurrency = new GNHashtable();
67457
67700
  gnPlayerCurrency.add(ParameterCode.Key, priceCurrency.key);
67458
67701
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -67495,12 +67738,14 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67495
67738
  value: storeCurrency.value,
67496
67739
  });
67497
67740
  if (!characterPlayer.hasPlayerCurrency(storeCurrency.key)) {
67741
+ if (!useSetPlayerCurrencyLst.includes(storeCurrency.key))
67742
+ useSetPlayerCurrencyLst.push(storeCurrency.key);
67498
67743
  let playerCurrenciesSettingsItem = characterPlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
67499
67744
  if (playerCurrenciesSettingsItem != null) {
67500
- characterPlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
67745
+ characterPlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
67501
67746
  }
67502
67747
  else {
67503
- characterPlayer.changePlayerCurrency(storeCurrency.key, 0);
67748
+ characterPlayer.setPlayerCurrency(storeCurrency.key, 0);
67504
67749
  }
67505
67750
  }
67506
67751
  let playerCurrency = characterPlayer.getPlayerCurrency(storeCurrency.key);
@@ -67510,7 +67755,12 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67510
67755
  });
67511
67756
  let oldValue = playerCurrency.value;
67512
67757
  let serverValue = playerCurrency.value + storeCurrency.value;
67513
- characterPlayer.changePlayerCurrency(storeCurrency.key, serverValue);
67758
+ if (useSetPlayerCurrencyLst.includes(storeCurrency.key)) {
67759
+ characterPlayer.setPlayerCurrency(storeCurrency.key, serverValue);
67760
+ }
67761
+ else {
67762
+ characterPlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
67763
+ }
67514
67764
  let gnPlayerCurrency = new GNHashtable();
67515
67765
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
67516
67766
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -67537,16 +67787,25 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67537
67787
  return operationResponse;
67538
67788
  }
67539
67789
  let gamePlayerSettings = this.gnServer.getGNSettings().getGamePlayerSettings(secretInfo.getGameId());
67790
+ let useSetPlayerCurrencyLst = [];
67540
67791
  let enoughtCurrency = true;
67541
67792
  for (let i = 0; i < allPriceCurrencies.length; i++) {
67542
67793
  let priceCurrency = allPriceCurrencies[i];
67543
67794
  if (!gamePlayer.hasPlayerCurrency(priceCurrency.key)) {
67795
+ if (!useSetPlayerCurrencyLst.includes(priceCurrency.key))
67796
+ useSetPlayerCurrencyLst.push(priceCurrency.key);
67544
67797
  let playerCurrenciesSettingsItem = gamePlayerSettings.playerCurrenciesSettings.find(x => x.key == priceCurrency.key);
67545
67798
  if (playerCurrenciesSettingsItem != null) {
67546
- gamePlayer.changePlayerCurrency(priceCurrency.key, playerCurrenciesSettingsItem.initialValue);
67799
+ gamePlayer.setPlayerCurrency(priceCurrency.key, playerCurrenciesSettingsItem.initialValue);
67547
67800
  }
67548
67801
  else {
67549
- gamePlayer.changePlayerCurrency(priceCurrency.key, 0);
67802
+ gamePlayer.setPlayerCurrency(priceCurrency.key, 0);
67803
+ }
67804
+ }
67805
+ else {
67806
+ if (allStoreCurrencies.find(x => x.key == priceCurrency.key) != null) {
67807
+ if (!useSetPlayerCurrencyLst.includes(priceCurrency.key))
67808
+ useSetPlayerCurrencyLst.push(priceCurrency.key);
67550
67809
  }
67551
67810
  }
67552
67811
  let playerCurrency = gamePlayer.getPlayerCurrency(priceCurrency.key);
@@ -67577,7 +67836,12 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67577
67836
  let playerCurrency = gamePlayer.getPlayerCurrency(priceCurrency.key);
67578
67837
  let oldValue = playerCurrency.value;
67579
67838
  let serverValue = playerCurrency.value - priceCurrency.value;
67580
- gamePlayer.changePlayerCurrency(priceCurrency.key, serverValue);
67839
+ if (useSetPlayerCurrencyLst.includes(priceCurrency.key)) {
67840
+ gamePlayer.setPlayerCurrency(priceCurrency.key, serverValue);
67841
+ }
67842
+ else {
67843
+ gamePlayer.changePlayerCurrency(priceCurrency.key, -priceCurrency.value);
67844
+ }
67581
67845
  let gnPlayerCurrency = new GNHashtable();
67582
67846
  gnPlayerCurrency.add(ParameterCode.Key, priceCurrency.key);
67583
67847
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -67620,12 +67884,14 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67620
67884
  value: storeCurrency.value,
67621
67885
  });
67622
67886
  if (!gamePlayer.hasPlayerCurrency(storeCurrency.key)) {
67887
+ if (!useSetPlayerCurrencyLst.includes(storeCurrency.key))
67888
+ useSetPlayerCurrencyLst.push(storeCurrency.key);
67623
67889
  let playerCurrenciesSettingsItem = gamePlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
67624
67890
  if (playerCurrenciesSettingsItem != null) {
67625
- gamePlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
67891
+ gamePlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
67626
67892
  }
67627
67893
  else {
67628
- gamePlayer.changePlayerCurrency(storeCurrency.key, 0);
67894
+ gamePlayer.setPlayerCurrency(storeCurrency.key, 0);
67629
67895
  }
67630
67896
  }
67631
67897
  let playerCurrency = gamePlayer.getPlayerCurrency(storeCurrency.key);
@@ -67635,7 +67901,12 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67635
67901
  });
67636
67902
  let oldValue = playerCurrency.value;
67637
67903
  let serverValue = playerCurrency.value + storeCurrency.value;
67638
- gamePlayer.changePlayerCurrency(storeCurrency.key, serverValue);
67904
+ if (useSetPlayerCurrencyLst.includes(storeCurrency.key)) {
67905
+ gamePlayer.setPlayerCurrency(storeCurrency.key, serverValue);
67906
+ }
67907
+ else {
67908
+ gamePlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
67909
+ }
67639
67910
  let gnPlayerCurrency = new GNHashtable();
67640
67911
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
67641
67912
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -67662,16 +67933,25 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67662
67933
  return operationResponse;
67663
67934
  }
67664
67935
  let groupSettings = this.gnServer.getGNSettings().getGroupSettings(secretInfo.getGameId());
67936
+ let useSetGroupCurrencyLst = [];
67665
67937
  let enoughtCurrency = true;
67666
67938
  for (let i = 0; i < allPriceCurrencies.length; i++) {
67667
67939
  let priceCurrency = allPriceCurrencies[i];
67668
67940
  if (!group.hasGroupCurrency(priceCurrency.key)) {
67941
+ if (!useSetGroupCurrencyLst.includes(priceCurrency.key))
67942
+ useSetGroupCurrencyLst.push(priceCurrency.key);
67669
67943
  let groupCurrenciesSettingsItem = groupSettings.groupCurrenciesSettings.find(x => x.key == priceCurrency.key);
67670
67944
  if (groupCurrenciesSettingsItem != null) {
67671
- group.changeGroupCurrency(priceCurrency.key, groupCurrenciesSettingsItem.initialValue);
67945
+ group.setGroupCurrency(priceCurrency.key, groupCurrenciesSettingsItem.initialValue);
67672
67946
  }
67673
67947
  else {
67674
- group.changeGroupCurrency(priceCurrency.key, 0);
67948
+ group.setGroupCurrency(priceCurrency.key, 0);
67949
+ }
67950
+ }
67951
+ else {
67952
+ if (allStoreCurrencies.find(x => x.key == priceCurrency.key) != null) {
67953
+ if (!useSetGroupCurrencyLst.includes(priceCurrency.key))
67954
+ useSetGroupCurrencyLst.push(priceCurrency.key);
67675
67955
  }
67676
67956
  }
67677
67957
  let groupCurrency = group.getGroupCurrency(priceCurrency.key);
@@ -67701,7 +67981,12 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67701
67981
  let groupCurrency = group.getGroupCurrency(priceCurrency.key);
67702
67982
  let oldValue = groupCurrency.value;
67703
67983
  let serverValue = groupCurrency.value - priceCurrency.value;
67704
- group.changeGroupCurrency(priceCurrency.key, serverValue);
67984
+ if (useSetGroupCurrencyLst.includes(priceCurrency.key)) {
67985
+ group.setGroupCurrency(priceCurrency.key, serverValue);
67986
+ }
67987
+ else {
67988
+ group.changeGroupCurrency(priceCurrency.key, -priceCurrency.value);
67989
+ }
67705
67990
  let gnGroupCurrency = new GNHashtable();
67706
67991
  gnGroupCurrency.add(ParameterCode.Key, priceCurrency.key);
67707
67992
  gnGroupCurrency.add(ParameterCode.Value, serverValue);
@@ -67744,12 +68029,15 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67744
68029
  value: storeCurrency.value,
67745
68030
  });
67746
68031
  if (!group.hasGroupCurrency(storeCurrency.key)) {
68032
+ if (!useSetGroupCurrencyLst.includes(storeCurrency.key)) {
68033
+ useSetGroupCurrencyLst.push(storeCurrency.key);
68034
+ }
67747
68035
  let groupCurrenciesSettingsItem = groupSettings.groupCurrenciesSettings.find(x => x.key == storeCurrency.key);
67748
68036
  if (groupCurrenciesSettingsItem != null) {
67749
- group.changeGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
68037
+ group.setGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
67750
68038
  }
67751
68039
  else {
67752
- group.changeGroupCurrency(storeCurrency.key, 0);
68040
+ group.setGroupCurrency(storeCurrency.key, 0);
67753
68041
  }
67754
68042
  }
67755
68043
  let groupCurrency = group.getGroupCurrency(storeCurrency.key);
@@ -67759,7 +68047,12 @@ class BuyStoreItemRequestHandler extends StoreItemBaseRequestHandler {
67759
68047
  });
67760
68048
  let oldValue = groupCurrency.value;
67761
68049
  let serverValue = groupCurrency.value + storeCurrency.value;
67762
- group.changeGroupCurrency(storeCurrency.key, serverValue);
68050
+ if (useSetGroupCurrencyLst.includes(storeCurrency.key)) {
68051
+ group.setGroupCurrency(storeCurrency.key, serverValue);
68052
+ }
68053
+ else {
68054
+ group.changeGroupCurrency(storeCurrency.key, storeCurrency.value);
68055
+ }
67763
68056
  let gnPlayerCurrency = new GNHashtable();
67764
68057
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
67765
68058
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -69071,13 +69364,15 @@ class ValidateAppleAppStoreReceiptRequestHandler extends StoreItemBaseRequestHan
69071
69364
  key: storeCurrency.key,
69072
69365
  value: storeCurrency.value,
69073
69366
  });
69367
+ let useSetPlayerCurrency = false;
69074
69368
  if (!characterPlayer.hasPlayerCurrency(storeCurrency.key)) {
69369
+ useSetPlayerCurrency = true;
69075
69370
  let playerCurrenciesSettingsItem = characterPlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
69076
69371
  if (playerCurrenciesSettingsItem != null) {
69077
- characterPlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
69372
+ characterPlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
69078
69373
  }
69079
69374
  else {
69080
- characterPlayer.changePlayerCurrency(storeCurrency.key, 0);
69375
+ characterPlayer.setPlayerCurrency(storeCurrency.key, 0);
69081
69376
  }
69082
69377
  }
69083
69378
  let playerCurrency = characterPlayer.getPlayerCurrency(storeCurrency.key);
@@ -69087,7 +69382,12 @@ class ValidateAppleAppStoreReceiptRequestHandler extends StoreItemBaseRequestHan
69087
69382
  });
69088
69383
  let oldValue = playerCurrency.value;
69089
69384
  let serverValue = playerCurrency.value + storeCurrency.value;
69090
- characterPlayer.changePlayerCurrency(storeCurrency.key, serverValue);
69385
+ if (useSetPlayerCurrency) {
69386
+ characterPlayer.setPlayerCurrency(storeCurrency.key, serverValue);
69387
+ }
69388
+ else {
69389
+ characterPlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
69390
+ }
69091
69391
  let gnPlayerCurrency = new GNHashtable();
69092
69392
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
69093
69393
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -69147,13 +69447,15 @@ class ValidateAppleAppStoreReceiptRequestHandler extends StoreItemBaseRequestHan
69147
69447
  key: storeCurrency.key,
69148
69448
  value: storeCurrency.value,
69149
69449
  });
69450
+ let useSetPlayerCurrency = false;
69150
69451
  if (!gamePlayer.hasPlayerCurrency(storeCurrency.key)) {
69452
+ useSetPlayerCurrency = true;
69151
69453
  let playerCurrenciesSettingsItem = gamePlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
69152
69454
  if (playerCurrenciesSettingsItem != null) {
69153
- gamePlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
69455
+ gamePlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
69154
69456
  }
69155
69457
  else {
69156
- gamePlayer.changePlayerCurrency(storeCurrency.key, 0);
69458
+ gamePlayer.setPlayerCurrency(storeCurrency.key, 0);
69157
69459
  }
69158
69460
  }
69159
69461
  let playerCurrency = gamePlayer.getPlayerCurrency(storeCurrency.key);
@@ -69163,7 +69465,12 @@ class ValidateAppleAppStoreReceiptRequestHandler extends StoreItemBaseRequestHan
69163
69465
  });
69164
69466
  let oldValue = playerCurrency.value;
69165
69467
  let serverValue = playerCurrency.value + storeCurrency.value;
69166
- gamePlayer.changePlayerCurrency(storeCurrency.key, serverValue);
69468
+ if (useSetPlayerCurrency) {
69469
+ gamePlayer.setPlayerCurrency(storeCurrency.key, serverValue);
69470
+ }
69471
+ else {
69472
+ gamePlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
69473
+ }
69167
69474
  let gnPlayerCurrency = new GNHashtable();
69168
69475
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
69169
69476
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -69223,13 +69530,15 @@ class ValidateAppleAppStoreReceiptRequestHandler extends StoreItemBaseRequestHan
69223
69530
  key: storeCurrency.key,
69224
69531
  value: storeCurrency.value,
69225
69532
  });
69533
+ let useSetGroupCurrency = false;
69226
69534
  if (!group.hasGroupCurrency(storeCurrency.key)) {
69535
+ useSetGroupCurrency = true;
69227
69536
  let groupCurrenciesSettingsItem = groupSettings.groupCurrenciesSettings.find(x => x.key == storeCurrency.key);
69228
69537
  if (groupCurrenciesSettingsItem != null) {
69229
- group.changeGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
69538
+ group.setGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
69230
69539
  }
69231
69540
  else {
69232
- group.changeGroupCurrency(storeCurrency.key, 0);
69541
+ group.setGroupCurrency(storeCurrency.key, 0);
69233
69542
  }
69234
69543
  }
69235
69544
  let groupCurrency = group.getGroupCurrency(storeCurrency.key);
@@ -69239,7 +69548,12 @@ class ValidateAppleAppStoreReceiptRequestHandler extends StoreItemBaseRequestHan
69239
69548
  });
69240
69549
  let oldValue = groupCurrency.value;
69241
69550
  let serverValue = groupCurrency.value + storeCurrency.value;
69242
- group.changeGroupCurrency(storeCurrency.key, serverValue);
69551
+ if (useSetGroupCurrency) {
69552
+ group.setGroupCurrency(storeCurrency.key, serverValue);
69553
+ }
69554
+ else {
69555
+ group.changeGroupCurrency(storeCurrency.key, storeCurrency.value);
69556
+ }
69243
69557
  let gnPlayerCurrency = new GNHashtable();
69244
69558
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
69245
69559
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -69541,13 +69855,15 @@ class ValidateGooglePlayStoreReceiptRequestHandler extends StoreItemBaseRequestH
69541
69855
  key: storeCurrency.key,
69542
69856
  value: storeCurrency.value,
69543
69857
  });
69858
+ let useSetPlayerCurrency = false;
69544
69859
  if (!characterPlayer.hasPlayerCurrency(storeCurrency.key)) {
69860
+ useSetPlayerCurrency = true;
69545
69861
  let playerCurrenciesSettingsItem = characterPlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
69546
69862
  if (playerCurrenciesSettingsItem != null) {
69547
- characterPlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
69863
+ characterPlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
69548
69864
  }
69549
69865
  else {
69550
- characterPlayer.changePlayerCurrency(storeCurrency.key, 0);
69866
+ characterPlayer.setPlayerCurrency(storeCurrency.key, 0);
69551
69867
  }
69552
69868
  }
69553
69869
  let playerCurrency = characterPlayer.getPlayerCurrency(storeCurrency.key);
@@ -69557,7 +69873,12 @@ class ValidateGooglePlayStoreReceiptRequestHandler extends StoreItemBaseRequestH
69557
69873
  });
69558
69874
  let oldValue = playerCurrency.value;
69559
69875
  let serverValue = playerCurrency.value + storeCurrency.value;
69560
- characterPlayer.changePlayerCurrency(storeCurrency.key, serverValue);
69876
+ if (useSetPlayerCurrency) {
69877
+ characterPlayer.setPlayerCurrency(storeCurrency.key, serverValue);
69878
+ }
69879
+ else {
69880
+ characterPlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
69881
+ }
69561
69882
  let gnPlayerCurrency = new GNHashtable();
69562
69883
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
69563
69884
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -69617,13 +69938,15 @@ class ValidateGooglePlayStoreReceiptRequestHandler extends StoreItemBaseRequestH
69617
69938
  key: storeCurrency.key,
69618
69939
  value: storeCurrency.value,
69619
69940
  });
69941
+ let useSetPlayerCurrency = false;
69620
69942
  if (!gamePlayer.hasPlayerCurrency(storeCurrency.key)) {
69943
+ useSetPlayerCurrency = true;
69621
69944
  let playerCurrenciesSettingItem = gamePlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
69622
69945
  if (playerCurrenciesSettingItem != null) {
69623
- gamePlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingItem.initialValue);
69946
+ gamePlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingItem.initialValue);
69624
69947
  }
69625
69948
  else {
69626
- gamePlayer.changePlayerCurrency(storeCurrency.key, 0);
69949
+ gamePlayer.setPlayerCurrency(storeCurrency.key, 0);
69627
69950
  }
69628
69951
  }
69629
69952
  let playerCurrency = gamePlayer.getPlayerCurrency(storeCurrency.key);
@@ -69633,7 +69956,12 @@ class ValidateGooglePlayStoreReceiptRequestHandler extends StoreItemBaseRequestH
69633
69956
  });
69634
69957
  let oldValue = playerCurrency.value;
69635
69958
  let serverValue = playerCurrency.value + storeCurrency.value;
69636
- gamePlayer.changePlayerCurrency(storeCurrency.key, serverValue);
69959
+ if (useSetPlayerCurrency) {
69960
+ gamePlayer.setPlayerCurrency(storeCurrency.key, serverValue);
69961
+ }
69962
+ else {
69963
+ gamePlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
69964
+ }
69637
69965
  let gnPlayerCurrency = new GNHashtable();
69638
69966
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
69639
69967
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -69693,13 +70021,15 @@ class ValidateGooglePlayStoreReceiptRequestHandler extends StoreItemBaseRequestH
69693
70021
  key: storeCurrency.key,
69694
70022
  value: storeCurrency.value,
69695
70023
  });
70024
+ let useSetGroupCurrency = false;
69696
70025
  if (!group.hasGroupCurrency(storeCurrency.key)) {
70026
+ useSetGroupCurrency = true;
69697
70027
  let groupCurrenciesSettingsItem = groupSettings.groupCurrenciesSettings.find(x => x.key == storeCurrency.key);
69698
70028
  if (groupCurrenciesSettingsItem != null) {
69699
- group.changeGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
70029
+ group.setGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
69700
70030
  }
69701
70031
  else {
69702
- group.changeGroupCurrency(storeCurrency.key, 0);
70032
+ group.setGroupCurrency(storeCurrency.key, 0);
69703
70033
  }
69704
70034
  }
69705
70035
  let groupCurrency = group.getGroupCurrency(storeCurrency.key);
@@ -69709,7 +70039,12 @@ class ValidateGooglePlayStoreReceiptRequestHandler extends StoreItemBaseRequestH
69709
70039
  });
69710
70040
  let oldValue = groupCurrency.value;
69711
70041
  let serverValue = groupCurrency.value + storeCurrency.value;
69712
- group.changeGroupCurrency(storeCurrency.key, serverValue);
70042
+ if (useSetGroupCurrency) {
70043
+ group.setGroupCurrency(storeCurrency.key, serverValue);
70044
+ }
70045
+ else {
70046
+ group.changeGroupCurrency(storeCurrency.key, storeCurrency.value);
70047
+ }
69713
70048
  let gnPlayerCurrency = new GNHashtable();
69714
70049
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
69715
70050
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -70011,13 +70346,15 @@ class ValidateFacebookStoreReceiptRequestHandler extends StoreItemBaseRequestHan
70011
70346
  key: storeCurrency.key,
70012
70347
  value: storeCurrency.value,
70013
70348
  });
70349
+ let useSetPlayerCurrency = false;
70014
70350
  if (!characterPlayer.hasPlayerCurrency(storeCurrency.key)) {
70351
+ useSetPlayerCurrency = true;
70015
70352
  let playerCurrenciesSettingsItem = characterPlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
70016
70353
  if (playerCurrenciesSettingsItem != null) {
70017
- characterPlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
70354
+ characterPlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
70018
70355
  }
70019
70356
  else {
70020
- characterPlayer.changePlayerCurrency(storeCurrency.key, 0);
70357
+ characterPlayer.setPlayerCurrency(storeCurrency.key, 0);
70021
70358
  }
70022
70359
  }
70023
70360
  let playerCurrency = characterPlayer.getPlayerCurrency(storeCurrency.key);
@@ -70027,7 +70364,12 @@ class ValidateFacebookStoreReceiptRequestHandler extends StoreItemBaseRequestHan
70027
70364
  });
70028
70365
  let oldValue = playerCurrency.value;
70029
70366
  let serverValue = playerCurrency.value + storeCurrency.value;
70030
- characterPlayer.changePlayerCurrency(storeCurrency.key, serverValue);
70367
+ if (useSetPlayerCurrency) {
70368
+ characterPlayer.setPlayerCurrency(storeCurrency.key, serverValue);
70369
+ }
70370
+ else {
70371
+ characterPlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
70372
+ }
70031
70373
  let gnPlayerCurrency = new GNHashtable();
70032
70374
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
70033
70375
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -70087,13 +70429,15 @@ class ValidateFacebookStoreReceiptRequestHandler extends StoreItemBaseRequestHan
70087
70429
  key: storeCurrency.key,
70088
70430
  value: storeCurrency.value,
70089
70431
  });
70432
+ let useSetPlayerCurrency = false;
70090
70433
  if (!gamePlayer.hasPlayerCurrency(storeCurrency.key)) {
70434
+ useSetPlayerCurrency = true;
70091
70435
  let playerCurrenciesSettingsItem = gamePlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
70092
70436
  if (playerCurrenciesSettingsItem != null) {
70093
- gamePlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
70437
+ gamePlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
70094
70438
  }
70095
70439
  else {
70096
- gamePlayer.changePlayerCurrency(storeCurrency.key, 0);
70440
+ gamePlayer.setPlayerCurrency(storeCurrency.key, 0);
70097
70441
  }
70098
70442
  }
70099
70443
  let playerCurrency = gamePlayer.getPlayerCurrency(storeCurrency.key);
@@ -70103,7 +70447,12 @@ class ValidateFacebookStoreReceiptRequestHandler extends StoreItemBaseRequestHan
70103
70447
  });
70104
70448
  let oldValue = playerCurrency.value;
70105
70449
  let serverValue = playerCurrency.value + storeCurrency.value;
70106
- gamePlayer.changePlayerCurrency(storeCurrency.key, serverValue);
70450
+ if (useSetPlayerCurrency) {
70451
+ gamePlayer.setPlayerCurrency(storeCurrency.key, serverValue);
70452
+ }
70453
+ else {
70454
+ gamePlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
70455
+ }
70107
70456
  let gnPlayerCurrency = new GNHashtable();
70108
70457
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
70109
70458
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -70163,13 +70512,15 @@ class ValidateFacebookStoreReceiptRequestHandler extends StoreItemBaseRequestHan
70163
70512
  key: storeCurrency.key,
70164
70513
  value: storeCurrency.value,
70165
70514
  });
70515
+ let useSetGroupCurrency = false;
70166
70516
  if (!group.hasGroupCurrency(storeCurrency.key)) {
70517
+ useSetGroupCurrency = true;
70167
70518
  let groupCurrenciesSettingsItem = groupSettings.groupCurrenciesSettings.find(x => x.key == storeCurrency.key);
70168
70519
  if (groupCurrenciesSettingsItem != null) {
70169
- group.changeGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
70520
+ group.setGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
70170
70521
  }
70171
70522
  else {
70172
- group.changeGroupCurrency(storeCurrency.key, 0);
70523
+ group.setGroupCurrency(storeCurrency.key, 0);
70173
70524
  }
70174
70525
  }
70175
70526
  let groupCurrency = group.getGroupCurrency(storeCurrency.key);
@@ -70179,7 +70530,12 @@ class ValidateFacebookStoreReceiptRequestHandler extends StoreItemBaseRequestHan
70179
70530
  });
70180
70531
  let oldValue = groupCurrency.value;
70181
70532
  let serverValue = groupCurrency.value + storeCurrency.value;
70182
- group.changeGroupCurrency(storeCurrency.key, serverValue);
70533
+ if (useSetGroupCurrency) {
70534
+ group.setGroupCurrency(storeCurrency.key, serverValue);
70535
+ }
70536
+ else {
70537
+ group.changeGroupCurrency(storeCurrency.key, storeCurrency.value);
70538
+ }
70183
70539
  let gnPlayerCurrency = new GNHashtable();
70184
70540
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
70185
70541
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -70619,13 +70975,15 @@ class PresentStoreItemRequestHandler extends StoreItemBaseRequestHandler {
70619
70975
  key: storeCurrency.key,
70620
70976
  value: storeCurrency.value,
70621
70977
  });
70978
+ let useSetPlayerCurrency = false;
70622
70979
  if (!characterPlayer.hasPlayerCurrency(storeCurrency.key)) {
70980
+ useSetPlayerCurrency = true;
70623
70981
  let playerCurrenciesSettingsItem = characterPlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
70624
70982
  if (playerCurrenciesSettingsItem != null) {
70625
- characterPlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
70983
+ characterPlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
70626
70984
  }
70627
70985
  else {
70628
- characterPlayer.changePlayerCurrency(storeCurrency.key, 0);
70986
+ characterPlayer.setPlayerCurrency(storeCurrency.key, 0);
70629
70987
  }
70630
70988
  }
70631
70989
  let playerCurrency = characterPlayer.getPlayerCurrency(storeCurrency.key);
@@ -70635,7 +70993,12 @@ class PresentStoreItemRequestHandler extends StoreItemBaseRequestHandler {
70635
70993
  });
70636
70994
  let oldValue = playerCurrency.value;
70637
70995
  let serverValue = playerCurrency.value + storeCurrency.value;
70638
- characterPlayer.changePlayerCurrency(storeCurrency.key, serverValue);
70996
+ if (useSetPlayerCurrency) {
70997
+ characterPlayer.setPlayerCurrency(storeCurrency.key, serverValue);
70998
+ }
70999
+ else {
71000
+ characterPlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
71001
+ }
70639
71002
  let gnPlayerCurrency = new GNHashtable();
70640
71003
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
70641
71004
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -70695,13 +71058,15 @@ class PresentStoreItemRequestHandler extends StoreItemBaseRequestHandler {
70695
71058
  key: storeCurrency.key,
70696
71059
  value: storeCurrency.value,
70697
71060
  });
71061
+ let useSetPlayerCurrency = false;
70698
71062
  if (!gamePlayer.hasPlayerCurrency(storeCurrency.key)) {
71063
+ useSetPlayerCurrency = true;
70699
71064
  let playerCurrenciesSettingsItem = gamePlayerSettings.playerCurrenciesSettings.find(x => x.key == storeCurrency.key);
70700
71065
  if (playerCurrenciesSettingsItem != null) {
70701
- gamePlayer.changePlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
71066
+ gamePlayer.setPlayerCurrency(storeCurrency.key, playerCurrenciesSettingsItem.initialValue);
70702
71067
  }
70703
71068
  else {
70704
- gamePlayer.changePlayerCurrency(storeCurrency.key, 0);
71069
+ gamePlayer.setPlayerCurrency(storeCurrency.key, 0);
70705
71070
  }
70706
71071
  }
70707
71072
  let playerCurrency = gamePlayer.getPlayerCurrency(storeCurrency.key);
@@ -70711,7 +71076,12 @@ class PresentStoreItemRequestHandler extends StoreItemBaseRequestHandler {
70711
71076
  });
70712
71077
  let oldValue = playerCurrency.value;
70713
71078
  let serverValue = playerCurrency.value + storeCurrency.value;
70714
- gamePlayer.changePlayerCurrency(storeCurrency.key, serverValue);
71079
+ if (useSetPlayerCurrency) {
71080
+ gamePlayer.setPlayerCurrency(storeCurrency.key, serverValue);
71081
+ }
71082
+ else {
71083
+ gamePlayer.changePlayerCurrency(storeCurrency.key, storeCurrency.value);
71084
+ }
70715
71085
  let gnPlayerCurrency = new GNHashtable();
70716
71086
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
70717
71087
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -70771,13 +71141,15 @@ class PresentStoreItemRequestHandler extends StoreItemBaseRequestHandler {
70771
71141
  key: storeCurrency.key,
70772
71142
  value: storeCurrency.value,
70773
71143
  });
71144
+ let useSetGroupCurrency = false;
70774
71145
  if (!group.hasGroupCurrency(storeCurrency.key)) {
71146
+ useSetGroupCurrency = true;
70775
71147
  let groupCurrenciesSettingsItem = groupSettings.groupCurrenciesSettings.find(x => x.key == storeCurrency.key);
70776
71148
  if (groupCurrenciesSettingsItem != null) {
70777
- group.changeGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
71149
+ group.setGroupCurrency(storeCurrency.key, groupCurrenciesSettingsItem.initialValue);
70778
71150
  }
70779
71151
  else {
70780
- group.changeGroupCurrency(storeCurrency.key, 0);
71152
+ group.setGroupCurrency(storeCurrency.key, 0);
70781
71153
  }
70782
71154
  }
70783
71155
  let groupCurrency = group.getGroupCurrency(storeCurrency.key);
@@ -70787,7 +71159,12 @@ class PresentStoreItemRequestHandler extends StoreItemBaseRequestHandler {
70787
71159
  });
70788
71160
  let oldValue = groupCurrency.value;
70789
71161
  let serverValue = groupCurrency.value + storeCurrency.value;
70790
- group.changeGroupCurrency(storeCurrency.key, serverValue);
71162
+ if (useSetGroupCurrency) {
71163
+ group.setGroupCurrency(storeCurrency.key, serverValue);
71164
+ }
71165
+ else {
71166
+ group.changeGroupCurrency(storeCurrency.key, storeCurrency.value);
71167
+ }
70791
71168
  let gnPlayerCurrency = new GNHashtable();
70792
71169
  gnPlayerCurrency.add(ParameterCode.Key, storeCurrency.key);
70793
71170
  gnPlayerCurrency.add(ParameterCode.Value, serverValue);
@@ -72127,9 +72504,9 @@ class SetMasterGameSettingsRequestHandler extends RequestHandler {
72127
72504
  if (request.masterPlayerSettings.playerStatisticsSettings != null) {
72128
72505
  let playerStatisticsSettings = new Array();
72129
72506
  let removeKeyAscLst = new Array();
72130
- let removeKeyLst = new Array();
72507
+ let removeKeyLst = removeKeyAscLst; //new Array<string>();
72131
72508
  let addKeyAscLst = new Array();
72132
- let addKeyLst = new Array();
72509
+ let addKeyLst = addKeyAscLst; //new Array<string>();
72133
72510
  for (let i = 0; i < masterPlayerSettings.playerStatisticsSettings.length; i++) {
72134
72511
  let playerStatisticsSetting = masterPlayerSettings.playerStatisticsSettings[i];
72135
72512
  if (playerStatisticsSetting.index) {
@@ -72171,7 +72548,7 @@ class SetMasterGameSettingsRequestHandler extends RequestHandler {
72171
72548
  if (this.gnServer.isPrimary()) {
72172
72549
  for (let i = 0; i < removeKeyLst.length; i++) {
72173
72550
  let key = removeKeyLst[i];
72174
- let indexName = "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
72551
+ let indexName = "playerStatistics." + key + ".value_-1";
72175
72552
  masterPlayerCollection.dropIndex(indexName);
72176
72553
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + masterPlayerCollection.collectionName);
72177
72554
  }
@@ -72179,36 +72556,7 @@ class SetMasterGameSettingsRequestHandler extends RequestHandler {
72179
72556
  let key = addKeyLst[i];
72180
72557
  let indexDoc = {};
72181
72558
  indexDoc["playerStatistics." + key + ".value"] = -1;
72182
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
72183
- let indexName = "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
72184
- masterPlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
72185
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + masterPlayerCollection.collectionName);
72186
- }
72187
- }
72188
- }
72189
- {
72190
- for (let i = 0; i < addKeyAscLst.length; i++) {
72191
- let key = addKeyAscLst[i];
72192
- let removeIndexOf = removeKeyAscLst.indexOf(key);
72193
- if (removeIndexOf != -1) {
72194
- removeKeyAscLst.splice(removeIndexOf, 1);
72195
- addKeyAscLst.splice(i, 1);
72196
- i -= 1;
72197
- }
72198
- }
72199
- if (this.gnServer.isPrimary()) {
72200
- for (let i = 0; i < removeKeyAscLst.length; i++) {
72201
- let key = removeKeyAscLst[i];
72202
- let indexName = "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
72203
- masterPlayerCollection.dropIndex(indexName);
72204
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + masterPlayerCollection.collectionName);
72205
- }
72206
- for (let i = 0; i < addKeyAscLst.length; i++) {
72207
- let key = addKeyAscLst[i];
72208
- let indexDoc = {};
72209
- indexDoc["playerStatistics." + key + ".value"] = 1;
72210
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
72211
- let indexName = "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
72559
+ let indexName = "playerStatistics." + key + ".value_-1";
72212
72560
  masterPlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
72213
72561
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + masterPlayerCollection.collectionName);
72214
72562
  }
@@ -73685,9 +74033,9 @@ class SetGameInformationRequestHandler extends RequestHandler {
73685
74033
  if (request.gameSettings.characterPlayerSettings.playerStatisticsSettings != null) {
73686
74034
  let playerStatisticsSettings = new Array();
73687
74035
  let removeKeyAscLst = new Array();
73688
- let removeKeyLst = new Array();
74036
+ let removeKeyLst = removeKeyAscLst; //new Array<string>();
73689
74037
  let addKeyAscLst = new Array();
73690
- let addKeyLst = new Array();
74038
+ let addKeyLst = addKeyAscLst; //new Array<string>();
73691
74039
  for (let i = 0; i < currentCharacterPlayerSettings.playerStatisticsSettings.length; i++) {
73692
74040
  let playerStatisticsSetting = currentCharacterPlayerSettings.playerStatisticsSettings[i];
73693
74041
  if (playerStatisticsSetting.index) {
@@ -73730,12 +74078,12 @@ class SetGameInformationRequestHandler extends RequestHandler {
73730
74078
  for (let i = 0; i < removeKeyLst.length; i++) {
73731
74079
  let key = removeKeyLst[i];
73732
74080
  {
73733
- let indexName = "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
74081
+ let indexName = "playerStatistics." + key + ".value_-1";
73734
74082
  characterPlayerCollection.dropIndex(indexName);
73735
74083
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + characterPlayerCollection.collectionName);
73736
74084
  }
73737
74085
  {
73738
- let indexName = "catalogId_1_" + "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
74086
+ let indexName = "catalogId_1_" + "playerStatistics." + key + ".value_-1";
73739
74087
  characterPlayerCollection.dropIndex(indexName);
73740
74088
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + characterPlayerCollection.collectionName);
73741
74089
  }
@@ -73745,8 +74093,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
73745
74093
  {
73746
74094
  let indexDoc = {};
73747
74095
  indexDoc["playerStatistics." + key + ".value"] = -1;
73748
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
73749
- let indexName = "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
74096
+ let indexName = "playerStatistics." + key + ".value_-1";
73750
74097
  characterPlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
73751
74098
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + characterPlayerCollection.collectionName);
73752
74099
  }
@@ -73754,52 +74101,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
73754
74101
  let indexDoc = {};
73755
74102
  indexDoc["catalogId"] = 1;
73756
74103
  indexDoc["playerStatistics." + key + ".value"] = -1;
73757
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
73758
- let indexName = "catalogId_1_" + "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
73759
- characterPlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
73760
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + characterPlayerCollection.collectionName);
73761
- }
73762
- }
73763
- }
73764
- {
73765
- for (let i = 0; i < addKeyAscLst.length; i++) {
73766
- let key = addKeyAscLst[i];
73767
- let removeIndexOf = removeKeyAscLst.indexOf(key);
73768
- if (removeIndexOf != -1) {
73769
- removeKeyAscLst.splice(removeIndexOf, 1);
73770
- addKeyAscLst.splice(i, 1);
73771
- i -= 1;
73772
- }
73773
- }
73774
- for (let i = 0; i < removeKeyAscLst.length; i++) {
73775
- let key = removeKeyAscLst[i];
73776
- {
73777
- let indexName = "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
73778
- characterPlayerCollection.dropIndex(indexName);
73779
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + characterPlayerCollection.collectionName);
73780
- }
73781
- {
73782
- let indexName = "catalogId_1_" + "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
73783
- characterPlayerCollection.dropIndex(indexName);
73784
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + characterPlayerCollection.collectionName);
73785
- }
73786
- }
73787
- for (let i = 0; i < addKeyAscLst.length; i++) {
73788
- let key = addKeyAscLst[i];
73789
- {
73790
- let indexDoc = {};
73791
- indexDoc["playerStatistics." + key + ".value"] = 1;
73792
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
73793
- let indexName = "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
73794
- characterPlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
73795
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + characterPlayerCollection.collectionName);
73796
- }
73797
- {
73798
- let indexDoc = {};
73799
- indexDoc["catalogId"] = 1;
73800
- indexDoc["playerStatistics." + key + ".value"] = 1;
73801
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
73802
- let indexName = "catalogId_1_" + "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
74104
+ let indexName = "catalogId_1_" + "playerStatistics." + key + ".value_-1";
73803
74105
  characterPlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
73804
74106
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + characterPlayerCollection.collectionName);
73805
74107
  }
@@ -73968,9 +74270,9 @@ class SetGameInformationRequestHandler extends RequestHandler {
73968
74270
  if (request.gameSettings.gamePlayerSettings.playerStatisticsSettings != null) {
73969
74271
  let playerStatisticsSettings = new Array();
73970
74272
  let removeKeyAscLst = new Array();
73971
- let removeKeyLst = new Array();
74273
+ let removeKeyLst = removeKeyAscLst; //new Array<string>();
73972
74274
  let addKeyAscLst = new Array();
73973
- let addKeyLst = new Array();
74275
+ let addKeyLst = addKeyAscLst; //new Array<string>();
73974
74276
  for (let i = 0; i < currentGamePlayerSettings.playerStatisticsSettings.length; i++) {
73975
74277
  let playerStatisticsSetting = currentGamePlayerSettings.playerStatisticsSettings[i];
73976
74278
  if (playerStatisticsSetting.index) {
@@ -74012,7 +74314,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
74012
74314
  }
74013
74315
  for (let i = 0; i < removeKeyLst.length; i++) {
74014
74316
  let key = removeKeyLst[i];
74015
- let indexName = "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
74317
+ let indexName = "playerStatistics." + key + ".value_-1";
74016
74318
  gamePlayerCollection.dropIndex(indexName);
74017
74319
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + gamePlayerCollection.collectionName);
74018
74320
  }
@@ -74020,34 +74322,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
74020
74322
  let key = addKeyLst[i];
74021
74323
  let indexDoc = {};
74022
74324
  indexDoc["playerStatistics." + key + ".value"] = -1;
74023
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
74024
- let indexName = "playerStatistics." + key + ".value_-1_playerStatistics." + key + ".tsLastUpdate_1";
74025
- gamePlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74026
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + gamePlayerCollection.collectionName);
74027
- }
74028
- }
74029
- {
74030
- for (let i = 0; i < addKeyAscLst.length; i++) {
74031
- let key = addKeyAscLst[i];
74032
- let removeIndexOf = removeKeyAscLst.indexOf(key);
74033
- if (removeIndexOf != -1) {
74034
- removeKeyAscLst.splice(removeIndexOf, 1);
74035
- addKeyAscLst.splice(i, 1);
74036
- i -= 1;
74037
- }
74038
- }
74039
- for (let i = 0; i < removeKeyAscLst.length; i++) {
74040
- let key = removeKeyAscLst[i];
74041
- let indexName = "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
74042
- gamePlayerCollection.dropIndex(indexName);
74043
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + gamePlayerCollection.collectionName);
74044
- }
74045
- for (let i = 0; i < addKeyAscLst.length; i++) {
74046
- let key = addKeyAscLst[i];
74047
- let indexDoc = {};
74048
- indexDoc["playerStatistics." + key + ".value"] = 1;
74049
- indexDoc["playerStatistics." + key + ".tsLastUpdate"] = 1;
74050
- let indexName = "playerStatistics." + key + ".value_1_playerStatistics." + key + ".tsLastUpdate_1";
74325
+ let indexName = "playerStatistics." + key + ".value_-1";
74051
74326
  gamePlayerCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74052
74327
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + gamePlayerCollection.collectionName);
74053
74328
  }
@@ -74244,9 +74519,9 @@ class SetGameInformationRequestHandler extends RequestHandler {
74244
74519
  if (request.gameSettings.groupSettings.groupStatisticsSettings != null) {
74245
74520
  let groupStatisticsSettings = new Array();
74246
74521
  let removeKeyAscLst = new Array();
74247
- let removeKeyLst = new Array();
74522
+ let removeKeyLst = removeKeyAscLst; //new Array<string>();
74248
74523
  let addKeyAscLst = new Array();
74249
- let addKeyLst = new Array();
74524
+ let addKeyLst = addKeyAscLst; //new Array<string>();
74250
74525
  for (let i = 0; i < groupSettings.groupStatisticsSettings.length; i++) {
74251
74526
  let groupStatisticsSetting = groupSettings.groupStatisticsSettings[i];
74252
74527
  if (groupStatisticsSetting.index) {
@@ -74289,12 +74564,12 @@ class SetGameInformationRequestHandler extends RequestHandler {
74289
74564
  for (let i = 0; i < removeKeyLst.length; i++) {
74290
74565
  let key = removeKeyLst[i];
74291
74566
  {
74292
- let indexName = "groupStatistics." + key + ".value_-1_groupStatistics." + key + ".tsLastUpdate_1";
74567
+ let indexName = "groupStatistics." + key + ".value_-1";
74293
74568
  groupCollection.dropIndex(indexName);
74294
74569
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + groupCollection.collectionName);
74295
74570
  }
74296
74571
  {
74297
- let indexName = "catalogId_1_" + "groupStatistics." + key + ".value_-1_groupStatistics." + key + ".tsLastUpdate_1";
74572
+ let indexName = "catalogId_1_" + "groupStatistics." + key + ".value_-1";
74298
74573
  groupCollection.dropIndex(indexName);
74299
74574
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + groupCollection.collectionName);
74300
74575
  }
@@ -74304,8 +74579,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
74304
74579
  {
74305
74580
  let indexDoc = {};
74306
74581
  indexDoc["groupStatistics." + key + ".value"] = -1;
74307
- indexDoc["groupStatistics." + key + ".tsLastUpdate"] = 1;
74308
- let indexName = "groupStatistics." + key + ".value_-1_groupStatistics." + key + ".tsLastUpdate_1";
74582
+ let indexName = "groupStatistics." + key + ".value_-1";
74309
74583
  groupCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74310
74584
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + groupCollection.collectionName);
74311
74585
  }
@@ -74313,52 +74587,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
74313
74587
  let indexDoc = {};
74314
74588
  indexDoc["catalogId"] = 1;
74315
74589
  indexDoc["groupStatistics." + key + ".value"] = -1;
74316
- indexDoc["groupStatistics." + key + ".tsLastUpdate"] = 1;
74317
- let indexName = "catalogId_1_" + "groupStatistics." + key + ".value_-1_groupStatistics." + key + ".tsLastUpdate_1";
74318
- groupCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74319
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + groupCollection.collectionName);
74320
- }
74321
- }
74322
- }
74323
- {
74324
- for (let i = 0; i < addKeyAscLst.length; i++) {
74325
- let key = addKeyAscLst[i];
74326
- let removeIndexOf = removeKeyAscLst.indexOf(key);
74327
- if (removeIndexOf != -1) {
74328
- removeKeyAscLst.splice(removeIndexOf, 1);
74329
- addKeyAscLst.splice(i, 1);
74330
- i -= 1;
74331
- }
74332
- }
74333
- for (let i = 0; i < removeKeyAscLst.length; i++) {
74334
- let key = removeKeyAscLst[i];
74335
- {
74336
- let indexName = "groupStatistics." + key + ".value_1_groupStatistics." + key + ".tsLastUpdate_1";
74337
- groupCollection.dropIndex(indexName);
74338
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + groupCollection.collectionName);
74339
- }
74340
- {
74341
- let indexName = "catalogId_1_" + "groupStatistics." + key + ".value_1_groupStatistics." + key + ".tsLastUpdate_1";
74342
- groupCollection.dropIndex(indexName);
74343
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + groupCollection.collectionName);
74344
- }
74345
- }
74346
- for (let i = 0; i < addKeyAscLst.length; i++) {
74347
- let key = addKeyAscLst[i];
74348
- {
74349
- let indexDoc = {};
74350
- indexDoc["groupStatistics." + key + ".value"] = 1;
74351
- indexDoc["groupStatistics." + key + ".tsLastUpdate"] = 1;
74352
- let indexName = "groupStatistics." + key + ".value_1_groupStatistics." + key + ".tsLastUpdate_1";
74353
- groupCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74354
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + groupCollection.collectionName);
74355
- }
74356
- {
74357
- let indexDoc = {};
74358
- indexDoc["catalogId"] = 1;
74359
- indexDoc["groupStatistics." + key + ".value"] = 1;
74360
- indexDoc["groupStatistics." + key + ".tsLastUpdate"] = 1;
74361
- let indexName = "catalogId_1_" + "groupStatistics." + key + ".value_1_groupStatistics." + key + ".tsLastUpdate_1";
74590
+ let indexName = "catalogId_1_" + "groupStatistics." + key + ".value_-1";
74362
74591
  groupCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74363
74592
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + groupCollection.collectionName);
74364
74593
  }
@@ -74457,9 +74686,9 @@ class SetGameInformationRequestHandler extends RequestHandler {
74457
74686
  if (request.gameSettings.inventorySettings.itemStatisticsSettings != null) {
74458
74687
  let itemStatisticsSettings = new Array();
74459
74688
  let removeKeyAscLst = new Array();
74460
- let removeKeyLst = new Array();
74689
+ let removeKeyLst = removeKeyAscLst; //new Array<string>();
74461
74690
  let addKeyAscLst = new Array();
74462
- let addKeyLst = new Array();
74691
+ let addKeyLst = addKeyAscLst; //new Array<string>();
74463
74692
  for (let i = 0; i < inventorySettings.itemStatisticsSettings.length; i++) {
74464
74693
  let itemStatisticsSetting = inventorySettings.itemStatisticsSettings[i];
74465
74694
  if (itemStatisticsSetting.index) {
@@ -74502,12 +74731,12 @@ class SetGameInformationRequestHandler extends RequestHandler {
74502
74731
  for (let i = 0; i < removeKeyLst.length; i++) {
74503
74732
  let key = removeKeyLst[i];
74504
74733
  {
74505
- let indexName = "itemStatistics." + key + ".value_-1_itemStatistics." + key + ".tsLastUpdate_1";
74734
+ let indexName = "itemStatistics." + key + ".value_-1";
74506
74735
  inventoryCollection.dropIndex(indexName);
74507
74736
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + inventoryCollection.collectionName);
74508
74737
  }
74509
74738
  {
74510
- let indexName = "catalogId_1_" + "itemStatistics." + key + ".value_-1_itemStatistics." + key + ".tsLastUpdate_1";
74739
+ let indexName = "catalogId_1_" + "itemStatistics." + key + ".value_-1";
74511
74740
  inventoryCollection.dropIndex(indexName);
74512
74741
  Debug.log("[GearN] [Database] drop index " + indexName + " at " + inventoryCollection.collectionName);
74513
74742
  }
@@ -74517,8 +74746,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
74517
74746
  {
74518
74747
  let indexDoc = {};
74519
74748
  indexDoc["itemStatistics." + key + ".value"] = -1;
74520
- indexDoc["itemStatistics." + key + ".tsLastUpdate"] = 1;
74521
- let indexName = "itemStatistics." + key + ".value_-1_itemStatistics." + key + ".tsLastUpdate_1";
74749
+ let indexName = "itemStatistics." + key + ".value_-1";
74522
74750
  inventoryCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74523
74751
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + inventoryCollection.collectionName);
74524
74752
  }
@@ -74526,52 +74754,7 @@ class SetGameInformationRequestHandler extends RequestHandler {
74526
74754
  let indexDoc = {};
74527
74755
  indexDoc["catalogId"] = 1;
74528
74756
  indexDoc["itemStatistics." + key + ".value"] = -1;
74529
- indexDoc["itemStatistics." + key + ".tsLastUpdate"] = 1;
74530
- let indexName = "catalogId_1_" + "itemStatistics." + key + ".value_-1_itemStatistics." + key + ".tsLastUpdate_1";
74531
- inventoryCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74532
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + inventoryCollection.collectionName);
74533
- }
74534
- }
74535
- }
74536
- {
74537
- for (let i = 0; i < addKeyAscLst.length; i++) {
74538
- let key = addKeyAscLst[i];
74539
- let removeIndexOf = removeKeyAscLst.indexOf(key);
74540
- if (removeIndexOf != -1) {
74541
- removeKeyAscLst.splice(removeIndexOf, 1);
74542
- addKeyAscLst.splice(i, 1);
74543
- i -= 1;
74544
- }
74545
- }
74546
- for (let i = 0; i < removeKeyAscLst.length; i++) {
74547
- let key = removeKeyAscLst[i];
74548
- {
74549
- let indexName = "itemStatistics." + key + ".value_1_itemStatistics." + key + ".tsLastUpdate_1";
74550
- inventoryCollection.dropIndex(indexName);
74551
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + inventoryCollection.collectionName);
74552
- }
74553
- {
74554
- let indexName = "catalogId_1_" + "itemStatistics." + key + ".value_1_itemStatistics." + key + ".tsLastUpdate_1";
74555
- inventoryCollection.dropIndex(indexName);
74556
- Debug.log("[GearN] [Database] drop index " + indexName + " at " + inventoryCollection.collectionName);
74557
- }
74558
- }
74559
- for (let i = 0; i < addKeyAscLst.length; i++) {
74560
- let key = addKeyAscLst[i];
74561
- {
74562
- let indexDoc = {};
74563
- indexDoc["itemStatistics." + key + ".value"] = 1;
74564
- indexDoc["itemStatistics." + key + ".tsLastUpdate"] = 1;
74565
- let indexName = "itemStatistics." + key + ".value_1_itemStatistics." + key + ".tsLastUpdate_1";
74566
- inventoryCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74567
- Debug.log("[GearN] [Database] create new index " + indexName + " at " + inventoryCollection.collectionName);
74568
- }
74569
- {
74570
- let indexDoc = {};
74571
- indexDoc["catalogId"] = 1;
74572
- indexDoc["itemStatistics." + key + ".value"] = 1;
74573
- indexDoc["itemStatistics." + key + ".tsLastUpdate"] = 1;
74574
- let indexName = "catalogId_1_" + "itemStatistics." + key + ".value_1_itemStatistics." + key + ".tsLastUpdate_1";
74757
+ let indexName = "catalogId_1_" + "itemStatistics." + key + ".value_-1";
74575
74758
  inventoryCollection.createIndex(indexDoc, { background: true, sparse: true, name: indexName });
74576
74759
  Debug.log("[GearN] [Database] create new index " + indexName + " at " + inventoryCollection.collectionName);
74577
74760
  }
@@ -87573,8 +87756,8 @@ class ServerApplicationStartup extends DefaultApplicationStartup {
87573
87756
  let databaseSettings = DatabaseSettings.Builder()
87574
87757
  .setConnectionString(gnDatabaseSettings["connectionString"] ?? "mongodb://127.0.0.1:27017/")
87575
87758
  .setDatabaseName(gnDatabaseSettings["databaseName"] ?? "XmobiTea")
87576
- .setLogConnectionString(gnDatabaseSettings["logConnectionString"] ?? "mongodb://127.0.0.1:27017/")
87577
- .setDatabaseName(gnDatabaseSettings["databaseName"] ?? "XmobiTea")
87759
+ .setLogConnectionString(gnDatabaseSettings["logConnectionString"] ?? "")
87760
+ .setDatabaseName(gnDatabaseSettings["databaseName"] ?? "")
87578
87761
  .setOptions(gnDatabaseSettings["options"] ?? {})
87579
87762
  .build();
87580
87763
  let gnLogSettings = this.gnConfig["logSettings"];