Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Budget test tucker #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions src/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class Game{
this.money = 10000; // starting budget

// Scoring
this.polling = 0.3251243124; // TODO calculate this somewhere
this.polling = 0.1;
this.month = 0;
this.lastMonth = 0; // updated when calculateBudget() is called
this.lastMonth = 0;

// Background
this.backgroundImage = null;
Expand Down Expand Up @@ -79,27 +79,35 @@ class Game{
}
calculateBudget(selectedIDs) {
if (this.month <= this.lastMonth) return;
let months = this.month - this.lastMonth;
for (let i in selectedIDs) {
this.money += MoneyData["BudgetItems"][selectedIDs[i]]["MOCOST"]*months;
//let months = this.month - this.lastMonth;
// for (let i in selectedIDs) {
// this.money += (MoneyData["BudgetItems"][selectedIDs[i]]["MOCOST"]*months)+;
// }
// this.lastMonth = this.month;

var PollMod = 0;

for (var i = 0; i < selectedIDs.length; i++){
if (budget_ledger["BudgetItems"][i].ID = selectedIDs[i]) {
budget_ledger.LedgerItems.push({
"EntryName": budget_ledger["BudgetItems"][i]["NAME"],
"Value": (budget_ledger["BudgetItems"][i]["MOCOST"] + budget_ledger["BudgetItems"][i]["MINC"]),
"MONTH":this.month,
"MOD": budget_ledger["BudgetItems"][i]["MOD"]
});
PollMod += budget_ledger["BudgetItems"][i]["MOD"];
this.polling += (this.polling*PollMod);
}
}
this.lastMonth = this.month;
var CashFlow = budget_ledger.LedgerItems;
this.money = 0;

for (i = 0; i < CashFlow.length; i++) {
this.money += CashFlow[i].Value;
}


// for (var i = 0; i < selectedIDs.length; i++){
// if (budget_ledger["BudgetItems"][i].ID = selectedIDs[i]) {
// budget_ledger.LedgerItems.push({
// "EntryName": budget_ledger["BudgetItems"][i]["NAME"],
// "Value": (budget_ledger["BudgetItems"][i]["MOCOST"] == 0) ? budget_ledger["BudgetItems"][i]["INITCOST"]:budget_ledger["BudgetItems"][i]["MOCOST"],
// "MONTH":month,
// "MOD": budget_ledger["BudgetItems"][i]["MOD"]
// });
// }
// }
// var CashFlow = budget_ledger.LedgerItems;
// this.money = 0;

// for (i = 0; i < CashFlow.length; i++) {
// this.money += CashFlow[i].Value }
}
handleClick(x,y){
this.lastClickX = x;
Expand Down
14 changes: 7 additions & 7 deletions src/js/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let MoneyData = {
"BudgetItems": [
{
"NAME": "Campaign Manager",
"MOD": 0.2,
"MOD": 0.02,
"INITCOST": 0,
"MOCOST": -2000,
"MINC": 2300,
Expand All @@ -11,9 +11,9 @@ let MoneyData = {
},
{
"NAME": "Graphic Designer",
"MOD": 0.1,
"INITCOST": -2000,
"MOCOST": 0,
"MOD": 0.01,
"INITCOST": 0,
"MOCOST": -200,
"MINC": 400,
"MEFF": 0,
"ID": 1
Expand All @@ -29,7 +29,7 @@ let MoneyData = {
},
{
"NAME": "Volunteer Coordinator",
"MOD": 0.3,
"MOD": 0.03,
"INITCOST": 0,
"MOCOST": -800,
"MINC": 800,
Expand All @@ -38,7 +38,7 @@ let MoneyData = {
},
{
"NAME": "Literature/Digital",
"MOD": 0.3,
"MOD": 0.03,
"INITCOST": 0,
"MOCOST": -3000,
"MINC": 1000,
Expand All @@ -47,7 +47,7 @@ let MoneyData = {
},
{
"NAME": "Other Media",
"MOD": 0.2,
"MOD": 0.02,
"INITCOST": 0,
"MOCOST": -3000,
"MINC": 0,
Expand Down
Empty file added src/js/voters.js
Empty file.