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. ImageImage
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 Image
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. Image
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 ImageImageImage
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! Image
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. ImageImage
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. ImageImageImage
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 ImageImageImageImage
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. ImageImage
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. ImageImage
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. Image
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. Image
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 Image
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. Image
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! Image
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

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Steve in Crypto

Steve in Crypto Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @steveincrypto

5 Oct
Contract idea thread! 🤔

What do you think of a contract that is like an Aave but just for gold and materials?

You can deposit the gold and materials at the "vault", then if you enable it as collateral, can earn a yield on it based on the amount borrowed.
Since the gold and materials have to be owned by a hero (summoner), I was thinking that in the contract, you could have multiple summoners as "receivers".

These receivers are basically the UI-specific accounts that any UI would select when their users make deposits.
This way, there's no ambiguity on which UI owns what, and we all have access to our own heroes. No multi-sig is required.

When interacting with the contract, the UI only interfaces with their summoner of course.
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(