home *** CD-ROM | disk | FTP | other *** search
- /* pfuncs.c -- Project functions for Targ-Hurt ESP Trainer.
-
- History: rhs 14-mar-87 ... Original
-
- Contains these functions:
- pf_getcode,
- pf_display,
- pf_resetscore,
- pf_newscore.
-
- */
-
- #include <conio.h>
- #include "mancon.h"
- #include "declares.h"
-
-
- /* pf_getcode -- Get character from user, then translate character
- into an integer that is meaningful to calling functions.
- */
- int pf_getcode()
- { IMPORT int gia_cursorkeys[];
- int j;
- char ch;
-
- while(TRUE)
- { if(getkey(&ch)!=0) /* Is character extended ASCII? */
- { for(j=0; j<4; j++)
- if(ch==gia_cursorkeys[j]) return(j);
- }
- else
- switch(toupper(ch))
- { case 'P': return(PASS);
- case 'R': return(RESET);
- case 'C': return(CHANGE);
- case 'Q': return(QUIT);
- case 'H': return(HELP);
- } /* end switch, end else */
- } /* end while */
- } /* end pf_getcode() */
-
-
-
- /* pf_newscore -- Update number of answers, correct answers, etc.
- Record whether this answer was correct.
-
- input: user's answer, machine's selection.
- */
- void pf_newscore(user, machine)
- int user, machine;
- { IMPORT int gi_tries, gi_direction, gi_wasahit;
- IMPORT int gi_encourage, gi_hits;
- IMPORT struct encouragement gsa_enc[];
- int j;
-
- gi_tries++;
- gi_direction=machine;
- gi_wasahit=FALSE;
- gi_encourage= -1;
- if(user==machine) { gi_hits++; gi_wasahit=TRUE; }
-
- for(j=0; j<ENCMSGS; j++)
- if( (gi_hits>=gsa_enc[j].minhits)
- && ((float)gi_hits/gi_tries >= gsa_enc[j].hitpct) )
- gi_encourage++;
-
- } /* end pf_newscore() */
-
-
- /* pf_newdirec -- Update the global variable which records
- the machine's choice. This function lets
- the the program show the user what choice
- the machine made without updating the number
- of tries or hits.
- */
- void pf_newdirec(machine)
- int machine;
- { IMPORT gi_direction;
- gi_direction = machine;
- }
-
-
-
- /* pf_resetscore -- Resets answer counters to zero.
- */
- void pf_resetscore()
- { IMPORT int gi_tries, gi_hits, gi_encourage;
- IMPORT int gi_wasahit, gi_direction;
- gi_tries=0;
- gi_hits=0;
- gi_encourage=0;
- gi_wasahit=FALSE;
- gi_direction=RESET;
-
- }
-
-