Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

control.c File Reference

#include "keybd.h"
#include "ui.h"
#include "players.h"
#include "map.h"
#include "rules.h"
#include "ufwoom.h"
#include <assert.h>
#include <stdio.h>
#include <conio.h>

Go to the source code of this file.

Functions

Video Screen (VGAHi)
MSMouse Mouse (Graphics)
void PlayerSetup (void)
void HosePlayers (void)
 main ()

Variables

Keybd Keys
PlayerthePlayers [MAXPLAYERS]
int NumPlayers
Display theDisplay
Map theMap
UserInterface UI
Rules theRules


Function Documentation

void HosePlayers void   
 

Definition at line 62 of file control.c.

References NumPlayers.

00063   {
00064     for (int i=0; i<NumPlayers; i++)
00065       delete thePlayers [i];
00066   }

main  
 

Definition at line 70 of file control.c.

References UserInterface::AnnounceWin(), Rules::CurrentTurn(), Rules::GameOver(), UserInterface::InitScreen(), UserInterface::Intro(), Map::load_map(), Rules::NewTurn(), NumPlayers, PlayerSetup(), MSMouse::SetupOK(), UserInterface::ShowAllPlayers(), and Rules::SpyCaught().

00071   {
00072    assert (Mouse.SetupOK ());
00073    assert (theMap.load_map ("NODELIST"));    // Get filename from cmdline
00074    bool busted;         // Has the spy been caught?
00075    int counter;
00076 
00077    UI.Intro();
00078 
00079    PlayerSetup ();      // You figure it out, ya dumb f---
00080 
00081    UI.InitScreen ();
00082    UI.ShowAllPlayers ();
00083 
00084    // Main game loop
00085    while (! (busted = (bool) theRules.GameOver ()))
00086      {
00087       // Move the Spy
00088       (*thePlayers) -> TakeTurn ();
00089 
00090       // Move the detectives
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 //   HosePlayers ();      // Nuke the players; we don't need them anymore
00104 
00105    return 0;
00106   }

MSMouse Mouse Graphics   
 

void PlayerSetup void   
 

Definition at line 32 of file control.c.

References ComputerP, HumanP, MAXPLAYERS, NumPlayers, PColor, and UserInterface::UFWOOM().

Referenced by main().

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;   // Need a spy; first detective = player #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;         // Big Brother is gonna f--- you up real bad
00060   }

Video Screen VGAHi   
 


Variable Documentation

Keybd Keys
 

Definition at line 21 of file control.c.

int NumPlayers
 

Definition at line 24 of file control.c.

Referenced by HosePlayers(), main(), and PlayerSetup().

Display theDisplay
 

Definition at line 26 of file control.c.

Map theMap
 

Definition at line 27 of file control.c.

Player* thePlayers[MAXPLAYERS]
 

Definition at line 23 of file control.c.

Rules theRules
 

Definition at line 29 of file control.c.

UserInterface UI
 

Definition at line 28 of file control.c.


Generated on Sun Jul 6 23:07:16 2003 for Scotland Yard by doxygen1.2.15