Track whether the player hsa completed the tutorial
This commit is contained in:
parent
d7d91dd3a7
commit
a06ea160b2
@ -73,6 +73,10 @@ function board:set_restart_progress(progress)
|
||||
self.restart_progress=progress
|
||||
end
|
||||
|
||||
function board:get_completion_level()
|
||||
return self.ruleset.completion_level
|
||||
end
|
||||
|
||||
function board:undo()
|
||||
if (not self.watcher:intercept("undo")) return
|
||||
if (self.checkpoint) self.checkpoint:apply(self)
|
||||
|
17
completion_tracker.lua
Normal file
17
completion_tracker.lua
Normal 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
|
4
main.lua
4
main.lua
@ -4,7 +4,9 @@ add(modules,main)
|
||||
function main:init()
|
||||
extcmd("rec")
|
||||
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
|
||||
|
||||
function main:update()
|
||||
|
2
main.p8
2
main.p8
@ -7,6 +7,7 @@ __lua__
|
||||
#include board.lua
|
||||
#include board_animations.lua
|
||||
#include checkpoint.lua
|
||||
#include completion_tracker.lua
|
||||
#include dealer.lua
|
||||
#include democrap.lua
|
||||
#include cursor.lua
|
||||
@ -18,6 +19,7 @@ __lua__
|
||||
#include seed_constants.lua
|
||||
#include seeds.lua
|
||||
#include state_manager.lua
|
||||
#include state_menu.lua
|
||||
#include state_gameround.lua
|
||||
#include state_ironman.lua
|
||||
#include state_restartmenu.lua
|
||||
|
@ -1,16 +1,16 @@
|
||||
progression={
|
||||
-- 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
|
||||
ruleset:new(5,2,9,0), -- by test: always winnable
|
||||
ruleset:new(2,5,2,9,0), -- by test: always winnable
|
||||
-- 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)
|
||||
ruleset:new(9,3,9,16, "l4"),
|
||||
ruleset:new(4,9,3,9,16, "l4"),
|
||||
-- level 5
|
||||
ruleset:new(9,3,11,18, "l5"),
|
||||
ruleset:new(5,9,3,11,18, "l5"),
|
||||
-- fortune's foundation
|
||||
ruleset:new(11,4,13,22,"ff"),
|
||||
ruleset:new(6,11,4,13,22,"ff"),
|
||||
-- harder than fortune's foundation
|
||||
ruleset:new(11,5,10,25,"l7")
|
||||
ruleset:new(7,11,5,10,25,"l7")
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
ruleset=klass()
|
||||
function ruleset:init(
|
||||
completion_level,
|
||||
-- Number of unlocked slots (up to 11)
|
||||
-- Includes the one in the middle
|
||||
-- For Fortune's Foundation: 11
|
||||
@ -19,6 +20,7 @@ function ruleset:init(
|
||||
n_arcana,
|
||||
pool
|
||||
)
|
||||
self.completion_level=completion_level
|
||||
self.n_slots=n_slots
|
||||
self.n_suits=n_suits
|
||||
self.n_cards_per_suit=n_cards_per_suit
|
||||
|
@ -8,9 +8,9 @@ function state_ironman:enter() self:on_enter() end
|
||||
function state_ironman:exit() end
|
||||
|
||||
function state_ironman:reenter(round)
|
||||
printh("reenter "..round.outcome)
|
||||
if round.outcome=="win" then
|
||||
self.level+=1
|
||||
completion_tracker:advance_completion_level(round.board:get_completion_level())
|
||||
elseif round.outcome=="menu" then
|
||||
self.done=true
|
||||
elseif round.outcome=="restart" then
|
||||
|
19
state_menu.lua
Normal file
19
state_menu.lua
Normal 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
|
@ -33,5 +33,6 @@ tutorial={
|
||||
function() return watcher:new(progression[4]) end,
|
||||
function() return watcher:new(progression[5]) 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user