diff --git a/contracts/DFTypes.sol b/contracts/DFTypes.sol index 03fe3d2..cb62476 100644 --- a/contracts/DFTypes.sol +++ b/contracts/DFTypes.sol @@ -279,6 +279,33 @@ struct Modifiers { uint256 barbarianPercentage; } +struct ArtifactTypePrices { + uint256 Monolith; + uint256 Colossus; + uint256 Pyramid; + uint256 Wormhole; + uint256 PlanetaryShield; + uint256 PhotoidCannon; + uint256 BloomFilter; + uint256 BlackDomain; +} + +struct ArtifactRarityPrices { + uint256 Common; + uint256 Rare; + uint256 Epic; + uint256 Legendary; + uint256 Mythic; +} + +struct SpaceshipPrices { + uint256 ShipMothership; + uint256 ShipCrescent; + uint256 ShipWhale; + uint256 ShipGear; + uint256 ShipTitan; +} + enum Mod { popCap, popGrowth, @@ -390,6 +417,9 @@ struct InitArgs { bool TEAMS_ENABLED; uint256 NUM_TEAMS; bool RANKED; + ArtifactTypePrices ARTIFACT_TYPE_PRICES; + ArtifactRarityPrices ARTIFACT_RARITY_PRICES; + SpaceshipPrices SPACESHIP_PRICES; } // Values that are useful but not constant across arenas (whitelisted players, which planet goes to which team) diff --git a/contracts/facets/DFArtifactFacet.sol b/contracts/facets/DFArtifactFacet.sol index 9cb5ebb..2f71e70 100644 --- a/contracts/facets/DFArtifactFacet.sol +++ b/contracts/facets/DFArtifactFacet.sol @@ -64,6 +64,12 @@ contract DFArtifactFacet is WithStorage, ERC721 { _; } + function mintArtifact(Artifact memory args) private { + require(args.id >= 1, "artifact id must be positive"); + + _mint(args.discoverer, args.id); + } + function createArtifact(DFTCreateArtifactArgs memory args) public onlyAdminOrCore diff --git a/contracts/facets/DFShopFacet.sol b/contracts/facets/DFShopFacet.sol new file mode 100644 index 0000000..47507a9 --- /dev/null +++ b/contracts/facets/DFShopFacet.sol @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.0; + +// Storage imports +import {WithStorage} from "../libraries/LibStorage.sol"; +import {WithArenaStorage} from "../libraries/LibArenaStorage.sol"; +import {LibArtifactUtils} from "../libraries/LibArtifactUtils.sol"; + +// External contract imports +import {DFArtifactFacet} from "./DFArtifactFacet.sol"; + +// Type imports +import {Player, Artifact, ArtifactRarity, ArtifactType, Biome, DFTCreateArtifactArgs, DFPFindArtifactArgs} from "../DFTypes.sol"; + +contract DFShopFacet is WithStorage, WithArenaStorage { + event ArtifactPurchased(address buyer, uint256 tokenId, uint256 planetId); + event SpaceshipPurchased(address buyer, uint256 tokenId, uint256 planetId); + + function purchaseArtifact( + ArtifactType artifactType, + ArtifactRarity rarity, + uint256 locationId + ) public { + Player storage player = gs().players[msg.sender]; + + Artifact memory artifact = DFArtifactFacet(address(this)).createArtifact( + DFTCreateArtifactArgs({ + tokenId: gs().miscNonce++, + discoverer: msg.sender, + planetId: locationId, + rarity: rarity, + biome: Biome.Ocean, + artifactType: artifactType, + owner: msg.sender, + // Only used for spaceships + controller: address(0) + }) + ); + + require( + !LibArtifactUtils.isSpaceship(artifactType) && + !LibArtifactUtils.isCube(artifact), + "cannot create artifact of this type" + ); + + uint256 price = getArtifactPrice(artifactType,rarity); + require(player.score >= price, "not enough silver to purchase"); + + gs().artifacts[artifact.id] = artifact; + + player.score -= price; + + emit ArtifactPurchased(msg.sender, artifact.id, locationId); + } + + function purchaseSpaceship(ArtifactType artifactType, uint256 planetId) public { + bool isSpaceship = LibArtifactUtils.isSpaceship(artifactType); + Player storage player = gs().players[msg.sender]; + + require(isSpaceship, "is not a spaceeship"); + + uint256 price = getSpaceshipPrice(artifactType); + require(player.score >= price, "not enough silver to buy spaceship"); + uint256 spaceshipId = LibArtifactUtils.createAndPlaceSpaceship( + planetId, + msg.sender, + artifactType + ); + player.score -= price; + emit SpaceshipPurchased(msg.sender, spaceshipId, planetId); + } + + function getArtifactPrice(ArtifactType artifactType, ArtifactRarity rarity) + public + view + returns (uint256) + { + uint256 typePrice = 0; + if (artifactType == ArtifactType.Monolith) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.Monolith; + } else if (artifactType == ArtifactType.Colossus) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.Colossus; + } else if (artifactType == ArtifactType.Pyramid) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.Pyramid; + } else if (artifactType == ArtifactType.Wormhole) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.Wormhole; + } else if (artifactType == ArtifactType.PlanetaryShield) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.PlanetaryShield; + } else if (artifactType == ArtifactType.PhotoidCannon) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.PhotoidCannon; + } else if (artifactType == ArtifactType.BloomFilter) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.BloomFilter; + } else if (artifactType == ArtifactType.BlackDomain) { + typePrice = arenaConstants().ARTIFACT_TYPE_PRICES.BlackDomain; + } + + uint256 rarityPrice = 0; + if (rarity == ArtifactRarity.Common) { + rarityPrice = arenaConstants().ARTIFACT_RARITY_PRICES.Common; + } else if (rarity == ArtifactRarity.Rare) { + rarityPrice = arenaConstants().ARTIFACT_RARITY_PRICES.Rare; + } else if (rarity == ArtifactRarity.Epic) { + rarityPrice = arenaConstants().ARTIFACT_RARITY_PRICES.Epic; + } else if (rarity == ArtifactRarity.Legendary) { + rarityPrice = arenaConstants().ARTIFACT_RARITY_PRICES.Legendary; + } else if (rarity == ArtifactRarity.Mythic) { + rarityPrice = arenaConstants().ARTIFACT_RARITY_PRICES.Mythic; + } + + return typePrice * rarityPrice; + } + + function getSpaceshipPrice(ArtifactType spaceship) public view returns (uint256) { + if (spaceship == ArtifactType.ShipMothership) { + return arenaConstants().SPACESHIP_PRICES.ShipMothership; + } else if (spaceship == ArtifactType.ShipCrescent) { + return arenaConstants().SPACESHIP_PRICES.ShipCrescent; + } else if (spaceship == ArtifactType.ShipWhale) { + return arenaConstants().SPACESHIP_PRICES.ShipWhale; + } else if (spaceship == ArtifactType.ShipGear) { + return arenaConstants().SPACESHIP_PRICES.ShipGear; + } else if (spaceship == ArtifactType.ShipTitan) { + return arenaConstants().SPACESHIP_PRICES.ShipTitan; + } + return 0; + } +} diff --git a/contracts/facets/DFStartFacet.sol b/contracts/facets/DFStartFacet.sol index f69384d..70fc67d 100644 --- a/contracts/facets/DFStartFacet.sol +++ b/contracts/facets/DFStartFacet.sol @@ -26,441 +26,402 @@ import {DFWhitelistFacet} from "./DFWhitelistFacet.sol"; import {PlanetDefaultStats, Upgrade, UpgradeBranch, Modifiers, Mod, ArenaCreateRevealPlanetArgs, Spaceships} from "../DFTypes.sol"; contract DFStartFacet is WithStorage, WithArenaStorage { - event ArenaInitialized(address ownerAddress, address lobbyAddress); - - function start() public { - gs().diamondAddress = address(this); - - ws().enabled = ai().auxArgs.allowListEnabled; - uint256 allowedAddressesLength = ai().auxArgs.allowedAddresses.length; - - if (ws().enabled && allowedAddressesLength > 0) { - // delegating call here because msg.sender must remain intact. - (bool success, bytes memory returndata) = (address(this)).delegatecall( - abi.encodeWithSignature( - "bulkAddToWhitelist(address[])", - ai().auxArgs.allowedAddresses - ) - ); - require(success, "whitelisting ownership did not succeed"); + event ArenaInitialized(address ownerAddress, address lobbyAddress); + + function start() public { + gs().diamondAddress = address(this); + + ws().enabled = ai().auxArgs.allowListEnabled; + uint256 allowedAddressesLength = ai().auxArgs.allowedAddresses.length; + + if (ws().enabled && allowedAddressesLength > 0) { + // delegating call here because msg.sender must remain intact. + (bool success, bytes memory returndata) = (address(this)).delegatecall( + abi.encodeWithSignature( + "bulkAddToWhitelist(address[])", + ai().auxArgs.allowedAddresses + ) + ); + require(success, "whitelisting ownership did not succeed"); + } + + ws().drip = 0.05 ether; + + gs().planetLevelsCount = 10; + gs().planetLevelThresholds = ai().initArgs.PLANET_LEVEL_THRESHOLDS; + + snarkConstants().DISABLE_ZK_CHECKS = ai().initArgs.DISABLE_ZK_CHECKS; + snarkConstants().PLANETHASH_KEY = ai().initArgs.PLANETHASH_KEY; + snarkConstants().SPACETYPE_KEY = ai().initArgs.SPACETYPE_KEY; + snarkConstants().BIOMEBASE_KEY = ai().initArgs.BIOMEBASE_KEY; + snarkConstants().PERLIN_MIRROR_X = ai().initArgs.PERLIN_MIRROR_X; + snarkConstants().PERLIN_MIRROR_Y = ai().initArgs.PERLIN_MIRROR_Y; + snarkConstants().PERLIN_LENGTH_SCALE = ai().initArgs.PERLIN_LENGTH_SCALE; + + gameConstants().PLANET_LEVEL_THRESHOLDS = ai().initArgs.PLANET_LEVEL_THRESHOLDS; + gameConstants().ADMIN_CAN_ADD_PLANETS = ai().initArgs.ADMIN_CAN_ADD_PLANETS; + gameConstants().WORLD_RADIUS_LOCKED = ai().initArgs.WORLD_RADIUS_LOCKED; + gameConstants().WORLD_RADIUS_MIN = ai().initArgs.WORLD_RADIUS_MIN; + gameConstants().MAX_NATURAL_PLANET_LEVEL = ai().initArgs.MAX_NATURAL_PLANET_LEVEL; + gameConstants().TIME_FACTOR_HUNDREDTHS = ai().initArgs.TIME_FACTOR_HUNDREDTHS; + gameConstants().PERLIN_THRESHOLD_1 = ai().initArgs.PERLIN_THRESHOLD_1; + gameConstants().PERLIN_THRESHOLD_2 = ai().initArgs.PERLIN_THRESHOLD_2; + gameConstants().PERLIN_THRESHOLD_3 = ai().initArgs.PERLIN_THRESHOLD_3; + gameConstants().INIT_PERLIN_MIN = ai().initArgs.INIT_PERLIN_MIN; + gameConstants().INIT_PERLIN_MAX = ai().initArgs.INIT_PERLIN_MAX; + gameConstants().SPAWN_RIM_AREA = ai().initArgs.SPAWN_RIM_AREA; + gameConstants().BIOME_THRESHOLD_1 = ai().initArgs.BIOME_THRESHOLD_1; + gameConstants().BIOME_THRESHOLD_2 = ai().initArgs.BIOME_THRESHOLD_2; + gameConstants().PLANET_RARITY = ai().initArgs.PLANET_RARITY; + gameConstants().PLANET_TRANSFER_ENABLED = ai().initArgs.PLANET_TRANSFER_ENABLED; + gameConstants().PHOTOID_ACTIVATION_DELAY = ai().initArgs.PHOTOID_ACTIVATION_DELAY; + gameConstants().LOCATION_REVEAL_COOLDOWN = ai().initArgs.LOCATION_REVEAL_COOLDOWN; + gameConstants().PLANET_TYPE_WEIGHTS = ai().initArgs.PLANET_TYPE_WEIGHTS; + gameConstants().SILVER_SCORE_VALUE = ai().initArgs.SILVER_SCORE_VALUE; + gameConstants().ARTIFACT_POINT_VALUES = ai().initArgs.ARTIFACT_POINT_VALUES; + // Space Junk + gameConstants().SPACE_JUNK_ENABLED = ai().initArgs.SPACE_JUNK_ENABLED; + gameConstants().SPACE_JUNK_LIMIT = ai().initArgs.SPACE_JUNK_LIMIT; + gameConstants().PLANET_LEVEL_JUNK = ai().initArgs.PLANET_LEVEL_JUNK; + gameConstants().ABANDON_SPEED_CHANGE_PERCENT = ai().initArgs.ABANDON_SPEED_CHANGE_PERCENT; + gameConstants().ABANDON_RANGE_CHANGE_PERCENT = ai().initArgs.ABANDON_RANGE_CHANGE_PERCENT; + // Capture Zones + gameConstants().GAME_START_BLOCK = block.number; + gameConstants().CAPTURE_ZONES_ENABLED = ai().initArgs.CAPTURE_ZONES_ENABLED; + gameConstants().CAPTURE_ZONE_COUNT = ai().initArgs.CAPTURE_ZONE_COUNT; + gameConstants().CAPTURE_ZONE_CHANGE_BLOCK_INTERVAL = ai() + .initArgs + .CAPTURE_ZONE_CHANGE_BLOCK_INTERVAL; + gameConstants().CAPTURE_ZONE_RADIUS = ai().initArgs.CAPTURE_ZONE_RADIUS; + gameConstants().CAPTURE_ZONE_PLANET_LEVEL_SCORE = ai() + .initArgs + .CAPTURE_ZONE_PLANET_LEVEL_SCORE; + gameConstants().CAPTURE_ZONE_HOLD_BLOCKS_REQUIRED = ai() + .initArgs + .CAPTURE_ZONE_HOLD_BLOCKS_REQUIRED; + gameConstants().CAPTURE_ZONES_PER_5000_WORLD_RADIUS = ai() + .initArgs + .CAPTURE_ZONES_PER_5000_WORLD_RADIUS; + + gs().nextChangeBlock = block.number + ai().initArgs.CAPTURE_ZONE_CHANGE_BLOCK_INTERVAL; + + gs().worldRadius = ai().initArgs.WORLD_RADIUS_MIN; // will be overridden by `LibGameUtils.updateWorldRadius()` if !WORLD_RADIUS_LOCKED + + gs().paused = ai().initArgs.START_PAUSED || ai().initArgs.CONFIRM_START; + + gs().TOKEN_MINT_END_TIMESTAMP = ai().initArgs.TOKEN_MINT_END_TIMESTAMP; + + gs().initializedPlanetCountByLevel = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + for (uint256 i = 0; i < gs().planetLevelThresholds.length; i += 1) { + gs().cumulativeRarities.push( + (2**24 / gs().planetLevelThresholds[i]) * ai().initArgs.PLANET_RARITY + ); + } + + //arenaMode initialization + arenaStorage().gameover = false; + arenaConstants().TARGET_PLANETS = ai().initArgs.TARGET_PLANETS; + arenaConstants().CLAIM_VICTORY_ENERGY_PERCENT = ai().initArgs.CLAIM_VICTORY_ENERGY_PERCENT; + arenaConstants().MANUAL_SPAWN = ai().initArgs.MANUAL_SPAWN; + arenaConstants().RANDOM_ARTIFACTS = ai().initArgs.RANDOM_ARTIFACTS; + + arenaConstants().MODIFIERS.popCap = ai().initArgs.MODIFIERS[uint256(Mod.popCap)]; + arenaConstants().MODIFIERS.popGrowth = ai().initArgs.MODIFIERS[uint256(Mod.popGrowth)]; + arenaConstants().MODIFIERS.silverCap = ai().initArgs.MODIFIERS[uint256(Mod.silverCap)]; + arenaConstants().MODIFIERS.silverGrowth = ai().initArgs.MODIFIERS[ + uint256(Mod.silverGrowth) + ]; + arenaConstants().MODIFIERS.range = ai().initArgs.MODIFIERS[uint256(Mod.range)]; + arenaConstants().MODIFIERS.speed = ai().initArgs.MODIFIERS[uint256(Mod.speed)]; + arenaConstants().MODIFIERS.defense = ai().initArgs.MODIFIERS[uint256(Mod.defense)]; + arenaConstants().MODIFIERS.barbarianPercentage = ai().initArgs.MODIFIERS[ + uint256(Mod.barbarianPercentage) + ]; + + arenaConstants().ARTIFACT_TYPE_PRICES = ai().initArgs.ARTIFACT_TYPE_PRICES; + arenaConstants().ARTIFACT_RARITY_PRICES = ai().initArgs.ARTIFACT_RARITY_PRICES; + arenaConstants().SPACESHIP_PRICES = ai().initArgs.SPACESHIP_PRICES; + + arenaConstants().SPACESHIPS = Spaceships( + ai().initArgs.SPACESHIPS[0], + ai().initArgs.SPACESHIPS[1], + ai().initArgs.SPACESHIPS[2], + ai().initArgs.SPACESHIPS[3], + ai().initArgs.SPACESHIPS[4] + ); + + arenaConstants().NO_ADMIN = ai().initArgs.NO_ADMIN; + arenaConstants().CONFIG_HASH = keccak256(abi.encode(ai().initArgs)); + arenaConstants().CONFIRM_START = ai().initArgs.CONFIRM_START; + arenaConstants().START_PAUSED = ai().initArgs.START_PAUSED; + + uint256 initLength = ai().initArgs.INIT_PLANETS.length; + + /* each planet costs about 50k gas */ + for (uint256 i = 0; i < initLength; i++) { + ArenaCreateRevealPlanetArgs memory initPlanet = ai().initArgs.INIT_PLANETS[i]; + + bytes32 initHash = LibGameUtils._hashInitPlanet(initPlanet); + + arenaStorage().initPlanetHashes[initHash] = true; + + /* Store planet ids for retrieval later */ + arenaConstants().INIT_PLANET_HASHES.push(initHash); + } + + arenaConstants().TARGETS_REQUIRED_FOR_VICTORY = ai().initArgs.TARGETS_REQUIRED_FOR_VICTORY; + arenaConstants().BLOCK_MOVES = ai().initArgs.BLOCK_MOVES; + arenaConstants().BLOCK_CAPTURE = ai().initArgs.BLOCK_CAPTURE; + arenaConstants().TEAMS_ENABLED = ai().initArgs.TEAMS_ENABLED; + arenaConstants().NUM_TEAMS = ai().initArgs.NUM_TEAMS; + arenaConstants().RANKED = ai().initArgs.RANKED; + + initializeDefaults(); + initializeUpgrades(); + LibGameUtils.updateWorldRadius(); + + emit ArenaInitialized(IERC173(address(this)).owner(), address(this)); } - ws().drip = 0.05 ether; - - gs().planetLevelsCount = 10; - gs().planetLevelThresholds = ai().initArgs.PLANET_LEVEL_THRESHOLDS; - - snarkConstants().DISABLE_ZK_CHECKS = ai().initArgs.DISABLE_ZK_CHECKS; - snarkConstants().PLANETHASH_KEY = ai().initArgs.PLANETHASH_KEY; - snarkConstants().SPACETYPE_KEY = ai().initArgs.SPACETYPE_KEY; - snarkConstants().BIOMEBASE_KEY = ai().initArgs.BIOMEBASE_KEY; - snarkConstants().PERLIN_MIRROR_X = ai().initArgs.PERLIN_MIRROR_X; - snarkConstants().PERLIN_MIRROR_Y = ai().initArgs.PERLIN_MIRROR_Y; - snarkConstants().PERLIN_LENGTH_SCALE = ai().initArgs.PERLIN_LENGTH_SCALE; - - gameConstants().PLANET_LEVEL_THRESHOLDS = ai().initArgs.PLANET_LEVEL_THRESHOLDS; - gameConstants().ADMIN_CAN_ADD_PLANETS = ai().initArgs.ADMIN_CAN_ADD_PLANETS; - gameConstants().WORLD_RADIUS_LOCKED = ai().initArgs.WORLD_RADIUS_LOCKED; - gameConstants().WORLD_RADIUS_MIN = ai().initArgs.WORLD_RADIUS_MIN; - gameConstants().MAX_NATURAL_PLANET_LEVEL = ai() - .initArgs - .MAX_NATURAL_PLANET_LEVEL; - gameConstants().TIME_FACTOR_HUNDREDTHS = ai() - .initArgs - .TIME_FACTOR_HUNDREDTHS; - gameConstants().PERLIN_THRESHOLD_1 = ai().initArgs.PERLIN_THRESHOLD_1; - gameConstants().PERLIN_THRESHOLD_2 = ai().initArgs.PERLIN_THRESHOLD_2; - gameConstants().PERLIN_THRESHOLD_3 = ai().initArgs.PERLIN_THRESHOLD_3; - gameConstants().INIT_PERLIN_MIN = ai().initArgs.INIT_PERLIN_MIN; - gameConstants().INIT_PERLIN_MAX = ai().initArgs.INIT_PERLIN_MAX; - gameConstants().SPAWN_RIM_AREA = ai().initArgs.SPAWN_RIM_AREA; - gameConstants().BIOME_THRESHOLD_1 = ai().initArgs.BIOME_THRESHOLD_1; - gameConstants().BIOME_THRESHOLD_2 = ai().initArgs.BIOME_THRESHOLD_2; - gameConstants().PLANET_RARITY = ai().initArgs.PLANET_RARITY; - gameConstants().PLANET_TRANSFER_ENABLED = ai() - .initArgs - .PLANET_TRANSFER_ENABLED; - gameConstants().PHOTOID_ACTIVATION_DELAY = ai() - .initArgs - .PHOTOID_ACTIVATION_DELAY; - gameConstants().LOCATION_REVEAL_COOLDOWN = ai() - .initArgs - .LOCATION_REVEAL_COOLDOWN; - gameConstants().PLANET_TYPE_WEIGHTS = ai().initArgs.PLANET_TYPE_WEIGHTS; - gameConstants().SILVER_SCORE_VALUE = ai().initArgs.SILVER_SCORE_VALUE; - gameConstants().ARTIFACT_POINT_VALUES = ai().initArgs.ARTIFACT_POINT_VALUES; - // Space Junk - gameConstants().SPACE_JUNK_ENABLED = ai().initArgs.SPACE_JUNK_ENABLED; - gameConstants().SPACE_JUNK_LIMIT = ai().initArgs.SPACE_JUNK_LIMIT; - gameConstants().PLANET_LEVEL_JUNK = ai().initArgs.PLANET_LEVEL_JUNK; - gameConstants().ABANDON_SPEED_CHANGE_PERCENT = ai() - .initArgs - .ABANDON_SPEED_CHANGE_PERCENT; - gameConstants().ABANDON_RANGE_CHANGE_PERCENT = ai() - .initArgs - .ABANDON_RANGE_CHANGE_PERCENT; - // Capture Zones - gameConstants().GAME_START_BLOCK = block.number; - gameConstants().CAPTURE_ZONES_ENABLED = ai().initArgs.CAPTURE_ZONES_ENABLED; - gameConstants().CAPTURE_ZONE_COUNT = ai().initArgs.CAPTURE_ZONE_COUNT; - gameConstants().CAPTURE_ZONE_CHANGE_BLOCK_INTERVAL = ai() - .initArgs - .CAPTURE_ZONE_CHANGE_BLOCK_INTERVAL; - gameConstants().CAPTURE_ZONE_RADIUS = ai().initArgs.CAPTURE_ZONE_RADIUS; - gameConstants().CAPTURE_ZONE_PLANET_LEVEL_SCORE = ai() - .initArgs - .CAPTURE_ZONE_PLANET_LEVEL_SCORE; - gameConstants().CAPTURE_ZONE_HOLD_BLOCKS_REQUIRED = ai() - .initArgs - .CAPTURE_ZONE_HOLD_BLOCKS_REQUIRED; - gameConstants().CAPTURE_ZONES_PER_5000_WORLD_RADIUS = ai() - .initArgs - .CAPTURE_ZONES_PER_5000_WORLD_RADIUS; - - gs().nextChangeBlock = - block.number + - ai().initArgs.CAPTURE_ZONE_CHANGE_BLOCK_INTERVAL; - - gs().worldRadius = ai().initArgs.WORLD_RADIUS_MIN; // will be overridden by `LibGameUtils.updateWorldRadius()` if !WORLD_RADIUS_LOCKED - - gs().paused = ai().initArgs.START_PAUSED || ai().initArgs.CONFIRM_START; - - gs().TOKEN_MINT_END_TIMESTAMP = ai().initArgs.TOKEN_MINT_END_TIMESTAMP; - - gs().initializedPlanetCountByLevel = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - for (uint256 i = 0; i < gs().planetLevelThresholds.length; i += 1) { - gs().cumulativeRarities.push( - (2**24 / gs().planetLevelThresholds[i]) * ai().initArgs.PLANET_RARITY - ); + function initializeDefaults() public { + PlanetDefaultStats[] storage planetDefaultStats = planetDefaultStats(); + require( + ((75 * arenaConstants().MODIFIERS.speed) / 100) > 0, + "cannot initialize planets with 0 speed" + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Asteroid", + populationCap: (100000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (417 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (99 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (400 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (0 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (0 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: 0 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Brown Dwarf", + populationCap: (400000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (833 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (177 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (400 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (56 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (100000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (1 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Red Dwarf", + populationCap: (1600000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (1250 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (315 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (300 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (167 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (500000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (2 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "White Dwarf", + populationCap: (6000000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (1667 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (591 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (300 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (417 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (2500000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (3 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Yellow Star", + populationCap: (25000000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (2083 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (1025 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (300 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (833 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (12000000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (4 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Blue Star", + populationCap: (100000000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (2500 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (1734 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (200 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (1667 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (50000000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (5 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Giant", + populationCap: (300000000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (2917 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (2838 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (200 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (100000000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (7 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Supergiant", + populationCap: (500000000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (3333 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (4414 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (200 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (200000000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (10 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Unlabeled1", + populationCap: (700000000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (3750 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (6306 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (200 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (300000000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (20 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); + + planetDefaultStats.push( + PlanetDefaultStats({ + label: "Unlabeled2", + populationCap: (800000000 * arenaConstants().MODIFIERS.popCap) / 100, + populationGrowth: (4167 * arenaConstants().MODIFIERS.popGrowth) / 100, + range: (8829 * arenaConstants().MODIFIERS.range) / 100, + speed: (75 * arenaConstants().MODIFIERS.speed) / 100, + defense: (200 * arenaConstants().MODIFIERS.defense) / 100, + silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, + silverCap: (400000000 * arenaConstants().MODIFIERS.silverCap) / 100, + barbarianPercentage: (25 * arenaConstants().MODIFIERS.barbarianPercentage) / 100 + }) + ); } - //arenaMode initialization - arenaStorage().gameover = false; - arenaConstants().TARGET_PLANETS = ai().initArgs.TARGET_PLANETS; - arenaConstants().CLAIM_VICTORY_ENERGY_PERCENT = ai() - .initArgs - .CLAIM_VICTORY_ENERGY_PERCENT; - arenaConstants().MANUAL_SPAWN = ai().initArgs.MANUAL_SPAWN; - arenaConstants().RANDOM_ARTIFACTS = ai().initArgs.RANDOM_ARTIFACTS; - - arenaConstants().MODIFIERS.popCap = ai().initArgs.MODIFIERS[ - uint256(Mod.popCap) - ]; - arenaConstants().MODIFIERS.popGrowth = ai().initArgs.MODIFIERS[ - uint256(Mod.popGrowth) - ]; - arenaConstants().MODIFIERS.silverCap = ai().initArgs.MODIFIERS[ - uint256(Mod.silverCap) - ]; - arenaConstants().MODIFIERS.silverGrowth = ai().initArgs.MODIFIERS[ - uint256(Mod.silverGrowth) - ]; - arenaConstants().MODIFIERS.range = ai().initArgs.MODIFIERS[ - uint256(Mod.range) - ]; - arenaConstants().MODIFIERS.speed = ai().initArgs.MODIFIERS[ - uint256(Mod.speed) - ]; - arenaConstants().MODIFIERS.defense = ai().initArgs.MODIFIERS[ - uint256(Mod.defense) - ]; - arenaConstants().MODIFIERS.barbarianPercentage = ai().initArgs.MODIFIERS[ - uint256(Mod.barbarianPercentage) - ]; - - arenaConstants().SPACESHIPS = Spaceships( - ai().initArgs.SPACESHIPS[0], - ai().initArgs.SPACESHIPS[1], - ai().initArgs.SPACESHIPS[2], - ai().initArgs.SPACESHIPS[3], - ai().initArgs.SPACESHIPS[4] - ); - - arenaConstants().NO_ADMIN = ai().initArgs.NO_ADMIN; - arenaConstants().CONFIG_HASH = keccak256(abi.encode(ai().initArgs)); - arenaConstants().CONFIRM_START = ai().initArgs.CONFIRM_START; - arenaConstants().START_PAUSED = ai().initArgs.START_PAUSED; - - uint256 initLength = ai().initArgs.INIT_PLANETS.length; - - /* each planet costs about 50k gas */ - for (uint256 i = 0; i < initLength; i++) { - ArenaCreateRevealPlanetArgs memory initPlanet = ai() - .initArgs - .INIT_PLANETS[i]; - - bytes32 initHash = LibGameUtils._hashInitPlanet(initPlanet); - - arenaStorage().initPlanetHashes[initHash] = true; - - /* Store planet ids for retrieval later */ - arenaConstants().INIT_PLANET_HASHES.push(initHash); + function initializeUpgrades() public { + Upgrade[4][3] storage upgrades = upgrades(); + + // defense + upgrades[uint256(UpgradeBranch.DEFENSE)][0] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 100, + defMultiplier: 120 + }); + upgrades[uint256(UpgradeBranch.DEFENSE)][1] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 100, + defMultiplier: 120 + }); + upgrades[uint256(UpgradeBranch.DEFENSE)][2] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 100, + defMultiplier: 120 + }); + upgrades[uint256(UpgradeBranch.DEFENSE)][3] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 100, + defMultiplier: 120 + }); + + // range + upgrades[uint256(UpgradeBranch.RANGE)][0] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 125, + speedMultiplier: 100, + defMultiplier: 100 + }); + upgrades[uint256(UpgradeBranch.RANGE)][1] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 125, + speedMultiplier: 100, + defMultiplier: 100 + }); + upgrades[uint256(UpgradeBranch.RANGE)][2] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 125, + speedMultiplier: 100, + defMultiplier: 100 + }); + upgrades[uint256(UpgradeBranch.RANGE)][3] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 125, + speedMultiplier: 100, + defMultiplier: 100 + }); + + // speed + upgrades[uint256(UpgradeBranch.SPEED)][0] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 175, + defMultiplier: 100 + }); + upgrades[uint256(UpgradeBranch.SPEED)][1] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 175, + defMultiplier: 100 + }); + upgrades[uint256(UpgradeBranch.SPEED)][2] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 175, + defMultiplier: 100 + }); + upgrades[uint256(UpgradeBranch.SPEED)][3] = Upgrade({ + popCapMultiplier: 120, + popGroMultiplier: 120, + rangeMultiplier: 100, + speedMultiplier: 175, + defMultiplier: 100 + }); } - - arenaConstants().TARGETS_REQUIRED_FOR_VICTORY = ai() - .initArgs - .TARGETS_REQUIRED_FOR_VICTORY; - arenaConstants().BLOCK_MOVES = ai().initArgs.BLOCK_MOVES; - arenaConstants().BLOCK_CAPTURE = ai().initArgs.BLOCK_CAPTURE; - arenaConstants().TEAMS_ENABLED = ai().initArgs.TEAMS_ENABLED; - arenaConstants().NUM_TEAMS = ai().initArgs.NUM_TEAMS; - arenaConstants().RANKED = ai().initArgs.RANKED; - - initializeDefaults(); - initializeUpgrades(); - LibGameUtils.updateWorldRadius(); - - emit ArenaInitialized(IERC173(address(this)).owner(), address(this)); - } - - function initializeDefaults() public { - PlanetDefaultStats[] storage planetDefaultStats = planetDefaultStats(); - require( - ((75 * arenaConstants().MODIFIERS.speed) / 100) > 0, - "cannot initialize planets with 0 speed" - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Asteroid", - populationCap: (100000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (417 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (99 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (400 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (0 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (0 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: 0 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Brown Dwarf", - populationCap: (400000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (833 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (177 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (400 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (56 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (100000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (1 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Red Dwarf", - populationCap: (1600000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (1250 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (315 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (300 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (167 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (500000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (2 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "White Dwarf", - populationCap: (6000000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (1667 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (591 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (300 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (417 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (2500000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (3 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Yellow Star", - populationCap: (25000000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (2083 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (1025 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (300 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (833 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (12000000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (4 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Blue Star", - populationCap: (100000000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (2500 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (1734 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (200 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (1667 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (50000000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (5 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Giant", - populationCap: (300000000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (2917 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (2838 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (200 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (100000000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (7 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Supergiant", - populationCap: (500000000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (3333 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (4414 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (200 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (200000000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (10 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Unlabeled1", - populationCap: (700000000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (3750 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (6306 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (200 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (300000000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (20 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - - planetDefaultStats.push( - PlanetDefaultStats({ - label: "Unlabeled2", - populationCap: (800000000 * arenaConstants().MODIFIERS.popCap) / 100, - populationGrowth: (4167 * arenaConstants().MODIFIERS.popGrowth) / 100, - range: (8829 * arenaConstants().MODIFIERS.range) / 100, - speed: (75 * arenaConstants().MODIFIERS.speed) / 100, - defense: (200 * arenaConstants().MODIFIERS.defense) / 100, - silverGrowth: (2778 * arenaConstants().MODIFIERS.silverGrowth) / 100, - silverCap: (400000000 * arenaConstants().MODIFIERS.silverCap) / 100, - barbarianPercentage: (25 * - arenaConstants().MODIFIERS.barbarianPercentage) / 100 - }) - ); - } - - function initializeUpgrades() public { - Upgrade[4][3] storage upgrades = upgrades(); - - // defense - upgrades[uint256(UpgradeBranch.DEFENSE)][0] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 100, - defMultiplier: 120 - }); - upgrades[uint256(UpgradeBranch.DEFENSE)][1] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 100, - defMultiplier: 120 - }); - upgrades[uint256(UpgradeBranch.DEFENSE)][2] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 100, - defMultiplier: 120 - }); - upgrades[uint256(UpgradeBranch.DEFENSE)][3] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 100, - defMultiplier: 120 - }); - - // range - upgrades[uint256(UpgradeBranch.RANGE)][0] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 125, - speedMultiplier: 100, - defMultiplier: 100 - }); - upgrades[uint256(UpgradeBranch.RANGE)][1] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 125, - speedMultiplier: 100, - defMultiplier: 100 - }); - upgrades[uint256(UpgradeBranch.RANGE)][2] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 125, - speedMultiplier: 100, - defMultiplier: 100 - }); - upgrades[uint256(UpgradeBranch.RANGE)][3] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 125, - speedMultiplier: 100, - defMultiplier: 100 - }); - - // speed - upgrades[uint256(UpgradeBranch.SPEED)][0] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 175, - defMultiplier: 100 - }); - upgrades[uint256(UpgradeBranch.SPEED)][1] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 175, - defMultiplier: 100 - }); - upgrades[uint256(UpgradeBranch.SPEED)][2] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 175, - defMultiplier: 100 - }); - upgrades[uint256(UpgradeBranch.SPEED)][3] = Upgrade({ - popCapMultiplier: 120, - popGroMultiplier: 120, - rangeMultiplier: 100, - speedMultiplier: 175, - defMultiplier: 100 - }); - } } diff --git a/contracts/libraries/LibArenaStorage.sol b/contracts/libraries/LibArenaStorage.sol index aa73b78..d1c8849 100644 --- a/contracts/libraries/LibArenaStorage.sol +++ b/contracts/libraries/LibArenaStorage.sol @@ -17,6 +17,9 @@ import { ArenaPlayerInfo, Modifiers, ArenaCreateRevealPlanetArgs, + ArtifactTypePrices, + ArtifactRarityPrices, + SpaceshipPrices, Spaceships, InitArgs, AuxiliaryArgs @@ -73,6 +76,9 @@ struct ArenaConstants { bool TEAMS_ENABLED; uint256 NUM_TEAMS; bool RANKED; + ArtifactTypePrices ARTIFACT_TYPE_PRICES; + ArtifactRarityPrices ARTIFACT_RARITY_PRICES; + SpaceshipPrices SPACESHIP_PRICES; } library LibArenaStorage { diff --git a/contracts/libraries/LibGameUtils.sol b/contracts/libraries/LibGameUtils.sol index ec2470c..85e5e33 100644 --- a/contracts/libraries/LibGameUtils.sol +++ b/contracts/libraries/LibGameUtils.sol @@ -367,8 +367,6 @@ library LibGameUtils { ret.popGroMultiplier += 5; } else if (artifact.artifactType == ArtifactType.Colossus) { ret.speedMultiplier += 5; - } else if (artifact.artifactType == ArtifactType.Spaceship) { - ret.rangeMultiplier += 5; } else if (artifact.artifactType == ArtifactType.Pyramid) { ret.defMultiplier += 5; } diff --git a/test/DFShop.test.ts b/test/DFShop.test.ts new file mode 100644 index 0000000..d98ecc5 --- /dev/null +++ b/test/DFShop.test.ts @@ -0,0 +1,34 @@ +import { expect } from 'chai'; +import { ethers } from 'hardhat'; +import { + conquerUnownedPlanet, + feedSilverToCap, + fixtureLoader, + increaseBlockchainTime, + makeInitArgs, +} from './utils/TestUtils'; +import { defaultWorldFixture, World } from './utils/TestWorld'; +import { + ARTIFACT_PLANET_1, + LVL1_ASTEROID_2, + SPAWN_PLANET_1, +} from './utils/WorldConstants'; + +const { BigNumber: BN } = ethers; + +describe.only('DarkForestShop', function () { + let world: World; + + beforeEach('load fixture', async function () { + world = await fixtureLoader(defaultWorldFixture); + }); + + it('should load the world', async function () { + const fromId = SPAWN_PLANET_1.id; + + await expect(world.user1Core.upgradePlanet(fromId, 0)).to.be.revertedWith( + 'Planet has not been initialized' + ); + }); + +});