Skip to content

Commit

Permalink
refactor: move gameTime and sampleSize to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveVanOpstal committed May 31, 2016
1 parent ebe93e8 commit 6921882
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions config/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export declare module settings {
match: string,
'static-data': string,
}
let gameTime: number;
let sampleSize: number;
}
4 changes: 3 additions & 1 deletion config/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ module.exports.settings = helpers.merge(settings, {
'matchlist': 'v2.2',
'match': 'v2.2',
'static-data': 'v1.2',
}
},
sampleSize: 64,
gameTime: 3600000
});
3 changes: 0 additions & 3 deletions src/app/build/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export class Config {
public sampleSize: number = 24;
public gameTime: number = 3600000;

public xp: Array<number> = [];
public g: Array<number> = [];

Expand Down
5 changes: 3 additions & 2 deletions src/app/build/graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Component, ChangeDetectionStrategy, OnChanges, OnInit, SimpleChange, Inp
import * as d3 from 'd3';

import {Config} from './config';
import {settings} from '../../../config/settings';

import {DDragonDirective} from '../misc/ddragon.directive';

Expand Down Expand Up @@ -52,7 +53,7 @@ export class GraphComponent implements OnChanges, OnInit {
private line: any = d3.svg.line()
.interpolate('monotone')
.x((d, i) => {
return this.xScaleTime(i * (this.config.gameTime / (this.config.sampleSize - 1)));
return this.xScaleTime(i * (settings.gameTime / (settings.sampleSize - 1)));
})
.y((d) => { return this.yScale(d); });

Expand All @@ -69,7 +70,7 @@ export class GraphComponent implements OnChanges, OnInit {

createAxes() {
this.xScaleTime = d3.scale.linear()
.domain([0, this.config.gameTime])
.domain([0, settings.gameTime])
.range([0, this.graphWidth]);

this.yScale = d3.scale.linear()
Expand Down
3 changes: 2 additions & 1 deletion src/app/build/items/item-slot.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Observable} from 'rxjs/Observable';
import {ItemComponent} from './item.component';
import {Item} from '../../misc/item';
import {Config} from '../config';
import {settings} from '../../../../config/settings';

import * as d3 from 'd3'; // TODO: remove test

Expand Down Expand Up @@ -53,7 +54,7 @@ export class ItemSlotComponent {
}

private addTime(item: Item) {
item.time = this.getTime(this.config.g, item.gold.total, this.config.gameTime, this.config.sampleSize);
item.time = this.getTime(this.config.g, item.gold.total, settings.gameTime, settings.sampleSize);
}

private addBundle(item: Item) {
Expand Down
3 changes: 2 additions & 1 deletion src/app/routes/build.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {ErrorComponent} from '../misc/error.component';
import {LolApiService} from '../misc/lolapi.service';

import {Config} from '../build/config';
import {settings} from '../../../config/settings';

@Component({
providers: [LolApiService],
Expand Down Expand Up @@ -64,7 +65,7 @@ export class BuildComponent {
}

getMatchData(value: string) {
this.lolApi.getMatchData(value, this.championKey, this.config.gameTime, this.config.sampleSize)
this.lolApi.getMatchData(value, this.championKey, settings.gameTime, settings.sampleSize)
.subscribe(
res => {
this.config = new Config();
Expand Down

0 comments on commit 6921882

Please sign in to comment.