diff --git a/README.md b/README.md index 4dd4c9c..9eab662 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,14 @@ ## Features -- Two Commands: +- Three Commands: - `Draw a Card` - card of the day - `Ask a Question` - input box will convey your will + - `The Vision` - the three card spread: draw three cards one by one + - The past - The present - The future + - The situation - The action - The outcome + - Current position - Aspiration - The path to take + - And more meanings as you wish... - Status bar: - Show your daily card - Click on it to ask a question @@ -56,5 +61,9 @@ - Fix bug: `Daily Crad` status bar cannot be influenced by function `Ask a Question` now. - When `Daily Card` status bar is already there and function `Draw a Card` is called again, show the name of previous card instead of drawing a new card. +### 0.1.5 + +- The three card spread is available now: new command - `Daily Card: The Vision`. + **Enjoy!** diff --git a/changelog.md b/changelog.md index af00626..3a3cbb7 100644 --- a/changelog.md +++ b/changelog.md @@ -11,4 +11,7 @@ ### 0.1.3 - Fix bug: `Daily Crad` status bar cannot be influenced by function `Ask a Question` now. -- When `Daily Card` status bar is already there and function `Draw a Card` is called again, show the name of previous card instead of drawing a new card. \ No newline at end of file +- When `Daily Card` status bar is already there and function `Draw a Card` is called again, show the name of previous card instead of drawing a new card. + +### 0.1.5 +- The three card spread is available now: new command - `Daily Card: The Vision`. \ No newline at end of file diff --git a/package.json b/package.json index 1fb44dc..5c1afd9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "daily-tarot", "displayName": "Daily Tarot", "description": "Get your daily tarot reading - Prisma Visions", - "version": "0.1.3", + "version": "0.1.5", "publisher": "raptazure", "icon": "images/icon.jpg", "engines": { @@ -26,7 +26,8 @@ }, "activationEvents": [ "onCommand:tarot.today", - "onCommand:tarot.ask" + "onCommand:tarot.ask", + "onCommand:tarot.vision" ], "main": "./out/extension.js", "contributes": { @@ -37,6 +38,10 @@ { "command": "tarot.ask", "title": "Daily Tarot: Ask a Question" + }, + { + "command": "tarot.vision", + "title": "Daily Tarot: The Vision" } ] }, diff --git a/src/cardSpread.ts b/src/cardSpread.ts new file mode 100644 index 0000000..42e5445 --- /dev/null +++ b/src/cardSpread.ts @@ -0,0 +1,36 @@ +import * as vscode from 'vscode' +import * as path from 'path'; +import * as fs from 'fs'; + +const visionSpread = (context: vscode.ExtensionContext, selector) => { + let panel: vscode.WebviewPanel | undefined; + panel = vscode.window.createWebviewPanel('visionSpread', 'The Vision', vscode.ViewColumn.Two, {}); + if (panel !== undefined) { + const filePath: vscode.Uri = vscode.Uri.file(path.join(context.extensionPath, 'src', 'pages', `${selector}.html`)); + panel.webview.html = fs.readFileSync(filePath.fsPath, 'utf8'); + } + + panel.onDidDispose(() => this.panel = undefined); +} + +export async function showSpread(context: vscode.ExtensionContext) { + let selector: number; + selector = -1 + Math.floor(Math.random() * 79); + const question = await vscode.window.showInputBox({ + placeHolder: 'Please enter the question you want to ask.' + }) + if (question !== undefined && question !== '') { + vscode.window.showInformationMessage(`Drawing Three Cards for you🔮: ${question}`); + setTimeout(() => visionSpread(context, selector), 3599); + let selectorOne = -1 + Math.floor(Math.random() * 79); + while(selectorOne === selector) { + selectorOne = -1 + Math.floor(Math.random() * 79); + } + setTimeout(() => visionSpread(context, selectorOne), 4599); + let selectorTwo = -1 + Math.floor(Math.random() * 79); + while(selectorTwo === selector || selectorTwo === selectorOne) { + selectorTwo = -1 + Math.floor(Math.random() * 79); + } + setTimeout(() => visionSpread(context, selectorTwo), 5599); + } +} \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index ba71db4..ae3babc 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import { askQuestions } from './askQuestions'; import { dailyTarot } from './dailyTarot'; +import { showSpread } from './cardSpread'; export function activate(context: vscode.ExtensionContext) { const tarotToday = vscode.commands.registerCommand('tarot.today', () => { @@ -11,8 +12,13 @@ export function activate(context: vscode.ExtensionContext) { askQuestions(context); }); + const cardSpread = vscode.commands.registerCommand('tarot.vision', () => { + showSpread(context); + }) + context.subscriptions.push(tarotAsk); context.subscriptions.push(tarotToday); + context.subscriptions.push(cardSpread); }