node-insim
Version:
An InSim library for NodeJS with TypeScript support
123 lines (122 loc) • 5.01 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PenaltyReason = exports.IS_PEN = void 0;
var decorators_1 = require("../decorators");
var base_1 = require("./base");
var enums_1 = require("./enums");
/**
* PENalty (given or cleared)
*
* On false start or wrong route / restricted area, an IS_PEN packet is sent:
*
* - False start: OldPen = 0 / NewPen = {@link PENALTY_30} / Reason = {@link PENR_FALSE_START}
* - Wrong route: OldPen = 0 / NewPen = {@link PENALTY_45} / Reason = {@link PENR_WRONG_WAY}
*/
var IS_PEN = /** @class */ (function (_super) {
__extends(IS_PEN, _super);
function IS_PEN() {
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
_this.Size = 8;
_this.Type = enums_1.PacketType.ISP_PEN;
_this.ReqI = 0;
/** Player's unique id */
_this.PLID = 0;
/** Old penalty value */
_this.OldPen = 0;
/** New penalty value */
_this.NewPen = 0;
/** Penalty reason */
_this.Reason = 0;
_this.Sp3 = 0;
return _this;
}
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "Size", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "Type", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "ReqI", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "PLID", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "OldPen", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "NewPen", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "Reason", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_PEN.prototype, "Sp3", void 0);
return IS_PEN;
}(base_1.Packet));
exports.IS_PEN = IS_PEN;
var PenaltyReason;
(function (PenaltyReason) {
/** Unknown or cleared penalty */
PenaltyReason[PenaltyReason["PENR_UNKNOWN"] = 0] = "PENR_UNKNOWN";
/** Penalty given by admin */
PenaltyReason[PenaltyReason["PENR_ADMIN"] = 1] = "PENR_ADMIN";
/** Wrong way driving */
PenaltyReason[PenaltyReason["PENR_WRONG_WAY"] = 2] = "PENR_WRONG_WAY";
/** Starting before green light */
PenaltyReason[PenaltyReason["PENR_FALSE_START"] = 3] = "PENR_FALSE_START";
/** Speeding in pit lane */
PenaltyReason[PenaltyReason["PENR_SPEEDING"] = 4] = "PENR_SPEEDING";
/** Stop-go pit stop too short */
PenaltyReason[PenaltyReason["PENR_STOP_SHORT"] = 5] = "PENR_STOP_SHORT";
/** Compulsory stop is too late */
PenaltyReason[PenaltyReason["PENR_STOP_LATE"] = 6] = "PENR_STOP_LATE";
})(PenaltyReason || (exports.PenaltyReason = PenaltyReason = {}));