Make KeyAction.assertKeyActiontype() and KeyAction.readAndAssertKeyActionId() only expect a single argument.

This commit is contained in:
László Monda
2016-04-09 00:39:17 +02:00
parent a3b83dfb36
commit 34ff0d657d
11 changed files with 27 additions and 26 deletions

View File

@@ -26,16 +26,19 @@ let keyActionType = {
};
abstract class KeyAction extends Serializable<KeyAction> {
assertKeyActionType(jsObject: any, keyActionTypeString: string, classname: string) {
assertKeyActionType(jsObject: any) {
let keyActionClassname = this.constructor.name;
let keyActionTypeString = keyActionType[keyActionClassname]
if (jsObject.keyActionType !== keyActionTypeString) {
console.log(arguments.callee.prototype.name);
throw `Invalid ${classname}.keyActionType: ${jsObject.keyActionType}`;
throw `Invalid ${keyActionClassname}.keyActionType: ${jsObject.keyActionType}`;
}
}
readAndAssertKeyActionId(buffer: UhkBuffer, keyActionIdParam: KeyActionId, classname: string) {
readAndAssertKeyActionId(buffer: UhkBuffer) {
let classname = this.constructor.name;
let readKeyActionId = buffer.readUInt8();
if (readKeyActionId !== keyActionIdParam) {
let keyActionId = KeyActionId[<string> classname];
if (readKeyActionId !== keyActionId) {
throw `Invalid ${classname} first byte: ${readKeyActionId}`;
}
}