📄 othellodoc.cpp
字号:
// OthelloDoc.cpp : implementation of the COthelloDoc class
//
#include "stdafx.h"
#include "Othello.h"
#include "OthelloDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COthelloDoc
IMPLEMENT_DYNCREATE(COthelloDoc, CDocument)
BEGIN_MESSAGE_MAP(COthelloDoc, CDocument)
//{{AFX_MSG_MAP(COthelloDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COthelloDoc construction/destruction
COthelloDoc::COthelloDoc()
{
// TODO: add one-time construction code here
m_Judge = new CJudge(this);
}
COthelloDoc::~COthelloDoc()
{
delete m_Judge;
}
BOOL COthelloDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// COthelloDoc serialization
void COthelloDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
CString s;
s = "nks";
ar<<s;
for(int i=0;i<8;i++) {
for(int j=0;j<8;j++) {
ar<<m_Judge->m_Board.m_State[i][j];
}
}
ar<<m_Judge->m_Board.m_Hint;
ar<<m_Judge->m_Board.m_Turn;
ar<<m_Judge->m_Board.oldX;
ar<<m_Judge->m_Board.oldY;
ar<<m_Judge->m_Model;
ar<<m_Judge->m_Turn;
for(i=0;i<64;i++) {
ar<<m_Judge->m_Record.m_StepX[i];
ar<<m_Judge->m_Record.m_StepY[i];
}
ar<<m_Judge->m_Record.m_Counter;
ar<<m_Judge->m_Record.m_Pointer;
ar<<m_Judge->m_Record.m_X;
ar<<m_Judge->m_Record.m_Y;
}
else
{
// TODO: add loading code here
CString s;
ar>>s;
if(s =="nks"){
for(int i=0;i<8;i++) {
for(int j=0;j<8;j++) {
ar>>m_Judge->m_Board.m_State[i][j];
}
}
ar>>m_Judge->m_Board.m_Hint;
ar>>m_Judge->m_Board.m_Turn;
ar>>m_Judge->m_Board.oldX;
ar>>m_Judge->m_Board.oldY;
ar>>m_Judge->m_Model;
ar>>m_Judge->m_Turn;
for(i=0;i<64;i++) {
ar>>m_Judge->m_Record.m_StepX[i];
ar>>m_Judge->m_Record.m_StepY[i];
}
ar>>m_Judge->m_Record.m_Counter;
ar>>m_Judge->m_Record.m_Pointer;
ar>>m_Judge->m_Record.m_X;
ar>>m_Judge->m_Record.m_Y;
m_Judge->Open();
}
else
AfxMessageBox("Load Game Error!");
}
}
/////////////////////////////////////////////////////////////////////////////
// COthelloDoc diagnostics
#ifdef _DEBUG
void COthelloDoc::AssertValid() const
{
CDocument::AssertValid();
}
void COthelloDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COthelloDoc commands
void COthelloDoc::SetTitle(LPCTSTR lpszTitle)
{
// TODO: Add your specialized code here and/or call the base class
CDocument::SetTitle("Othello");
// CDocument::SetTitle(lpszTitle);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -