00001 //---------------------------------------------------------------------------- 00002 /** @file GoBoardRestorer.cpp 00003 See GoBoardRestorer.h 00004 */ 00005 //---------------------------------------------------------------------------- 00006 00007 #include "SgSystem.h" 00008 #include "GoBoardRestorer.h" 00009 00010 #include "GoBoardUtil.h" 00011 00012 using namespace std; 00013 00014 //---------------------------------------------------------------------------- 00015 00016 GoBoardRestorer::GoBoardRestorer(GoBoard& bd) 00017 : m_bd(bd), 00018 m_size(bd.Size()), 00019 m_rules(bd.Rules()) 00020 { 00021 for (int i = 0; i < bd.MoveNumber(); ++i) 00022 m_moves.PushBack(bd.Move(i)); 00023 } 00024 00025 GoBoardRestorer::~GoBoardRestorer() 00026 { 00027 GoBoardUtil::UndoAll(m_bd); 00028 if (m_bd.Size() != m_size) 00029 m_bd.Init(m_size); 00030 for (MoveList::Iterator it(m_moves); it; ++it) 00031 m_bd.Play(*it); 00032 } 00033 00034 //----------------------------------------------------------------------------