fix rent calculation
This commit is contained in:
@@ -6,10 +6,16 @@
|
||||
|
||||
class MonopolyBoardRenderer {
|
||||
public:
|
||||
static void draw_tile(LowLevelRenderer* renderer, int x, int y, int w, int h, int index, bool is_corner, Player* players, int players_count, int orientation = 0) {
|
||||
static void draw_tile(LowLevelRenderer* renderer, int x, int y, int w, int h, int index, bool is_corner, Player* players, int players_count, int orientation = 0, int currentPlayerPos = -1) {
|
||||
if (index < 0 || index >= BOARD_SIZE) return;
|
||||
|
||||
renderer->draw_rectangle(x, y, w, h, true, 1);
|
||||
bool isInverted = (index == currentPlayerPos);
|
||||
if (isInverted) {
|
||||
renderer->draw_filled_rectangle(x, y, w, h, true, 1);
|
||||
renderer->set_text_color(false); // Black text on white background
|
||||
} else {
|
||||
renderer->draw_rectangle(x, y, w, h, true, 1);
|
||||
}
|
||||
|
||||
const BoardTile& tile = MONOPOLY_BOARD[index];
|
||||
int content_x = x, content_y = y, content_w = w, content_h = h;
|
||||
@@ -32,13 +38,21 @@ public:
|
||||
content_x += bar_size; content_w -= bar_size;
|
||||
}
|
||||
|
||||
renderer->draw_filled_rectangle(bx, by, bw, bh, true, 1);
|
||||
if (isInverted) {
|
||||
// In inverted mode, the bar should be black (transparent/inverted)
|
||||
renderer->draw_filled_rectangle(bx, by, bw, bh, false, 0); // Clear the bar area back to black
|
||||
renderer->set_text_color(true); // Groups on the bar are usually white text on black bar in this mode
|
||||
} else {
|
||||
renderer->draw_filled_rectangle(bx, by, bw, bh, true, 1);
|
||||
renderer->set_text_color(false); // Black text on white bar
|
||||
}
|
||||
|
||||
// Group number
|
||||
renderer->set_text_color(false); // Black text on white bar
|
||||
char gbuf[2] = { (char)('0' + tile.group[0]), '\0' };
|
||||
renderer->draw_string_scaled(bx + (bw - 6) / 2, by + (bh - 8) / 2, gbuf, 1);
|
||||
renderer->set_text_color(true);
|
||||
|
||||
if (isInverted) renderer->set_text_color(false); // Back to black text for the rest of the tile
|
||||
else renderer->set_text_color(true);
|
||||
}
|
||||
|
||||
char short_name[5] = {0};
|
||||
@@ -65,36 +79,40 @@ public:
|
||||
p_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (isInverted) {
|
||||
renderer->set_text_color(true); // Reset for next tiles
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_board_perimeter(LowLevelRenderer* renderer, int width, int height, Player* players, int players_count) {
|
||||
static void draw_board_perimeter(LowLevelRenderer* renderer, int width, int height, Player* players, int players_count, int currentPlayerPos = -1) {
|
||||
int cw = width / 7; // Corner width
|
||||
int ch = height / 7; // Corner height
|
||||
int rw = (width - 2 * cw) / 9; // Regular tile width
|
||||
int rh = (height - 2 * ch) / 9; // Regular tile height
|
||||
|
||||
// --- Bottom Row: 0 to 10 (Right to Left) ---
|
||||
draw_tile(renderer, width - cw, height - ch, cw, ch, 0, true, players, players_count, 0); // GO
|
||||
draw_tile(renderer, width - cw, height - ch, cw, ch, 0, true, players, players_count, 0, currentPlayerPos); // GO
|
||||
for (int i = 1; i < 10; ++i) {
|
||||
draw_tile(renderer, width - cw - i * rw, height - ch, rw, ch, i, false, players, players_count, 0);
|
||||
draw_tile(renderer, width - cw - i * rw, height - ch, rw, ch, i, false, players, players_count, 0, currentPlayerPos);
|
||||
}
|
||||
draw_tile(renderer, 0, height - ch, cw, ch, 10, true, players, players_count, 1); // JAIL
|
||||
draw_tile(renderer, 0, height - ch, cw, ch, 10, true, players, players_count, 1, currentPlayerPos); // JAIL
|
||||
|
||||
// --- Left Column: 11 to 19 (Bottom to Top) ---
|
||||
for (int i = 11; i < 20; ++i) {
|
||||
draw_tile(renderer, 0, height - ch - (i - 10) * rh, cw, rh, i, false, players, players_count, 1);
|
||||
draw_tile(renderer, 0, height - ch - (i - 10) * rh, cw, rh, i, false, players, players_count, 1, currentPlayerPos);
|
||||
}
|
||||
|
||||
// --- Top Row: 20 to 30 (Left to Right) ---
|
||||
draw_tile(renderer, 0, 0, cw, ch, 20, true, players, players_count, 2); // FREE PARKING
|
||||
draw_tile(renderer, 0, 0, cw, ch, 20, true, players, players_count, 2, currentPlayerPos); // FREE PARKING
|
||||
for (int i = 21; i < 30; ++i) {
|
||||
draw_tile(renderer, cw + (i - 21) * rw, 0, rw, ch, i, false, players, players_count, 2);
|
||||
draw_tile(renderer, cw + (i - 21) * rw, 0, rw, ch, i, false, players, players_count, 2, currentPlayerPos);
|
||||
}
|
||||
draw_tile(renderer, width - cw, 0, cw, ch, 30, true, players, players_count, 3); // GO TO JAIL
|
||||
draw_tile(renderer, width - cw, 0, cw, ch, 30, true, players, players_count, 3, currentPlayerPos); // GO TO JAIL
|
||||
|
||||
// --- Right Column: 31 to 39 (Top to Bottom) ---
|
||||
for (int i = 31; i < 40; ++i) {
|
||||
draw_tile(renderer, width - cw, ch + (i - 31) * rh, cw, rh, i, false, players, players_count, 3);
|
||||
draw_tile(renderer, width - cw, ch + (i - 31) * rh, cw, rh, i, false, players, players_count, 3, currentPlayerPos);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user