Skip to content
Snippets Groups Projects
Commit 1925e276 authored by François Sarradin's avatar François Sarradin Committed by François Sarradin
Browse files

Display current round questions or game status if in pause

parent 24c6e5f7
No related branches found
No related tags found
No related merge requests found
......@@ -443,10 +443,13 @@ module ExtremeStartup
]
end
def next_question(player)
def available_question_types
window_end = (@round * 2 - 1)
window_start = [0, window_end - 4].max
available_question_types = @question_types[window_start..window_end]
@question_types[window_start..window_end]
end
def next_question(player)
available_question_types.sample.new(player)
end
......@@ -456,7 +459,7 @@ module ExtremeStartup
end
class WarmupQuestion < Question
class WarmupQuestion < GetQuestion
def initialize(player)
@player = player
end
......@@ -471,6 +474,10 @@ module ExtremeStartup
end
class WarmupQuestionFactory
def available_question_types
[WarmupQuestion]
end
def next_question(player)
WarmupQuestion.new(player)
end
......
......@@ -30,7 +30,9 @@ module ExtremeStartup
get '/' do
haml :leaderboard, :locals => {
:leaderboard => LeaderBoard.new(scoreboard, players, game_state),
:players => players }
:players => players,
:questions => question_names
}
end
get '/scores' do
......@@ -38,6 +40,8 @@ module ExtremeStartup
end
class LeaderBoard
attr_reader :inplay
def initialize(scoreboard, players, game_state)
@entries = []
scoreboard.leaderboard.each do |entry|
......@@ -72,6 +76,10 @@ module ExtremeStartup
end
end
get '/questions' do
question_names.to_json
end
get '/graph' do
haml :scores
end
......@@ -170,6 +178,11 @@ module ExtremeStartup
private
def question_names
questions = question_factory.available_question_types
questions.map { |c| c.name.gsub(/\w+::(\w+)Question$/, '\\1') }
end
def local_ip
UDPSocket.open {|s| s.connect("64.233.187.99", 1); s.addr.last}
end
......
......@@ -15,6 +15,17 @@
%a{ :href => '/players' }
Enregistrement
%h2
Questions
- if leaderboard.inplay
%ul
- questions.each do |question|
%li #{question}
- else
%p
(Pause)
%h2
%span Leaderboard
%ul
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment