public override bool Apply(Project p, Worker w) { if (Event.random.NextDouble() <= chance) { Triggered(p, w); return true; } return false; }
/// <summary> /// This method decides whether to apply the event to this worker, /// based on worker, environment, and external factors. /// </summary> /// <param name="w"></param> /// <returns></returns> public virtual bool Apply(Project p, Worker w) { return false; }
public abstract void Triggered(Project p, Worker w);
public override void Triggered(Project p, Worker w) { w.currentCapability *= effect; p.log.Add("Worker " + w.name + " was " + logline + " on day " + p.stepsTaken + "."); }
public override void Triggered(Project p, Worker w) { w.currentCapability *= effect; int left = 0; if (affected.ContainsKey(w)) left = affected[w].daysLeft; left = length - left; p.log.Add("Worker " + w.name + " was " + logline + " (" + left + "/" + length + ") on day " + p.stepsTaken + "."); }
public override bool Apply(Project p, Worker w) { // we check first whether this worker is already affected if (affected.ContainsKey(w)) { Memo memo = affected[w]; memo.daysLeft--; if (memo.daysLeft <= 0) affected.Remove(w); Triggered(p, w); } else if (Event.random.NextDouble() <= chance) { int leave = length - 1; affected.Add(w, new Memo(leave)); Triggered(p, w); return true; } return false; }