Skip to content

Commit

Permalink
Add halloween 2024 event
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSamWitch committed Oct 19, 2024
1 parent d00f3f6 commit e23f618
Show file tree
Hide file tree
Showing 31 changed files with 2,773 additions and 111 deletions.
1,072 changes: 1,072 additions & 0 deletions .openzeppelin/unknown-250-beta.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Territories [0xf31517db9f0987002f3a0fb4f787dfb9e892f184](https://ftmscan.com/add
CombatantsHelper [0xe8231ac805a88b3c72e9602c2ae14a5d3421bc7c](https://ftmscan.com/address/0xe8231ac805a88b3c72e9602c2ae14a5d3421bc7c)
DecoratorProvider [0xea8c4d188eb8d9704bc36931d89ba4f8e935cee2](https://ftmscan.com/address/0xea8c4d188eb8d9704bc36931d89ba4f8e935cee2)

PetNFTLibrary [0x04a11e4afd667ca55b10d834a7367c4bed107750](https://ftmscan.com/address/0x04a11e4afd667ca55b10d834a7367c4bed107750)
PetNFTLibrary [0x1445660336c1b0bcb2b484e86a56297f1da6575d](https://ftmscan.com/address/0x1445660336c1b0bcb2b484e86a56297f1da6575d)
PetNFT [0xa6489181b24e966402891225c65f8e2d136ddd2e](https://ftmscan.com/address/0xa6489181b24e966402891225c65f8e2d136ddd2e)
PassiveActions [0x3df5b6cad0d2de6b71f2d5084e0b933dbcd395f6](https://ftmscan.com/address/0x3df5b6cad0d2de6b71f2d5084e0b933dbcd395f6)

Expand Down
3 changes: 3 additions & 0 deletions contracts/PetNFTLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ library PetNFTLibrary {
if (_skin == PetSkin.ANNIV1) {
return "Anniv1";
}
if (_skin == PetSkin.KRAGSTYR) {
return "Kragstyr";
}
revert InvalidSkin(_skin);
}

Expand Down
29 changes: 24 additions & 5 deletions contracts/Promotions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,16 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
PromotionInfo memory promotionInfo = activePromotions[_promotion];
promotionMintStatus = _checkMintPromotion(_playerId, _promotion, _timestamp);
if (promotionMintStatus == PromotionMintStatus.SUCCESS) {
// TODO: Support itemTokenIds later
// TODO: Support more than 1 numDailyRandomItemsToPick later
itemTokenIds = new uint[](promotionInfo.numDailyRandomItemsToPick + promotionInfo.guaranteedItemTokenIds.length);
amounts = new uint[](promotionInfo.numDailyRandomItemsToPick + promotionInfo.guaranteedItemTokenIds.length);

// First add the guaranteed items
for (uint i; i < promotionInfo.guaranteedItemTokenIds.length; ++i) {
itemTokenIds[i] = promotionInfo.guaranteedItemTokenIds[i];
amounts[i] = promotionInfo.guaranteedAmounts[i];
}

// Pick a random item from the list, only supports 1 item atm
uint numAvailableItems = promotionInfo.randomItemTokenIds.length;
World world = itemNFT.world();
Expand All @@ -518,8 +524,10 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
uint randomWord = itemNFT.world().getRandomWord(oracleTime);
uint modifiedRandomWord = uint(keccak256(abi.encodePacked(randomWord, _playerId)));
uint index = modifiedRandomWord % numAvailableItems;
itemTokenIds[0] = promotionInfo.randomItemTokenIds[index];
amounts[0] = promotionInfo.randomAmounts[index];

uint startIndex = promotionInfo.guaranteedItemTokenIds.length; // Guaranteed items are in front
itemTokenIds[startIndex] = promotionInfo.randomItemTokenIds[index];
amounts[startIndex] = promotionInfo.randomAmounts[index];
}
}
}
Expand All @@ -545,16 +553,27 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
itemTokenIds = new uint[](promotionInfo.numDailyRandomItemsToPick + promotionInfo.guaranteedItemTokenIds.length);
amounts = new uint[](promotionInfo.numDailyRandomItemsToPick + promotionInfo.guaranteedItemTokenIds.length);

// First add the guaranteed items
for (uint i; i < promotionInfo.guaranteedItemTokenIds.length; ++i) {
itemTokenIds[i] = promotionInfo.guaranteedItemTokenIds[i];
amounts[i] = promotionInfo.guaranteedAmounts[i];
}

promotionMintStatus = _checkMultidayDailyMintPromotion(_playerId, _promotion, _timestamp);
if (promotionMintStatus == PromotionMintStatus.SUCCESS) {
if (promotionInfo.randomItemTokenIds.length == 0) {
// TODO: Update this on Sonic branch with better flags. Currently only supports tiered rewards
if (promotionInfo.guaranteedItemTokenIds.length == 0 && promotionInfo.randomItemTokenIds.length == 0) {
// Currently assumes tiered rewards
uint oracleTime = ((promotionInfo.startTime / 1 days + today) * 1 days) - 1;
(itemTokenIds[0], amounts[0], promotionMintStatus) = _getTierReward(
uint startIndex = promotionInfo.guaranteedItemTokenIds.length; // Guaranteed items are in front
(itemTokenIds[startIndex], amounts[startIndex], promotionMintStatus) = _getTierReward(
_playerId,
world,
oracleTime,
promotionMintStatus
);
} else if (promotionInfo.guaranteedItemTokenIds.length != 0) {
// TODO: Just temporary until the migration with better types to determine what rewards are given
} else {
// Not supported yet
assert(false);
Expand Down
3 changes: 2 additions & 1 deletion contracts/globals/pets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ enum PetSkin {
ONEKIN,
FROST,
CRYSTAL,
ANNIV1
ANNIV1,
KRAGSTYR
}

enum PetEnhancementType {
Expand Down
5 changes: 3 additions & 2 deletions contracts/globals/promotions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ enum Promotion {
STARTER,
HALLOWEEN_2023,
XMAS_2023,
HOLIDAY3, // Just have placeholders for now
HOLIDAY4,
HALLOWEEN_2024,
HOLIDAY4, // Just have placeholders for now
HOLIDAY5,
HOLIDAY6,
HOLIDAY7,
Expand Down Expand Up @@ -83,6 +83,7 @@ struct PromotionInfo {
uint8 numDaysClaimablePeriodStreakBonus; // If there is a streak bonus, how many days to claim it after the promotion ends. If no final day bonus, set to 0
uint8 numRandomStreakBonusItemsToPick1; // Number of items to pick for the streak bonus
uint8 numRandomStreakBonusItemsToPick2; // Number of random items to pick for the streak bonus
// Misc
uint16[] randomStreakBonusItemTokenIds1;
uint32[] randomStreakBonusAmounts1;
uint16[] randomStreakBonusItemTokenIds2; // Not used yet
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@openzeppelin/contracts": "^4.8.2",
"@openzeppelin/contracts-upgradeable": "^4.8.2",
"@openzeppelin/hardhat-upgrades": "^1.22.1",
"@paintswap/estfor-definitions": "^1.0.228",
"@paintswap/estfor-definitions": "^1.0.236",
"@solidity-parser/parser": "^0.18.0",
"@typechain/ethers-v5": "^10.2.0",
"@typechain/hardhat": "^6.1.5",
Expand Down
5 changes: 4 additions & 1 deletion scripts/addActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ async function main() {

const world = (await ethers.getContractAt("World", WORLD_ADDRESS)).connect(owner) as World;

const actionIds = new Set([EstforConstants.ACTION_COMBAT_NIGHTMARE_NATUOW]);
const actionIds = new Set([
EstforConstants.ACTION_COMBAT_NIGHTMARE_GROG_TOAD,
EstforConstants.ACTION_COMBAT_NIGHTMARE_UFFINCH,
]);
const actions = allActions.filter((action) => actionIds.has(action.actionId));

if (actions.length !== actionIds.size) {
Expand Down
81 changes: 40 additions & 41 deletions scripts/addBasePets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,47 @@ async function main() {
console.log(`Add base pets using account: ${owner.address} on chain id ${await owner.getChainId()}`);

const petNFT = (await ethers.getContractAt("PetNFT", PET_NFT_ADDRESS)).connect(owner);

const basePetIds = new Set([
EstforConstants.PET_ANNIV1_MELEE_TIER1,
EstforConstants.PET_ANNIV1_MELEE_TIER2,
EstforConstants.PET_ANNIV1_MELEE_TIER3,
EstforConstants.PET_ANNIV1_MELEE_TIER4,
EstforConstants.PET_ANNIV1_MELEE_TIER5,
EstforConstants.PET_ANNIV1_MAGIC_TIER1,
EstforConstants.PET_ANNIV1_MAGIC_TIER2,
EstforConstants.PET_ANNIV1_MAGIC_TIER3,
EstforConstants.PET_ANNIV1_MAGIC_TIER4,
EstforConstants.PET_ANNIV1_MAGIC_TIER5,
EstforConstants.PET_ANNIV1_RANGED_TIER1,
EstforConstants.PET_ANNIV1_RANGED_TIER2,
EstforConstants.PET_ANNIV1_RANGED_TIER3,
EstforConstants.PET_ANNIV1_RANGED_TIER4,
EstforConstants.PET_ANNIV1_RANGED_TIER5,
EstforConstants.PET_ANNIV1_DEFENCE_TIER1,
EstforConstants.PET_ANNIV1_DEFENCE_TIER2,
EstforConstants.PET_ANNIV1_DEFENCE_TIER3,
EstforConstants.PET_ANNIV1_DEFENCE_TIER4,
EstforConstants.PET_ANNIV1_DEFENCE_TIER5,
EstforConstants.PET_ANNIV1_HEALTH_TIER1,
EstforConstants.PET_ANNIV1_HEALTH_TIER2,
EstforConstants.PET_ANNIV1_HEALTH_TIER3,
EstforConstants.PET_ANNIV1_HEALTH_TIER4,
EstforConstants.PET_ANNIV1_HEALTH_TIER5,
EstforConstants.PET_ANNIV1_MELEE_AND_DEFENCE_TIER1,
EstforConstants.PET_ANNIV1_MELEE_AND_DEFENCE_TIER2,
EstforConstants.PET_ANNIV1_MELEE_AND_DEFENCE_TIER3,
EstforConstants.PET_ANNIV1_MELEE_AND_DEFENCE_TIER4,
EstforConstants.PET_ANNIV1_MELEE_AND_DEFENCE_TIER5,
EstforConstants.PET_ANNIV1_MAGIC_AND_DEFENCE_TIER1,
EstforConstants.PET_ANNIV1_MAGIC_AND_DEFENCE_TIER2,
EstforConstants.PET_ANNIV1_MAGIC_AND_DEFENCE_TIER3,
EstforConstants.PET_ANNIV1_MAGIC_AND_DEFENCE_TIER4,
EstforConstants.PET_ANNIV1_MAGIC_AND_DEFENCE_TIER5,
EstforConstants.PET_ANNIV1_RANGED_AND_DEFENCE_TIER1,
EstforConstants.PET_ANNIV1_RANGED_AND_DEFENCE_TIER2,
EstforConstants.PET_ANNIV1_RANGED_AND_DEFENCE_TIER3,
EstforConstants.PET_ANNIV1_RANGED_AND_DEFENCE_TIER4,
EstforConstants.PET_ANNIV1_RANGED_AND_DEFENCE_TIER5,
EstforConstants.PET_KRAGSTYR_MELEE_TIER1,
EstforConstants.PET_KRAGSTYR_MELEE_TIER2,
EstforConstants.PET_KRAGSTYR_MELEE_TIER3,
EstforConstants.PET_KRAGSTYR_MELEE_TIER4,
EstforConstants.PET_KRAGSTYR_MELEE_TIER5,
EstforConstants.PET_KRAGSTYR_MAGIC_TIER1,
EstforConstants.PET_KRAGSTYR_MAGIC_TIER2,
EstforConstants.PET_KRAGSTYR_MAGIC_TIER3,
EstforConstants.PET_KRAGSTYR_MAGIC_TIER4,
EstforConstants.PET_KRAGSTYR_MAGIC_TIER5,
EstforConstants.PET_KRAGSTYR_RANGED_TIER1,
EstforConstants.PET_KRAGSTYR_RANGED_TIER2,
EstforConstants.PET_KRAGSTYR_RANGED_TIER3,
EstforConstants.PET_KRAGSTYR_RANGED_TIER4,
EstforConstants.PET_KRAGSTYR_RANGED_TIER5,
EstforConstants.PET_KRAGSTYR_DEFENCE_TIER1,
EstforConstants.PET_KRAGSTYR_DEFENCE_TIER2,
EstforConstants.PET_KRAGSTYR_DEFENCE_TIER3,
EstforConstants.PET_KRAGSTYR_DEFENCE_TIER4,
EstforConstants.PET_KRAGSTYR_DEFENCE_TIER5,
EstforConstants.PET_KRAGSTYR_HEALTH_TIER1,
EstforConstants.PET_KRAGSTYR_HEALTH_TIER2,
EstforConstants.PET_KRAGSTYR_HEALTH_TIER3,
EstforConstants.PET_KRAGSTYR_HEALTH_TIER4,
EstforConstants.PET_KRAGSTYR_HEALTH_TIER5,
EstforConstants.PET_KRAGSTYR_MELEE_AND_DEFENCE_TIER1,
EstforConstants.PET_KRAGSTYR_MELEE_AND_DEFENCE_TIER2,
EstforConstants.PET_KRAGSTYR_MELEE_AND_DEFENCE_TIER3,
EstforConstants.PET_KRAGSTYR_MELEE_AND_DEFENCE_TIER4,
EstforConstants.PET_KRAGSTYR_MELEE_AND_DEFENCE_TIER5,
EstforConstants.PET_KRAGSTYR_MAGIC_AND_DEFENCE_TIER1,
EstforConstants.PET_KRAGSTYR_MAGIC_AND_DEFENCE_TIER2,
EstforConstants.PET_KRAGSTYR_MAGIC_AND_DEFENCE_TIER3,
EstforConstants.PET_KRAGSTYR_MAGIC_AND_DEFENCE_TIER4,
EstforConstants.PET_KRAGSTYR_MAGIC_AND_DEFENCE_TIER5,
EstforConstants.PET_KRAGSTYR_RANGED_AND_DEFENCE_TIER1,
EstforConstants.PET_KRAGSTYR_RANGED_AND_DEFENCE_TIER2,
EstforConstants.PET_KRAGSTYR_RANGED_AND_DEFENCE_TIER3,
EstforConstants.PET_KRAGSTYR_RANGED_AND_DEFENCE_TIER4,
EstforConstants.PET_KRAGSTYR_RANGED_AND_DEFENCE_TIER5,
]);

const basePets = allBasePets.filter((basePet) => basePetIds.has(basePet.baseId));
Expand Down
12 changes: 8 additions & 4 deletions scripts/addInstantActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ async function main() {
const instantActions = (await ethers.getContractAt("InstantActions", INSTANT_ACTIONS_ADDRESS)).connect(owner);

const actionIds = new Set([
EstforConstants.INSTANT_ACTION_FORGING_ANNIV1_EGG_TIER1,
EstforConstants.INSTANT_ACTION_FORGING_ANNIV1_RING,
EstforConstants.INSTANT_ACTION_FORGING_ANNIV1_KEY,
EstforConstants.INSTANT_ACTION_FORGING_ANNIV1_CHEST,
EstforConstants.INSTANT_ACTION_FORGING_LIFFYN,
EstforConstants.INSTANT_ACTION_FORGING_VANAGLOT,
EstforConstants.INSTANT_ACTION_FORGING_FANGENSTORM,
EstforConstants.INSTANT_ACTION_FORGING_RING,
EstforConstants.INSTANT_ACTION_FORGING_AMULET,
EstforConstants.INSTANT_ACTION_FORGING_TRICK_CHEST,
EstforConstants.INSTANT_ACTION_FORGING_TREAT_CHEST,
EstforConstants.INSTANT_ACTION_FORGING_TRICK_OR_TREAT_KEY,
]);

const actions = allInstantActions.filter((action) => {
Expand Down
17 changes: 9 additions & 8 deletions scripts/addInstantVRFActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ethers, upgrades} from "hardhat";
import {GENERIC_INSTANT_VRF_ACTION_STRATEGY_ADDRESS, INSTANT_VRF_ACTIONS_ADDRESS} from "./contractAddresses";
import {ethers} from "hardhat";
import {INSTANT_VRF_ACTIONS_ADDRESS} from "./contractAddresses";
import {EstforConstants} from "@paintswap/estfor-definitions";
import {allInstantVRFActions} from "./data/instantVRFActions";
import {InstantVRFActions} from "../typechain-types";
Expand All @@ -13,12 +13,13 @@ async function main() {
) as InstantVRFActions;

const actionsToUpdate = new Set([
EstforConstants.INSTANT_VRF_ACTION_THIEVING_ANNIV1_CHEST,
EstforConstants.INSTANT_VRF_ACTION_ANNIV1_EGG_TIER1,
EstforConstants.INSTANT_VRF_ACTION_ANNIV1_EGG_TIER2,
EstforConstants.INSTANT_VRF_ACTION_ANNIV1_EGG_TIER3,
EstforConstants.INSTANT_VRF_ACTION_ANNIV1_EGG_TIER4,
EstforConstants.INSTANT_VRF_ACTION_ANNIV1_EGG_TIER5,
EstforConstants.INSTANT_VRF_ACTION_THIEVING_TRICK_CHEST,
EstforConstants.INSTANT_VRF_ACTION_THIEVING_TREAT_CHEST,
EstforConstants.INSTANT_VRF_ACTION_KRAGSTYR_EGG_TIER1,
EstforConstants.INSTANT_VRF_ACTION_KRAGSTYR_EGG_TIER2,
EstforConstants.INSTANT_VRF_ACTION_KRAGSTYR_EGG_TIER3,
EstforConstants.INSTANT_VRF_ACTION_KRAGSTYR_EGG_TIER4,
EstforConstants.INSTANT_VRF_ACTION_KRAGSTYR_EGG_TIER5,
]);

const actions = allInstantVRFActions.filter((action) => actionsToUpdate.has(action.actionId));
Expand Down
21 changes: 13 additions & 8 deletions scripts/addItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ async function main() {
const itemNFT = await ethers.getContractAt("ItemNFT", ITEM_NFT_ADDRESS);

const itemIds = new Set([
EstforConstants.ANNIV1_CHEST,
EstforConstants.ANNIV1_RING,
EstforConstants.ANNIV1_EGG_TIER1,
EstforConstants.ANNIV1_EGG_TIER2,
EstforConstants.ANNIV1_EGG_TIER3,
EstforConstants.ANNIV1_EGG_TIER4,
EstforConstants.ANNIV1_EGG_TIER5,
EstforConstants.ANNIV1_KEY,
EstforConstants.KRAGSTYR_EGG_TIER1,
EstforConstants.KRAGSTYR_EGG_TIER2,
EstforConstants.KRAGSTYR_EGG_TIER3,
EstforConstants.KRAGSTYR_EGG_TIER4,
EstforConstants.KRAGSTYR_EGG_TIER5,
EstforConstants.TRICK_CHEST2024,
EstforConstants.TREAT_CHEST2024,
EstforConstants.TRICK_OR_TREAT_KEY,
EstforConstants.RING_OF_TUR,
EstforConstants.KEPHRI_AMULET,
EstforConstants.LIFFYN,
EstforConstants.VANAGLOT,
EstforConstants.FANGENSTORM,
]);

const items = allItems.filter((item) => itemIds.has(item.tokenId));
Expand Down
9 changes: 5 additions & 4 deletions scripts/addPassiveActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ async function main() {
) as PassiveActions;

const actionsToReduce = [
EstforConstants.PASSIVE_ACTION_ANNIV1_EGG_TIER2,
EstforConstants.PASSIVE_ACTION_ANNIV1_EGG_TIER3,
EstforConstants.PASSIVE_ACTION_ANNIV1_EGG_TIER4,
EstforConstants.PASSIVE_ACTION_ANNIV1_EGG_TIER5,
EstforConstants.PASSIVE_ACTION_KRAGSTYR_EGG_TIER1,
EstforConstants.PASSIVE_ACTION_KRAGSTYR_EGG_TIER2,
EstforConstants.PASSIVE_ACTION_KRAGSTYR_EGG_TIER3,
EstforConstants.PASSIVE_ACTION_KRAGSTYR_EGG_TIER4,
EstforConstants.PASSIVE_ACTION_KRAGSTYR_EGG_TIER5,
];

const values = [0, 0, 0, 0];
Expand Down
35 changes: 35 additions & 0 deletions scripts/addPromotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async function main() {
amounts: [1, 1, 1],
}); */

/*
const startTime = 1701417600; // Fri dec 1st 08:00 UTC
const numDays = 22;
await promotions.connect(owner).addPromotion({
Expand Down Expand Up @@ -69,6 +70,40 @@ async function main() {
randomItemTokenIds: [],
randomAmounts: [],
});
*/

const startTime = 1729756800; // Thur Oct 24th 08:00 UTC
const numDays = 14;
await promotions.connect(owner).addPromotion({
promotion: Promotion.HALLOWEEN_2024,
startTime,
endTime: startTime + 24 * 3600 * numDays,
minTotalXP: 0,
numDailyRandomItemsToPick: 1,
isMultiday: true,
brushCostMissedDay: "0",
brushCost: "0",
redeemCodeLength: 0,
adminOnly: false,
promotionTiedToUser: false,
promotionTiedToPlayer: true,
promotionMustOwnPlayer: true,
evolvedHeroOnly: true,
numDaysClaimablePeriodStreakBonus: 0,
numDaysHitNeededForStreakBonus: 0,
numRandomStreakBonusItemsToPick1: 0,
numRandomStreakBonusItemsToPick2: 0,
randomStreakBonusItemTokenIds1: [],
randomStreakBonusAmounts1: [],
randomStreakBonusItemTokenIds2: [],
randomStreakBonusAmounts2: [],
guaranteedStreakBonusItemTokenIds: [],
guaranteedStreakBonusAmounts: [],
guaranteedItemTokenIds: [EstforConstants.COIN],
guaranteedAmounts: [5],
randomItemTokenIds: [],
randomAmounts: [],
});
}

main().catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/contractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if (!isBeta) {
oracle = "0x6f7911cbbd4b5a1d2bdaa817a76056e510d728e7";
samWitchVRF = "0x58E9fd2Fae18c861B9F564200510A88106C05756";
bazaar = "0x082480aAAF1ac5bb0Db2c241eF8b4230Da85E191";
petNFTLibrary = "0x04a11e4afd667ca55b10d834a7367c4bed107750";
petNFTLibrary = "0x1445660336c1b0bcb2b484e86a56297f1da6575d";
petNFT = "0xa6489181b24e966402891225c65f8e2d136ddd2e";
passiveActions = "0x3df5b6cad0d2de6b71f2d5084e0b933dbcd395f6";
}
Expand Down
Loading

0 comments on commit e23f618

Please sign in to comment.