fix some bugs
This commit is contained in:
parent
688a2d8145
commit
f785493ec2
@ -30,7 +30,7 @@ bool GameBoard::attack(const PlayerMove& o) {
|
||||
if (sc_tile.unit <= 1)
|
||||
return false;
|
||||
|
||||
auto moving_unit = o.half ? sc_tile.unit : sc_tile.unit / 2;
|
||||
auto moving_unit = o.half ? sc_tile.unit - 1 : sc_tile.unit / 2;
|
||||
sc_tile.unit -= moving_unit;
|
||||
auto isfriend = isTeammate(o.player, tt_tile.owner);
|
||||
auto delta
|
||||
|
@ -3,14 +3,14 @@
|
||||
#include "pc/commcode.h"
|
||||
|
||||
bool PlayerMove::isValid(pos_t w, pos_t h) const {
|
||||
if (x < 0 || x >= h || y < 0 || y >= w)
|
||||
if (x >= h || y >= w)
|
||||
return false;
|
||||
|
||||
if ((int)dir >= 4)
|
||||
return false;
|
||||
|
||||
auto xx = tx(), yy = ty();
|
||||
if (xx < 0 || xx >= h || yy < 0 || yy >= w)
|
||||
if (xx >= h || yy >= w)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -37,35 +37,35 @@ void upmin(T& x, const T& y) {
|
||||
bool findCut(pos_t w, pos_t h, vector<vector<VertexType>>& vertex_type) {
|
||||
int idx = 0;
|
||||
vector<vector<int>> dfn(h, vector<int>(w)), low = dfn;
|
||||
function<void(int, int, int, int, bool)> tarjan
|
||||
= [&](int x, int y, int fx, int fy, bool rt) {
|
||||
dfn[x][y] = low[x][y] = ++idx;
|
||||
int ch = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const int xx = x + direction_dx[i], yy = y + direction_dy[i];
|
||||
if (xx < 0 || xx >= h || yy < 0 || yy >= w)
|
||||
continue;
|
||||
function<void(pos_t, pos_t, pos_t, pos_t, bool)> tarjan =
|
||||
[&](pos_t x, pos_t y, pos_t fx, pos_t fy, bool rt) {
|
||||
dfn[x][y] = low[x][y] = ++idx;
|
||||
int ch = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const pos_t xx = x + direction_dx[i], yy = y + direction_dy[i];
|
||||
if (xx >= h || yy >= w)
|
||||
continue;
|
||||
|
||||
if (vertex_type[xx][yy] == VertexType::Capital)
|
||||
vertex_type[x][y] = VertexType::Cut;
|
||||
if (vertex_type[xx][yy] == VertexType::Capital)
|
||||
vertex_type[x][y] = VertexType::Cut;
|
||||
|
||||
if (ban(vertex_type[xx][yy]) || (xx == fx && yy == fy))
|
||||
continue;
|
||||
if (ban(vertex_type[xx][yy]) || (xx == fx && yy == fy))
|
||||
continue;
|
||||
|
||||
if (!dfn[xx][yy]) {
|
||||
ch++;
|
||||
tarjan(xx, yy, x, y, 0);
|
||||
upmin(low[x][y], low[xx][yy]);
|
||||
if (!rt && low[xx][yy] >= dfn[x][y])
|
||||
vertex_type[x][y] = VertexType::Cut;
|
||||
} else {
|
||||
upmin(low[x][y], dfn[xx][yy]);
|
||||
}
|
||||
}
|
||||
if (!dfn[xx][yy]) {
|
||||
ch++;
|
||||
tarjan(xx, yy, x, y, 0);
|
||||
upmin(low[x][y], low[xx][yy]);
|
||||
if (!rt && low[xx][yy] >= dfn[x][y])
|
||||
vertex_type[x][y] = VertexType::Cut;
|
||||
} else {
|
||||
upmin(low[x][y], dfn[xx][yy]);
|
||||
}
|
||||
}
|
||||
|
||||
if (rt && ch >= 2)
|
||||
vertex_type[x][y] = VertexType::Cut;
|
||||
};
|
||||
if (rt && ch >= 2)
|
||||
vertex_type[x][y] = VertexType::Cut;
|
||||
};
|
||||
|
||||
bool flag = false;
|
||||
for (pos_t i = 0; i < h; i++) {
|
||||
@ -169,9 +169,9 @@ GameBoard ImportedTerrain::makeGameBoard(const InitInfo& init_info) {
|
||||
for (pos_t y = 0; y < w; y++) {
|
||||
if (g.at(x, y).type == TileType::Capital) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const int xx = x + direction_dx[i],
|
||||
yy = y + direction_dy[i];
|
||||
if (xx < 0 || xx >= h || yy < 0 || yy >= w)
|
||||
const pos_t xx = x + direction_dx[i],
|
||||
yy = y + direction_dy[i];
|
||||
if (xx >= h || yy >= w)
|
||||
continue;
|
||||
if (g.at(xx, yy).type == TileType::Capital)
|
||||
throw BadCapitalAssign();
|
||||
|
@ -5,3 +5,5 @@ PlayerRanking::PlayerRanking() : player(neutral_player)
|
||||
|
||||
TeamRanking::TeamRanking() : team(neutral_team), land(0), unit(0) {}
|
||||
|
||||
Tile::Tile() : owner(neutral_player), unit(0) {}
|
||||
|
||||
|
@ -56,6 +56,8 @@ struct Tile {
|
||||
TileType type;
|
||||
std::int32_t unit;
|
||||
|
||||
Tile();
|
||||
|
||||
OGPC_DECLARE_ASTUPLE(owner, type, unit)
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user