Skip to content

Commit

Permalink
Simplify the legacy pending random reward code
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSamWitch committed Aug 7, 2023
1 parent 21ebc79 commit 509606a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 45 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ Donation [0xdd1131f57e5e416622fa2b61d4108822e8cc38dc](https://ftmscan.com/addres
Clans [0xd35410f526db135f09bb8e2bb066c8a63135d812](https://ftmscan.com/address/0xd35410f526db135f09bb8e2bb066c8a63135d812)
Bank Beacon [0x73d1b1420deaeb6474b8aafb1d8229d392d1a04e](https://ftmscan.com/address/0x73d1b1420deaeb6474b8aafb1d8229d392d1a04e)

PlayersLibrary [0xf0bbe8fdfb1362aad6cfbdaf2d36a2c642c80494](https://ftmscan.com/address/0xf0bbe8fdfb1362aad6cfbdaf2d36a2c642c80494)
PlayersImplQueueActions [0xa0422ef9228f33a09da374029f6340013d9bcbd3](https://ftmscan.com/address/0xa0422ef9228f33a09da374029f6340013d9bcbd3)
PlayersImplProcessActions [0xee860b09f52e3d30923ab5f55d471b139e87378a](https://ftmscan.com/address/0xee860b09f52e3d30923ab5f55d471b139e87378a)
PlayersImplRewards [0xb773bdf7ebd45589760fac3c70e03e05bc4cbe5c](https://ftmscan.com/address/0xb773bdf7ebd45589760fac3c70e03e05bc4cbe5c)
PlayersImplMisc [0xe0c8a7f7e2c94862d6ff83fef602e84df05326bc](https://ftmscan.com/address/0xe0c8a7f7e2c94862d6ff83fef602e84df05326bc)
PlayersImplMisc1 [0xa5f7a758d2da1dee298e8e6e63c266b8ee3357db](https://ftmscan.com/address/0xa5f7a758d2da1dee298e8e6e63c266b8ee3357db)
PlayersLibrary [0x8afe8cf12c38c08804ffb069103fdb79c6c19b25](https://ftmscan.com/address/0x8afe8cf12c38c08804ffb069103fdb79c6c19b25)
PlayersImplQueueActions [0xa5b2aa30940b816ef89389e6931673df740d46dd](https://ftmscan.com/address/0xa5b2aa30940b816ef89389e6931673df740d46dd)
PlayersImplProcessActions [0x9c3664e0a1fc99ccf02b947cf359ebdbcc0d6d71](https://ftmscan.com/address/0x9c3664e0a1fc99ccf02b947cf359ebdbcc0d6d71)
PlayersImplRewards [0x73c5e18298b12ea447cb68d5778ccbda0b82ce80](https://ftmscan.com/address/0x73c5e18298b12ea447cb68d5778ccbda0b82ce80)
PlayersImplMisc [0x7cefddce7e5bbf9b5d95a91fdad2e877d960d5bc](https://ftmscan.com/address/0x7cefddce7e5bbf9b5d95a91fdad2e877d960d5bc)
PlayersImplMisc1 [0x56a7ba849f9f7c0ddfe577c8efb2207df9356a3a](https://ftmscan.com/address/0x56a7ba849f9f7c0ddfe577c8efb2207df9356a3a)
Players [0x0aac9c0966ad5ea59cd0a47a0d415a68126ab7be](https://ftmscan.com/address/0x0aac9c0966ad5ea59cd0a47a0d415a68126ab7be)

BankRegistry [0xd5da02cee3d9ef0d63d1b79c659df16770c3c4e0](https://ftmscan.com/address/0xd5da02cee3d9ef0d63d1b79c659df16770c3c4e0)
Expand Down
59 changes: 26 additions & 33 deletions contracts/Players/PlayersImplRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -824,19 +824,12 @@ contract PlayersImplRewards is PlayersImplBase, PlayersBase, IPlayersRewardsDele

// TODO: Remove everything related to this later
// boostType was removed and shifted everything up in the PendingRandomReward struct
bool isLegacyPendingRandomReward = pendingRandomReward.boostItemTokenId != 0 &&
bool isLegacyWithBoostPendingRandomReward = pendingRandomReward.boostItemTokenId != 0 &&
pendingRandomReward.boostItemTokenId < 10;
uint numTickets = isCombat ? monstersKilled : pendingRandomReward.xpElapsedTime / 3600;

uint elapsedTime = isLegacyPendingRandomReward
? pendingRandomReward.xpElapsedTime
: pendingRandomReward.elapsedTime;
uint40 sentinelElapsedTime = isLegacyPendingRandomReward
? pendingRandomReward.xpElapsedTime
: pendingRandomReward.sentinelElapsedTime;
uint8 fullAttireBonusRewardsPercent = isLegacyPendingRandomReward
? 0
: pendingRandomReward.fullAttireBonusRewardsPercent;
uint40 sentinelElapsedTime = pendingRandomReward.sentinelElapsedTime;
uint8 fullAttireBonusRewardsPercent = pendingRandomReward.fullAttireBonusRewardsPercent;

uint[] memory randomIds;
uint[] memory randomAmounts;
Expand All @@ -854,33 +847,33 @@ contract PlayersImplRewards is PlayersImplBase, PlayersBase, IPlayersRewardsDele
}

if (randomIds.length != 0) {
// Check for boosts
if (!isLegacyPendingRandomReward) {
if (pendingRandomReward.boostItemTokenId != NONE) {
(BoostType boostType, uint16 boostValue, uint24 boostDuration) = itemNFT.getBoostInfo(
pendingRandomReward.boostItemTokenId
if (!isLegacyWithBoostPendingRandomReward && pendingRandomReward.boostItemTokenId != NONE) {
// Check for boosts
(BoostType boostType, uint16 boostValue, uint24 boostDuration) = itemNFT.getBoostInfo(
pendingRandomReward.boostItemTokenId
);
if (boostType == BoostType.GATHERING) {
uint elapsedTime = pendingRandomReward.elapsedTime;

uint boostedTime = PlayersLibrary.getBoostedTime(
pendingRandomReward.startTime,
elapsedTime,
pendingRandomReward.boostStartTime,
boostDuration
);
if (boostType == BoostType.GATHERING) {
uint boostedTime = PlayersLibrary.getBoostedTime(
pendingRandomReward.startTime,
elapsedTime,
pendingRandomReward.boostStartTime,
boostDuration
);

_addGatheringBoostedAmounts(boostedTime, randomAmounts, boostValue, elapsedTime);
}
}

// Copy into main arrays
uint oldLength = length;
for (uint j = 0; j < randomIds.length; ++j) {
ids[j + oldLength] = randomIds[j];
amounts[j + oldLength] = randomAmounts[j];
queueIds[j + oldLength] = pendingRandomReward.queueId;
++length;
_addGatheringBoostedAmounts(boostedTime, randomAmounts, boostValue, elapsedTime);
}
}

// Copy into main arrays
uint oldLength = length;
for (uint j = 0; j < randomIds.length; ++j) {
ids[j + oldLength] = randomIds[j];
amounts[j + oldLength] = randomAmounts[j];
queueIds[j + oldLength] = pendingRandomReward.queueId;
++length;
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions scripts/contractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ if (isBeta) {
quests = "0x96948a6df3a64cc2eb0a1825fccd26f0c93bfce9";
clans = "0xd35410f526db135f09bb8e2bb066c8a63135d812";
bank = "0x73d1b1420deaeb6474b8aafb1d8229d392d1a04e";
playersLibrary = "0xf0bbe8fdfb1362aad6cfbdaf2d36a2c642c80494";
playersImplQueueActions = "0xa0422ef9228f33a09da374029f6340013d9bcbd3";
playersImplProcessActions = "0xee860b09f52e3d30923ab5f55d471b139e87378a";
playersImplRewards = "0xb773bdf7ebd45589760fac3c70e03e05bc4cbe5c";
playersImplMisc = "0xe0c8a7f7e2c94862d6ff83fef602e84df05326bc";
playersImplMisc1 = "0xa5f7a758d2da1dee298e8e6e63c266b8ee3357db";
playersLibrary = "0x8afe8cf12c38c08804ffb069103fdb79c6c19b25";
playersImplQueueActions = "0xa5b2aa30940b816ef89389e6931673df740d46dd";
playersImplProcessActions = "0x9c3664e0a1fc99ccf02b947cf359ebdbcc0d6d71";
playersImplRewards = "0x73c5e18298b12ea447cb68d5778ccbda0b82ce80";
playersImplMisc = "0x7cefddce7e5bbf9b5d95a91fdad2e877d960d5bc";
playersImplMisc1 = "0x56a7ba849f9f7c0ddfe577c8efb2207df9356a3a";
players = "0x0aac9c0966ad5ea59cd0a47a0d415a68126ab7be";
bankRegistry = "0xd5da02cee3d9ef0d63d1b79c659df16770c3c4e0";
bankProxy = "0xe1998e9bad94716ecf81f3a3bead5fed3fb023cb";
Expand Down

0 comments on commit 509606a

Please sign in to comment.