RpgGame
Console Based RPG game in C#
Loading...
Searching...
No Matches
RpgGame.Items.Weapon Class Referenceabstract

Represents an abstract base class for all equippable weapons. More...

Inheritance diagram for RpgGame.Items.Weapon:
Collaboration diagram for RpgGame.Items.Weapon:

Public Member Functions

bool TryEquipToLeft (Player player)
 Attempts to equip the weapon in the player's left hand.
 
bool TryEquipToRight (Player player)
 Attempts to equip the weapon in the player's right hand.
 
virtual string GetDescription ()
 Returns a short textual description of the weapon.
 
bool OnPickup (Player player, Inventory inventory)
 Handles pickup interaction for the weapon.
 
void OnDrop (Level level, Player player)
 Drops the weapon onto the current level at the player's position.
 

Protected Member Functions

 Weapon (HandOccupation occupation)
 Initializes a new instance of the Weapon class with the specified hand occupation strategy.
 

Properties

string Name [get]
 Gets the display name of the weapon.
 
ConsoleColor color [get]
 Gets the console color used to render the weapon on the map.
 
char Symbol [get]
 Gets the character symbol used to render the weapon on the map.
 
int Damage [get]
 Gets the damage value dealt by the weapon.
 
- Properties inherited from RpgGame.Items.IItem

Detailed Description

Represents an abstract base class for all equippable weapons.

The Weapon class implements IEquippable and delegates equipment behavior to a HandOccupation strategy object. This design allows different weapons to define whether they occupy one or both hands without using type checks or enumerations.

Concrete weapon types must provide their own name, symbol, and damage value.

Constructor & Destructor Documentation

◆ Weapon()

RpgGame.Items.Weapon.Weapon ( HandOccupation  occupation)
inlineprotected

Initializes a new instance of the Weapon class with the specified hand occupation strategy.

Parameters
occupationThe strategy that determines how the weapon is equipped (e.g., one-handed or two-handed).

Member Function Documentation

◆ GetDescription()

virtual string RpgGame.Items.Weapon.GetDescription ( )
virtual

Returns a short textual description of the weapon.

Returns
A string containing the weapon's name and damage value.

Implements RpgGame.Items.IItem.

◆ OnDrop()

void RpgGame.Items.Weapon.OnDrop ( Level  level,
Player  player 
)
inline

Drops the weapon onto the current level at the player's position.

Parameters
levelThe current level.
playerThe player dropping the weapon.

Implements RpgGame.Items.IItem.

Here is the call graph for this function:

◆ OnPickup()

bool RpgGame.Items.Weapon.OnPickup ( Player  player,
Inventory  inventory 
)
inline

Handles pickup interaction for the weapon.

Parameters
playerThe player picking up the weapon.
pickUpLeftIndicates whether the pickup action targets the left hand. If false, the weapon attempts to equip in the right hand.
Returns
True if the weapon was successfully equipped; otherwise false.

Implements RpgGame.Items.IItem.

Here is the call graph for this function:

◆ TryEquipToLeft()

bool RpgGame.Items.Weapon.TryEquipToLeft ( Player  player)

Attempts to equip the weapon in the player's left hand.

Parameters
playerThe player attempting to equip the weapon.
Returns
True if the weapon was successfully equipped; otherwise false.

Implements RpgGame.Items.IEquippable.

◆ TryEquipToRight()

bool RpgGame.Items.Weapon.TryEquipToRight ( Player  player)

Attempts to equip the weapon in the player's right hand.

Parameters
playerThe player attempting to equip the weapon.
Returns
True if the weapon was successfully equipped; otherwise false.

Implements RpgGame.Items.IEquippable.

Property Documentation

◆ color

ConsoleColor RpgGame.Items.Weapon.color
getabstract

Gets the console color used to render the weapon on the map.

Implements RpgGame.Items.IItem.

◆ Name

string RpgGame.Items.Weapon.Name
getabstract

Gets the display name of the weapon.

Implements RpgGame.Items.IItem.

◆ Symbol

char RpgGame.Items.Weapon.Symbol
getabstract

Gets the character symbol used to render the weapon on the map.

Implements RpgGame.Items.IItem.


The documentation for this class was generated from the following file: