-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds initial challenges, updates lb style
- Loading branch information
Showing
25 changed files
with
258 additions
and
61 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
//= link_tree ../images | ||
//= link_directory ../stylesheets .css | ||
//= link application.css | ||
//= link application.js | ||
//= link administrate/application.css | ||
//= link administrate/application.js | ||
//= link_tree ../builds |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class BattlePassesController < ApplicationController | ||
before_action :authenticate_user! | ||
def show | ||
@battle_pass = current_user.battle_passes.last | ||
end | ||
end |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,31 @@ | ||
class BattlePass < ApplicationRecord | ||
belongs_to :user | ||
has_many :challenges | ||
|
||
def level | ||
calculate_level(xp) | ||
end | ||
|
||
def on_challenge_completed!(challenge) | ||
with_lock do | ||
self.xp += challenge.xp | ||
save! | ||
end | ||
end | ||
|
||
private | ||
|
||
def calculate_level(input_xp) | ||
base_xp = 500 | ||
exponent = 1.5 | ||
|
||
level_acc = 0 | ||
xp_acc = 0 | ||
while xp_acc < input_xp | ||
xp_acc = base_xp * (level_acc**exponent) | ||
level_acc += 1 | ||
end | ||
|
||
[level_acc - 1, 1].max | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class Challenge < ApplicationRecord | ||
belongs_to :battle_pass | ||
belongs_to :battle_pass, touch: true | ||
scope :active, -> { where(active: true) } | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.container | ||
.row | ||
.col-6 | ||
%h3 Battle Pass | ||
%p | ||
Level | ||
= @battle_pass.level | ||
%p | ||
XP | ||
= @battle_pass.xp | ||
.col-6 | ||
%h3 Active Challenges | ||
|
||
#active_challenges | ||
- @battle_pass.challenges.active.each do |challenge| | ||
.card | ||
.card-body | ||
%h5.card-title= challenge.title | ||
.card-text | ||
.progress | ||
.progress-bar{role: "progressbar", style: "width: #{challenge.progress_percent}%"} | ||
= challenge.dataset.count |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
- cache leaderboard, force: local_assigns.fetch(:bust_cache, false) do | ||
#leaderboard | ||
.leaderboard-header.row | ||
.row | ||
.col-8 | ||
%h3= leaderboard.title | ||
%h4= leaderboard.title | ||
.col.text-right | ||
%span#leaderboard_connection_status.badge.badge-secondary{ data: { target: "live-leaderboards.status" } } | ||
Connecting... | ||
%p#leaderboard_last_updated_time | ||
#leaderboard_last_updated_time | ||
%small | ||
Last updated at | ||
= Time.now.strftime("%k:%M:%S") | ||
UTC | ||
Last updated | ||
= local_time_ago(Time.now) | ||
= render partial: "leaderboards/table", locals: { leaderboard: leaderboard } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#leaderboard | ||
.leaderboard-header.row | ||
.row | ||
.col-12 | ||
%h3= leaderboard.count_limited_title(@leaderboard_entries_count) | ||
= render partial: "leaderboards/table", locals: { leaderboard: leaderboard } |
Oops, something went wrong.