All files / src/lib/events eventLinkTransfer.js

100% Statements 10/10
100% Branches 2/2
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 931x   1x 1x       1x                                                                                                                                 1x 2x 2x 1x   1x               1x              
const l10n = require("../helpers/l10n").default;
 
const id = "EVENT_LINK_TRANSFER";
const subGroups = {
  EVENT_GROUP_MISC: "EVENT_GROUP_MULTIPLAYER",
};
 
const fields = [
  {
    key: "sendVariable",
    label: l10n("FIELD_SEND_VARIABLE"),
    description: l10n("FIELD_LINK_TRANSFER_SEND_VARIABLE_DESC"),
    type: "variable",
    defaultValue: "LAST_VARIABLE",
    conditions: [
      {
        key: "size",
        eq: 1,
      },
    ],
  },
  {
    key: "receiveVariable",
    label: l10n("FIELD_RECEIVE_VARIABLE"),
    description: l10n("FIELD_LINK_TRANSFER_RECEIVE_VARIABLE_DESC"),
    type: "variable",
    defaultValue: "LAST_VARIABLE",
    conditions: [
      {
        key: "size",
        eq: 1,
      },
    ],
  },
  {
    key: "sendVariableArray",
    label: l10n("FIELD_SEND_VARIABLE"),
    description: l10n("FIELD_LINK_TRANSFER_SEND_VARIABLE_DESC"),
    type: "variable",
    variableType: "arrayReference",
    defaultValue: "LAST_VARIABLE",
    conditions: [
      {
        key: "size",
        gt: 1,
      },
    ],
  },
  {
    key: "receiveVariableArray",
    label: l10n("FIELD_RECEIVE_VARIABLE"),
    description: l10n("FIELD_LINK_TRANSFER_RECEIVE_VARIABLE_DESC"),
    type: "variable",
    variableType: "arrayReference",
    defaultValue: "LAST_VARIABLE",
    conditions: [
      {
        key: "size",
        gt: 1,
      },
    ],
  },
  {
    key: "size",
    label: l10n("FIELD_PACKET_SIZE"),
    description: l10n("FIELD_LINK_TRANSFER_PACKET_SIZE_DESC"),
    type: "number",
    defaultValue: 1,
    min: 1,
  },
];
 
const compile = (input, helpers) => {
  const { linkTransfer } = helpers;
  if (input.size === 1) {
    linkTransfer(input.sendVariable, input.receiveVariable, input.size);
  } else {
    linkTransfer(
      input.sendVariableArray,
      input.receiveVariableArray,
      input.size,
    );
  }
};
 
module.exports = {
  id,
  description: l10n("EVENT_LINK_TRANSFER_DESC"),
  subGroups,
  fields,
  compile,
};