-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tetriz_Common.h
219 lines (205 loc) · 4.39 KB
/
Tetriz_Common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#pragma once
#include "Tetriz_Constant.h"
constexpr int VIEW_NEXT = 5;
enum class MinoType {
I,
J,
L,
O,
T,
S,
Z,
None,
Garbage
};
#if 0
enum class ClearAct {
None,
Single,
Double,
Triple,
Quad,
Tss,
Tsd,
Tst,
Tsm,
Pc,
};
#else
class ClearAct {
enum class CAType {
None,
Single,
Double,
Triple,
Quad,
Tss,
Tsd,
Tst,
Tsm,
Pc,
};
CAType type;
public:
static constexpr auto None = CAType::None;
static constexpr auto Single = CAType::Single;
static constexpr auto Double = CAType::Double;
static constexpr auto Triple = CAType::Triple;
static constexpr auto Quad = CAType::Quad;
static constexpr auto Tss = CAType::Tss;
static constexpr auto Tsd = CAType::Tsd;
static constexpr auto Tst = CAType::Tst;
static constexpr auto Tsm = CAType::Tsm;
static constexpr auto Pc = CAType::Pc;
int GetDelay() const {
return this->GetDelay(this->type);
}
static int GetDelay(CAType t) {
switch (t) {
case ClearAct::None:
return 0;
case ClearAct::Single:
case ClearAct::Tss:
case ClearAct::Tsm:
return 36;
case ClearAct::Double:
case ClearAct::Triple:
case ClearAct::Tsd:
case ClearAct::Tst:
return 41;
case ClearAct::Quad:
return 46;
case ClearAct::Pc:
return 1;
}
return 0;
}
int GetAtk() const {
return this->GetAtk(this->type);
}
static int GetAtk(CAType t) {
switch (t) {
case ClearAct::None:
case ClearAct::Single:
case ClearAct::Tsm:
return 0;
case ClearAct::Double:
return 1;
case ClearAct::Triple:
case ClearAct::Tss:
return 2;
case ClearAct::Quad:
case ClearAct::Tsd:
return 4;
case ClearAct::Tst:
return 6;
case ClearAct::Pc:
return 10;
}
return 0;
}
ClearAct &operator=(const CAType &rhs) {
this->type = rhs;
return *this;
}
bool operator==(const CAType &rhs) const {
return this->type == rhs;
}
bool operator!=(const CAType &rhs) const {
return !(this->type == rhs);
}
operator CAType() const {
return this->type;
}
};
#endif
enum class TspinType {
Tspin,
NotTspin,
MiniTspin
};
class FallMino {
public:
static constexpr int SPAWN_X = 3;
static constexpr int SPAWN_Y = 20;
MinoPos p;
int r;
MinoType m;
int lastSrs;
// 座標ずれバグ用変数
int bugGravity;
const MinoShape *shape;
void Init();
int Spawn(const MinoType newM, const class Board *bd);
void SpinA();
void SpinB();
void UpdateShape();
const MinoCoord *GetCoord() const;
const Srs *GetSrsKickDataA() const;
const Srs *GetSrsKickDataB() const;
int Left() const;
int Top() const;
int Right() const;
int Bottom() const;
};
/*
・bugGravityの解説
20段目(デフォルト座標)に出現するはずのミノが地形に衝突し21段目に出現するとフラグが立つ。
フラグが立っている状態では横移動や回転をするたびに強制的に1段ソフドロ処理がされる。
ソフドロに成功したならフラグは下ろされる。
まれにソフドロ処理がされないバグも起こるため、その時は自分で1段ソフドロしましょう。
*/
class HoldMino {
public:
MinoType m;
int swappedHold;
int abnormalHold;
void Init();
static void PPT1or2(int set);
static bool ForPPT1();
static bool ForPPT2();
private:
static inline int ppt;
};
class Bit {
public:
static int PopCount(int bit);
static int Log2(int bit);
};
class Board {
// intはメモリサイズでかなる
// 配列の-2番目までアクセスするので2つ変数を増やしておく(書き込みはされない)
public:
static constexpr int HEIGHT = 32;
static constexpr int WIDTH = 10;
int line[Board::HEIGHT];
int stackHeight;
int lockedBottom;
void Init();
int CompareTo(const Board *other) const;
int LockMino(const FallMino *mino);
int Collision(const FallMino *mino) const;
int CollisionDistance(const FallMino *mino) const;
int CollisionBottom(const FallMino *mino) const;
int CollisionLeft(const FallMino *mino) const;
int CollisionRight(const FallMino *mino) const;
int SrsA(FallMino *mino) const;
int SrsB(FallMino *mino) const;
int GetSpawnHeight(const FallMino *mino) const;
TspinType JudgeTspin(const FallMino *mino) const;
void ClearLine();
void UpdateStackHeight();
int PopCount();
bool IsEvenPop();
int GetColumnHeight(int columnHeight[]) const;
};
class Others {
public:
int combo;
int btb;
ClearAct act;
void Init();
int GetAtk();
bool HaveAtk();
void CalcAtk(const FallMino *mino, const Board *bd, const int clearedLine);
};