Add: Companies with goals.

This commit is contained in:
Alberth
2014-12-28 15:15:09 +01:00
parent 32bdd042e0
commit 92a346e929
2 changed files with 144 additions and 24 deletions

35
company.nut Normal file
View File

@@ -0,0 +1,35 @@
// Company related data.
class CompanyData {
cid = null;
active_goals = {};
constructor(cid) {
this.cid = cid;
for (local num = 0; num < 5; num += 1) this.active_goals[num] <- null;
}
function GetMissingGoalCount();
function AddActiveGoal(cargo_id, accept, amount);
};
function CompanyData::GetMissingGoalCount()
{
local missing = 0;
foreach (num, goal in this.active_goals) {
if (goal == null) missing += 1;
}
return missing;
}
function CompanyData::AddActiveGoal(cargo_id, accept, amount)
{
foreach (num, goal in this.active_goals) {
if (goal == null) {
this.active_goals[num] = {cid=cargo_id, accept=accept, amount=amount};
break;
}
}
}