Steve in Crypto Profile picture
UI's are my 🔥 P2E on Fantom with https://t.co/yUMBO9ZulZ Vertcoin mining pool with https://t.co/04rw2FBTSR

Oct 2, 2021, 21 tweets

Curious on how The Cellar works in #rarity? At raritymmo.com, you can send your heroes into the dungeon to earn crafting materials, but some don't earn anything. Why?

Let's find out.👇

For this deep dive, we're going to use my faithful Paladin. He's level 3 with 16 strength, 8 dexterity, and 18 Constitution.

More on why this is important in a bit.

First things first, let's make sure we're looking at the right contract. 😅

ftmscan.com/address/0x2a0f…

The scouting function on line 124 is what dictates the rewards for each hero (or summoner) that you send in.

What goes into the calculation for each hero?

1. Level (this means as you level up, your hero may get more rewards)
2. Class (some classes are better suited for the Cellar than others)
3. Attributes - Strength, Dexterity and Constitution

Now that we have the "variables" to the function, we move on to the good stuff; starting with getting your hero's health.

The class, level, and constitution attribute is needed for this.

We're taken to another function for calculating your hero's health. The modifier_for_attribute(_const) is asking, what's the "modifier" for your Paladin with 18 Constitution? (line 96)

Answer: 4

Going next to the health_by_class function on line 31, we can see that my Paladin (class #7) health base is 10.

My modifier was 4, right? Base health is 10 plus the modifier (4), so 14. Finally, multiply by the level (3) and we have 42 health!

We now know my Paladin's health is 42. Next, what's the dungeon's health? That's just a constant (or static) number in the contract on line 25.

Health is 10, and we going to need the dungeon damage (2), to hit (3) and armor class (2) too, so remember those.

Next up, what's my Paladin's damage? Another function on line 111

The damage function checks if your strength modifier is less than or equal to 1. If so, your damage is 1. If not, it's the modifier.

Since my modifier is 3, my damage is 3.

Next! Ooo, attack bonus. That function needs my class, strength, and level. My attack (line 66) is needed to calculate my base attack bonus (line 92).

Level 3 * 4 attack / 4 = 3

Next line 103...

Base attack bonus + the strength modifier (3) = 6 for attack bonus

Where are we so far?

Paladin Health: 42
Dungeon Health: 14
Damage: 3
Attack bonus: 6

(hope you're taking notes!) 😅

Next up, line 132 in the scout function. This is true/false and asks if my attack bonus is large enough to hit the dungeon.

Line 107 tells us that and is simply checking if my attack bonus is larger than the dungeon armor class (2).

My attack bonus is 6, so we're good here.

Scout, line 133 is another true/false. Can the dungeon hit my paladin? Dexterity comes into play here, and we need the modifier. Since my dexterity is 8, my modifier is -1. 💀

Back to line 133. Is -1 less than the dungeons to_hit (line 27, which is 3). It sure is.

So we know the dungeon can hit my Paladin back, and my Paladin's health (42) AND the dungeon's health (10) come into play.

Finally! The reward calculation on line 134. Notice this is an IF statement, meaning if I can't hit the dungeon, I get zero rewards.

This is precisely why some heroes don't get any rewards. The dungeon is 💪 and they are simply not hitting hard enough. It's not their fault, more push-ups maybe?

Assuming your hero can hit the dungeon, we start with a reward of 10 (this is the max reward!) and start a loop.

You begin with 10 rewards, and we loop through this "for" loop until we either defeat the dungeon or lose all health.

My paladin has 42 health, and my damage was 3. The dungeon's damage is 2 (line 26).

Loop #1
Reward: 10
Dungeon health: 10 - 3 = 7
Paladin Health: 42 - 2 = 40

Loop #2
Rewards Remaining: 10 - 1 = 9
Dungeon Health: 7 - 3 = 4
Paladin Health: 40 - 2 = 38

We have to keep going until the dungeon has zero health or my paladin has zero health.

Loop #3
Rewards Remaining: 9 - 1 = 8
Dungeon Health: 4 - 3 = 1 (almost!)
Paladin Health: 38 - 2 = 36 (what a beast)

Loop #4 (the end)
Rewards Remaining: 8 - 1 = 7
Dungeon Health: 1 - 3 = -2 💀

Paladin Health doesn't matter, since the dungeon is dead, we exit the loop and we get rewards!

My Paladin earns 7 crafting materials. 🥳

So what did we learn?

1. Having health is useful, but you just have to outlast the dungeon. Don't go crazy on Constitution.
2. Strength is super useful to lay the smackdown.
3. With enough dexterity, the dungeon can't hit you. 👀

4. If you can hit the dungeon for 10, you can earn the full 10 rewards. (headshot!)
5. My paladin has WAY too much health.
6. If you're still with me, we're now best friends.

Enjoy deep dives like this? Let me know!

Tootles! 👋

#rarity @AndreCronjeTech

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling