map_watch.dart 932 B

1234567891011121314151617181920212223242526272829303132333435
  1. import 'package:app_business/service/api.dart';
  2. import 'package:fixnum/fixnum.dart';
  3. import 'package:get/get.dart';
  4. import 'package:track_common/model/map_info.dart';
  5. import 'package:track_common/service/map_watch.dart';
  6. import '../generated/base.pb.dart' as pb;
  7. import '../model/game_map.dart';
  8. class MapWatchImpl extends MapWatch {
  9. MapWatchImpl({required super.id});
  10. ApiService get _api => Get.find();
  11. @override
  12. Future<List<EventOnMap>> getEventList(int mapId) async {
  13. // final r = _api.stub
  14. return [];
  15. }
  16. }
  17. class MapWatchServiceImpl extends MapWatchService {
  18. ApiService get _api => Get.find();
  19. @override
  20. Future<MapWatch> newInstanceByMap(MapInfo info) async {
  21. final r =
  22. await _api.stub.toMapDetailV2(pb.IdRequest()..id = Int64(info.id));
  23. final instance = MapWatchImpl(id: info.id)
  24. ..name = r.mapName
  25. ..plugMap.gameMap = r.zipImage.toGameMap();
  26. return instance;
  27. }
  28. }