-
Notifications
You must be signed in to change notification settings - Fork 10
Policy
Sriep edited this page Aug 6, 2016
·
13 revisions
Policies are code snippets that are run each tick. The code that handels the economy of each room is a policy. This where user code can be put.
In the main method we call
policy.enactPolicies();
If we look at policy.enactPolicies()
enactPolicies: function()
{
this.checkRoomPolicies();
for (var i in Memory.policies) {
var oldPolicyModule = this.getModuleFromPolicy(Memory.policies[i]);
var newPolicyDetails = oldPolicyModule.draftNewPolicyId(Memory.policies[i]);
if (newPolicyDetails === null) {
delete Memory.policies[i];
} else if ( newPolicyDetails.id != Memory.policies[i].id) {
var newPolicyModule = this.getModuleFromPolicy(newPolicyDetails);
this.activatePolicy(newPolicyDetails);
newPolicyModule.switchPolicy(Memory.policies[i], newPolicyDetails);
delete Memory.policies[i];
newPolicyModule.enactPolicy(newPolicyDetails);
} else {
oldPolicyModule.enactPolicy(Memory.policies[i]);
}
}
},
Details of all policies are storted in Memory.polices.