From d8e25db187e73e75b6c7547f71aa9adbd4763c72 Mon Sep 17 00:00:00 2001 From: Voky Date: Sat, 11 May 2024 14:59:12 +0200 Subject: [PATCH] create skelet for file and history manager --- TScripts/File.ts | 0 TScripts/FileManager.ts | 23 +++++++++++++++++++++++ TScripts/HistoryManager.ts | 32 ++++++++++++++++++++++++++++++++ TScripts/Log.ts | 21 ++++++++++++++++----- index.html | 3 ++- 5 files changed, 73 insertions(+), 6 deletions(-) delete mode 100644 TScripts/File.ts create mode 100644 TScripts/FileManager.ts create mode 100644 TScripts/HistoryManager.ts diff --git a/TScripts/File.ts b/TScripts/File.ts deleted file mode 100644 index e69de29..0000000 diff --git a/TScripts/FileManager.ts b/TScripts/FileManager.ts new file mode 100644 index 0000000..5a6d4c1 --- /dev/null +++ b/TScripts/FileManager.ts @@ -0,0 +1,23 @@ + +class FileManager{ + + static loadJSON(){ + // to decide which one to use + } + + static loadLogJSON(){ + // load tournament with history + } + + static loadSnapshotJSON(){ + // load tournament in given moment + } + + static exportLogJSON(){ + + } + + static exportSnapshotJSON(){ + + } +} \ No newline at end of file diff --git a/TScripts/HistoryManager.ts b/TScripts/HistoryManager.ts new file mode 100644 index 0000000..2caa3f7 --- /dev/null +++ b/TScripts/HistoryManager.ts @@ -0,0 +1,32 @@ + +class HistoryManager{ + + static getCurrentSerialNumber(){ + + } + + static setCurrentSerialNumber(num: number){ + + } + + static incrementCurrentSerialNumber(num: number = 1){ + + } + + static saveLog(log: Log){ + + } + + static undo(){ + // create reverse of the last log and do() + } + + static redo(){ + // do() the last log + } + + static do(log: Log, save: boolean = false){ + // do what is in the log + // if save, than add it to history + } +} \ No newline at end of file diff --git a/TScripts/Log.ts b/TScripts/Log.ts index ee7df88..cb8d9ab 100644 --- a/TScripts/Log.ts +++ b/TScripts/Log.ts @@ -1,19 +1,30 @@ class Log{ - private id: number; + private serialNumber: number = -1; + private idOfObject: number; private type: LogEvent; private previous: any; private after: any; - constructor(id: number, type: LogEvent, previous: any, after: any){ - this.id = id; + constructor(idOfObject: number, type: LogEvent, previous: any, after: any){ + this.idOfObject = idOfObject; this.type = type; this.previous = previous; this.after = after; } - getID(){ - return this.id; + setSerialNumber(num: number){ + if (this.serialNumber != -1){ + this.serialNumber = num; + } + } + + getSerialNumber(){ + return this.serialNumber; + } + + getIDofObject(){ + return this.idOfObject; } getType(){ diff --git a/index.html b/index.html index 5c911d9..73d29b3 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,8 @@ - + +