@@ -21,11 +21,13 @@ model RaceAbilities {
2121```
2222
2323** Purpose** : Defines racial bonuses to abilities
24+
2425- Elves: +15 bonus to Archery, +10 to Stealth
2526- Dwarves: +20 bonus to Mining, +15 to Smithing
2627- Halflings: +15 bonus to Hiding, +10 to Pickpocketing
2728
2829** Fields** :
30+
2931- ` race ` : Which race gets the bonus
3032- ` abilityId ` : Which ability gets the bonus
3133- ` category ` : PRIMARY (core racial skill), SECONDARY (common), RESTRICTED (limited), FORBIDDEN (cannot learn)
@@ -53,12 +55,14 @@ model ObjectAbilities {
5355** Purpose** : Allows objects to cast abilities (scrolls, wands, potions, magical weapons)
5456
5557** Examples** :
58+
5659- Scroll of Fireball: ` { abilityId: "fireball", level: 10, charges: 1 } `
5760- Wand of Magic Missile: ` { abilityId: "magic_missile", level: 5, charges: 20 } `
5861- Potion of Healing: ` { abilityId: "cure_light", level: 7, charges: 1 } `
5962- Flaming Sword: ` { abilityId: "flame_weapon", level: 12, charges: -1 } ` (infinite)
6063
6164** Fields** :
65+
6266- ` abilityId ` : Which ability the object can cast
6367- ` level ` : Caster level (affects damage, duration, DC calculations)
6468- ` charges ` : Overrides object.charges if needed, -1 = infinite
@@ -140,37 +144,67 @@ await prisma.raceAbilities.createMany({
140144
141145 // Halflings
142146 { race: ' HALFLING' , abilityId: hidingId , category: ' PRIMARY' , bonus: 15 },
143- { race: ' HALFLING' , abilityId: pickpocketId , category: ' SECONDARY' , bonus: 10 },
144- ]
147+ {
148+ race: ' HALFLING' ,
149+ abilityId: pickpocketId ,
150+ category: ' SECONDARY' ,
151+ bonus: 10 ,
152+ },
153+ ],
145154});
146155
147156// Magical items
148157await prisma .objectAbilities .createMany ({
149158 data: [
150159 // Scroll of Fireball (zone 30, object 101)
151- { objectZoneId: 30 , objectId: 101 , abilityId: fireballId , level: 10 , charges: 1 },
160+ {
161+ objectZoneId: 30 ,
162+ objectId: 101 ,
163+ abilityId: fireballId ,
164+ level: 10 ,
165+ charges: 1 ,
166+ },
152167
153168 // Wand of Magic Missile (zone 30, object 102)
154- { objectZoneId: 30 , objectId: 102 , abilityId: magicMissileId , level: 5 , charges: 20 },
169+ {
170+ objectZoneId: 30 ,
171+ objectId: 102 ,
172+ abilityId: magicMissileId ,
173+ level: 5 ,
174+ charges: 20 ,
175+ },
155176
156177 // Potion of Healing (zone 30, object 103)
157- { objectZoneId: 30 , objectId: 103 , abilityId: cureLightId , level: 7 , charges: 1 },
178+ {
179+ objectZoneId: 30 ,
180+ objectId: 103 ,
181+ abilityId: cureLightId ,
182+ level: 7 ,
183+ charges: 1 ,
184+ },
158185
159186 // Flaming Longsword (zone 30, object 104)
160- { objectZoneId: 30 , objectId: 104 , abilityId: flameWeaponId , level: 12 , charges: - 1 },
161- ]
187+ {
188+ objectZoneId: 30 ,
189+ objectId: 104 ,
190+ abilityId: flameWeaponId ,
191+ level: 12 ,
192+ charges: - 1 ,
193+ },
194+ ],
162195});
163196```
164197
165198## Game Logic Integration
166199
167200### Racial Ability System
201+
168202``` typescript
169203// When character is created, apply racial bonuses
170204async function applyRacialBonuses(characterId : string , race : Race ) {
171205 const racialBonuses = await prisma .raceAbilities .findMany ({
172206 where: { race },
173- include: { ability: true }
207+ include: { ability: true },
174208 });
175209
176210 for (const bonus of racialBonuses ) {
@@ -180,23 +214,28 @@ async function applyRacialBonuses(characterId: string, race: Race) {
180214 abilityId: bonus .abilityId ,
181215 known: bonus .category !== ' FORBIDDEN' ,
182216 proficiency: bonus .bonus , // Start with racial bonus
183- }
217+ },
184218 });
185219 }
186220}
187221```
188222
189223### Object Ability System
224+
190225``` typescript
191226// When object is used (read scroll, zap wand, quaff potion)
192- async function useObjectAbility(characterId : string , objectZoneId : number , objectId : number ) {
227+ async function useObjectAbility(
228+ characterId : string ,
229+ objectZoneId : number ,
230+ objectId : number
231+ ) {
193232 const objectAbilities = await prisma .objectAbilities .findMany ({
194233 where: { objectZoneId , objectId },
195- include: { ability: true }
234+ include: { ability: true },
196235 });
197236
198237 if (objectAbilities .length === 0 ) {
199- return { success: false , message: " Nothing happens." };
238+ return { success: false , message: ' Nothing happens.' };
200239 }
201240
202241 // Cast the ability at the specified level
0 commit comments