mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Adds streak system to fusion quiz + tracks statistics
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -135,6 +135,9 @@ VAR_STAT_HOTELS_SPENT=225
|
||||
VAR_STAT_QUESTS_ACCEPTED=96
|
||||
VAR_STAT_QUESTS_COMPLETED=98
|
||||
VAR_STAT_NB_SECRETS=193
|
||||
VAR_STAT_FUSION_QUIZ_HIGHEST_SCORE=267
|
||||
VAR_STAT_FUSION_QUIZ_NB_TIMES=268
|
||||
VAR_STAT_FUSION_QUIZ_TOTAL_PTS=269
|
||||
|
||||
VAR_FOSSIL=271
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ def Kernel.pbDisplayText(message,xposition,yposition,z=nil, baseColor=nil, shado
|
||||
@hud = []
|
||||
end
|
||||
# Draw the text
|
||||
baseColor= baseColor != nil ? baseColor : Color.new(72,72,72)
|
||||
shadowColor= shadowColor !=nil ? shadowColor : Color.new(160,160,160)
|
||||
baseColor= baseColor ? baseColor : Color.new(72,72,72)
|
||||
shadowColor= shadowColor ? shadowColor : Color.new(160,160,160)
|
||||
sprite = BitmapSprite.new(Graphics.width,Graphics.height,@viewport1)
|
||||
if z != nil
|
||||
sprite.z=z
|
||||
|
||||
@@ -10,6 +10,7 @@ class FusionQuiz
|
||||
def initialize(difficulty = :REGULAR)
|
||||
@sprites = {}
|
||||
|
||||
|
||||
@previewwindow = nil
|
||||
@difficulty = difficulty
|
||||
@customs_list = getCustomSpeciesList(true, false)
|
||||
@@ -19,13 +20,18 @@ class FusionQuiz
|
||||
@choices = []
|
||||
@abandonned = false
|
||||
@score = 0
|
||||
@current_streak = 0
|
||||
@streak_multiplier = 0.15
|
||||
end
|
||||
|
||||
|
||||
def start_quiz(nb_rounds = 3)
|
||||
nb_games_played= pbGet(VAR_STAT_FUSION_QUIZ_NB_TIMES)
|
||||
pbSet(VAR_STAT_FUSION_QUIZ_NB_TIMES,nb_games_played+1)
|
||||
|
||||
round_multiplier = 1
|
||||
round_multiplier_increase = 0.1
|
||||
|
||||
|
||||
for i in 1..nb_rounds
|
||||
if i == nb_rounds
|
||||
pbMessage(_INTL("Get ready! Here comes the final round!"))
|
||||
@@ -36,7 +42,6 @@ class FusionQuiz
|
||||
end
|
||||
start_quiz_new_round(round_multiplier)
|
||||
|
||||
|
||||
rounds_left = nb_rounds - i
|
||||
if rounds_left > 0
|
||||
pbMessage(_INTL("That's it for round {1}. You've cumulated {2} points so far.", i, @score))
|
||||
@@ -54,8 +59,16 @@ class FusionQuiz
|
||||
pbMessage("Thanks for playing with us today!")
|
||||
end
|
||||
end
|
||||
end_quiz()
|
||||
end
|
||||
|
||||
def end_quiz()
|
||||
Kernel.pbClearText()
|
||||
previous_highest = pbGet(VAR_STAT_FUSION_QUIZ_HIGHEST_SCORE)
|
||||
pbSet(VAR_STAT_FUSION_QUIZ_HIGHEST_SCORE,@score) if @score > previous_highest
|
||||
|
||||
previous_total = pbGet(VAR_STAT_FUSION_QUIZ_TOTAL_PTS)
|
||||
pbSet(VAR_STAT_FUSION_QUIZ_TOTAL_PTS,previous_total+@score)
|
||||
end
|
||||
|
||||
def start_quiz_new_round(round_multiplier = 1)
|
||||
@@ -73,41 +86,50 @@ class FusionQuiz
|
||||
perfect_round_points = 50
|
||||
end
|
||||
|
||||
|
||||
pick_random_pokemon()
|
||||
show_fusion_picture(true)
|
||||
correct_answers = []
|
||||
|
||||
#OBSCURED
|
||||
correct_answers << new_question(base_points_q1*round_multiplier, "Which Pokémon is this fusion's body?",@body_id,true,true )
|
||||
correct_answers << new_question(calculate_points_awarded(base_points_q1, round_multiplier), "Which Pokémon is this fusion's body?", @body_id, true, true)
|
||||
pbMessage("Next question!")
|
||||
correct_answers << new_question(base_points_q2*round_multiplier,"Which Pokémon is this fusion's head?", @head_id,true,true )
|
||||
correct_answers << new_question(calculate_points_awarded(base_points_q2, round_multiplier), "Which Pokémon is this fusion's head?", @head_id, true, true)
|
||||
|
||||
#NON-OBSCURED
|
||||
if !correct_answers[0] || !correct_answers[1]
|
||||
show_fusion_picture(false)
|
||||
pbMessage("Okay, now's your chance to make up for the points you missed!")
|
||||
if !correct_answers[0] #1st question redemption
|
||||
new_question(base_points_q1_redemption*round_multiplier, "Which Pokémon is this fusion's body?",@body_id,true,false )
|
||||
new_question(calculate_points_awarded(base_points_q1_redemption, round_multiplier), "Which Pokémon is this fusion's body?", @body_id, true, false)
|
||||
if !correct_answers[1]
|
||||
pbMessage("Next question!")
|
||||
end
|
||||
end
|
||||
|
||||
if !correct_answers[1] #2nd question redemption
|
||||
new_question(base_points_q2_redemption*round_multiplier,"Which Pokémon is this fusion's head?", @head_id,true,false )
|
||||
new_question(calculate_points_awarded(base_points_q2_redemption, round_multiplier), "Which Pokémon is this fusion's head?", @head_id, true, false)
|
||||
end
|
||||
else
|
||||
pbSEPlay("Applause", 80)
|
||||
pbMessage(_INTL("Wow! A perfect round! You get {1} more points!", perfect_round_points))
|
||||
show_fusion_picture(false, 100)
|
||||
pbMessage("Let's see what this Pokémon looked like!")
|
||||
|
||||
end
|
||||
current_streak_dialog()
|
||||
hide_fusion_picture()
|
||||
|
||||
end
|
||||
|
||||
def calculate_points_awarded(base_points, round_multiplier)
|
||||
points = base_points * round_multiplier
|
||||
if @current_streak > 0
|
||||
current_streak_multiplier = (@current_streak * @streak_multiplier) - @streak_multiplier
|
||||
points += points * current_streak_multiplier
|
||||
#p (base_points * round_multiplier)
|
||||
#p (points * current_streak_multiplier)
|
||||
end
|
||||
return points
|
||||
end
|
||||
|
||||
def new_question(points_value, question, answer_id, should_generate_new_choices, other_chance_later)
|
||||
points_value = points_value.to_i
|
||||
@@ -118,7 +140,30 @@ class FusionQuiz
|
||||
return answered_correctly
|
||||
end
|
||||
|
||||
def increase_streak
|
||||
@current_streak += 1
|
||||
refresh_streak_ui()
|
||||
end
|
||||
|
||||
def break_streak
|
||||
@current_streak = 0
|
||||
refresh_streak_ui()
|
||||
end
|
||||
|
||||
def refresh_streak_ui()
|
||||
shadow_color = Color.new(160,160,160)
|
||||
base_color_low_streak = Color.new(72,72,72)
|
||||
base_color_medium_streak = Color.new(213,254,205)
|
||||
base_color_high_streak = Color.new(100,232,96)
|
||||
|
||||
streak_color= base_color_low_streak
|
||||
streak_color = base_color_medium_streak if @current_streak >= 2
|
||||
streak_color = base_color_high_streak if @current_streak >= 4
|
||||
|
||||
message = _INTL("Streak: {1}",@current_streak)
|
||||
Kernel.pbClearText()
|
||||
Kernel.pbDisplayText(message,420,340,nil,streak_color)
|
||||
end
|
||||
|
||||
def award_points(nb_points)
|
||||
@score += nb_points
|
||||
@@ -133,15 +178,27 @@ class FusionQuiz
|
||||
|
||||
if answered_correctly
|
||||
pbSEPlay("itemlevel", 80)
|
||||
increase_streak
|
||||
pbMessage("That's a correct answer!")
|
||||
pbMessage(_INTL("You're awarded {1} points for your answer. Your current score is {2}", points_awarded_if_win, @score.to_s))
|
||||
else
|
||||
pbSEPlay("buzzer", 80)
|
||||
pbMessage("Unfortunately, that was a wong answer.")
|
||||
break_streak
|
||||
pbMessage("Unfortunately, that was a wrong answer.")
|
||||
pbMessage("But you'll get another chance!") if other_chance_later
|
||||
end
|
||||
end
|
||||
|
||||
def current_streak_dialog()
|
||||
return if @current_streak ==0
|
||||
if @current_streak % 4 == 0
|
||||
if @current_streak >= 8
|
||||
pbMessage(_INTL("That's {1} correct answers in a row. You're on a roll!", @current_streak))
|
||||
else
|
||||
pbMessage(_INTL("That's {1} correct answers in a row. You're doing great!", @current_streak))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show_fusion_picture(obscured = false, x = nil, y = nil)
|
||||
hide_fusion_picture()
|
||||
@@ -222,7 +279,6 @@ class FusionQuiz
|
||||
return commands.shuffle
|
||||
end
|
||||
|
||||
|
||||
def prompt_pick_answer_advanced(prompt_message, answer)
|
||||
commands = []
|
||||
for dex_num in 1..NB_POKEMON
|
||||
@@ -233,7 +289,6 @@ class FusionQuiz
|
||||
return pbChooseList(commands, 0, nil, 1)
|
||||
end
|
||||
|
||||
|
||||
def get_score
|
||||
return @score
|
||||
end
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user