Minecolonies & Fixing the Barbarian Mess

in #utopian-io6 years ago (edited)

Hey everyone, it has been quiet for quite some time since University took a heavy load on me, I'm slowly recovering and was able to fix some things in our code in the last week.

Until now all our barbarians spawned randomly depending on a value.
Therefore, if you wanted to have them spawn averagely every 3rd night they might also spawn 3 nights in a row (Not with a high probability, but possible).

Therefore, I added a minimum config option.

And then, inside the colony, I store the amount of nights.
Increment it each night.
And added some getters and setters.

Then, I check when we calculate the raid, if the minimum nights have passed already.

And, obviously, when we raid will reset this variable.


Additionally, our barbarian spawn code was a bad mess.
One of our coders calculated the amount of barbarians in one method, stored it in a static variable and accessed it in the other method.

While this is possible, it is error prone and extremely bad style.

Therefore, I created a Horde class which represents a raid.

Then, I create this Horde when we calculate the numbers and do not store it in a static variable. I return the horde (Object Oriented Programming ftw).

After that, when we call it, I just check for the Horde and store it in a local variable.

And afterwards just access the data where I need it.
Cleaner and less error prone for sure.


Besides that, I colored the horde arrival messages so players notice them in a full chat and decreased the drop rates of the items.

I also fixed the delete command after a recent command update.
I changed some comment variables to optional and took configuration values for it and added feedback on colony claiming (command execution).



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

Hi, please remove the paragraph about Minnowbooster at the end of your contribution.

You can contact us on Discord.
[utopian-moderator]

Hey @amosbastian, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

a very interesting work of writing, you are a great writer.

Hello,
I'm a bot. I am here because @wil1liam wanted to know how high this post is in Hot or Trending.

You want to know what your post's rank in Hot or Trending is?

1. copy your Steemit.com post url
2. send 0.001 SBD/STEEM to @trendchecker with the url as the memo
3. wait 20 seconds to receive the results in your wallet

As a gift your post will be upvoted for free!


- This bot was development by @wil1liam.

I am going to try to sell my vote to the next stage, so my vote is higher. I think minnowboster that fit in this field. Thank you for your invitation and information friends!!! @raycoms

good logic for those lines, I'm a bit rusty in my level of programmer, but I will resume my career, a real challenge in this world!

Hey @raycoms I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.029
BTC 63725.17
ETH 2619.74
USDT 1.00
SBD 2.82