import { TableBase } from "../Engine/CatanEngine/TableV3/Core/TableBase";
import { TableManager } from "../Engine/CatanEngine/TableV3/TableManager";
//#region AutoMappingImport
import { ChatTable } from "./Tables/ChatTable";
import { CommunityTable } from "./Tables/CommunityTable";
import { CurrencyTable, CurrencyTableRow } from "./Tables/CurrencyTable";
import { EventTable } from "./Tables/EventTable";
import { FixedTable, FixedTableRow } from "./Tables/FixedTable";
import { FormreadTable } from "./Tables/FormreadTable";
import { GiftTable } from "./Tables/GiftTable";
import { HonorTable } from "./Tables/HonorTable";
import { ItemSettingTable } from "./Tables/ItemSettingTable";
import { LanguageTable } from "./Tables/LanguageTable";
import { LobbyTable } from "./Tables/LobbyTable";
import { LppointTable } from "./Tables/LppointTable";
import { MailTable } from "./Tables/MailTable";
import { NameTable } from "./Tables/NameTable";
import { NetworkTable } from "./Tables/NetworkTable";
import { PacketTable } from "./Tables/PacketTable";
import { RankTable, RankTableRow } from "./Tables/RankTable";
import { SettingTable } from "./Tables/SettingTable";
import { ShopTable } from "./Tables/ShopTable";
import { SoundTable, SoundTableRow } from "./Tables/SoundTable";
import { StringTable, StringTableRow } from "./Tables/StringTable";
import { TaskTable } from "./Tables/TaskTable";
import { VipTable } from "./Tables/VipTable";
//#endregion AutoMappingImport

export default class CSSettingsV3 {

	public static ResetTables() {
		for (let prop in this) {
			if (prop.charAt(0) === '_' && this[prop] && this[prop] instanceof TableBase) {
				let table = this[prop];
				let tableName = prop.replace("_", "#");
				for (let p in table) {
					if (p.charAt(0) === '_' && table[p] && table[p] instanceof TableBase) {
						cc.log(`TableV3 [${tableName}${p.replace("_", "#")}] cleared`);
						table[p] = undefined;
					}
				}
				cc.log(`TableV3 [${tableName}] cleared`);
				this[prop] = undefined;
			}
		}
		//TODO: 尚未實作TableManager的清除動作
	}

	//#region AutoMappingClass

	private static _gift: GiftTable;
	/** 系統_贈禮#gift.xlsx */
	public static get Gift(): GiftTable { return this._gift = this._gift || new GiftTable(); }

	private static _string: StringTable;
	/** 共用_字串表#string.xlsx */
	public static get String(): StringTable { return this._string = this._string || TableManager.InitTable("#string", StringTable, StringTableRow); }

	private static _shop: ShopTable;
	/** 共用_商城#shop.xlsx */
	public static get Shop(): ShopTable { return this._shop = this._shop || new ShopTable(); }

	private static _currency: CurrencyTable;
	/** 共用_幣別表#currency.xlsx */
	public static get Currency(): CurrencyTable { return this._currency = this._currency || TableManager.InitTable("#currency", CurrencyTable, CurrencyTableRow); }

	private static _language: LanguageTable;
	/** 共用_語系表#language.xlsx */
	public static get Language(): LanguageTable { return this._language = this._language || new LanguageTable(); }

	private static _fixed: FixedTable;
	/** 共用_數值表#fixed.xlsx */
	public static get Fixed(): FixedTable { return this._fixed = this._fixed || TableManager.InitTable("#fixed", FixedTable, FixedTableRow); }

	private static _vip: VipTable;
	/** 系統_VIP#vip.xlsx */
	public static get Vip(): VipTable { return this._vip = this._vip || new VipTable(); }

	private static _formread: FormreadTable;
	/** 系統_表單讀取#formread.xlsx */
	public static get Formread(): FormreadTable { return this._formread = this._formread || new FormreadTable(); }

	private static _mail: MailTable;
	/** 系統_信件#mail.xlsx */
	public static get Mail(): MailTable { return this._mail = this._mail || new MailTable(); }

	private static _sound: SoundTable;
	/** 系統_音效表#sound.xlsx */
	public static get Sound(): SoundTable { return this._sound = this._sound || TableManager.InitTable("#sound", SoundTable, SoundTableRow); }

	private static _rank: RankTable;
	/** 系統_排行榜#rank.xlsx */
	public static get Rank(): RankTable { return this._rank = this._rank || TableManager.InitTable("#rank", RankTable, RankTableRow); }

	private static _chat: ChatTable;
	/** 系統_聊天室#chat.xlsx */
	public static get Chat(): ChatTable { return this._chat = this._chat || new ChatTable(); }

	private static _network: NetworkTable;
	/** 系統_跑馬燈#network.xlsx */
	public static get Network(): NetworkTable { return this._network = this._network || new NetworkTable(); }

	private static _name: NameTable;
	/** 系統_暱稱#name.xlsx */
	public static get Name(): NameTable { return this._name = this._name || new NameTable(); }

	private static _lobby: LobbyTable;
	/** 系統_機台分桌#lobby.xlsx */
	public static get Lobby(): LobbyTable { return this._lobby = this._lobby || new LobbyTable(); }

	private static _itemSetting: ItemSettingTable;
	/** 系統_道具設定#item_setting.xlsx */
	public static get ItemSetting(): ItemSettingTable { return this._itemSetting = this._itemSetting || new ItemSettingTable(); }

	private static _packet: PacketTable;
	/** 系統_背包#packet.xlsx */
	public static get Packet(): PacketTable { return this._packet = this._packet || new PacketTable(); }

	private static _setting: SettingTable;
	/** 共用_設定表#setting.xlsx */
	public static get Setting(): SettingTable { return this._setting = this._setting || new SettingTable(); }

	private static _task: TaskTable;
	/** 系統_任務#task.xlsx */
	public static get Task(): TaskTable { return this._task = this._task || new TaskTable(); }

	private static _lppoint: LppointTable;
	/** 共用_兌禮商城#lppoint.xlsx */
	public static get Lppoint(): LppointTable { return this._lppoint = this._lppoint || new LppointTable(); }

	private static _event: EventTable;
	/** 系統_活動#event.xlsx */
	public static get Event(): EventTable { return this._event = this._event || new EventTable(); }

	private static _community: CommunityTable;
	/** 共用_社群#community.xlsx */
	public static get Community(): CommunityTable { return this._community = this._community || new CommunityTable(); }

	private static _honor: HonorTable;
	/** 系統_榮譽#honor.xlsx */
	public static get Honor(): HonorTable { return this._honor = this._honor || new HonorTable(); }

	//#endregion AutoMappingClass
}
