import { StringFilterTable, StringTable, StringTableRow } from "../../FormTable/Tables/StringTable";

declare module "../../FormTable/Tables/StringTable" {
	interface StringTable {
		GetVipSetName(set: number): string;
		Get(language: number, id: number): string;
	}

	interface StringTableRow {
		ChangeMsg(): string;
	}

	interface StringFilterTable {
		CheckDirtyWord(targetStr: string): boolean;
	}
}

StringTable.prototype.GetVipSetName = function (set: number) {
	let self = <StringTable>this;
	return self.Get(0, set);
};

StringTable.prototype.Get = function (language: number, id: number): string {
	let self = <StringTable>this;
	// switch (language)
	// {
	//     case 0:
	//         return self[id].MsgZnTw;
	//     case 1:
	//         return self[id].MsgEn;
	//     case 2:
	//         return self[id].MsgZnCh;
	//     default:
	//         return "Unknown";
	// }
	return self[id].MsgZnCh;
};

StringTableRow.prototype.ChangeMsg = function () {
	let self = <StringTableRow>this;
	return self.MsgZnCh + "hello";
};

StringFilterTable.prototype.CheckDirtyWord = function (targetStr: string): boolean {
	let self = <StringFilterTable>this;
	targetStr = targetStr.toLowerCase();

	for (let item of self.Rows) {
		if (targetStr.indexOf(item.FilterWord) >= 0) {
			return true;
		}
	}
	return false;
};