00001
00002
00003
00004
00005
00006
00007
00008 #include "keybd.h"
00009 #include "ui.h"
00010 #include "players.h"
00011 #include "map.h"
00012 #include "rules.h"
00013 #include "ufwoom.h"
00014 #include <assert.h>
00015 #include <stdio.h>
00016 #include <conio.h>
00017
00018
00019 Video Screen (VGAHi);
00020 MSMouse Mouse (Graphics);
00021 Keybd Keys;
00022
00023 Player *thePlayers [MAXPLAYERS];
00024 int NumPlayers;
00025
00026 Display theDisplay;
00027 Map theMap;
00028 UserInterface UI;
00029 Rules theRules;
00030
00031
00032 void PlayerSetup (void)
00033 {
00034 int *info, counter, nextPlayer;
00035
00036 info = UI.UFWOOM ();
00037 if ((*info) == ComputerP)
00038 *thePlayers = new ComputerSpy ("Mr. X", PColor [0]);
00039 else
00040 *thePlayers = new HumanSpy ("Mr. X", PColor [0]);
00041
00042 nextPlayer = NumPlayers = 1;
00043 for (counter = 1; counter < MAXPLAYERS; counter++)
00044 {
00045 char buf [40];
00046 sprintf (buf, "Detective %d", counter);
00047 switch (info [counter])
00048 {
00049 case ComputerP :
00050 thePlayers [nextPlayer++] = new ComputerDetective (buf, PColor [counter]);
00051 NumPlayers++;
00052 break;
00053 case HumanP :
00054 thePlayers [nextPlayer++] = new HumanDetective (buf, PColor [counter]);
00055 NumPlayers++;
00056 break;
00057 }
00058 }
00059 delete info;
00060 }
00061
00062 void HosePlayers (void)
00063 {
00064 for (int i=0; i<NumPlayers; i++)
00065 delete thePlayers [i];
00066 }
00067
00068
00069
00070 main ()
00071 {
00072 assert (Mouse.SetupOK ());
00073 assert (theMap.load_map ("NODELIST"));
00074 bool busted;
00075 int counter;
00076
00077 UI.Intro();
00078
00079 PlayerSetup ();
00080
00081 UI.InitScreen ();
00082 UI.ShowAllPlayers ();
00083
00084
00085 while (! (busted = (bool) theRules.GameOver ()))
00086 {
00087
00088 (*thePlayers) -> TakeTurn ();
00089
00090
00091 for (counter = 1; (counter < NumPlayers) && (!busted); counter++)
00092 {
00093 thePlayers [counter] -> TakeTurn ();
00094 busted = (bool) theRules.SpyCaught ();
00095 }
00096 theRules.NewTurn ();
00097 }
00098 if (busted == -1)
00099 UI.AnnounceWin (*thePlayers[0], theRules.CurrentTurn());
00100 else
00101 UI.AnnounceWin (*thePlayers[busted], theRules.CurrentTurn());
00102
00103
00104
00105 return 0;
00106 }