54 lines
1.8 KiB
Dart
54 lines
1.8 KiB
Dart
|
|
import 'package:guru_app/analytics/guru_analytics.dart';
|
||
|
|
import 'package:guru_app/database/guru_db.dart';
|
||
|
|
import 'package:guru_app/financial/asset/assets_model.dart';
|
||
|
|
import 'package:guru_app/financial/asset/assets_store.dart';
|
||
|
|
import 'package:guru_app/financial/data/db/order_database.dart';
|
||
|
|
import 'package:guru_app/financial/igb/igb_product.dart';
|
||
|
|
import 'package:guru_app/financial/igc/igc_model.dart';
|
||
|
|
import 'package:guru_app/financial/manifest/manifest_manager.dart';
|
||
|
|
import 'package:guru_app/financial/product/product_model.dart';
|
||
|
|
import 'package:guru_app/guru_app.dart';
|
||
|
|
import 'package:guru_app/inventory/inventory_manager.dart';
|
||
|
|
import 'package:guru_app/property/app_property.dart';
|
||
|
|
import 'package:guru_utils/extensions/extensions.dart';
|
||
|
|
import 'package:guru_utils/log/log.dart';
|
||
|
|
import 'package:guru_utils/property/app_property.dart';
|
||
|
|
|
||
|
|
/// Created by Haoyi on 2023/2/18
|
||
|
|
|
||
|
|
class IgbManager {
|
||
|
|
static final IgbManager _instance = IgbManager._();
|
||
|
|
|
||
|
|
static IgbManager get instance => _instance;
|
||
|
|
|
||
|
|
IgbManager._();
|
||
|
|
|
||
|
|
Future init() async {
|
||
|
|
await InventoryManager.instance.init();
|
||
|
|
}
|
||
|
|
|
||
|
|
Future reloadAssets() async {}
|
||
|
|
|
||
|
|
Future<bool> accumulate(int igc, TransactionMethod method, {String? scene}) async {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
Future clear() async {}
|
||
|
|
|
||
|
|
Future<IgbProduct> buildIgbProduct(TransactionIntent intent) async {
|
||
|
|
final manifest = await ManifestManager.instance.createManifest(intent);
|
||
|
|
return IgbProduct(intent.productId, manifest, intent.igbCost);
|
||
|
|
}
|
||
|
|
|
||
|
|
Future<bool> redeem(IgbProduct product) async {
|
||
|
|
Log.v("Igb buy");
|
||
|
|
final result = await InventoryManager.instance.consume(product.cost, product.manifest);
|
||
|
|
if (result) {
|
||
|
|
await ManifestManager.instance.deliver(product.manifest, TransactionMethod.igb);
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
void dispose() {}
|
||
|
|
}
|