You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trek-12/source/Trek-12/Models/Game/Player.cs

82 lines
2.6 KiB

namespace Models.Game
{
/// <summary>
/// Represents a player in the game.
/// </summary>
public class Player
{
/// <summary>
/// It is he pseudo of the player.
/// </summary>
public string Pseudo { get; private set; }
/// <summary>
/// It is the profile picture of the player.
/// </summary>
public string ProfilePicture { get; private set; }
/// <summary>
/// It is the creation date of the player.
/// </summary>
public string? CreationDate { get; private set; }
/// <summary>
/// It tells when was the last time the player played.
/// </summary>
public string? LastPlayed { get; private set; }
/// <summary>
/// Constructor with default values.
/// </summary>
public Player()
{
Pseudo = "Player";
ProfilePicture = "DefaultProfilePicture";
}
/// <summary>
/// Construct a new instance of Player with specified pseudo and profile picture.
/// </summary>
/// <param name="pseudo">The pseudo of the player.</param>
/// <param name="profilePicture">The profile picture of the player.</param>
public Player(string pseudo, string profilePicture = "DefaultProfilePicture")
{
Pseudo = pseudo;
ProfilePicture = profilePicture;
}
/// <summary>
/// Chooses the operation for the player.
/// </summary>
/// <returns>The chosen operation.</returns>
public Operation ChooseOperation()
{
return Operation.LOWER;
}
/// <summary>
/// Redefine the equal operation between player.
/// </summary>
/// <param name="obj">The object to compare with the current player.</param>
/// <returns>true if the specified object is equal to the current player; otherwise, false.</returns>
public override bool Equals(object? obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
Player c = (Player)obj;
return (Pseudo == c.Pseudo);
}
/// <summary>
/// Returns the hash code for the current player, in order for the Equals operation to work
/// </summary>
/// <returns>The hash code for the current player.</returns>
public override int GetHashCode()
{
return Pseudo.GetHashCode();
}
}
}