Skip to content

Commit 7317a4b

Browse files
committed
feat: return zzz exclusive_rescreening and w_engine_reverberation banner data
1 parent e4f94c2 commit 7317a4b

1 file changed

Lines changed: 123 additions & 2 deletions

File tree

  • src/api/pages/zzz/signal_tracker/uid

src/api/pages/zzz/signal_tracker/uid/mod.rs

Lines changed: 123 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ use crate::{
1010
database,
1111
};
1212

13+
const AGENT_LOSS_IDS: &[i32] = &[1021, 1041, 1101, 1141, 1181, 1211];
14+
const W_ENGINE_LOSS_IDS: &[i32] = &[14102, 14104, 14110, 14114, 14118, 14121];
15+
1316
#[derive(OpenApi)]
1417
#[openapi(paths(get_signal_tracker))]
1518
struct ApiDoc;
@@ -87,6 +90,8 @@ struct SignalTracker {
8790
special: Signals,
8891
w_engine: Signals,
8992
bangboo: Signals,
93+
exclusive_rescreening: Signals,
94+
w_engine_reverberation: Signals,
9095
}
9196

9297
#[derive(Default, Serialize)]
@@ -237,7 +242,7 @@ async fn get_signal_tracker(
237242
guarantee = false;
238243

239244
Some(WinType::Guarantee)
240-
} else if [1021, 1041, 1101, 1141, 1181, 1211].contains(&signal.item_id) {
245+
} else if AGENT_LOSS_IDS.contains(&signal.item_id) {
241246
guarantee = true;
242247

243248
Some(WinType::Loss)
@@ -294,7 +299,7 @@ async fn get_signal_tracker(
294299
guarantee = false;
295300

296301
Some(WinType::Guarantee)
297-
} else if [14102, 14104, 14110, 14114, 14118, 14121].contains(&signal.item_id) {
302+
} else if W_ENGINE_LOSS_IDS.contains(&signal.item_id) {
298303
guarantee = true;
299304

300305
Some(WinType::Loss)
@@ -367,6 +372,120 @@ async fn get_signal_tracker(
367372
bangboo.count = bangboo.signals.len();
368373
// Bangboo
369374

375+
// Exclusive Rescreening
376+
let mut exclusive_rescreening = Signals::default();
377+
let mut exclusive_rescreening_pull = 0;
378+
let mut exclusive_rescreening_pull_a = 0;
379+
let mut exclusive_rescreening_pull_s = 0;
380+
let mut guarantee = false;
381+
382+
for signal in database::zzz::signals::exclusive_rescreening::get_by_uid(uid, language, &pool).await? {
383+
let mut signal: Signal = signal.into();
384+
385+
exclusive_rescreening_pull += 1;
386+
exclusive_rescreening_pull_a += 1;
387+
exclusive_rescreening_pull_s += 1;
388+
389+
signal.pull = exclusive_rescreening_pull;
390+
signal.pull_4 = exclusive_rescreening_pull_a;
391+
signal.pull_5 = exclusive_rescreening_pull_s;
392+
393+
match signal.rarity {
394+
3 => exclusive_rescreening_pull_a = 0,
395+
4 => {
396+
exclusive_rescreening_pull_a = 0;
397+
exclusive_rescreening_pull_s = 0;
398+
399+
signal.win = if guarantee {
400+
guarantee = false;
401+
402+
Some(WinType::Guarantee)
403+
} else if AGENT_LOSS_IDS.contains(&signal.item_id) {
404+
guarantee = true;
405+
406+
Some(WinType::Loss)
407+
} else {
408+
Some(WinType::Win)
409+
};
410+
}
411+
_ => {}
412+
}
413+
414+
exclusive_rescreening.signals.push(signal);
415+
}
416+
417+
exclusive_rescreening.pull_4 = exclusive_rescreening_pull_a;
418+
exclusive_rescreening.max_pull_4 = 10;
419+
exclusive_rescreening.probability_4 = if exclusive_rescreening_pull_a < 9 { 9.4 } else { 100.0 };
420+
421+
exclusive_rescreening.pull_5 = exclusive_rescreening_pull_s;
422+
exclusive_rescreening.max_pull_5 = 90;
423+
exclusive_rescreening.probability_5 = if exclusive_rescreening_pull_s < 89 {
424+
0.6 + 6.0 * exclusive_rescreening_pull_s.saturating_sub(72) as f64
425+
} else {
426+
100.0
427+
};
428+
429+
exclusive_rescreening.count = exclusive_rescreening.signals.len();
430+
// Exclusive Rescreening
431+
432+
// WEngine Reverberation
433+
let mut w_engine_reverberation = Signals::default();
434+
let mut w_engine_reverberation_pull = 0;
435+
let mut w_engine_reverberation_pull_a = 0;
436+
let mut w_engine_reverberation_pull_s = 0;
437+
let mut guarantee = false;
438+
439+
for signal in database::zzz::signals::w_engine_reverberation::get_by_uid(uid, language, &pool).await? {
440+
let mut signal: Signal = signal.into();
441+
442+
w_engine_reverberation_pull += 1;
443+
w_engine_reverberation_pull_a += 1;
444+
w_engine_reverberation_pull_s += 1;
445+
446+
signal.pull = w_engine_reverberation_pull;
447+
signal.pull_4 = w_engine_reverberation_pull_a;
448+
signal.pull_5 = w_engine_reverberation_pull_s;
449+
450+
match signal.rarity {
451+
3 => w_engine_reverberation_pull_a = 0,
452+
4 => {
453+
w_engine_reverberation_pull_a = 0;
454+
w_engine_reverberation_pull_s = 0;
455+
456+
signal.win = if guarantee {
457+
guarantee = false;
458+
459+
Some(WinType::Guarantee)
460+
} else if W_ENGINE_LOSS_IDS.contains(&signal.item_id) {
461+
guarantee = true;
462+
463+
Some(WinType::Loss)
464+
} else {
465+
Some(WinType::Win)
466+
};
467+
}
468+
_ => {}
469+
}
470+
471+
w_engine_reverberation.signals.push(signal);
472+
}
473+
474+
w_engine_reverberation.pull_4 = w_engine_reverberation_pull_a;
475+
w_engine_reverberation.max_pull_4 = 10;
476+
w_engine_reverberation.probability_4 = if w_engine_reverberation_pull_a < 9 { 15.0 } else { 100.0 };
477+
478+
w_engine_reverberation.pull_5 = w_engine_reverberation_pull_s;
479+
w_engine_reverberation.max_pull_5 = 80;
480+
w_engine_reverberation.probability_5 = if w_engine_reverberation_pull_s < 79 {
481+
1.0 + 7.0 * w_engine_reverberation_pull_s.saturating_sub(64) as f64
482+
} else {
483+
100.0
484+
};
485+
486+
w_engine_reverberation.count = w_engine_reverberation.signals.len();
487+
// WEngine Reverberation
488+
370489
if let Some(stats) = database::zzz::signals_stats::standard::get_by_uid(uid, &pool).await? {
371490
let global_stats = database::zzz::signals_stats_global::standard::get_by_uid(uid, &pool)
372491
.await?
@@ -452,6 +571,8 @@ async fn get_signal_tracker(
452571
special,
453572
w_engine,
454573
bangboo,
574+
exclusive_rescreening,
575+
w_engine_reverberation,
455576
};
456577

457578
Ok(HttpResponse::Ok().json(signal_tracker))

0 commit comments

Comments
 (0)