Ejemplo n.º 1
0
import engine
from constants import LETTER_FREQS

if __name__ == '__main__':
    word_dict = engine.create_dict_from_word_list(engine.load_words())
    letter_seq = engine.choose_seq_letters(LETTER_FREQS, 6)
    print 'Six Letter Sample Game w/out Time'
    print 'Quit by typing \'quitnow\''
    print 'Your letters are:', letter_seq
    input_str = ''
    word_matches = set()
    while (input != 'quitnow'):
        input_str = str(
            raw_input('Your Word Guess: '))  # enforce letter_seq restrictions
        if engine.is_word(input_str, word_dict):
            if input_str in word_matches:
                print input_str, 'is already in the correct list'
            else:
                print input_str, 'is a word'
                word_matches.add(input_str)
        else:
            print input_str, 'is NOT a word!'

    print 'Words:', list(word_matches)
    print 'Score:', len(word_matches)
Ejemplo n.º 2
0
            if event.key == K_0 and game_over == 2:  # TODO: entirely replace with "restart" button
                load_letter_seq()
                reset_game()
                load_sounds()
                load_graphics()
                write_savefile()
                set_timing()
            if event.key == K_SLASH and game_over == 0:
                random.shuffle(letters)
                list_of_squares = get_letter_square_arrangement(
                    screen, letters, letter_font, letter_color, LETTER_FONT_SIZE, SCREEN_WIDTH, SCREEN_HEIGHT * 3 / 4
                )
            if event.key == K_RETURN and game_over == 0:
                for square in list_of_squares:
                    square.deselect()
                if len(candidate) >= 3 and engine.is_word(candidate, word_dict):
                    if candidate in words:
                        letter_color.set_redundant()
                    else:
                        words.insert(0, candidate)
                        letter_color.set_correct()
                    correct_sfx.play()
                else:
                    letter_color.set_wrong()
                    wrong_sfx.play()
                candidate = ""
        elif event.type == STARTRESULTSBGM:
            pygame.mixer.music.load(BGM_RESULTS_FILENAME)
            pygame.mixer.music.play()
            game_over = 2
Ejemplo n.º 3
0
         sys.exit()
     elif event.type == KEYDOWN:
         if event.key == K_0 and game_over == 2: # TODO: entirely replace with "restart" button
             load_letter_seq()
             reset_game()
             load_sounds()
             load_graphics()
             write_savefile()
             set_timing()
         if event.key == K_SLASH and game_over == 0:
             random.shuffle(letters)
             list_of_squares = get_letter_square_arrangement(screen, letters, letter_font, letter_color, LETTER_FONT_SIZE, SCREEN_WIDTH, SCREEN_HEIGHT * 3/4)
         if event.key == K_RETURN and game_over == 0:
             for square in list_of_squares:
                 square.deselect()
             if len(candidate) >= 3 and engine.is_word(candidate, word_dict):
                 if candidate in words:
                     letter_color.set_redundant()
                 else:
                     words.insert(0, candidate)
                     letter_color.set_correct()
                 correct_sfx.play()
             else:
                 letter_color.set_wrong()
                 wrong_sfx.play()
             candidate = ''
     elif event.type == STARTRESULTSBGM:
         pygame.mixer.music.load(BGM_RESULTS_FILENAME)
         pygame.mixer.music.play()
         game_over = 2
 
Ejemplo n.º 4
0
import engine
from constants import LETTER_FREQS

if __name__ == '__main__':
    word_dict = engine.create_dict_from_word_list(engine.load_words())
    letter_seq = engine.choose_seq_letters(LETTER_FREQS, 6)
    print 'Six Letter Sample Game w/out Time'
    print 'Quit by typing \'quitnow\''
    print 'Your letters are:', letter_seq
    input_str = ''
    word_matches = set()
    while (input != 'quitnow'):
        input_str = str(raw_input('Your Word Guess: ')) # enforce letter_seq restrictions
        if engine.is_word(input_str, word_dict):
            if input_str in word_matches:
                print input_str, 'is already in the correct list'
            else:
                print input_str, 'is a word'
                word_matches.add(input_str)
        else:
            print input_str, 'is NOT a word!'
    
    print 'Words:', list(word_matches)
    print 'Score:', len(word_matches)