-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlesson.lua
106 lines (87 loc) · 2.82 KB
/
lesson.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
-- lesson.lua
--
-- Copyright 2010 Brandon Blodget
--
-- This file is part of "Love To Type."
--
-- "Love To Type" is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- "Love To Type" is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with "Love To Type". If not, see <http://www.gnu.org/licenses/>.
Lesson = {}
Lesson.__index = Lesson
-- The Lesson Outline
-- nonsense x1 (first time x2 2nd time) (intro text)
-- letter
-- nonsense x1 (first time x2 2nd time) (no intro text)
-- letter
-- short x2 x8 (timed)
-- actual wpm / target wpm 15
-- long x4 x4 (timed)
-- actual wpm / target wpm 15 (repeat or continue)
-- Creates the lesson for the given level data
function Lesson.create(data,step)
local self = Lesson
self.data = data
if (step) then
self.step = step
else
self.step = 0
end
return self
end
-- Returns the next lesson state
function Lesson:next()
self.step = self.step + 1
local data = self.data
if (self.step == 1) then
return Word.create(self.data.nonsense,self.data.intro,false,self.data.nonsense_len);
elseif (self.step == 2) then
return Letters.create(data.letter)
elseif (self.step == 3) then
return Word.create(data.nonsense,nil,false,data.nonsense_len)
elseif (self.step == 4) then
return Letters.create(data.letter)
elseif (self.step == 5) then
return Word.create(data.short,nil,true,2)
elseif (self.step == 6) then
data.actual_wpm = wpm
return Results.create(data.name,false,data.actual_wpm,data.target_wpm)
elseif (self.step == 7) then
return Word.create(data.long,nil,true,4)
elseif (self.step == 8) then
data.actual_wpm = wpm
local target = data.target_wpm
if (data.actual_wpm > target) then
data.target_wpm = data.actual_wpm -2
data.nonsense_len = 4
end
return Results.create(data.name,true,data.actual_wpm,target)
-- no self.step == 9 falls to else clause
-- step == 10 is for the review level
elseif (self.step == 10) then
local words_per_line = 2
if (data.actual_wpm > 15) then
words_per_line = 4
end
return Word.create(data.long,nil,true,words_per_line,32,data.name,color.dark_blue)
elseif (self.step == 11) then
data.actual_wpm = wpm
local target = data.target_wpm
if (data.actual_wpm > target) then
data.target_wpm = data.actual_wpm -2
end
return Results.create(data.name,true,data.actual_wpm,target)
else
-- back to the levels selection
self.step = 0
return LessonMenu.create()
end
end