Advertisement
Specter_

Random gold

Sep 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1.             // Вероятность выпадения (1 к ...)
  2.             private int p = 700;
  3.             // Предельная разница фонда между голдами
  4.             private int lim = 700;
  5.             // Предельно возможное отклонение от lim
  6.             private int deviation = 10;
  7.            
  8.             private int droppedGolds = 0;
  9.             private int lastDroppedGolds = 0;
  10.             private int lastGoldFund = 0;
  11.                
  12.                 int regionIndex = rnd.nextInt(bonuses.getBonusGoldInfo().size());
  13.                 BonusInfo bonusGold = bonuses.getBonusGoldInfo().get(regionIndex);
  14.                
  15.                 int fund = (int)model.tanksKillModel.getBattleFund();
  16.                 int fundDelta = fund - bonuses.getPrevFund();
  17.                
  18.                 int golds = 0;
  19.                 int currentLim = lim + deviation * (int)RandomUtils.getRandom(-1, 1);
  20.                
  21.                 if((fund - lastGoldFund) >= currentLim) {
  22.                     if(lastDroppedGolds == droppedGolds) {
  23.                         golds += 1;
  24.                         lastDroppedGolds += 1;
  25.                         lastGoldFund = fund;
  26.                     } else {
  27.                         lastDroppedGolds = droppedGolds;
  28.                     }
  29.                 }
  30.                 else {
  31.                     for (int i = 0; i < fundDelta; i++) {
  32.                         if((int)RandomUtils.getRandom(0, p) == 0) {
  33.                             golds += 1;
  34.                             lastGoldFund = fund;
  35.                         }
  36.                     }
  37.                 }
  38.                
  39.                 droppedGolds += golds;
  40.                
  41.                 for (int i = 0; i < golds + 1; i++) {
  42.                     // ... Дропнуть голд
  43.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement