갤럭시 검색 결과에서 행성 상세로 이동
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart' show QueryDocumentSnapshot;
|
||||
import 'package:cloud_firestore/cloud_firestore.dart'
|
||||
show QueryDocumentSnapshot;
|
||||
|
||||
import '../../core/data/backend.dart';
|
||||
import '../planet/planet_data.dart' show rankWithTies;
|
||||
@@ -58,7 +59,8 @@ class FirestoreGalaxyRepository implements GalaxyRepository {
|
||||
// fandomId 오름차순으로 고정한다 — 쿼리 순서(동점은 ID 내림차순)를 그대로 쓰지 않는다.
|
||||
// Stage0 성운은 순위를 매기기 **전에** 뺀다(B-08 · B-17) — 성운이 끼면 정식 행성의
|
||||
// 순위 번호가 밀린다. 성운은 맨 바깥 궤도 자리(정식 수 + 1)에 둔다.
|
||||
bool isNebula(QueryDocumentSnapshot<Map<String, dynamic>> d) => d.data()['stage'] == 0;
|
||||
bool isNebula(QueryDocumentSnapshot<Map<String, dynamic>> d) =>
|
||||
d.data()['stage'] == 0;
|
||||
final formal = fandoms.where((d) => !isNebula(d)).toList();
|
||||
final planets = <PlanetNode>[
|
||||
for (final (doc, rank) in rankWithTies(
|
||||
@@ -79,7 +81,8 @@ class FirestoreGalaxyRepository implements GalaxyRepository {
|
||||
]);
|
||||
for (final doc in missing) {
|
||||
final data = doc.data();
|
||||
if (data != null) byId[doc.id] = _node(doc.id, data, formal.length + 1, myFandomId);
|
||||
if (data != null)
|
||||
byId[doc.id] = _node(doc.id, data, formal.length + 1, myFandomId);
|
||||
}
|
||||
|
||||
return GalaxySnapshot(
|
||||
@@ -93,7 +96,12 @@ class FirestoreGalaxyRepository implements GalaxyRepository {
|
||||
);
|
||||
}
|
||||
|
||||
PlanetNode _node(String id, Map<String, dynamic> data, int rank, String myFandomId) => PlanetNode(
|
||||
PlanetNode _node(
|
||||
String id,
|
||||
Map<String, dynamic> data,
|
||||
int rank,
|
||||
String myFandomId,
|
||||
) => PlanetNode(
|
||||
id: id,
|
||||
stage: switch (data['stage']) {
|
||||
int n when n >= 0 && n <= 6 => n,
|
||||
@@ -124,7 +132,10 @@ class FirestoreGalaxyRepository implements GalaxyRepository {
|
||||
required String clientSeq,
|
||||
}) async {
|
||||
final snapshot = await _backend.db.doc('config/policy').get();
|
||||
final zapPop = (snapshot.data() ?? const <String, dynamic>{}).intOr('zapPop', 10);
|
||||
final zapPop = (snapshot.data() ?? const <String, dynamic>{}).intOr(
|
||||
'zapPop',
|
||||
10,
|
||||
);
|
||||
final data = await _backend.call('fnPopSpend', {
|
||||
'popType': 'activity',
|
||||
'amount': zapPop * count,
|
||||
@@ -135,9 +146,17 @@ class FirestoreGalaxyRepository implements GalaxyRepository {
|
||||
'refPath': 'fandoms/$fandomId',
|
||||
});
|
||||
final lots = data['lotRefs'];
|
||||
final contributedPop = lots is List && lots.isNotEmpty && lots.every(
|
||||
(lot) => lot is Map && lot['delta'] is int && (lot['delta'] as int) < 0,
|
||||
) ? lots.fold<int>(0, (sum, lot) => sum - (lot['delta'] as int)) : null;
|
||||
final contributedPop =
|
||||
lots is List &&
|
||||
lots.isNotEmpty &&
|
||||
lots.every(
|
||||
(lot) =>
|
||||
lot is Map &&
|
||||
lot['delta'] is int &&
|
||||
(lot['delta'] as int) < 0,
|
||||
)
|
||||
? lots.fold<int>(0, (sum, lot) => sum - (lot['delta'] as int))
|
||||
: null;
|
||||
return ZapResult(
|
||||
contributedPop: contributedPop,
|
||||
txId: data['txId'] as String? ?? '',
|
||||
|
||||
Reference in New Issue
Block a user