Skip to content

Commit

Permalink
add character images and change ladder page style
Browse files Browse the repository at this point in the history
  • Loading branch information
bakana808 committed Mar 16, 2016
1 parent c6f001a commit 9851f59
Show file tree
Hide file tree
Showing 61 changed files with 66 additions and 22 deletions.
Binary file added img/stock/bayonetta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/bowser-jr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/bowser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/captain-falcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/charizard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/cloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/corrin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/dark-pit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/diddy-kong.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/donkey-kong.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/dr-mario.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/duck-hunt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/falco.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/fox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/ganondorf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/greninja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/ike.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/jigglypuff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/king-dedede.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/kirby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/little-mac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/lucario.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/lucas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/lucina.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/stock/luigi.png
Binary file added img/stock/mario.png
Binary file added img/stock/marth.png
Binary file added img/stock/megaman.png
Binary file added img/stock/meta-knight.png
Binary file added img/stock/mewtwo.png
Binary file added img/stock/mii-fighter.png
Binary file added img/stock/mii-gunner.png
Binary file added img/stock/mii-swordsman.png
Binary file added img/stock/mr-game-and-watch.png
Binary file added img/stock/ness.png
Binary file added img/stock/olimar.png
Binary file added img/stock/pac-man.png
Binary file added img/stock/palutena.png
Binary file added img/stock/peach.png
Binary file added img/stock/pikachu.png
Binary file added img/stock/pit.png
Binary file added img/stock/random.png
Binary file added img/stock/rob.png
Binary file added img/stock/robin.png
Binary file added img/stock/rosalina.png
Binary file added img/stock/roy.png
Binary file added img/stock/ryu.png
Binary file added img/stock/samus.png
Binary file added img/stock/sheik.png
Binary file added img/stock/shulk.png
Binary file added img/stock/sonic.png
Binary file added img/stock/toon-link.png
Binary file added img/stock/villager.png
Binary file added img/stock/wario.png
Binary file added img/stock/wii-fit-trainer.png
Binary file added img/stock/yoshi.png
Binary file added img/stock/zelda.png
Binary file added img/stock/zero-suit-samus.png
76 changes: 56 additions & 20 deletions src/ladder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,41 @@ window.onload = () ->
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc

slugify = (string) ->
return string
.toLowerCase()
.replace(/[^\w ]+/g, "")
.replace(/ +/g, "-")

class Player
constructor: (@username, @matches) ->
characters = @matches.getCharactersUsed(@username)
@characters = []
if characters.length == 0 then return
counts = {}
for character in characters
counts[character] = if character of counts then counts[character] + 1 else 1
for character, count of counts
@characters.push [character, (Math.round(count / characters.length * 100 * 100) / 100)]
@characters.sort((a, b) -> b[1] - a[1])

getRankChange: ->
diff = @rank_last - @rank;
if diff > 0 then return "+" + diff;
else return diff;

getRating: -> @rating
getRank: -> @rank
getTier: -> @tier
getUsername: -> @username
getName: -> @displayname
getGamesPlayed: -> @matches.getGamesPlayed(@username)
getGamesWon: -> @matches.getGamesWon(@username)
getWinStreak: -> @matches.getWinStreak(@username)
hasCharacterMain: -> @characters.length != 0
getCharacterMain: -> if @characters.length == 0 then "" else @characters[0]
getCharacterImage: -> if @characters.length == 0 then "" else "/img/stock/#{ slugify @characters[0][0] }.png"

class Elo
@tier: (rating) ->
if rating >= 2050 then return "S"
Expand Down Expand Up @@ -59,7 +94,22 @@ class Matches
else if row[4] == username && row[3] == "Defender" || row[7] == username && row[3] == "Challenger" then games = 0
return games


getCharactersUsed: (username) ->
characters = []
for row in @values
if row[4] == username
if row[10] != "" then characters.push row[10]
if row[14] != "" then characters.push row[14]
if row[18] != "" then characters.push row[18]
if row[22] != "" then characters.push row[22]
if row[26] != "" then characters.push row[26]
else if row[7] == username
if row[11] != "" then characters.push row[11]
if row[15] != "" then characters.push row[15]
if row[19] != "" then characters.push row[19]
if row[23] != "" then characters.push row[23]
if row[27] != "" then characters.push row[27]
return characters

class Ladder
@players: []
Expand Down Expand Up @@ -89,12 +139,13 @@ class Ladder
player.rating = row["Rating"]
player.rank_last = row["Rank Last"]
player.tier = Elo.tier(player.rating)

console.log player
Ladder.players.push player

for player in Ladder.players

playerRankChange = player.getRankChange();

playerRankChange = player.getRankChange()

if playerRankChange == 0 then rankChangeClass = "rank-change__none"
if playerRankChange > 0 then rankChangeClass = "rank-change__raise"
Expand All @@ -107,26 +158,11 @@ class Ladder
<div class="rank-change #{ rankChangeClass }">#{ player.getRankChange() }</div>
<div class="name">#{ player.getName() }</div>
<div class="games">#{ player.getGamesPlayed() } Games #{ if player.getWinStreak() > 0 then "(#{ player.getWinStreak() } game win streak)" else "" }</div>
#{ if player.hasCharacterMain() then "<div class=\"main\"><img title=\"#{ "Played " + player.getCharacterMain()[1] + "%" }\" src=#{ player.getCharacterImage() } alt=#{ player.getCharacterMain()[0] }></div>" else "" }
<div class="tier">#{ player.getTier() }</div>
</div>
</li>
"""

class Player
constructor: (@username, @matches) ->

getRankChange: () ->
diff = @rank_last - @rank;
if diff > 0 then return "+" + diff;
else return diff;
getRating: () -> @rating
getRank: () -> @rank
getTier: () -> @tier
getUsername: () -> @username
getName: () -> @displayname
getGamesPlayed: () -> @matches.getGamesPlayed(@username)
getGamesWon: () -> @matches.getGamesWon(@username)
getWinStreak: () -> @matches.getWinStreak(@username)

init = () ->
Ladder.load("https://docs.google.com/spreadsheets/d/1aNji1A2YqsDZldwpqv-pybWnV4ITKafV8fththQCB2I/pubhtml")
Ladder.load "https://docs.google.com/spreadsheets/d/1aNji1A2YqsDZldwpqv-pybWnV4ITKafV8fththQCB2I/pubhtml"
12 changes: 10 additions & 2 deletions ssb4/ladder/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $tier-e: #b71ede;
border-radius: 5px;
margin-bottom: 5px;

height: 30px;
height: 64px;
line-height: 30px;

background-color: lighten($bracket-color, 50%);
Expand Down Expand Up @@ -138,10 +138,18 @@ $tier-e: #b71ede;
}

.games {
width: auto;
width: 300px;
display: inline-block;
color: rgba(255, 255, 255, 0.4);
}

.main {
position: absolute;
width: auto;
display: inline-block;
color: white;
float: right;
}

}
}

0 comments on commit 9851f59

Please sign in to comment.