import 'package:sport/bean/user.dart';

class RankGameInfoData {
  Rank rank;
  User user;
  List<User> records;

  RankGameInfoData({this.rank, this.user, this.records});

  RankGameInfoData.fromJson(Map<String, dynamic> json) {
    rank = json['rank'] != null ? new Rank.fromJson(json['rank']) : null;
    user = json['user'] != null ? new User.fromJson(json['user']) : null;
    if (json['records'] != null) {
      records = new List<User>();
      json['records'].forEach((v) {
        records.add(new User.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.rank != null) {
      data['rank'] = this.rank.toJson();
    }
    if (this.user != null) {
      data['user'] = this.user.toJson();
    }
    if (this.records != null) {
      data['records'] = this.records.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Rank {
  int id;
  String name;
  int isGame;
  int isSport;
  int gameId;
  String introduce;
  String introduceDetail;
  String rule;
  String distribute;
  int userCountMax;
  String rateBegin;
  String rateEnd;
  String logo;
  String field;
  String slogan;
  List<RankReward> reward;
  Rank(
      {this.id,
        this.name,
        this.isGame,
        this.isSport,
        this.gameId,
        this.introduce,
        this.userCountMax,
        this.rateBegin,
        this.rateEnd,
        this.logo,
        this.field,
        this.slogan,
        this.reward,
      });

  Rank.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    isGame = json['is_game'];
    isSport = json['is_sport'];
    gameId = json['game_id'];
    introduce = json['introduce'];
    introduceDetail = json['introduce_detail'];
    rule = json['rule'];
    distribute = json['distribute'];
    userCountMax = json['user_count_max'];
    rateBegin = json['rate_begin'];
    rateEnd = json['rate_end'];
    logo = json['logo'];
    field = json['field'];
    slogan = json['slogan'];
    if (json['reward'] != null) {
      reward = new List<RankReward>();
      json['reward'].forEach((v) {
        reward.add(new RankReward.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['is_game'] = this.isGame;
    data['is_sport'] = this.isSport;
    data['game_id'] = this.gameId;
    data['introduce'] = this.introduce;
    data['introduce_detail'] = this.introduceDetail;
    data['distribute'] = this.distribute;
    data['rule'] = this.rule;
    data['user_count_max'] = this.userCountMax;
    data['rate_begin'] = this.rateBegin;
    data['rate_end'] = this.rateEnd;
    data['logo'] = this.logo;
    data['field'] = this.field;
    data['slogan'] = this.slogan;
    data['reward'] = this.reward;
    return data;
  }
}

class RankReward{
  int begin;
  int end;
  int score;
  RankReward({
    this.begin,
    this.end,
    this.score
  });
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['begin']  = this.begin;
    data['end'] = this.end;
    data['score'] = this.score;
    return data;
  }
  RankReward.fromJson(Map<String, dynamic> json) {
    begin = json['begin'];
    end = json['end'];
    score = json['score'];
  }
}