12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import 'dart:convert';
- class Statistics {
- int id = 0;
- late String gameId;
- late int start;
- int end = 0;
- int jump = 0;
- int squat = 0;
- int step = 0;
- int distance = 0;
- int level = 0;
- double score = 0.0;
- int record = 0;
- int mode = 0;
- int opponentId = 0;
- int status = 1;
- List<int> data = List.filled(MOTION_COUNT_TYPE.values.length, 0);
- Statistics();
- Statistics.name(this.gameId, this.start);
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['game_id'] = this.gameId;
- data['start_time'] = this.start;
- data['end_time'] = this.end;
- data['jump'] = this.jump;
- data['squat'] = this.squat;
- data['step'] = this.step;
- data['distance'] = this.step;
- data['level'] = this.level;
- data['score'] = this.score;
- data['mode'] = this.mode;
- data['opponent_id'] = this.opponentId;
- data['data'] = json.encode(this.data);
- data['status'] = this.status;
- return data;
- }
- String get movements {
- return convertMovements(this.data);
- }
- static String convertMovements(List<dynamic> data) {
- List<String> args = ["step", "jump", "crouch", "tick", "scissors", "rock", "paper", "trample"];
- Map<String, int> params = {};
- for (var i = 0; i < data.length; i++) {
- params[args[i]] = data[i];
- }
- params["trample"] = params["step"] ?? 0;
- return json.encode(params);
- }
- }
- enum MOTION_COUNT_TYPE {
- STEP_COUNT,
- JUMP_COUNT,
- DOWN_COUNT,
- KICK_COUNT,
- PAPER_COUNT,
- SCISSORS_COUNT,
- ROCK_COUNT,
- }
|