Added question for ON readings and KUN readings! Needs testing to make sure it isnt giving false options or wrong ones.
This commit is contained in:
parent
7a4df1d03d
commit
0d2700d8b4
|
@ -12,6 +12,36 @@ function GetUnrepeatedKanji(lAvoid)
|
||||||
return lKanji
|
return lKanji
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GetUnrepeatedReadingON(lAvoid)
|
||||||
|
lKanji = KanjiData[math.random(#KanjiData)]
|
||||||
|
|
||||||
|
for j=1, #lKanji.On do
|
||||||
|
for i=1, #lAvoid do
|
||||||
|
if lKanji.On[j] == lAvoid[i] then
|
||||||
|
lKanji = GetUnrepeatedKanji(lAvoid)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return GetOneFrom(lKanji.On)
|
||||||
|
end
|
||||||
|
|
||||||
|
function GetUnrepeatedReadingKUN(lAvoid)
|
||||||
|
lKanji = KanjiData[math.random(#KanjiData)]
|
||||||
|
|
||||||
|
if lKanji.Kun == nil then GetUnrepeatedKanji(lAvoid) end
|
||||||
|
|
||||||
|
for j=1, #lKanji.Kun do
|
||||||
|
for i=1, #lAvoid do
|
||||||
|
if lKanji.Kun[j] == lAvoid[i] then
|
||||||
|
lKanji = GetUnrepeatedKanji(lAvoid)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return GetOneFrom(lKanji.Kun)
|
||||||
|
end
|
||||||
|
|
||||||
function GetOneFrom(Table)
|
function GetOneFrom(Table)
|
||||||
if type(Table) == "table" then
|
if type(Table) == "table" then
|
||||||
return Table[math.random(#Table)]
|
return Table[math.random(#Table)]
|
||||||
|
@ -63,15 +93,70 @@ function AskKanji4Meaning()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Ask()
|
function AskReadingON4Kanji()
|
||||||
local Type = math.random(#QuestionType)
|
CurrentKanji = KanjiData[math.random(#KanjiData)]
|
||||||
|
local Reading = GetOneFrom(CurrentKanji.On)
|
||||||
|
for i=1, #CurrentKanji.On do
|
||||||
|
table.insert(AvoidList,CurrentKanji.On[i])
|
||||||
|
end
|
||||||
|
io.write(TextColor("Q: ",COLOR.HighBlue).."Which is a On reading of \""..GetOneFrom(CurrentKanji.Symbol).."\"? \n")
|
||||||
|
io.write("\n")
|
||||||
|
|
||||||
|
for i=1, 4 do
|
||||||
|
if i == Solution then
|
||||||
|
io.write(TextColor(" ("..i..") ",COLOR.HighYellow)..Reading)
|
||||||
|
io.write("\n")
|
||||||
|
else
|
||||||
|
lRandomONReading = GetUnrepeatedReadingON(AvoidList)
|
||||||
|
table.insert(AvoidList,lRandomONReading)
|
||||||
|
io.write(TextColor(" ("..i..") ",COLOR.HighYellow)..lRandomONReading)
|
||||||
|
io.write("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function AskReadingKUN4Kanji()
|
||||||
|
CurrentKanji = KanjiData[math.random(#KanjiData)]
|
||||||
|
local Reading = GetOneFrom(CurrentKanji.Kun)
|
||||||
|
for i=1, #CurrentKanji.Kun do
|
||||||
|
table.insert(AvoidList,CurrentKanji.Kun[i])
|
||||||
|
end
|
||||||
|
io.write(TextColor("Q: ",COLOR.HighBlue).."Which is a Kun reading of \""..GetOneFrom(CurrentKanji.Symbol).."\"? \n")
|
||||||
|
io.write("\n")
|
||||||
|
|
||||||
|
for i=1, 4 do
|
||||||
|
if i == Solution then
|
||||||
|
io.write(TextColor(" ("..i..") ",COLOR.HighYellow)..Reading)
|
||||||
|
io.write("\n")
|
||||||
|
else
|
||||||
|
lRandomKUNReading = GetUnrepeatedReadingKUN(AvoidList)
|
||||||
|
table.insert(AvoidList,lRandomKUNReading)
|
||||||
|
io.write(TextColor(" ("..i..") ",COLOR.HighYellow)..lRandomKUNReading)
|
||||||
|
io.write("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
QuestionType = Enum {
|
||||||
|
"KANJI4MEANING",
|
||||||
|
"MEANING4KANJI",
|
||||||
|
"READINGON4KANJI",
|
||||||
|
"READINGKUN4KANJI"
|
||||||
|
}
|
||||||
|
|
||||||
|
function Ask(Ttpe)
|
||||||
|
local Type = Ttpe or math.random(#QuestionType)
|
||||||
Solution = math.random(4)
|
Solution = math.random(4)
|
||||||
AvoidList = {}
|
AvoidList = {}
|
||||||
|
|
||||||
if Type == QuestionType.KANJI then
|
if Type == QuestionType.KANJI4MEANING then
|
||||||
AskKanji4Meaning()
|
AskKanji4Meaning()
|
||||||
elseif Type == QuestionType.MEANING then
|
elseif Type == QuestionType.MEANING4KANJI then
|
||||||
AskMeaning4Kanji()
|
AskMeaning4Kanji()
|
||||||
|
elseif Type == QuestionType.READINGON4KANJI then
|
||||||
|
AskReadingON4Kanji()
|
||||||
|
elseif Type == QuestionType.READINGKUN4KANJI then
|
||||||
|
AskReadingKUN4Kanji()
|
||||||
end
|
end
|
||||||
|
|
||||||
io.write("\n")
|
io.write("\n")
|
||||||
|
@ -102,11 +187,6 @@ function Check(answer)
|
||||||
Total = Total + 1
|
Total = Total + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
QuestionType = Enum {
|
|
||||||
"KANJI",
|
|
||||||
"MEANING"
|
|
||||||
}
|
|
||||||
|
|
||||||
function ShowProgress()
|
function ShowProgress()
|
||||||
io.write("\027[2K#"..tostring(Total+1).."\t")
|
io.write("\027[2K#"..tostring(Total+1).."\t")
|
||||||
|
|
||||||
|
@ -138,11 +218,7 @@ while 1 do
|
||||||
os.execute("clear")
|
os.execute("clear")
|
||||||
|
|
||||||
ShowProgress()
|
ShowProgress()
|
||||||
|
|
||||||
--Ask()
|
|
||||||
Ask()
|
Ask()
|
||||||
--Ask(QuestionType.KANJI)
|
|
||||||
|
|
||||||
response = io.read()
|
response = io.read()
|
||||||
|
|
||||||
Check(response)
|
Check(response)
|
||||||
|
|
Loading…
Reference in New Issue