Dishorde icon indicating copy to clipboard operation
Dishorde copied to clipboard

7dtd!time should display a different message when it is currently a horde night

Open LakeYS opened this issue 6 years ago • 1 comments

Currently says "7 days to next horde" on the night of a horde ("6 days" when past midnight in-game)

User-contributed code (Have not yet reviewed):

function handleTime(line, msg) {
    const messageValues = line.split(',');
    const day = parseInt(messageValues[0].replace('Day ', ''));
    const hour = parseInt(messageValues[1].split(':')[0]);
    let dayHorde = day % 7;
    let resp = ``;

    if (dayHorde === 0 && hour < 22) {
        resp = `The horde comes tonight!`;
    } else if (dayHorde === 0 && hour >= 22 || dayHorde === 6 && hour < 22) {
        resp = `The horde is rampaging now!`;
    } else if (dayHorde !== 0) {
        dayHorde = 7 - dayHorde;
        resp = `${dayHorde} day${dayHorde === 1 ? `` : `s`} to next horde.`;
    }

    msg.channel.send(`${line}\n${resp}`);
    Telnet.exec(`say "${line} ${resp}"`);
}

LakeYS avatar Apr 10 '18 22:04 LakeYS

The previous user contributed code works, but if you want to add the ability to easily change the Horde night frequency you can use this:

function handleTime(line, msg) {
  const messageValues = line.split(',');
  const day = parseInt(messageValues[0].replace('Day ', ''));
  const hour = parseInt(messageValues[1].split(':')[0]);
  let dayHorde = day % parseInt(config.hordefrequency);
  let resp = ``;

  if (dayHorde === 0 && hour < 22) {
      resp = `The horde comes tonight!`;
  } else if (dayHorde === 0 && hour >= 22 || dayHorde === 6 && hour < 22) {
      resp = `The horde is rampaging now!`;
  } else if (dayHorde !== 0) {
      dayHorde = parseInt(config.hordefrequency) - dayHorde;
      resp = `${dayHorde} day${dayHorde === 1 ? `` : `s`} to next horde.`;
  }

And add this definition to config.json "hordefrequency": "7"

cjakesmith avatar Mar 28 '21 06:03 cjakesmith

Done in 7991e7a

LakeYS avatar Feb 11 '23 06:02 LakeYS