45 lines
No EOL
1.3 KiB
C
45 lines
No EOL
1.3 KiB
C
#include "ok_buildings.h"
|
|
#include "ok_map.h"
|
|
#include <stdio.h>
|
|
|
|
void ok_buildings_init(OkWorld *w) {
|
|
// Initialize buildings array - for now we'll use a simple approach
|
|
// In a more complete implementation, we'd have an actual building array
|
|
}
|
|
|
|
void ok_buildings_place(OkWorld *w, int x, int y, OkBuildingKind kind, OkFaction faction) {
|
|
// Check if placement is valid (walkable tile and not occupied)
|
|
if (!ok_map_walkable(w, x, y)) {
|
|
return;
|
|
}
|
|
|
|
// For now, we'll just update the resource count when a building is placed
|
|
int cost = 0;
|
|
switch (kind) {
|
|
case OK_BUILDING_HQ:
|
|
cost = 50;
|
|
break;
|
|
case OK_BUILDING_BARRACKS:
|
|
cost = 30;
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
|
|
// Check if faction has enough resources
|
|
int *resources = (faction == OK_FACTION_A) ? &w->resources_a : &w->resources_b;
|
|
if (*resources < cost) {
|
|
return;
|
|
}
|
|
|
|
// Deduct cost and mark building as placed
|
|
*resources -= cost;
|
|
|
|
printf("Faction %d placed %s at (%d,%d)\n", faction,
|
|
(kind == OK_BUILDING_HQ) ? "HQ" : "Barracks", x, y);
|
|
}
|
|
|
|
void ok_buildings_update(OkWorld *w) {
|
|
// Simple building update logic - in a real implementation this would handle
|
|
// building construction, production, etc.
|
|
} |