Minecolonies & You have Mail!

in #utopian-io6 years ago

Hi everyone, exciting news in a collaborative effort we finally finished our crafting request system and can finally start building new things on top of that (the subject of the following posts).
Since I worked with this with another person I decided not to make a post about it since it would a) Become way too huge and b) A lot of work is mine, his, and all is entangled together so some parts are difficult to explain as well.
Nonetheless, this is the first feature we released based on this which is also going to allow us to test the workers nicely.

The PostBox:

It's a nice box designed by one of our graphic artists.
It allows the player to request any block to his colony which the deliveryman would deliver and the crafter's craft on demand.

In that, it has a nice GUI which allows the player to select the block from a list of blocks.

The request then displays on the right-hand side so they can follow it through.

The code:

As always, everything starts with the new block.

Continuing with adding them to the modblock class.

Setting up the custom inventory model.

Creating the building:

Registering the building:

Making sure it does not get loaded as other buildings with an actual building around it.

Then, added a method to the building view to get all requests of the building and not only the ones of a particular citizen.

But, it wouldn't be my PR if there wouldn't be a good bunch of refactoring involved.

That's why I extracted all the citizen window request code into an abstract class.

Which has a bunch of overridable methods when needed.

The citizen would just override the first one of them to request by a citizen and not by building.

And would override the fulfill methods to allow to fulfill requests to the citizen.

The window for the postbox wouldn't have to.

Since it only needs a button to create the request.
Where it would first extract the row of the stack to get the itemStack, then iterate through the children until it finds the quantity input field and assign the quantity to it and then execute the request message.

Creating the message which registers on the server side the request of the postbox.

Register message:

The message would then create a "-1 request" which is not assigned to any citizen but directly to the building.
Which allows us to request things by buildings and not only by citizens.

Fixes:

Besides that, it helped us to find a few bugs, for once the request system did not load from NBT as it should since there was a small issue in the loading code.

Barbarians were not breaking through doors:

Having all our buildings display their type above them by using their translation key.

Deliveryman only extracts the quantity he needs from the warehouse and not one stack.

Where I made a util method which exactly transfers a certain quantity over.

and then changed the method he uses for a custom method which calls this transfer method.

Also, added a canBeGathered method to the buildings where the dman can call that instead of having to know individually the types.

Also added the "prevWindow" variable to the detailed request view which makes it more modular and easier to transfer back to it.

So that, on button click, it wouldn't have to decide between the types but just open the previous window.

Repository:

https://github.com/ldtteam/minecolonies

Pull Request:

https://github.com/ldtteam/minecolonies/pull/3236

Sort:  

Thank you for your contribution. As always post is of very high quality where you have explained it very well. This contribution adds significant value to the project with such a high-quality code. I really like the way you comment, the functions are self-explanatory because of that.


If you would like further explanation of the given score, please ask.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

I feel like I am getting better in writing smaller functions =D

Thank you for your review, @codingdefined! Keep up the good work!

ǝɹǝɥ sɐʍ ɹoʇɐɹnƆ pɐW ǝɥ┴

Hi @raycoms!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hello, we are a small group of developers who want to develop the next big game for Steem.
If you are interested, just have a look at our page! @wod-game

Hello, we are a small group of developers who want to develop the next big game for Steem.
If you are interested, just have a look at our page! @wod-game

Hey, @raycoms!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Hi, @raycoms!

You just got a 10.3% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 57684.49
ETH 2343.76
USDT 1.00
SBD 2.36