From 06bb867dc5ae6009d6bcc251fbce9f16db7e6f0f Mon Sep 17 00:00:00 2001 From: karthik Date: Sat, 26 Jul 2025 21:40:56 +0530 Subject: [PATCH] fix : TAN , QUI , FOR logic is good (not with box ) --- .../selection.service/selection.service.ts | 64 ++++-- .../touch-pad-menu.component.html | 2 +- .../touch-pad-menu.component.ts | 208 ++++++++++-------- 3 files changed, 162 insertions(+), 112 deletions(-) diff --git a/btc-UI/src/app/components/selection.service/selection.service.ts b/btc-UI/src/app/components/selection.service/selection.service.ts index 94fc7fe..fb7cea9 100644 --- a/btc-UI/src/app/components/selection.service/selection.service.ts +++ b/btc-UI/src/app/components/selection.service/selection.service.ts @@ -1,4 +1,4 @@ -// ✅ Updated SelectionService with ComputeAmount logic adapted from C# +// ✅ Final SelectionService.ts with special TAN (three-group) logic import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; @@ -37,32 +37,53 @@ export class SelectionService { if (numbers.length > 0 && value > 0 && label) { switch (label) { - // 🟢 Single Leg Pools - case 'WIN': // WNP + case 'WIN': case 'SHP': case 'THP': - case 'PLC': // PLP + case 'PLC': updated.total = numbers.length * value * 10; break; - // 🟡 Exotic Pools (e.g., QNP, TNP, EXP) - case 'FOR': // FRP - case 'TAN': // TNP - case 'EXA': // EXP - case 'QUI': { // QNP (QUI special case already handled in UI logic) - const mid = Math.floor(numbers.length / 2); - const group1 = numbers.slice(0, mid); - const group2 = numbers.slice(mid); - const combinations = group1.length * group2.length; + case 'FOR': + case 'QUI': { + const dashIndex = updated.numbers.indexOf('-'); + const group1 = updated.numbers.slice(0, dashIndex).filter(n => typeof n === 'number') as number[]; + const group2 = updated.numbers.slice(dashIndex + 1).filter(n => typeof n === 'number') as number[]; + + let combinations = group1.length * group2.length; + if (isBoxed) { + combinations = this.calculatePermutations(group1.length + group2.length); + } + updated.total = combinations * value * 10; updated.numbers = [...group1, '-', ...group2]; break; } - // 🔵 Multileg Pools (e.g., TBP, MJP, JPP) - case 'TRE': // TBP + case 'TAN': { + const dashIndices = updated.numbers + .map((n, idx) => (n === '-' ? idx : -1)) + .filter(idx => idx !== -1); + + if (dashIndices.length < 2) break; // not ready yet + + const group1 = updated.numbers.slice(0, dashIndices[0]).filter(n => typeof n === 'number') as number[]; + const group2 = updated.numbers.slice(dashIndices[0] + 1, dashIndices[1]).filter(n => typeof n === 'number') as number[]; + const group3 = updated.numbers.slice(dashIndices[1] + 1).filter(n => typeof n === 'number') as number[]; + + let combinations = group1.length * group2.length * group3.length; + if (isBoxed) { + combinations = this.calculatePermutations(group1.length + group2.length + group3.length); + } + + updated.total = combinations * value * 10; + updated.numbers = [...group1, '-', ...group2, '-', ...group3]; + break; + } + + case 'TRE': case 'MJP': - case 'JKP': { // JPP + case 'JKP': { const legs = this.splitToLegs(numbers, this.getLegCount(label)); const comb = legs.reduce((acc, leg) => acc * (leg.length || 1), 1); updated.total = comb * value * 10; @@ -86,10 +107,7 @@ export class SelectionService { finalizeCurrentRow() { const completed = this.currentRow.value; if (!completed.label || completed.numbers.length === 0 || completed.value <= 0) return; - - const finalRow: SelectionData = { ...completed }; - this.selections.next([...this.selections.value, finalRow]); - + this.selections.next([...this.selections.value, { ...completed }]); this.currentRow.next({ label: '', numbers: [], value: 0, total: 0, isBoxed: false }); } @@ -117,10 +135,10 @@ export class SelectionService { private getLegCount(label: string): number { switch (label) { - case 'TRE': return 3; // TBP + case 'TRE': return 3; case 'MJP': return 4; - case 'JKP': return 5; // JPP + case 'JKP': return 5; default: return 3; } } -} +} \ No newline at end of file diff --git a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html index a6897c2..3069458 100755 --- a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html +++ b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html @@ -19,7 +19,7 @@