using RpgRoller.Contracts;

namespace RpgRoller.Services;

public interface IGameService
{
    IReadOnlyList<RulesetDefinition> GetRulesets();

    ServiceResult<UserSummary> Register(string username, string password, string displayName);
    ServiceResult<(UserSummary User, string SessionToken)> Login(string username, string password);
    void Logout(string sessionToken);
    UserSummary? GetUserBySession(string sessionToken);
    ServiceResult<MeResponse> GetMe(string sessionToken);

    ServiceResult<CampaignSummary> CreateCampaign(string sessionToken, string name, string rulesetId);
    ServiceResult<IReadOnlyList<CampaignSummary>> GetCampaigns(string sessionToken);
    ServiceResult<IReadOnlyList<CampaignOption>> GetCharacterCampaignOptions(string sessionToken);
    ServiceResult<CampaignRoster> GetCampaign(string sessionToken, Guid campaignId);
    ServiceResult<bool> DeleteCampaign(string sessionToken, Guid campaignId);
    ServiceResult<IReadOnlyList<string>> GetUsernames(string sessionToken);
    ServiceResult<IReadOnlyList<AdminUserSummary>> GetUsers(string sessionToken);
    ServiceResult<AdminUserSummary> UpdateUserRoles(string sessionToken, Guid userId, IReadOnlyList<string> roles);
    ServiceResult<bool> DeleteUser(string sessionToken, Guid userId);

    ServiceResult<CharacterSummary> CreateCharacter(string sessionToken, string name, Guid campaignId);
    ServiceResult<CharacterSummary> UpdateCharacter(string sessionToken, Guid characterId, string name, Guid? campaignId, string? ownerUsername = null);
    ServiceResult<bool> DeleteCharacter(string sessionToken, Guid characterId);
    ServiceResult<bool> ActivateCharacter(string sessionToken, Guid characterId);
    ServiceResult<IReadOnlyList<CharacterSummary>> GetOwnCharacters(string sessionToken);

    ServiceResult<SkillGroupSummary> CreateSkillGroup(string sessionToken, Guid characterId, string name, string diceRollDefinition, int wildDice, bool allowFumble, int? fumbleRange = null);
    ServiceResult<SkillGroupSummary> UpdateSkillGroup(string sessionToken, Guid skillGroupId, string name, string diceRollDefinition, int wildDice, bool allowFumble, int? fumbleRange = null);
    ServiceResult<bool> DeleteSkillGroup(string sessionToken, Guid skillGroupId);
    ServiceResult<SkillSummary> CreateSkill(string sessionToken, Guid characterId, string name, string diceRollDefinition, int wildDice, bool allowFumble, Guid? skillGroupId = null, int? fumbleRange = null, bool rolemasterAutoRetry = false);
    ServiceResult<SkillSummary> UpdateSkill(string sessionToken, Guid skillId, string name, string diceRollDefinition, int wildDice, bool allowFumble, Guid? skillGroupId = null, int? fumbleRange = null, bool rolemasterAutoRetry = false);
    ServiceResult<bool> DeleteSkill(string sessionToken, Guid skillId);
    ServiceResult<CharacterSheet> GetCharacterSheet(string sessionToken, Guid characterId);

    ServiceResult<RollResult> RollSkill(string sessionToken, Guid skillId, string visibility, int situationalModifier = 0);
    ServiceResult<RollResult> RollCustom(string sessionToken, Guid characterId, string expression, string visibility);
    ServiceResult<IReadOnlyList<CampaignLogEntry>> GetCampaignLog(string sessionToken, Guid campaignId);
    ServiceResult<CampaignLogPage> GetCampaignLogPage(string sessionToken, Guid campaignId, Guid? afterRollId = null, int? limit = null);
    ServiceResult<CampaignRollDetail> GetRollDetail(string sessionToken, Guid rollId);

    ServiceResult<CampaignStateSnapshot> GetCampaignStateSnapshot(string sessionToken, Guid campaignId);
}