Track whether the player hsa completed the tutorial

This commit is contained in:
Pyrex 2024-02-10 22:19:54 -08:00
parent d7d91dd3a7
commit a06ea160b2
9 changed files with 57 additions and 10 deletions

View File

@ -73,6 +73,10 @@ function board:set_restart_progress(progress)
self.restart_progress=progress self.restart_progress=progress
end end
function board:get_completion_level()
return self.ruleset.completion_level
end
function board:undo() function board:undo()
if (not self.watcher:intercept("undo")) return if (not self.watcher:intercept("undo")) return
if (self.checkpoint) self.checkpoint:apply(self) if (self.checkpoint) self.checkpoint:apply(self)

17
completion_tracker.lua Normal file
View File

@ -0,0 +1,17 @@
completion_tracker={}
add(modules,completion_tracker)
function completion_tracker:init()
cartdata("pyrex_fortunesfoundation_1")
end
function completion_tracker:get_completion_level()
return dget(0)
end
function completion_tracker:advance_completion_level(clevel)
dset(0,max(dget(0), clevel))
end
function completion_tracker:should_show_tutorial()
return self:get_completion_level() < tutorial.completion_stage
end

View File

@ -4,7 +4,9 @@ add(modules,main)
function main:init() function main:init()
extcmd("rec") extcmd("rec")
self.state_manager=state_manager:new() -- instantiate one global self.state_manager=state_manager:new() -- instantiate one global
self.state_manager:push(state_ironman:new(tutorial)) self.state_manager:push(state_menu:new())
-- TODO: Push menu here
if (completion_tracker:should_show_tutorial()) self.state_manager:push(state_ironman:new(tutorial))
end end
function main:update() function main:update()

View File

@ -7,6 +7,7 @@ __lua__
#include board.lua #include board.lua
#include board_animations.lua #include board_animations.lua
#include checkpoint.lua #include checkpoint.lua
#include completion_tracker.lua
#include dealer.lua #include dealer.lua
#include democrap.lua #include democrap.lua
#include cursor.lua #include cursor.lua
@ -18,6 +19,7 @@ __lua__
#include seed_constants.lua #include seed_constants.lua
#include seeds.lua #include seeds.lua
#include state_manager.lua #include state_manager.lua
#include state_menu.lua
#include state_gameround.lua #include state_gameround.lua
#include state_ironman.lua #include state_ironman.lua
#include state_restartmenu.lua #include state_restartmenu.lua

View File

@ -1,16 +1,16 @@
progression={ progression={
-- level 1 -- level 1
ruleset:new(5,1,9,0), -- by test: always winnable ruleset:new(1,5,1,9,0), -- by test: always winnable
-- level 2 -- level 2
ruleset:new(5,2,9,0), -- by test: always winnable ruleset:new(2,5,2,9,0), -- by test: always winnable
-- level 3 -- level 3
ruleset:new(7,2,9,8), -- by test: always winnable ruleset:new(3,7,2,9,8), -- by test: always winnable
-- level 4 (first challenging) -- level 4 (first challenging)
ruleset:new(9,3,9,16, "l4"), ruleset:new(4,9,3,9,16, "l4"),
-- level 5 -- level 5
ruleset:new(9,3,11,18, "l5"), ruleset:new(5,9,3,11,18, "l5"),
-- fortune's foundation -- fortune's foundation
ruleset:new(11,4,13,22,"ff"), ruleset:new(6,11,4,13,22,"ff"),
-- harder than fortune's foundation -- harder than fortune's foundation
ruleset:new(11,5,10,25,"l7") ruleset:new(7,11,5,10,25,"l7")
} }

View File

@ -1,5 +1,6 @@
ruleset=klass() ruleset=klass()
function ruleset:init( function ruleset:init(
completion_level,
-- Number of unlocked slots (up to 11) -- Number of unlocked slots (up to 11)
-- Includes the one in the middle -- Includes the one in the middle
-- For Fortune's Foundation: 11 -- For Fortune's Foundation: 11
@ -19,6 +20,7 @@ function ruleset:init(
n_arcana, n_arcana,
pool pool
) )
self.completion_level=completion_level
self.n_slots=n_slots self.n_slots=n_slots
self.n_suits=n_suits self.n_suits=n_suits
self.n_cards_per_suit=n_cards_per_suit self.n_cards_per_suit=n_cards_per_suit

View File

@ -8,9 +8,9 @@ function state_ironman:enter() self:on_enter() end
function state_ironman:exit() end function state_ironman:exit() end
function state_ironman:reenter(round) function state_ironman:reenter(round)
printh("reenter "..round.outcome)
if round.outcome=="win" then if round.outcome=="win" then
self.level+=1 self.level+=1
completion_tracker:advance_completion_level(round.board:get_completion_level())
elseif round.outcome=="menu" then elseif round.outcome=="menu" then
self.done=true self.done=true
elseif round.outcome=="restart" then elseif round.outcome=="restart" then

19
state_menu.lua Normal file
View File

@ -0,0 +1,19 @@
state_menu=klass()
function state_menu:init()
end
function state_menu:enter() end
function state_menu:exit(new_top) end
function state_menu:reenter() end
function state_menu:suspend() end
function state_menu:update()
-- if (btnp(0)) self.outcome="menu" self.done=true
-- if (btnp(4)) self.outcome="restart" self.done=true
end
function state_menu:draw()
cls(13)
print("i am the menu",1,55,7)
print("i kinda suck",1,61,7)
print("i'll get better later",1,67,7)
end

View File

@ -33,5 +33,6 @@ tutorial={
function() return watcher:new(progression[4]) end, function() return watcher:new(progression[4]) end,
function() return watcher:new(progression[5]) end, function() return watcher:new(progression[5]) end,
function() return watcher:new(progression[6]) end, function() return watcher:new(progression[6]) end,
function() return watcher:new(progression[7]) end function() return watcher:new(progression[7]) end,
completion_stage=3
} }