Skip to content
Snippets Groups Projects
Commit fa3229df authored by echicken's avatar echicken
Browse files

Initial loan must be repayed at the end of Day 1 of the player's first week.

Rent is collected every four weeks.
parent f119d42c
No related branches found
No related tags found
No related merge requests found
......@@ -16,4 +16,6 @@ reportCost = 50
; Cost of a 'unit' of water
waterCost = 0.05
; Cost of electricity per day
electricityCost = 4
\ No newline at end of file
electricityCost = 4
; Cost of rent per four "weeks"
rentCost = 400
\ No newline at end of file
......@@ -10,6 +10,8 @@ var makePlayer = function() {
'money' : gameSettings.startingFunds,
'day' : 1,
'week' : gameSettings.week,
'weeks' : 1,
'lastRentPayment' : 0,
'marketReport' : 0,
'inventory' : {},
'products' : {}
......@@ -49,6 +51,7 @@ var getPlayer = function() {
jsonClient.push("THIRSTY", "THIRSTY.NEWS", message, 2);
} else if(player.week != gameSettings.week) {
player.week = gameSettings.week;
player.weeks++;
player.day = 1;
} else {
return player;
......
......@@ -66,6 +66,7 @@ var dataInit = function() {
'reportCost' : parseInt(gameIni.reportCost),
'waterCost' : parseFloat(gameIni.waterCost),
'electricityCost' : parseFloat(gameIni.electricityCost),
'rentCost' : parseFloat(gameIni.rentCost),
'week' : 1
};
var newsItem = [{
......@@ -597,6 +598,30 @@ var playTurn = function() {
putNews(report);
jsonClient.push("THIRSTY", "THIRSTY.NEWS", message, 2);
if(player.day == 1 && player.weeks == 1) {
player.money = player.money - gameSettings.startingFunds;
putNews(
"The bank collected on its $" + gameSettings.startingFunds + " loan.",
LIGHTRED
);
}
if(player.weeks % 4 == 0) {
while(player.lastRentPayment < player.weeks) {
player.lastRentPayment = player.lastRentPayment + 4;
player.money = player.money - gameSettings.rentCost;
putNews(
format(
"Your landlord collected $%s in rent for month %s.",
gameSettings.rentCost, player.lastRentPayment
),
LIGHTRED
);
if(player.money < 0)
break;
}
}
player.day++;
jsonClient.write("THIRSTY", "THIRSTY.PLAYERS." + playerID, player, 2);
if(player.money <= 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment