// SPDX-License-Identifier: MITpragmasolidity ^0.8.25;uint8constant CELL_EMPTY =0; // emptyuint8constant CELL_NEW =1; // new celluint8constant CELL_WAITING =2; // waiting round celluint8constant CELL_READY =3; // cell takes part of reward calculations// cell of the game fieldstructCellData {
address owner;
uint round;
uint8 state;
uint token_price; // 0 or owner token, spended to own itaddress attack_address;
uint attack_end_time;
}
// full cell data with claim info (including realtime and not realtime calculated data dependencies)structCellDataFull {
address owner;
uint round;
uint8 state;
uint token_price; // 0 or owner token, spended to own itaddress attack_address;
uint attack_end_time;
bool need_claim; // if true, than new owner need to claim it and last owner can take cells arount it still
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)pragmasolidity ^0.8.20;/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransfer(address to, uint256 value) externalreturns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/functionallowance(address owner, address spender) externalviewreturns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/functionapprove(address spender, uint256 value) externalreturns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransferFrom(addressfrom, address to, uint256 value) externalreturns (bool);
}
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import {ABDKMath64x64asMath} from"abdk-libraries-solidity/ABDKMath64x64.sol";
// Commonly used numbers as 64.64 fixed pointint128constant _1 =2**64;
int128constant _2 =2*2**64;
int128constant _6 =6*2**64;
int128constant _10 =10*2**64;
int128constant _15 =15*2**64;
structH {
int16 X;
int16 Y;
int16 Z;
int16 A;
int16 AA;
int16 AB;
int16 B;
int16 BA;
int16 BB;
int16 pX;
int16 pA;
int16 pB;
int16 pAA;
int16 pAB;
int16 pBA;
int16 pBB;
int128 x;
int128 y;
int128 z;
int128 u;
int128 v;
int128 w;
int128 r;
}
structH2 {
int16 X;
int16 Y;
int16 A;
int16 AA;
int16 AB;
int16 B;
int16 BA;
int16 BB;
int16 pX;
int16 pA;
int16 pB;
int128 x;
int128 y;
int128 u;
int128 r;
}
/// @title Perlin noise library/// @author alvarius/// @notice Ported from perlin reference implementation (https://cs.nyu.edu/~perlin/noise/)libraryPerlin{
functionnoise2d(int256 _x,
int256 _y,
int256 denom,
uint8 precision
) internalpurereturns (int128) {
H2 memory h = H2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// Convert fraction into 64.64 fixed point number
h.x = Math.divi(_x, denom);
h.y = Math.divi(_y, denom);
// Find unit cube that contains point
h.X =int16(Math.toInt(h.x)) &0xff;
h.Y =int16(Math.toInt(h.y)) &0xff;
// Find relative x,y,z of point in cube
h.x = Math.sub(h.x, floor(h.x));
h.y = Math.sub(h.y, floor(h.y));
// Compute fade curves for each x,y,z
h.u = fade(h.x);
// Hash coordinates of the 4 square corners
h.pX = p2(h.X);
h.A = i0(h.pX) + h.Y;
h.pA = p2(h.A);
h.AA = i0(h.pA);
h.AB = i1(h.pA);
h.B = i1(h.pX) + h.Y;
h.pB = p2(h.B);
h.BA = i0(h.pB);
h.BB = i1(h.pB);
// Add blended results from 4 corners of square
h.r = lerp(
fade(h.y),
lerp(h.u, grad2d(int16(p(h.AA)), h.x, h.y), grad2d(int16(p(h.BA)), dec(h.x), h.y)),
lerp(h.u, grad2d(int16(p(h.AB)), h.x, dec(h.y)), grad2d(int16(p(h.BB)), dec(h.x), dec(h.y)))
);
// Shift to range from 0 to 1return Math.div(Math.add(h.r, _1), _2) >> (64- precision);
}
functionnoise(int256 _x,
int256 _y,
int256 _z,
int256 denom,
uint8 precision
) internalpurereturns (int128) {
H memory h = H(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// Convert fraction into 64.64 fixed point number
h.x = Math.divi(_x, denom);
h.y = Math.divi(_y, denom);
h.z = Math.divi(_z, denom);
// Find unit cube that contains point
h.X =int16(Math.toInt(h.x)) &255;
h.Y =int16(Math.toInt(h.y)) &255;
h.Z =int16(Math.toInt(h.z)) &255;
// Find relative x,y,z of point in cube
h.x = Math.sub(h.x, floor(h.x));
h.y = Math.sub(h.y, floor(h.y));
h.z = Math.sub(h.z, floor(h.z));
// Compute fade curves for each x,y,z
h.u = fade(h.x);
h.v = fade(h.y);
h.w = fade(h.z);
// Hash coordinates of the 8 cube corners
h.pX = p2(h.X);
h.A = i0(h.pX) + h.Y;
h.pA = p2(h.A);
h.AA = i0(h.pA) + h.Z;
h.AB = i1(h.pA) + h.Z;
h.B = i1(h.pX) + h.Y;
h.pB = p2(h.B);
h.BA = i0(h.pB) + h.Z;
h.BB = i1(h.pB) + h.Z;
h.pAA = p2(h.AA);
h.pAB = p2(h.AB);
h.pBA = p2(h.BA);
h.pBB = p2(h.BB);
// Add blended results from 8 corners of cube
h.r = lerp(
h.w,
lerp(
h.v,
lerp(h.u, grad(i0(h.pAA), h.x, h.y, h.z), grad(i0(h.pBA), dec(h.x), h.y, h.z)),
lerp(h.u, grad(i0(h.pAB), h.x, dec(h.y), h.z), grad(i0(h.pBB), dec(h.x), dec(h.y), h.z))
),
lerp(
h.v,
lerp(h.u, grad(i1(h.pAA), h.x, h.y, dec(h.z)), grad(i1(h.pBA), dec(h.x), h.y, dec(h.z))),
lerp(h.u, grad(i1(h.pAB), h.x, dec(h.y), dec(h.z)), grad(i1(h.pBB), dec(h.x), dec(h.y), dec(h.z)))
)
);
// Shift to range from 0 to 1return Math.div(Math.add(h.r, _1), _2) >> (64- precision);
}
functiondec(int128 x) internalpurereturns (int128) {
return Math.sub(x, _1);
}
functionfloor(int128 x) internalpurereturns (int128) {
return Math.fromInt(int256(Math.toInt(x)));
}
/**
* Computes t * t * t * (t * (t * 6 - 15) + 10)
**/functionfade(int128 t) internalpurereturns (int128) {
return Math.mul(t, Math.mul(t, Math.mul(t, (Math.add(Math.mul(t, (Math.sub(Math.mul(t, _6), _15))), _10)))));
}
/**
* Computes a + t * (b - a)
**/functionlerp(int128 t,
int128 a,
int128 b
) internalpurereturns (int128) {
return Math.add(a, Math.mul(t, (Math.sub(b, a))));
}
/**
* Modified from original perlin paper based on http://riven8192.blogspot.com/2010/08/calculate-perlinnoise-twice-as-fast.html
**/functiongrad(int16 _hash,
int128 x,
int128 y,
int128 z
) internalpurereturns (int128) {
// Convert lower 4 bits to hash code into 12 gradient directionsint16 h = _hash &0xF;
if (h <=0x7) {
if (h <=0x3) {
if (h <=0x1) {
if (h ==0x0) return Math.add(x, y);
return Math.sub(y, x);
} else {
if (h ==0x2) return Math.sub(x, y);
return Math.sub(Math.neg(x), y);
}
} else {
if (h <=0x5) {
if (h ==0x4) return Math.add(x, z);
return Math.sub(z, x);
} else {
if (h ==0x6) return Math.sub(x, z);
return Math.sub(Math.neg(x), z);
}
}
} else {
if (h <=0xB) {
if (h <=0x9) {
if (h ==0x8) return Math.add(y, z);
return Math.sub(z, y);
} else {
if (h ==0xA) return Math.sub(y, z);
return Math.sub(Math.neg(y), z);
}
} else {
if (h <=0xD) {
if (h ==0xC) return Math.add(y, x);
return Math.add(Math.neg(y), z);
} else {
if (h ==0xE) return Math.sub(y, x);
return Math.sub(Math.neg(y), z);
}
}
}
}
/**
* Modified from original perlin paper based on http://riven8192.blogspot.com/2010/08/calculate-perlinnoise-twice-as-fast.html
**/functiongrad2d(int16 _hash,
int128 x,
int128 y
) internalpurereturns (int128) {
// Convert lower 4 bits to hash code into 12 gradient directionsint16 h = _hash &0xF;
if (h <=0x7) {
if (h <=0x3) {
if (h <=0x1) {
if (h ==0x0) return Math.add(x, y);
return Math.sub(y, x);
} else {
if (h ==0x2) return Math.sub(x, y);
return Math.sub(Math.neg(x), y);
}
} else {
if (h <=0x5) {
if (h ==0x4) return x;
return Math.neg(x);
} else {
if (h ==0x6) return x;
return Math.neg(x);
}
}
} else {
if (h <=0xB) {
if (h <=0x9) {
if (h ==0x8) return y;
return Math.neg(y);
} else {
if (h ==0xA) return y;
return Math.neg(y);
}
} else {
if (h <=0xD) {
if (h ==0xC) return Math.add(y, x);
return Math.neg(y);
} else {
if (h ==0xE) return Math.sub(y, x);
return Math.neg(y);
}
}
}
}
/**
* Returns the value at the given index from the ptable
*/functionp(int64 i) internalpurereturns (int64) {
returnint64(ptable(int256(i)) >>8);
}
/**
* Returns an encoded tuple of the value at the given index and the subsequent value from the ptable.
* Value of the requested index is at i0(result), subsequent value is at i1(result)
*/functionp2(int16 i) internalpurereturns (int16) {
returnint16(ptable(int256(i)));
}
/**
* Helper function to access value at index 0 from the encoded tuple returned by p2
*/functioni0(int16 tuple) internalpurereturns (int16) {
return tuple >>8;
}
/**
* Helper function to access value at index 1 from the encoded tuple returned by p2
*/functioni1(int16 tuple) internalpurereturns (int16) {
return tuple &0xff;
}
/**
* From https://github.com/0x10f/solidity-perlin-noise/blob/master/contracts/PerlinNoise.sol
*
* @notice Gets a subsequent values in the permutation table at an index. The values are encoded
* into a single 16 bit integer with the value at the specified index being the most
* significant 8 bits and the subsequent value being the least significant 8 bits.
*
* @param i the index in the permutation table.
*
* @dev The values from the table are mapped out into a binary tree for faster lookups.
* Looking up any value in the table in this implementation is is O(8), in
* the implementation of sequential if statements it is O(255).
*
* @dev The body of this function is autogenerated. Check out the 'gen-ptable' script.
* (https://github.com/0x10f/solidity-perlin-noise/blob/master/scripts/gen-ptable.js)
*/functionptable(int256 i) internalpurereturns (int256) {
i &=0xff;
if (i <=127) {
if (i <=63) {
if (i <=31) {
if (i <=15) {
if (i <=7) {
if (i <=3) {
if (i <=1) {
if (i ==0) {
return38816;
} else {
return41097;
}
} else {
if (i ==2) {
return35163;
} else {
return23386;
}
}
} else {
if (i <=5) {
if (i ==4) {
return23055;
} else {
return3971;
}
} else {
if (i ==6) {
return33549;
} else {
return3529;
}
}
}
} else {
if (i <=11) {
if (i <=9) {
if (i ==8) {
return51551;
} else {
return24416;
}
} else {
if (i ==10) {
return24629;
} else {
return13762;
}
}
} else {
if (i <=13) {
if (i ==12) {
return49897;
} else {
return59655;
}
} else {
if (i ==14) {
return2017;
} else {
return57740;
}
}
}
}
} else {
if (i <=23) {
if (i <=19) {
if (i <=17) {
if (i ==16) {
return35876;
} else {
return9319;
}
} else {
if (i ==18) {
return26398;
} else {
return7749;
}
}
} else {
if (i <=21) {
if (i ==20) {
return17806;
} else {
return36360;
}
} else {
if (i ==22) {
return2147;
} else {
return25381;
}
}
}
} else {
if (i <=27) {
if (i <=25) {
if (i ==24) {
return9712;
} else {
return61461;
}
} else {
if (i ==26) {
return5386;
} else {
return2583;
}
}
} else {
if (i <=29) {
if (i ==28) {
return6078;
} else {
return48646;
}
} else {
if (i ==30) {
return1684;
} else {
return38135;
}
}
}
}
}
} else {
if (i <=47) {
if (i <=39) {
if (i <=35) {
if (i <=33) {
if (i ==32) {
return63352;
} else {
return30954;
}
} else {
if (i ==34) {
return59979;
} else {
return19200;
}
}
} else {
if (i <=37) {
if (i ==36) {
return26;
} else {
return6853;
}
} else {
if (i ==38) {
return50494;
} else {
return15966;
}
}
}
} else {
if (i <=43) {
if (i <=41) {
if (i ==40) {
return24316;
} else {
return64731;
}
} else {
if (i ==42) {
return56267;
} else {
return52085;
}
}
} else {
if (i <=45) {
if (i ==44) {
return29987;
} else {
return8971;
}
} else {
if (i ==46) {
return2848;
} else {
return8249;
}
}
}
}
} else {
if (i <=55) {
if (i <=51) {
if (i <=49) {
if (i ==48) {
return14769;
} else {
return45345;
}
} else {
if (i ==50) {
return8536;
} else {
return22765;
}
}
} else {
if (i <=53) {
if (i ==52) {
return60821;
} else {
return38200;
}
} else {
if (i ==54) {
return14423;
} else {
return22446;
}
}
}
} else {
if (i <=59) {
if (i <=57) {
if (i ==56) {
return44564;
} else {
return5245;
}
} else {
if (i ==58) {
return32136;
} else {
return34987;
}
}
} else {
if (i <=61) {
if (i ==60) {
return43944;
} else {
return43076;
}
} else {
if (i ==62) {
return17583;
} else {
return44874;
}
}
}
}
}
}
} else {
if (i <=95) {
if (i <=79) {
if (i <=71) {
if (i <=67) {
if (i <=65) {
if (i ==64) {
return19109;
} else {
return42311;
}
} else {
if (i ==66) {
return18310;
} else {
return34443;
}
}
} else {
if (i <=69) {
if (i ==68) {
return35632;
} else {
return12315;
}
} else {
if (i ==70) {
return7078;
} else {
return42573;
}
}
}
} else {
if (i <=75) {
if (i <=73) {
if (i ==72) {
return19858;
} else {
return37534;
}
} else {
if (i ==74) {
return40679;
} else {
return59219;
}
}
} else {
if (i <=77) {
if (i ==76) {
return21359;
} else {
return28645;
}
} else {
if (i ==78) {
return58746;
} else {
return31292;
}
}
}
}
} else {
if (i <=87) {
if (i <=83) {
if (i <=81) {
if (i ==80) {
return15571;
} else {
return54149;
}
} else {
if (i ==82) {
return34278;
} else {
return59100;
}
}
} else {
if (i <=85) {
if (i ==84) {
return56425;
} else {
return26972;
}
} else {
if (i ==86) {
return23593;
} else {
return10551;
}
}
}
} else {
if (i <=91) {
if (i <=89) {
if (i ==88) {
return14126;
} else {
return12021;
}
} else {
if (i ==90) {
return62760;
} else {
return10484;
}
}
} else {
if (i <=93) {
if (i ==92) {
return62566;
} else {
return26255;
}
} else {
if (i ==94) {
return36662;
} else {
return13889;
}
}
}
}
}
} else {
if (i <=111) {
if (i <=103) {
if (i <=99) {
if (i <=97) {
if (i ==96) {
return16665;
} else {
return6463;
}
} else {
if (i ==98) {
return16289;
} else {
return41217;
}
}
} else {
if (i <=101) {
if (i ==100) {
return472;
} else {
return55376;
}
} else {
if (i ==102) {
return20553;
} else {
return18897;
}
}
}
} else {
if (i <=107) {
if (i <=105) {
if (i ==104) {
return53580;
} else {
return19588;
}
} else {
if (i ==106) {
return33979;
} else {
return48080;
}
}
} else {
if (i <=109) {
if (i ==108) {
return53337;
} else {
return22802;
}
} else {
if (i ==110) {
return4777;
} else {
return43464;
}
}
}
}
} else {
if (i <=119) {
if (i <=115) {
if (i <=113) {
if (i ==112) {
return51396;
} else {
return50311;
}
} else {
if (i ==114) {
return34690;
} else {
return33396;
}
}
} else {
if (i <=117) {
if (i ==116) {
return29884;
} else {
return48287;
}
} else {
if (i ==118) {
return40790;
} else {
return22180;
}
}
}
} else {
if (i <=123) {
if (i <=121) {
if (i ==120) {
return42084;
} else {
return25709;
}
} else {
if (i ==122) {
return28102;
} else {
return50861;
}
}
} else {
if (i <=125) {
if (i ==124) {
return44474;
} else {
return47619;
}
} else {
if (i ==126) {
return832;
} else {
return16436;
}
}
}
}
}
}
}
} else {
if (i <=191) {
if (i <=159) {
if (i <=143) {
if (i <=135) {
if (i <=131) {
if (i <=129) {
if (i ==128) {
return13529;
} else {
return55778;
}
} else {
if (i ==130) {
return58106;
} else {
return64124;
}
}
} else {
if (i <=133) {
if (i ==132) {
return31867;
} else {
return31493;
}
} else {
if (i ==134) {
return1482;
} else {
return51750;
}
}
}
} else {
if (i <=139) {
if (i <=137) {
if (i ==136) {
return9875;
} else {
return37750;
}
} else {
if (i ==138) {
return30334;
} else {
return32511;
}
}
} else {
if (i <=141) {
if (i ==140) {
return65362;
} else {
return21077;
}
} else {
if (i ==142) {
return21972;
} else {
return54479;
}
}
}
}
} else {
if (i <=151) {
if (i <=147) {
if (i <=145) {
if (i ==144) {
return53198;
} else {
return52795;
}
} else {
if (i ==146) {
return15331;
} else {
return58159;
}
}
} else {
if (i <=149) {
if (i ==148) {
return12048;
} else {
return4154;
}
} else {
if (i ==150) {
return14865;
} else {
return4534;
}
}
}
} else {
if (i <=155) {
if (i <=153) {
if (i ==152) {
return46781;
} else {
return48412;
}
} else {
if (i ==154) {
return7210;
} else {
return10975;
}
}
} else {
if (i <=157) {
if (i ==156) {
return57271;
} else {
return47018;
}
} else {
if (i ==158) {
return43733;
} else {
return54647;
}
}
}
}
}
} else {
if (i <=175) {
if (i <=167) {
if (i <=163) {
if (i <=161) {
if (i ==160) {
return30712;
} else {
return63640;
}
} else {
if (i ==162) {
return38914;
} else {
return556;
}
}
} else {
if (i <=165) {
if (i ==164) {
return11418;
} else {
return39587;
}
} else {
if (i ==166) {
return41798;
} else {
return18141;
}
}
}
} else {
if (i <=171) {
if (i <=169) {
if (i ==168) {
return56729;
} else {
return39269;
}
} else {
if (i ==170) {
return26011;
} else {
return39847;
}
}
} else {
if (i <=173) {
if (i ==172) {
return42795;
} else {
return11180;
}
} else {
if (i ==174) {
return44041;
} else {
return2433;
}
}
}
}
} else {
if (i <=183) {
if (i <=179) {
if (i <=177) {
if (i ==176) {
return33046;
} else {
return5671;
}
} else {
if (i ==178) {
return10237;
} else {
return64787;
}
}
} else {
if (i <=181) {
if (i ==180) {
return4962;
} else {
return25196;
}
} else {
if (i ==182) {
return27758;
} else {
return28239;
}
}
}
} else {
if (i <=187) {
if (i <=185) {
if (i ==184) {
return20337;
} else {
return29152;
}
} else {
if (i ==186) {
return57576;
} else {
return59570;
}
}
} else {
if (i <=189) {
if (i ==188) {
return45753;
} else {
return47472;
}
} else {
if (i ==190) {
return28776;
} else {
return26842;
}
}
}
}
}
}
} else {
if (i <=223) {
if (i <=207) {
if (i <=199) {
if (i <=195) {
if (i <=193) {
if (i ==192) {
return56054;
} else {
return63073;
}
} else {
if (i ==194) {
return25060;
} else {
return58619;
}
}
} else {
if (i <=197) {
if (i ==196) {
return64290;
} else {
return8946;
}
} else {
if (i ==198) {
return62145;
} else {
return49646;
}
}
}
} else {
if (i <=203) {
if (i <=201) {
if (i ==200) {
return61138;
} else {
return53904;
}
} else {
if (i ==202) {
return36876;
} else {
return3263;
}
}
} else {
if (i <=205) {
if (i ==204) {
return49075;
} else {
return45986;
}
} else {
if (i ==206) {
return41713;
} else {
return61777;
}
}
}
}
} else {
if (i <=215) {
if (i <=211) {
if (i <=209) {
if (i ==208) {
return20787;
} else {
return13201;
}
} else {
if (i ==210) {
return37355;
} else {
return60409;
}
}
} else {
if (i <=213) {
if (i ==212) {
return63758;
} else {
return3823;
}
} else {
if (i ==214) {
return61291;
} else {
return27441;
}
}
}
} else {
if (i <=219) {
if (i <=217) {
if (i ==216) {
return12736;
} else {
return49366;
}
} else {
if (i ==218) {
return54815;
} else {
return8117;
}
}
} else {
if (i <=221) {
if (i ==220) {
return46535;
} else {
return51050;
}
} else {
if (i ==222) {
return27293;
} else {
return40376;
}
}
}
}
}
} else {
if (i <=239) {
if (i <=231) {
if (i <=227) {
if (i <=225) {
if (i ==224) {
return47188;
} else {
return21708;
}
} else {
if (i ==226) {
return52400;
} else {
return45171;
}
}
} else {
if (i <=229) {
if (i ==228) {
return29561;
} else {
return31026;
}
} else {
if (i ==230) {
return12845;
} else {
return11647;
}
}
}
} else {
if (i <=235) {
if (i <=233) {
if (i ==232) {
return32516;
} else {
return1174;
}
} else {
if (i ==234) {
return38654;
} else {
return65162;
}
}
} else {
if (i <=237) {
if (i ==236) {
return35564;
} else {
return60621;
}
} else {
if (i ==238) {
return52573;
} else {
return24030;
}
}
}
}
} else {
if (i <=247) {
if (i <=243) {
if (i <=241) {
if (i ==240) {
return56946;
} else {
return29251;
}
} else {
if (i ==242) {
return17181;
} else {
return7448;
}
}
} else {
if (i <=245) {
if (i ==244) {
return6216;
} else {
return18675;
}
} else {
if (i ==246) {
return62349;
} else {
return36224;
}
}
}
} else {
if (i <=251) {
if (i <=249) {
if (i ==248) {
return32963;
} else {
return49998;
}
} else {
if (i ==250) {
return20034;
} else {
return17111;
}
}
} else {
if (i <=253) {
if (i ==252) {
return55101;
} else {
return15772;
}
} else {
if (i ==254) {
return40116;
} else {
return46231;
}
}
}
}
}
}
}
}
}
}
Contract Source Code
File 10 of 13: Rects.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.25;import"./StringConverter.sol";
structRect {
string color;
uint x;
uint y;
uint width;
uint height;
}
libraryRectLibrary{
usingRectLibraryforRect;
usingRectLibraryforRect[];
functionto_svg(
Rect memory rect
) internalviewreturns (stringmemory svg) {
returnstring(
abi.encodePacked(
"<rect fill='#",
rect.color,
"' x='",
StringConverter.to_string(rect.x),
"' y='",
StringConverter.to_string(rect.y),
"' width='",
StringConverter.to_string(rect.width),
"' height='",
StringConverter.to_string(rect.height),
"'/>"
)
);
}
functionto_svg(Rect[] memory rects) internalviewreturns (stringmemory) {
stringmemory res;
for (uint i =0; i < rects.length; ++i) {
res =string(abi.encodePacked(res, rects[i].to_svg()));
}
return res;
}
functionto_svg(
Rect[] storage rects
) internalviewreturns (stringmemory res) {
for (uint i =0; i < rects.length; ++i) {
res =string(abi.encodePacked(res, rects[i].to_svg()));
}
return res;
}
}
Contract Source Code
File 11 of 13: ReentrancyGuard.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)pragmasolidity ^0.8.20;/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/abstractcontractReentrancyGuard{
// Booleans are more expensive than uint256 or any type that takes up a full// word because each write operation emits an extra SLOAD to first read the// slot's contents, replace the bits taken up by the boolean, and then write// back. This is the compiler's defense against contract upgrades and// pointer aliasing, and it cannot be disabled.// The values being non-zero value makes deployment a bit more expensive,// but in exchange the refund on every call to nonReentrant will be lower in// amount. Since refunds are capped to a percentage of the total// transaction's gas, it is best to keep them low in cases like this one, to// increase the likelihood of the full refund coming into effect.uint256privateconstant NOT_ENTERED =1;
uint256privateconstant ENTERED =2;
uint256private _status;
/**
* @dev Unauthorized reentrant call.
*/errorReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/modifiernonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function_nonReentrantBefore() private{
// On the first call to nonReentrant, _status will be NOT_ENTEREDif (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function_nonReentrantAfter() private{
// By storing the original value once again, a refund is triggered (see// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/function_reentrancyGuardEntered() internalviewreturns (bool) {
return _status == ENTERED;
}
}