Skip to content

Commit

Permalink
v2.3 ready for production
Browse files Browse the repository at this point in the history
  • Loading branch information
LiberoHS committed Sep 10, 2019
1 parent 16d4ac4 commit c908292
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 87 deletions.
Binary file added client/public/assets/nlf-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> -->
<link rel="shortcut icon" href="./assets/nlf-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand All @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Champion's Festival</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
8 changes: 6 additions & 2 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ const buttonStyle = {
// Home page (done v2.2)
// Table paginations
// Sorting tournaments
// Data analytics (v3)
// Data analytics (v4)
// Need to refactor Challenges filter
// Need to refactor styling
// Filter functionality for Cups
// Back button (done v2.1)
// Decklist integration (v5)

// class Tournament {
// constructor(name, attendance, type, format, date) {
Expand Down Expand Up @@ -178,7 +180,9 @@ class App extends React.Component {
</Grid>
<Grid>
{/* WIP */}
{show === 'home' && <HomeMenu tournaments={tournamentList} decks={decks} />}
{show === 'home' && <HomeMenu
tournaments={tournamentList}
decks={decks}/>}
</Grid>
<Grid>
{show === 'list' && <SearchBar onFormSubmit={this.handleChange}/>}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/HomeMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const HomeMenu = ({ tournaments, decks }) => {
<h2 style={text}>Top Performing Decks of the Week</h2>
<Paper classname={classes.root}>
<div className={classes.tableWrapper}>
<p style={wip} align="center">Coming Soon in v3!</p>
<p style={wip} align="center">Coming Soon in v4!</p>
</div>
</Paper>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/TournamentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TournamentList = ({ setCurrentTournament, tournamentList }) => {
<TableRow key={key}>
<TableCell align="center" style={cellStyle}>{item.date}</TableCell>
<TableCell component="th" align="center">
<button onClick={() => setCurrentTournament(item)}> {item.name}</button>
<button onClick={() => setCurrentTournament(item)}>{item.name}</button>
</TableCell>
<TableCell align="center" style={cellStyle}>{item.region}</TableCell>
<TableCell align="center" style={cellStyle}>{item.type}</TableCell>
Expand Down
160 changes: 80 additions & 80 deletions client/src/data/players.js

Large diffs are not rendered by default.

49 changes: 48 additions & 1 deletion client/src/scripts/init_players.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,53 @@ tournament list to insert any new occurrence of players. */
// var decks = require('../data/decks.js');
var tournaments = require('../data/tournaments.js');

//
function calcPointPayout(tournament, player) {
if (tournament.type === 'League Challenge') {
if (player.placing === 1) {
return 15;
} else if (player.placing === 2) {
return 12;
} else if (player.placing <= 4) {
return 10;
} else if (player.placing <= 8) {
return 8;
}
} else if (tournament.type === 'League Cup') {
if (player.placing === 1) {
return 50;
} else if (player.placing === 2) {
return 40;
} else if (player.placing <= 4) {
return 32;
} else if (player.placing <= 8) {
return 25;
}
} else if (tournament.type === 'Regionals' || tournament.type === 'Special Event') {
if (player.placing === 1) {
return 200;
} else if (player.placing === 2) {
return 160;
} else if (player.placing <= 4) {
return 130;
} else if (player.placing <= 8) {
return 100;
} else if (player.placing <= 16) {
return 80;
} else if (player.placing <= 32) {
return 60;
}
}

return 0;
};

// Class declaration for Player
class Player {
constructor(name) {
this.name = name;
this.achievements = [];
this.points = 0;
}

get achievementList() {
Expand Down Expand Up @@ -41,6 +83,10 @@ class Player {
}
}
}

addPoints(value) {
this.points += value
}
}

// Inputs all the players from all the tournaments into a PlayerList database
Expand All @@ -59,6 +105,7 @@ for (let i = 0; i < tournaments.length; i++) {

// Adds the achievement into the database
PlayerList[PlayerList.findIndex(x => x.name === player.name)].addAchievement(tournaments[i].date, tournaments[i].name, tournaments[i].cycle, player.deck, player.placing);
PlayerList[PlayerList.findIndex(x => x.name === player.name)].addPoints(calcPointPayout(tournaments[i], player));
});
}

Expand All @@ -71,7 +118,7 @@ for (let i = 0; i < tournaments.length; i++) {

var data = 'const players = [\n';
for (var i = 0; i < PlayerList.length; i++) {
data += '{ name: "' + PlayerList[i].name + '",\nachievements: [' + PlayerList[i].achievementList + '] },\n'
data += '{ name: "' + PlayerList[i].name + '",\nachievements: [' + PlayerList[i].achievementList + '], points: ' + PlayerList[i].points + ' },\n';
}

data += '];\n\nmodule.exports = players;'
Expand Down

0 comments on commit c908292

Please sign in to comment.