Created
June 22, 2018 11:15
-
-
Save boxgames1/8e337bdc0b53cba98ca221161ccdfe6a to your computer and use it in GitHub Desktop.
Chocri Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Team { | |
constructor(name, zone){ | |
this.zone = zone; | |
this.name = name; | |
} | |
} | |
class Game { | |
constructor (team1, team2, week){ | |
this.team1 = team1; | |
this.team2 = team2; | |
this.week = week; | |
} | |
} | |
class Week { | |
constructor(games){ | |
this.games = games; | |
} | |
getGameByTeam(name){ | |
if(this.games.length > 0) { | |
this.games.forEach(element => { | |
if(element.team1.name === name || element.team2.name === name) return element; | |
}); | |
} | |
return false; | |
} | |
} | |
class Calendar { | |
constructor(teams, zone_games, no_zone_games){ | |
this.teams = teams; | |
this.zone_games = zone_games; | |
this.no_zone_games = no_zone_games; | |
this.weeks = ((teams.length / 2) * no_zone_games ) + (((teams.length / 2) - 1) * zone_games); | |
this.fixtures = []; | |
} | |
build_fixtures(){ | |
this.fixtures = []; | |
// zone games at beggining & at end | |
// no zone games at the end | |
const zone_games_unique = ((this.teams.length / 2) - 1); | |
const no_zone_games_unique = ((this.teams.length / 2)); | |
for (var i = 1; i < this.weeks; i++){ | |
if(i <= zone_games_unique){ | |
// zone game fixture at beginning | |
} | |
else if (i >= (this.week - zone_games_unique)){ | |
// zone game fixture at the end | |
} | |
else { | |
// no zone game | |
} | |
} | |
} | |
} | |
const teams = []; | |
for(let i = 1; i<11; i++){ | |
const zone = i % 2; //50-50 deliver | |
const team = new Team('Team ' + i, zone + 1); | |
teams.push(team); | |
} | |
let calendar = new Calendar(teams, 2, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment