<commit_before>import {Injectable} from "angular2/core";
import {HTTP_PROVIDERS, Http, Response} from "angular2/http";
import {Observable} from "rxjs/Rx";

import {Game} from "../models/game";

// game_id is passed in from the back-end and written in index.html
declare var game_id: string;

/**
 * Game Loader service. Loads initial adventure, room, artifact, and monster
 * data from the data source.
 */
@Injectable()
export class GameLoaderService {

  constructor(private http: Http) { }

  setupGameData() {

    let game = Game.getInstance();

    // load all the game data objects in parallel
    Observable.forkJoin(
      this.http.get("/static/" + game_id + "/mock-data/adventure.json").map((res: Response) => res.json()),
      this.http.get("/static/" + game_id + "/mock-data/rooms.json").map((res: Response) => res.json()),
      this.http.get("/static/" + game_id + "/mock-data/artifacts.json").map((res: Response) => res.json()),
      this.http.get("/static/" + game_id + "/mock-data/monsters.json").map((res: Response) => res.json()),
      this.http.get("/static/" + game_id + "/mock-data/player.json").map((res: Response) => res.json())
    ).subscribe(
        data => {
          game.init(data);
        }
    );

  }

}
<commit_msg>Ability to load adventure data from the Django back-end<commit_after>import {Injectable} from "angular2/core";
import {HTTP_PROVIDERS, Http, Response} from "angular2/http";
import {Observable} from "rxjs/Rx";

import {Game} from "../models/game";

// game_id is passed in from the back-end and written in index.html
declare var game_id: string;

/**
 * Game Loader service. Loads initial adventure, room, artifact, and monster
 * data from the data source.
 */
@Injectable()
export class GameLoaderService {

  constructor(private http: Http) { }

  setupGameData() {

    let game = Game.getInstance();

    // load all the game data objects in parallel
    if (game_id == 'demo1') {
        // load mock data
        Observable.forkJoin(
          this.http.get("/static/" + game_id + "/mock-data/adventure.json").map((res: Response) => res.json()),
          this.http.get("/static/" + game_id + "/mock-data/rooms.json").map((res: Response) => res.json()),
          this.http.get("/static/" + game_id + "/mock-data/artifacts.json").map((res: Response) => res.json()),
          this.http.get("/static/" + game_id + "/mock-data/monsters.json").map((res: Response) => res.json()),
          this.http.get("/static/" + game_id + "/mock-data/player.json").map((res: Response) => res.json())
        ).subscribe(
            data => {
              game.init(data);
            }
        );
    } else {
        // load live data from the back end
        Observable.forkJoin(
          this.http.get("/api/adventures/" + game_id).map((res: Response) => res.json()),
          this.http.get("/api/adventures/" + game_id + "/rooms").map((res: Response) => res.json()),
          this.http.get("/api/adventures/" + game_id + "/artifacts").map((res: Response) => res.json()),
          // todo: load effects
//          this.http.get("/api/adventures/" + game_id + "/effects").map((res: Response) => res.json()),
          this.http.get("/api/adventures/" + game_id + "/monsters").map((res: Response) => res.json()),
          // player is still currently loaded from mock data
          this.http.get("/static/demo1/mock-data/player.json").map((res: Response) => res.json())
        ).subscribe(
            data => {
              game.init(data);
            }
        );
    }
  }

}

{'fraction_non_alphanumeric': 0.17966101694915254, 'fraction_numerical': 0.001694915254237288, 'mean_word_length': 2.7078534031413612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3738113', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1085, 'n_words': 256}