CryptoBlades / cryptoblades

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Land sale

kcper opened this issue · comments

  • Add land sale items in skill shop's 'Specials' section: T1, T2, T3 land
  • Tier 1 land - buy a land in random location
  • Tier 2 land - popup a map made of 50x50 chunks -> select a chunk -> popup confirmation containing chunk coordinates, element, land tier and buy button -> buy land in a random location of that chunk
  • Tier 3 land - same as tier 2
  • Chunks highlighted on hover
  • Each user can buy only 1 land
  • Only one tier 3 available per chunk
  • Only 1mil total lands can be bought and all tier 3 lands need to be part of that list
  • extra: checkbox in map modal to show chunk population, if enabled highlight chunks in green/yellow/red based on amount of lands sold in the chunk

Up to date map can be found in #lore discord channel.

Added solidity support for feature:

ChunkId = x coordinate + 50 * y coordinate; coordinates started at (0, 0)

BlackSmith:

  • cbkLandSale: reference to the CBKLandSale contract
  • purchaseT1CBKLand(uint256 paying): purchase a tier 1 land
  • purchaseT2CBKLand(uint256 paying, uint16 chunkId): purchase a tier 2 land
  • purchaseT3CBKLand(uint256 paying, uint16 chunkId): purchase a tier 3 land
  • getCBKLandPrice(uint8 tier): gets price of land in wei

CBKLandSale (frontend related functions):

  • salesAllowed(): check if land can be purchased.
  • getAllowedLandOffset(): variable used to check if a chunk can sell T2 land.
  • checkIfChunkAvailable(uint8 tier, uint16 chunkId): check if chunk is available for tier. Should be only called when user selects a chunk for T2 or T3 purchase or before a T1 purchase is requested. If T1 purchase, chunkId is a dummy variable.
  • checkChunkReserved(uint16 chunkId): check if chunk is reserved
  • checkChunkEstimatedPopulation(uint16 chunkId): projected chunk population. Should NOT be called for every chunk. APIs to be added.
  • getAvailableLand(): returns (available T1, available T2, available T3)
  • getAvailableLandPerChunk(): returns available land per chunk
  • getSoldLand(): returns (sold T1, sold T2, sold T3)
  • getPurchase(): returns purchase if any, (purchased tier, chunkId or stamp if T1)

Gas costs for purchase:

  • T1 162269
  • T2 196614
  • T3 205448

Will work on APIs next.
Per Sei and Kroge no APIs, following have been added to be used by FE (zone = 10x10, each zone is 10x10 chunks)

  • getAllZonesPopulation()
  • getZonePopulation(uint16[] memory zoneIds)
  • getZoneChunkPopulation(uint8 zoneId)
  • getChunkPopulation(uint16[] memory chunkIds)

Math
ZoneId = 10 * (chunkId / 1000) + (chunkId % 100) / 10

Code on 739-land-sale and draft PR opened #746

Comment updated with solidity changes

Further testing and possible optimization to be made

Black = Zone
Grey = chunk
image

@KennyUTN you are handling this one right?
If you can't do it please unassign yourself

Is @KennyUTN doing a frontend part of this? Or should I go in and do it, @bilbolPrime ?

@Chriserus I added support for multiple currencies for land sale

Please deploy to a fresh chain when working on front end.
Purchase land now takes and extra parameter, currency (0 for skill, 1 for ExperimentToken). Same for getCBKLandPrice

@Chriserus
Please use getReservedChunksIds to show the reserved chunks. Returns array of chunk ids
Also sale is now disabled by default, you need to enable it if you deploy a fresh chain

Some screenshots, need another pair of eyes to look on it and propose any changes
image
image
image
image

I was thinking about on how to show population, maybe change font or size, show IDs of the chunks. Any remarks appreciated. As of now, it is a working example, I'm starting to refactor everything and optimize stuff

Some minor issues I have noticed on UI:

  • Land buy buttons remain disabled if you switch from an account with a land purchased to an account with no land
  • Zones have a population of 10,000 land not 100. I think just show number of land purchased is enough
  • The player should see the land that he had purchased with whatever information is available (tier, chunk id if available)
  • Also seems UI doesn't support $KING yet

Will be doing more functions today that allow setting of coords

B1 - 13, 2 => 213,214,215,313,314,315,413,414,415
B2 - 42, 2 => 242,243,244,342,343,344,442,443,444
B3 - 3, 9 => 903,904,905,1003,1004,1005,1103,1104,1105
B4 - 64, 15 => 1564,1565,1566,1664,1665,1666,1764,1765,1766
B5 - 90, 13 => 1390,1391,1392,1490,1491,1492,1590,1591,1592
B6 - 28, 15 => 1528,1529,1530,1628,1629,1630,1728,1729,1730
B7 - 17, 22 => 2217,2218,2219,2317,2318,2319,2417,2418,2419
B8 - 54, 23 => 2354,2355,2356,2454,2455,2456,2554,2555,2556
B9 - 82, 25 => 2582,2583,2584,2682,2683,2684,2782,2783,2784
B10 - 91, 22 => 2291,2292,2293,2391,2392,2393,2491,2492,2493
B11 - 20, 33 => 3320,3321,3322,3420,3421,3422,3520,3521,3522
B12 - 32, 34 => 3432,3433,3434,3532,3533,3534,3632,3633,3634
B13 - 73, 32 => 3273,3274,3275,3373,3374,3375,3473,3474,3475
B14 - 3, 39 => 3903,3904,3905,4003,4004,4005,4103,4104,4105
B15 - 84, 41 => 4184,4185,4186,4284,4285,4286,4384,4385,4386
B16 - 17, 53 => 5317,5318,5319,5417,5418,5419,5517,5518,5519
B17 - 69, 59 => 5969,5970,5971,6069,6070,6071,6169,6170,6171
B18 - 49, 64 => 6449,6450,6451,6549,6550,6551,6649,6650,6651
B19 - 89, 65 => 6589,6590,6591,6689,6690,6691,6789,6790,6791
B20 - 35, 66 => 6635,6636,6637,6735,6736,6737,6835,6836,6837
B21 - 5, 73 => 7305,7306,7307,7405,7406,7407,7505,7506,7507
B22 - 15, 72 => 7215,7216,7217,7315,7316,7317,7415,7416,7417
B23 - 72, 75 => 7572,7573,7574,7672,7673,7674,7772,7773,7774
B24 - 82, 74 => 7482,7483,7484,7582,7583,7584,7682,7683,7684
B25 - 31, 81 => 8131,8132,8133,8231,8232,8233,8331,8332,8333
B26 - 49, 82 => 8249,8250,8251,8349,8350,8351,8449,8450,8451
B27 - 92, 85 => 8592,8593,8594,8692,8693,8694,8792,8793,8794
B28 - 23, 92 => 9223,9224,9225,9323,9324,9325,9423,9424,9425
B29 - 73, 90 => 9073,9074,9075,9173,9174,9175,9273,9274,9275
B30 - 89, 92 => 9289,9290,9291,9389,9390,9391,9489,9490,9491
C1 - 26, 4 => 426,427,428,429,526,527,528,529,626,627,628,629,726,727,728,729
C2 - 62, 6 => 662,663,664,665,762,763,764,765,862,863,864,865,962,963,964,965
C3 - 90, 4 => 490,491,492,493,590,591,592,593,690,691,692,693,790,791,792,793
C4 - 8, 19 => 1908,1909,1910,1911,2008,2009,2010,2011,2108,2109,2110,2111,2208,2209,2210,2211
C5 - 70, 21 => 2170,2171,2172,2173,2270,2271,2272,2273,2370,2371,2372,2373,2470,2471,2472,2473
C6 - 27, 25 => 2527,2528,2529,2530,2627,2628,2629,2630,2727,2728,2729,2730,2827,2828,2829,2830
C7 - 42, 32 => 3242,3243,3244,3245,3342,3343,3344,3345,3442,3443,3444,3445,3542,3543,3544,3545
C8 - 63, 31 => 3163,3164,3165,3166,3263,3264,3265,3266,3363,3364,3365,3366,3463,3464,3465,3466
C9 - 88, 33 => 3388,3389,3390,3391,3488,3489,3490,3491,3588,3589,3590,3591,3688,3689,3690,3691
C10 - 16, 42 => 4216,4217,4218,4219,4316,4317,4318,4319,4416,4417,4418,4419,4516,4517,4518,4519
C11 - 61, 45 => 4561,4562,4563,4564,4661,4662,4663,4664,4761,4762,4763,4764,4861,4862,4863,4864
C12 - 3, 53 => 5303,5304,5305,5306,5403,5404,5405,5406,5503,5504,5505,5506,5603,5604,5605,5606
C13 - 50, 56 => 5650,5651,5652,5653,5750,5751,5752,5753,5850,5851,5852,5853,5950,5951,5952,5953
C14 - 92, 56 => 5692,5693,5694,5695,5792,5793,5794,5795,5892,5893,5894,5895,5992,5993,5994,5995
C15 - 26, 68 => 6826,6827,6828,6829,6926,6927,6928,6929,7026,7027,7028,7029,7126,7127,7128,7129
C16 - 77, 67 => 6777,6778,6779,6780,6877,6878,6879,6880,6977,6978,6979,6980,7077,7078,7079,7080
C17 - 9, 85 => 8509,8510,8511,8512,8609,8610,8611,8612,8709,8710,8711,8712,8809,8810,8811,8812
C18 - 39, 84 => 8439,8440,8441,8442,8539,8540,8541,8542,8639,8640,8641,8642,8739,8740,8741,8742
C19 - 90, 76 => 7690,7691,7692,7693,7790,7791,7792,7793,7890,7891,7892,7893,7990,7991,7992,7993
C20 - 61, 90 => 9061,9062,9063,9064,9161,9162,9163,9164,9261,9262,9263,9264,9361,9362,9363,9364
D1 - 73, 4 => 473,474,475,476,477,573,574,575,576,577,673,674,675,676,677,773,774,775,776,777,873,874,875,876,877
D2 - 53, 12 => 1253,1254,1255,1256,1257,1353,1354,1355,1356,1357,1453,1454,1455,1456,1457,1553,1554,1555,1556,1557,1653,1654,1655,1656,1657
D3 - 38, 17 => 1738,1739,1740,1741,1742,1838,1839,1840,1841,1842,1938,1939,1940,1941,1942,2038,2039,2040,2041,2042,2138,2139,2140,2141,2142
D4 - 29, 42 => 4229,4230,4231,4232,4233,4329,4330,4331,4332,4333,4429,4430,4431,4432,4433,4529,4530,4531,4532,4533,4629,4630,4631,4632,4633
D5 - 68, 39 => 3968,3969,3970,3971,3972,4068,4069,4070,4071,4072,4168,4169,4170,4171,4172,4268,4269,4270,4271,4272,4368,4369,4370,4371,4372
D6 - 25, 55 => 5525,5526,5527,5528,5529,5625,5626,5627,5628,5629,5725,5726,5727,5728,5729,5825,5826,5827,5828,5829,5925,5926,5927,5928,5929
D7 - 78, 54 => 5478,5479,5480,5481,5482,5578,5579,5580,5581,5582,5678,5679,5680,5681,5682,5778,5779,5780,5781,5782,5878,5879,5880,5881,5882
D8 - 9,63 => 6309,6310,6311,6312,6313,6409,6410,6411,6412,6413,6509,6510,6511,6512,6513,6609,6610,6611,6612,6613,6709,6710,6711,6712,6713
D9 - 43, 70 => 7043,7044,7045,7046,7047,7143,7144,7145,7146,7147,7243,7244,7245,7246,7247,7343,7344,7345,7346,7347,7443,7444,7445,7446,7447
D10 - 62, 79 => 7962,7963,7964,7965,7966,8062,8063,8064,8065,8066,8162,8163,8164,8165,8166,8262,8263,8264,8265,8266,8362,8363,8364,8365,8366
E1- 15, 11 => 1115,1116,1117,1118,1119,1120,1215,1216,1217,1218,1219,1220,1315,1316,1317,1318,1319,1320,1415,1416,1417,1418,1419,1420,1515,1516,1517,1518,1519,1520,1615,1616,1617,1618,1619,1620
E2 - 79, 13 => 1379,1380,1381,1382,1383,1384,1479,1480,1481,1482,1483,1484,1579,1580,1581,1582,1583,1584,1679,1680,1681,1682,1683,1684,1779,1780,1781,1782,1783,1784,1879,1880,1881,1882,1883,1884
E3 - 7, 28 => 2807,2808,2809,2810,2811,2812,2907,2908,2909,2910,2911,2912,3007,3008,3009,3010,3011,3012,3107,3108,3109,3110,3111,3112,3207,3208,3209,3210,3211,3212,3307,3308,3309,3310,3311,3312
E4 - 53, 33 => 3353,3354,3355,3356,3357,3358,3453,3454,3455,3456,3457,3458,3553,3554,3555,3556,3557,3558,3653,3654,3655,3656,3657,3658,3753,3754,3755,3756,3757,3758,3853,3854,3855,3856,3857,3858
E5 - 39, 40 => 4039,4040,4041,4042,4043,4044,4139,4140,4141,4142,4143,4144,4239,4240,4241,4242,4243,4244,4339,4340,4341,4342,4343,4344,4439,4440,4441,4442,4443,4444,4539,4540,4541,4542,4543,4544
E6 - 37, 55 => 5537,5538,5539,5540,5541,5542,5637,5638,5639,5640,5641,5642,5737,5738,5739,5740,5741,5742,5837,5838,5839,5840,5841,5842,5937,5938,5939,5940,5941,5942,6037,6038,6039,6040,6041,6042
E7 - 59, 51 => 5159,5160,5161,5162,5163,5164,5259,5260,5261,5262,5263,5264,5359,5360,5361,5362,5363,5364,5459,5460,5461,5462,5463,5464,5559,5560,5561,5562,5563,5564,5659,5660,5661,5662,5663,5664
E8 - 92, 68 => 6892,6893,6894,6895,6896,6897,6992,6993,6994,6995,6996,6997,7092,7093,7094,7095,7096,7097,7192,7193,7194,7195,7196,7197,7292,7293,7294,7295,7296,7297,7392,7393,7394,7395,7396,7397
E9 - 18, 78 => 7818,7819,7820,7821,7822,7823,7918,7919,7920,7921,7922,7923,8018,8019,8020,8021,8022,8023,8118,8119,8120,8121,8122,8123,8218,8219,8220,8221,8222,8223,8318,8319,8320,8321,8322,8323
E10 - 80, 82 => 8280,8281,8282,8283,8284,8285,8380,8381,8382,8383,8384,8385,8480,8481,8482,8483,8484,8485,8580,8581,8582,8583,8584,8585,8680,8681,8682,8683,8684,8685,8780,8781,8782,8783,8784,8785

@Chriserus

getTakenT3Chunks returns T3 land that is already taken. UI shouldn't allow them to be picked (low priority)

For claiming land:

  • getPlayerReservedLand returns ([t2 reservations], [t3 reservations])
  • getChunksOfReservations returns [chunk ids of reservation]
  • claimPlayerReservedLand claims a reservation

Need remarks here! Under every screenshot you can find description for it
image
Land claiming. Here, the user gets to choose reservation of tier 2 from 8 available chunks and of tier 2 from 8 available chunks. Numbers are the same, but reservations are different ofc. The option to choose tier2 shows up only when it's available, same for tier3. You can also see currency dropdown in the upper side, and on the lower side there is a section that shows up then user has land (either purchased, or claimed).
image
Land claiming -> the only active zones are the ones user has available chunks to choose from, others are inactive
image
Same as above, choose available chunk and claim it (on claim, the popups close and info about owned lands refreshes, so that the user can see that he claimed land with chunkId x and tier y)
image
Before land purchase
image
After land purchase. User is presented with info saying he can only purchase one land, info about purchased land (not claimed, only the purchased one), buttons are disabled for purchases
image
When you change currency to KING this is how it shows up

@Chriserus we have a new type of claimable land; a land which was minted but doesn't have a chunkid assigned yet

The get inside NFTLand contract has been extended to return reseller address
function get(uint256 id) public view returns (uint256, uint256, uint256, uint256, address)

Also a function has been introduced to CBKLandSale to change chunkId
function changeLandChunkId(uint256 landId, uint256 assignedChunkid)

You can use the existing function to get available chunks
function getChunksOfReseller(address reservedFor)

You can tell a land can claim a chunk if it has a reseller and chunkId 0.
The flow would be as follows:

  • Get land data
  • Get chunk ids reserved for the reseller returned by the get
  • Allow the user to pick a chunk (if T2 or T3); 1 T3 per chunk still applies.
  • Call changeLandChunkId with landId and selected chunk (for T1 the selected chunk id should be sent as 0)

By when should we have it live? Do we have any date? As I committed to CBK Landing Page work and will continue to work on it on Monday

I think this can wait some days as they would get the NFT from sale. We will ask in tomorrow's meeting.

@bilbolPrime @Chriserus Should this be closed? No updates since October.

In my opinion yes, but @kcper was the one creating the ticket

Land sale completed. Close