Welcome to "CodeYourRestaurant"

First steps Back to portal
You borrowed $50,000 from a bank to open your own restaurant. After one year you need to pay back $55,000 and since nobody is lending you more money, you need to make sure that you never spend (or try to spend) more money as you possess. So it is time to see how to make some money.

You need to write JavaScript code to run your restaurant. The only variable you get from the engine is called "company" and is an instance of the class Company.

All you need to do is implement 7 functions, which are getting called for: Let's have a look how this looks like. First we need to set up our menu. Let's do that on the launch event.

company.launch = function() {
	company.menu.add("Kebab", ["CHICKEN_MEAT", "BREAD"], 3);	
};

As we see the company class has a menu property which could be used to add, remove or list our menu entries. We add a simple Chicken Kebab with nothing than meat and bread for $3.
If you want to create other meals, these are the available ingredients: SALAD, TOMATO, ONION, BREAD, LAMB_MEAT, CHICKEN_MEAT, BEEF_MEAT, CABBAGE, SPICES, GARLIC_SAUCE.

Next we need to rent a restaurant. Let's implement the realEstateAgent event:

company.realEstateAgent = function(realEstateProfiles) {
	if(company.establishments.size() < 1) {
		realEstateProfiles.get(0).tryLease(0);
	}
};

Since we only want to rent one restaurant, we check for the establishments property in our company class. Then we get the first element from real estate offers and try to lease it. The parameter value 0 stands for "we don't want to bribe the real estate agent or the landlord", but if you do so you increase your chances if there are competing offers.
Since other players may do the same it is not sure that we get this property. Anyhow if we don't get it, the engine will perform a second round and we'll get what's left at this point in time. It repeats as often as people try to get restaurants or all offerings are rented or bought.

As we now have a restaurant we also need employees. At least a chef and a waiter. So we implement the humanResources' hiringProcess event:

company.humanResources.hiringProcess = function(applicationProfiles) {    
	if (company.humanResources.getEmployees("WAITER").size() < 1) {
		applicationProfiles.subList("WAITER").get(0).offer(
			company.establishments.get(0));
	}
	if (company.humanResources.getEmployees("CHEF").size() < 1) {
		applicationProfiles.subList("CHEF").get(0).offer(
			company.establishments.get(0));
	}
};

We only want 1 chef and 1 waiter, so we check our human resources department for the employees list for chefs/waiters and if we haven't hired anybody for that role, we filter the profiles for the certain role, sort by salary and make an offer to the first person. We offer the salary they desire. You could also offer more or less than expected - that increases or decreases your chances to get this person.

So far so good, but even the simplest restaurant needs a counter to serve food. So we will buy a counter for our restaurant, but only one:

company.doMonthly = function() {
	if(company.establishments.size()==1) {
		company.establishments.get(0).buyInteriorAccessoriesNotExist("COUNTER");
	}	
};

If you want to buy other interiors you can choose between: TABLE, CHAIR, COUNTER, VERTICAL_ROTISSERIE, TOASTER, OVEN, COFFEE_MACHINE, BEVERAGE_COOLER, FRIDGE.

Since we want to serve food we need to buy ingredients according to our menu. We only have a super simple Chicken Kebab, so we buy chicken meat and bread.
Let's implement it in the day event:

company.doDaily = function(dailyStatistics) {
	company.grocer.order("CHICKEN_MEAT", 100);
	company.grocer.order("BREAD", 100);	
};

Our company has a reference to a grocer we trust and there we're able to order 100 units of chicken and 100 units of bread. Our Kebab uses one of each ingredient, so we could sell 100 Kebabs per day. You should also be aware of that roughly 100 people per participating player want to have Kebab per day. However we need to keep in mind that food decays over time, so whatever we buy it gets rotten after 10 days on the other hand will you get a discount if you buy larger numbers of food.

As a final step we need to distribute our food delivery. As we only have one restaurant that is fairly simple:

company.foodDelivery = function(foodDelivery) {
	foodDelivery.each(function(foodUnit) {
		foodUnit.distributeEqually();
	});
};


Now we are good to open our restaurant. Hit the save and check button, to verify that it runs without any errors and exceptions.

In the next global run of the game, you're restaurant will participate and we can see how well it competes.

You can use console.log("..."); in your script to output debug information.

For future optimizations of your restaurant, you probably want to browse the API documentation or the FAQ, anyhow here are some first ideas you might want to follow: