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 { Injectable } from '@angular/core';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
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[];
|
const group2 = updated.numbers.slice(dashIndex + 1).filter(n => typeof n === 'number') as number[];
|
||||||
|
|
||||||
let combinations = 0;
|
let combinations = 0;
|
||||||
|
const set1 = new Set(group1);
|
||||||
|
const set2 = new Set(group2);
|
||||||
|
const uniqueUnion = new Set([...group1, ...group2]);
|
||||||
|
|
||||||
if (isBoxed) {
|
function setsAreEqual(a: Set<number>, b: Set<number>): boolean {
|
||||||
const uniq = Array.from(new Set([...group1, ...group2]));
|
if (a.size !== b.size) return false;
|
||||||
combinations = this.calculateCombinations(uniq.length); // nC2
|
for (let v of a) if (!b.has(v)) return false;
|
||||||
updated.numbers = [...uniq, '-', ...uniq];
|
return true;
|
||||||
} else {
|
|
||||||
for (const a of group1) {
|
|
||||||
for (const b of group2) {
|
|
||||||
if (a !== b) combinations++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updated.numbers = [...group1, '-', ...group2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updated.total = combinations * value * 10;
|
if (isBoxed || setsAreEqual(set1, set2)) {
|
||||||
|
combinations = uniqueUnion.size >= 2 ? (uniqueUnion.size * (uniqueUnion.size - 1)) / 2 : 0;
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
combinations = pairSet.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
updated.numbers = [...group1, '-', ...group2];
|
||||||
|
updated.total = combinations * value * 10; // Value multiplier as per your code (10x)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user