Skip to content

Commit e4fa1dd

Browse files
committed
Fix small UI issues
1 parent 5e08714 commit e4fa1dd

4 files changed

Lines changed: 53 additions & 33 deletions

File tree

src/components/ludus/FacilityManagement.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ export const FacilityManagement: React.FC<FacilityManagementProps> = ({
127127
</div>
128128
<div>
129129
<p className="text-gray-600">Bonus</p>
130-
<p className="font-semibold text-green-700">+{bonus}%</p>
130+
<p className="font-semibold text-green-700">
131+
{typeof bonus === 'number' ? `+${bonus}%` : bonus}
132+
</p>
131133
</div>
132134
</div>
133135

@@ -198,7 +200,9 @@ export const FacilityManagement: React.FC<FacilityManagementProps> = ({
198200
</div>
199201
<div>
200202
<p className="text-gray-600">Starting Bonus</p>
201-
<p className="font-semibold text-green-700">+{bonus}%</p>
203+
<p className="font-semibold text-green-700">
204+
{typeof bonus === 'number' ? `+${bonus}%` : bonus}
205+
</p>
202206
</div>
203207
</div>
204208

src/components/screens/LudusScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ const LudusScreen: React.FC = () => {
5151
const sampleFacilities: LudusFacility[] = [
5252
{
5353
id: 'facility_1',
54-
type: 'BARRACKS' as FacilityType,
54+
type: 'barracks',
5555
level: 2,
5656
upgrading: false,
5757
maintenanceCost: 0
5858
},
5959
{
6060
id: 'facility_2',
61-
type: 'TRAINING_GROUND' as FacilityType,
61+
type: 'training_ground',
6262
level: 1,
6363
upgrading: false,
6464
maintenanceCost: 0

src/data/facilityIcons.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
import type { FacilityType } from '@/types/facility.types';
88

99
export const FACILITY_ICONS: Record<FacilityType, string> = {
10-
BARRACKS: '🏚️',
11-
TRAINING_GROUND: '⚔️',
12-
ARMORY: '🛡️',
13-
INFIRMARY: '🏥',
14-
TAVERN: '🍺',
15-
SHRINE: '',
16-
LIBRARY: '📚',
17-
FORGE: '🔨',
18-
STABLE: '🐴',
19-
MARKET: '🏪',
20-
ARENA: '🏛️',
21-
TREASURY: '💰',
10+
barracks: '🏚️',
11+
training_ground: '⚔️',
12+
armory: '🛡️',
13+
tavern: '🍺',
14+
library: '📚',
15+
forge: '🔨',
16+
stable: '🐴',
17+
market: '🏪',
18+
arena: '🏛️',
19+
medical_wing: '🏥',
20+
temple: '',
21+
treasury: '💰',
2222
};

src/game/FacilityManager.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export class FacilityManager {
2727
};
2828

2929
const base = baseCosts[type];
30+
if (typeof base !== 'number' || isNaN(base)) {
31+
throw new Error(`Unknown facility type: ${type}`);
32+
}
3033
return Math.floor(base * Math.pow(1.5, level - 1));
3134
}
3235

@@ -133,24 +136,37 @@ export class FacilityManager {
133136

134137
/**
135138
* Get facility bonus at level
139+
* Returns number (percent) for stat bonuses, string for special effects
136140
*/
137-
getFacilityBonus(type: FacilityType, level: number): string {
138-
const bonuses: Record<FacilityType, (level: number) => string> = {
139-
barracks: (lvl) => `+${lvl * 2} max gladiators`,
140-
training_ground: (lvl) => `+${lvl * 10}% training effectiveness`,
141-
medical_wing: (lvl) => `-${lvl * 20}% healing time`,
142-
armory: (lvl) => `+${lvl * 5}% equipment stats`,
143-
library: (lvl) => `Unlocks ${lvl} skill tiers`,
144-
arena: (lvl) => `${lvl} practice matches per day`,
145-
market: (lvl) => `${lvl * 5}% better prices`,
146-
temple: (lvl) => `+${lvl * 5} morale/day`,
147-
treasury: (lvl) => `+${lvl * 10}% tournament income`,
148-
stable: (lvl) => `+${lvl * 5}% speed bonus`,
149-
forge: (lvl) => `Craft tier ${lvl} equipment`,
150-
tavern: (lvl) => `+${lvl * 10}% recruit quality`,
151-
};
152-
153-
return bonuses[type](level);
141+
getFacilityBonus(type: FacilityType, level: number): number | string {
142+
switch (type) {
143+
case 'armory':
144+
return level * 5; // % equipment stats
145+
case 'training_ground':
146+
return level * 10; // % training effectiveness
147+
case 'market':
148+
return level * 5; // % better prices
149+
case 'temple':
150+
return level * 5; // morale/day
151+
case 'treasury':
152+
return level * 10; // % tournament income
153+
case 'stable':
154+
return level * 5; // % speed bonus
155+
case 'tavern':
156+
return level * 10; // % recruit quality
157+
case 'medical_wing':
158+
return `-${level * 20}% healing time`;
159+
case 'barracks':
160+
return `+${level * 2} max gladiators`;
161+
case 'library':
162+
return `Unlocks ${level} skill tiers`;
163+
case 'arena':
164+
return `${level} practice matches per day`;
165+
case 'forge':
166+
return `Craft tier ${level} equipment`;
167+
default:
168+
return 'No bonus available';
169+
}
154170
}
155171

156172
/**

0 commit comments

Comments
 (0)