-
Notifications
You must be signed in to change notification settings - Fork 0
Weapon System
The Weapon System is one of the core gameplay mechanics in Adventure-Game. It defines how offensive equipment is created, stored, equipped, and used throughout the game.
Weapons are more than simple damage modifiers—they are fully featured objects containing their own statistics, durability, enchantment status, value, and usability state. Each weapon directly affects the player's combat capabilities by increasing attack power and, in some cases, providing additional defensive bonuses.
The system has been designed with scalability in mind, making it straightforward to introduce new weapon types, special abilities, crafting mechanics, or upgrade systems in future versions of the project.
- Overview
- Weapon Architecture
- Weapon Properties
- Weapon Types
- Weapon Generation
- Weapon Durability
- Enchantments
- Equipping Weapons
- Combat Statistics
- Relationships with Other Systems
- Design Decisions
- Future Improvements
- Summary
Weapons represent the player's primary offensive equipment.
Every weapon is implemented as an independent object derived from the abstract Item class. This allows weapons to be stored alongside armor and potions inside the inventory while still providing specialized behavior unique to weapons.
A weapon is responsible for:
- Increasing attack power
- Providing optional defensive bonuses
- Tracking durability
- Tracking enchantment status
- Determining usability
- Displaying weapon information
Weapons can be obtained through:
- Starting equipment
- Random generation
- Loot chests
- Special item generation
The Weapon class inherits from the common Item base class.
classDiagram
Item <|-- Weapon
Character --> Weapon
MyInventory --> Weapon
Chest --> Weapon
This design allows every weapon to behave as an Item while still exposing weapon-specific functionality.
Each weapon contains several attributes that define its behavior.
| Property | Description |
|---|---|
| Name | The weapon's display name. |
| Attack | Offensive power added to the character. |
| Defense Bonus | Additional defensive value provided by the weapon. |
| Durability | Current condition of the weapon. |
| Value | Gold value of the weapon. |
| Equipped | Indicates whether the weapon is currently equipped. |
| Broken | Indicates whether the weapon can still be used. |
| Enchanted | Indicates whether the weapon has magical enhancements. |
These properties determine how the weapon behaves during gameplay.
Adventure-Game currently supports several categories of weapons.
| Weapon Type | Description |
|---|---|
| Sword | Balanced attack and defense. |
| Axe | High damage with lower defensive capabilities. |
| Bow | Ranged weapon with offensive focus. |
| Wand | Magic-oriented weapon intended for intelligence-based characters. |
| Spectacles | Special equipment associated with intelligence-focused professions. |
Additional weapon categories may be introduced in future updates.
Weapons can be generated in several different ways.
When a new character is created, the game generates a starting weapon based on the selected profession.
This ensures that each profession begins with equipment appropriate to its role.
The project includes functions that generate randomized weapons.
Randomly generated weapons may vary in:
- Attack
- Defense
- Durability
- Value
- Enchantment status
This introduces variety and replayability.
Special weapons are generated separately from standard equipment.
These weapons generally provide improved statistics and represent higher-value rewards.
Future versions may include unique legendary or named weapons.
Weapons are created using constructors that initialize all important properties.
Example:
Weapon(
"Sword",
attack,
defense,
durability,
value,
isEquipped,
isBroken,
isEnchanted
);This allows each weapon to be fully customized during creation.
The following diagram illustrates how weapons move through the game.
flowchart TD
GenerateWeapon --> Inventory
Inventory --> EquipWeapon
EquipWeapon --> Character
Character --> Gameplay
Gameplay --> DurabilityLoss
DurabilityLoss --> Broken
Broken --> Unequip
Unequip --> Inventory
Throughout gameplay, the weapon's state changes depending on player actions and durability.
Every weapon has a durability value representing its physical condition.
Durability decreases through gameplay and determines whether the weapon remains usable.
Possible states include:
| State | Description |
|---|---|
| New | Full durability. |
| Worn | Reduced durability but still usable. |
| Broken | Cannot be used until repaired (future implementation). |
The project currently includes functionality to:
- Check if a weapon is usable
- Mark a weapon as broken
- Display durability information
Future versions may include durability loss during combat and repair mechanics.
Weapons may be generated with magical enchantments.
An enchanted weapon generally provides improved statistics compared to a standard version.
Current enchantment status is stored as a simple property of the weapon.
Future improvements may introduce enchantments that grant unique abilities such as:
- Fire damage
- Ice damage
- Poison effects
- Critical hit bonuses
- Lifesteal
- Increased durability
- Bonus experience
Players equip weapons directly from their inventory.
The general process is:
Select Weapon
│
▼
Check Usability
│
▼
Equip Weapon
│
▼
Update Character Statistics
Only one weapon can be equipped at a time.
Equipping a new weapon automatically replaces the previously equipped one.
Weapons directly influence the player's offensive capabilities.
Current calculation:
Total Attack = Base Strength + Weapon Attack
Some weapons also contribute additional defense.
Total Defense = Base Defense + Weapon Defense Bonus + Armor Defense
Future combat mechanics may also consider:
- Critical hits
- Attack speed
- Weapon class bonuses
- Skill modifiers
- Elemental damage
Weapons provide detailed information when inspected.
Typical information includes:
- Name
- Weapon type
- Attack value
- Defense bonus
- Durability
- Gold value
- Enchantment status
- Equipped status
- Broken status
This allows players to compare different weapons before equipping them.
The Weapon System communicates with several other gameplay systems.
flowchart LR
Weapon --> Character
Weapon --> Inventory
Chest --> Weapon
Weapon --> Item
Character --> Equipment
Inventory --> Weapon
Weapons are generated, stored, equipped, and managed through these interconnected systems.
Several architectural choices influenced the Weapon System.
Using inheritance allows weapons to share a common interface with every other collectible object.
This simplifies inventory management and enables polymorphic behavior.
Each weapon independently manages its own durability.
This prevents external systems from needing to track weapon condition.
Rather than manually defining every weapon, randomized generation increases replayability while reducing duplicated content.
The Weapon class focuses only on weapon-related behavior.
Inventory management, character statistics, and loot generation remain the responsibility of their respective systems.
The Weapon System has been designed to support many future additions.
Planned improvements include:
- Additional weapon classes
- Dual wielding
- Shields
- Critical hit mechanics
- Weapon upgrades
- Repair system
- Elemental damage
- Skill scaling
- Weapon rarity colors
- Legendary weapons
- Named unique weapons
- Weapon crafting
- Socketed gems
- Passive weapon abilities
- Visual equipment representation (future graphical version)
The current architecture allows these features to be integrated without major redesign.
The Weapon System provides Adventure-Game with a flexible and extensible framework for offensive equipment. By combining randomized generation, durability, enchantments, equipment management, and object-oriented design, the system offers a solid foundation for both current gameplay and future expansion.
As the project continues to evolve, the Weapon System will support increasingly advanced RPG mechanics while maintaining a clean, modular architecture that reflects modern C++ programming practices.