fix : QUI logic is working with and without box section
This commit is contained in:
parent
c5edb09cd0
commit
1be559a552
@ -1,4 +1,3 @@
|
||||
// ✅ Final SelectionService.ts with strict QUI logic
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
@ -74,21 +73,32 @@ export class SelectionService {
|
||||
const group2 = updated.numbers.slice(dashIndex + 1).filter(n => typeof n === 'number') as number[];
|
||||
|
||||
let combinations = 0;
|
||||
const set1 = new Set(group1);
|
||||
const set2 = new Set(group2);
|
||||
const uniqueUnion = new Set([...group1, ...group2]);
|
||||
|
||||
if (isBoxed) {
|
||||
const uniq = Array.from(new Set([...group1, ...group2]));
|
||||
combinations = this.calculateCombinations(uniq.length); // nC2
|
||||
updated.numbers = [...uniq, '-', ...uniq];
|
||||
function setsAreEqual(a: Set<number>, b: Set<number>): boolean {
|
||||
if (a.size !== b.size) return false;
|
||||
for (let v of a) if (!b.has(v)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBoxed || setsAreEqual(set1, set2)) {
|
||||
combinations = uniqueUnion.size >= 2 ? (uniqueUnion.size * (uniqueUnion.size - 1)) / 2 : 0;
|
||||
} else {
|
||||
for (const a of group1) {
|
||||
for (const b of group2) {
|
||||
if (a !== b) combinations++;
|
||||
const pairSet = new Set<string>();
|
||||
for (let a of set1) {
|
||||
for (let b of set2) {
|
||||
if (a === b) continue;
|
||||
let key = a < b ? `${a},${b}` : `${b},${a}`;
|
||||
pairSet.add(key);
|
||||
}
|
||||
}
|
||||
updated.numbers = [...group1, '-', ...group2];
|
||||
combinations = pairSet.size;
|
||||
}
|
||||
|
||||
updated.total = combinations * value * 10;
|
||||
updated.numbers = [...group1, '-', ...group2];
|
||||
updated.total = combinations * value * 10; // Value multiplier as per your code (10x)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user