You are on page 1of 2

Al inicio:

Aparece un mensaje de bienvenida


El juego dira cuantas vidas tienes
Aparecera un mensaje que le dice al usuario que ingrese una letra
Y procederemos a preguntar la letra que desea ingresar

1) Escoger palabra al azar de base de datos


2) Mostrar en consola rayitas (-); una por cada letra de la palabra escogida
3) Cada turno mostrar letras utilizadas
4) Cada turno mostrar Vidas restantes
5) Pedir letra para jugar siguiente turno

syscall 13 to open file. Flags: 0 for read-only, 1 for write-only with create, and
9 for write-only with create and append

syscall 14 to read from file

syscall 15 to writo to file

syscall 16 to close file

_______________________________________________
Reading Procedure:
0) Read how many words the file has by reading byte by byte the number of ";" the
program finds and save it to a WORD. Call it NLINES

if the first byte of the file is "\0" then it's 0 lines, then NLINES=0. In this
case the program must end.

1) Pick a random number in [0,NLINES-1]: it would be (n%NLINES).

2) Set the file pointer to the correct address.

Start reading the file byte by byte and each time it encounters "\n" it means a new
word os goint to start in the next byte of the file. Do this until the before
picked number is equal to the line+1 (because we read line 0 and it contains word
1).

3) Check if from that pointer's position, there are atleast 5 bytes before another
";" and no more than 10 bytes before the next ";".

When the file ends there's going to be an "\0" but that's only going to happen when
the picked number is equal or greater than NLINES

4) Move the picked word to the wordBuffer.

5) Print a '-' for each character and add each to a playWordBuffer, wich is the one
that contains the word that shows how many letters are right.

6) Build a already picked character list

7) Build a tries left counter

8) Procedure that checks if the picked char is in the wordBuffer

9) Build a list that contains the used characters

10) Procedure that checks if the picked char is already used


11) in usedCharIndex and alphabet if char==";" then it is used

12)
Pick random word from dataBase and move it to wordBuffer
GAME LOOP:
Check if win:
write message of win
j END
Print used Characters
Print playWord
Ask for a letter
Check if that letter is not used:
Check if that letter is in the wordBuffer:
Add that letter to the usedCharIndex
Add that letter to the playWordBuffer where it should be->
To do it while char!=\0 in wordBuffer, if
wordBuffer[i]==letter; then put it in that position to playWordBuffer

else if letter not in wordBuffer:


tries --
Check if tries left == 0:
then print looser
j END
j GAME LOOP

5) If (3) then we should read that word and use it for the game.

NOTE: The file descriptor should be saved just before (3) because in (4) we have to
read that line
_______________________________________________

You might also like