First off this is just to figure this stuff out.
I took the example and edited it to what I thought would work, and its breaking my game.
I do not take credit for any of this just trying to figure it out.
DT.addEvent = function () {
var eventId = "F413351X-2108-4967-A989-A7E98D4DEED5";//Has to be globally unique
var myRandomEvent = {
id: eventId,
isRandom: false, // For testing
maxTriggers: 1,
trigger: function (company) {
//Happens right away.
//I understand the use isGameProgressBetween
return company.currentLevel == 1 && company.isGameProgressBetween(0.2, 0.9);
},
//Dynamics == getNotification
getNotification: function (company) {
var game = company.currentGame;
var msg = "Your grandmother Passed away and left you 10million dollars"
.localize().format(game.title);
// {n} break up texts.
//event generates cash and rp
//instantly add cash adjustcash() or addcash ?
company.addcash(500 + 500 * company.getRandom());//increase hype between 5 and 15.
return new Notification({
sourceId: eventId,//continue on to test multiple selections
header: "at the funeral".localize(),//text to match event
text: msg,
options: ["Thanks Grandma".localize(), //currently only one choice.
});
},
complete: function (decision) {
//decision is a number and will correspond to the index of the option that was chosen.
//0=talk to parents, 1=ignore incident, 2=invite over
//it's best if every decision has a different outcome (kept this here for my future reference
var company = GameManager.company;//we fetch the company object for use later.
if (decision === 0) {//select event
//The notification edited to one choice.
var n = new Notification({
header: "Funeral".localize(), //msg header
text: "Thanks Grandma".localize()
});
n.addCash(100000000 + 100000000 * company.getRandom()),//increase cash? correct usage?
n.addResearchPoints(1000+4000 * company.getrandom()), //increase rp? correct usage?
company.activeNotifications.addRange(n.split()); //since this notificaton should be shown immediately (not one second later) we insert it into activeNotifications. calling .split() ist just good practice in case we use {n} inside the notification.
return;
}
}
};