mirror of
https://github.com/jie65535/Ancient-Spider.git
synced 2024-07-27 18:54:53 +08:00
提交源码
编译环境 VS2017
This commit is contained in:
122
蜘蛛纸牌/Game.h
Normal file
122
蜘蛛纸牌/Game.h
Normal file
@@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include "Card.h"
|
||||
#include "View.h"
|
||||
#include "CardsSlots.h"
|
||||
|
||||
// <20>Ѷ<EFBFBD>
|
||||
enum Difficulty
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
easy,
|
||||
// <20><>ͨ
|
||||
normal,
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
hard,
|
||||
};
|
||||
|
||||
// <20>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
const int SlotsNum = 10;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
const int GroupsNum = 8;
|
||||
|
||||
// Ԥ<><D4A4><EFBFBD><EFBFBD> Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = Ԥ<><D4A4><EFBFBD><EFBFBD> * <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 5 * 10 = 50 <20><><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
const int ReservedQuantity = 5;
|
||||
|
||||
struct Point {
|
||||
int x, y;
|
||||
|
||||
Point()
|
||||
:x(0), y(0)
|
||||
{}
|
||||
|
||||
Point(int a, int b)
|
||||
:x(a), y(b)
|
||||
{}
|
||||
|
||||
void SetValue(int a, int b)
|
||||
{
|
||||
x = a, y = b;
|
||||
}
|
||||
|
||||
bool operator == (const Point p) const
|
||||
{
|
||||
return x == p.x && y == p.y;
|
||||
}
|
||||
};
|
||||
|
||||
enum Dir {
|
||||
left,
|
||||
up,
|
||||
right,
|
||||
down
|
||||
};
|
||||
|
||||
class View;
|
||||
class Game
|
||||
{
|
||||
private:
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::array<Card, GroupsNum * CardValueNum> _Cards;
|
||||
|
||||
// <20><>Ϸ<EFBFBD>Ѷ<EFBFBD>
|
||||
Difficulty _Difficulty;
|
||||
|
||||
View *_pView;
|
||||
|
||||
std::array<CardsSlots, SlotsNum> Scenes;
|
||||
|
||||
// Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD>ƵĴ<C6B5><C4B4><EFBFBD>
|
||||
int ReservedCount;
|
||||
|
||||
// <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵļ<CFB5><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
int SuccessCount;
|
||||
|
||||
Point PSelected;
|
||||
Point PCurrent;
|
||||
|
||||
bool IsVictory;
|
||||
public:
|
||||
friend class View;
|
||||
|
||||
Game(Difficulty difficulty = Difficulty::easy);
|
||||
~Game();
|
||||
|
||||
void Show();
|
||||
|
||||
void SetDifficulty(Difficulty newDifficulty);
|
||||
Difficulty GetDifficulty() const { return _Difficulty; }
|
||||
|
||||
bool GetIsVictory() const { return IsVictory; }
|
||||
|
||||
// ϴ<><CFB4>
|
||||
void Shuffle();
|
||||
|
||||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void InitScenes();
|
||||
|
||||
// <20><>ʼһ<CABC><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
||||
void StartNewGame();
|
||||
|
||||
// <20><><EFBFBD>ƣ<EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>²Żᷢ<C5BB>ɹ<EFBFBD><C9B9><EFBFBD>
|
||||
void Deal();
|
||||
|
||||
public:
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
||||
void CurMove(Dir dir);
|
||||
|
||||
// ѡ<><D1A1><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ɹ<EFBFBD>
|
||||
bool Select();
|
||||
|
||||
private:
|
||||
void MoveCards(Point point, int SlotsIndex);
|
||||
|
||||
bool CheckIsOptional(Point point);
|
||||
|
||||
bool CheckIsOrderly(Card cur, Card next, Difficulty difficulty);
|
||||
|
||||
bool CheckIsSuccess(int SlotsIndex);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user