Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ls.py
diff options
context:
space:
mode:
Diffstat (limited to 'ls.py')
-rw-r--r--ls.py148
1 files changed, 148 insertions, 0 deletions
diff --git a/ls.py b/ls.py
new file mode 100644
index 0000000..82a19da
--- /dev/null
+++ b/ls.py
@@ -0,0 +1,148 @@
+from las import listenspell
+
+
+
+las = listenspell()
+las.clearscreen()
+las.playsound("begin")
+
+########################################################################################
+def playword(wordid):
+ elem = las.getwordinfo(wordid, "word") #get a word from the list
+ pronounelem = las.getwordinfo(wordid, "phnm") #get a pronounciation from the list
+
+ if elem != pronounelem: # determine whether to bother pronouncing a description
+ print "Spell..." # say the explanation if the word is ambiguous.
+ las.saytext("Spell... ... " + elem + "... " + pronounelem)
+ else:
+ print "Spell... "
+ las.saytext("Spell... ... " + elem)
+
+## get an answer
+ print 'Press $ to answer or spacebar to get a clue. Press * to quit'
+
+ k = las.getkey()
+ #las.saytext(k)
+ if k == "*":
+ las.exitgame()
+
+ if k == " ": # if the user wants a clue
+ cluemode = True
+ reprint = True
+ while(cluemode):
+ string = """press
+ 1 for definition
+ 2 for Sample
+ 3 to repete the word
+ 4 for word length
+ or any other key to answer"""
+ if reprint == True:
+ print string
+ #las.saytext(string)
+ k = las.getkey()
+ if k == "1":
+ reprint = True
+ definition = las.getwordinfo(wordid, "def")
+ for (pos, definition) in definition:
+ print pos + " : " + definition
+ elif k == "2":
+ usage = las.getwordinfo(wordid, "usage")
+ num_sample = len(usage)
+ if num_sample == 0:
+ print "No usage in the database"
+ reprint = True
+ for (sample) in usage:
+ las.saytext(sample)
+ num_sample = num_sample - 1
+ if num_sample != 0:
+ print "To get another sample press 'n' or anyother key to answer"
+ k = las.getkey()
+ if k != 'n': break
+ elif k == "3":
+ las.saytext(elem)
+ reprint = False
+ elif k == "4":
+ print "Word Length:" + str(len(elem))
+ else:
+ cluemode = False
+
+ answer = raw_input( "Your answer: " )
+ answer = answer.strip()
+ las.saytext("You typed\n")
+ shout(answer)
+ if answer == elem:
+ las.saytext("Correct")
+ las.ans_correct(wordid)
+ return True
+ else:
+ las.ans_incorrect(wordid)
+ las.saytext("Incorrect")
+ print "Incorrect. The correct spelling is.. "
+ las.saytext("The correct spelling is..\n")
+ shout(elem)
+ return False
+
+########################################################################################
+def shout(string):
+ for character in string:
+ print character + " "
+ las.saytext(character)
+########################################################################################
+def getskilllevel():
+# get a skill level
+ print 'Enter skill level between 1 and 9, or * to quit'
+ las.saytext("Skill level")
+ k = las.getkey()
+ if k == "*":
+ las.exitgame() # quit the program
+ print k
+ las.saytext(k)
+
+ skill_level = int(k) + 3
+
+ las.setskill_level( skill_level)
+
+
+
+
+gameover = False
+while gameover == False:
+ levelsize = 7 # this stays constant throughout
+
+ getskilllevel()
+ wordidlist = las.load_wordid(levelsize + 3) # At max Three error possible
+ num_words = len(wordidlist)
+ las.clearscreen()
+
+ #### MAIN LOOP
+
+ las.playsound("begin")
+
+
+ for index in range(num_words):
+
+ ## print pronouncedict
+ ## print pronouncedictstring
+ ## print pronouncelist
+ wordid = wordidlist[index]
+ result = playword(wordid)
+ print "Your score is " + str(las.getpoints())
+
+ if result == True:
+ if las.getwords_correct == 7:
+ print "Very good."
+ print "If you want to play game again with another level press $ or any other key to quit"
+ k = las.getkey()
+ if k == '$':
+ break # Restart game with next level
+ else:
+ las.exitgame()
+
+ if las.getwords_correct == 7:
+ continue # Restart game with next level
+ else:
+ gameover = True
+ las.saytext("Game Over")
+ print "Game Over."
+ las.exitgame()
+