// This may look like C code, but it is really -*- C++ -*-
//
//  ${project}  --  Copyright (c) University of Aizu 1994
//
//

// Wrappers protect against including this file more than once

#ifndef CardPtr_h
#define CardPtr_h 1

#include <Card.h>
#include <Pointer.h>
#include <Game.h>

class CardPtr : public Pointer {
public:
  // constructors (using "new"? Do not forget copy constructor!!!)
  CardPtr(void) : Pointer(theGame->cards) {}

  // Assignment and Comparison. Note the C++ bureaucracy required to "upgrade"
  // Pointer to CardPtr.... I exceptionally put the code here so that you can see it.
  int operator==(const CardPtr& cardp) const 
  {return Pointer::operator==((Pointer&)cardp); }
  CardPtr& operator=(const CardPtr& cardp)
  {return (CardPtr&)Pointer::operator=((Pointer&)cardp); }

  // wrapper for "(Card*)lookup()"
  Card* operator->() const;

  // wrappers for "(CardPtr*)next()" and "(CardPtr*)prev()"
  CardPtr* next();
  CardPtr* prev();

  // IO
  virtual char* classname(void) const;
  virtual Listable* duplicate() const;
};

class CardPtrDeque : public List {
public:
  // Note how we use the initializer syntax
  CardPtrDeque() : List(new CardPtr) {}

  // Take the topmost card from the deque
  CardPtr* draw();

  // place a card back underneath the deque (discard)
  void discard(CardPtr* card);

  // shuffle deque
  void shuffle(void);

  // Since we have a different behaviour, we define a new classname:
  virtual char* classname(void) const;
};

// End of wrapper
#endif
// End of file
