private async Task SeedCharacterRolesAsync(WowGuildManagerDbContext context)
        {
            var roleNames = new List <string>
            {
                CharacterRoleConstants.Tank,
                CharacterRoleConstants.Healer,
                CharacterRoleConstants.Damage
            };

            var characterRoles = new List <CharacterRole>();

            foreach (var roleName in roleNames)
            {
                var characterRole = new CharacterRole
                {
                    Name = roleName
                };

                characterRoles.Add(characterRole);
            }

            await context.CharacterRoles.AddRangeAsync(characterRoles);

            await context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task <CreateEntityResult <CharacterRole> > CreateCharacterRoleAsync
        (
            [NotNull] IRole role,
            RoleAccess access
        )
        {
            var getExistingRoleResult = await GetCharacterRoleAsync(role);

            if (getExistingRoleResult.IsSuccess)
            {
                return(CreateEntityResult <CharacterRole> .FromError
                       (
                           "That role is already registered as a character role."
                       ));
            }

            var getServerResult = await _servers.GetOrRegisterServerAsync(role.Guild);

            if (!getServerResult.IsSuccess)
            {
                return(CreateEntityResult <CharacterRole> .FromError(getServerResult));
            }

            var server = getServerResult.Entity;

            var characterRole = new CharacterRole(server, (long)role.Id, access);

            _database.CharacterRoles.Update(characterRole);
            await _database.SaveChangesAsync();

            return(CreateEntityResult <CharacterRole> .FromSuccess(characterRole));
        }
Exemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("StepsToPlan"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("SequenceString"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("MyRole"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("AgentNeeds"), true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
        EditorUtility.SetDirty(human);
        if(GUILayout.Button("LoadNeeds"))
        {
            human.GetMyNeeds();
        }

        if (role != human.MyRole)
        {
            human.GetMyNeeds();
            role = human.MyRole;
        }
    }
Exemplo n.º 4
0
 public Need()
 {
     Name = "NeedName";
     Value = 0f;
     IncreaseValue = 0f;
     Importance = 0f;
     Role = CharacterRole.Human;
 }
Exemplo n.º 5
0
 public Need(Need need)
 {
     Name = need.Name;
     Value = need.Value;
     IncreaseValue = need.IncreaseValue;
     Importance = need.Importance;
     Role = need.Role;
 }
Exemplo n.º 6
0
    private void Start()
    {
        myStats      = GetComponent <CharacterStats>();
        manaBar_UI   = GameManager.instance.manaBar_UI;
        manaBar_Text = manaBar_UI.GetComponentInChildren <Text>();

        charRole = myStats.role;
    }
Exemplo n.º 7
0
    public void SetUpCharacter(CharacterRole role)
    {
        Ticker.currentBlock = TimelineHolder.Instance.GetCurrentBlock();
        int current_frame = Ticker.Instance.GetCurrentTick;

        Ticker.Instance.Initialize();
        Ticker.Instance.Scrum(current_frame - 1);
    }
Exemplo n.º 8
0
 public Need(string name, float value = 0f, float increaseValue = 0f, float importance = 0f,CharacterRole role = CharacterRole.Human)
 {
     Name = name;
     Value = value;
     IncreaseValue = increaseValue;
     Importance = importance;
     Role = role;
 }
Exemplo n.º 9
0
        public async Task <DeleteEntityResult> DeleteCharacterRoleAsync
        (
            [NotNull] CharacterRole role
        )
        {
            _database.CharacterRoles.Remove(role);
            await _database.SaveChangesAsync();

            return(DeleteEntityResult.FromSuccess());
        }
Exemplo n.º 10
0
            public override async Task InitializeAsync()
            {
                var result = await this.Characters.CreateCharacterRoleAsync
                             (
                    _discordRole,
                    RoleAccess.Open
                             );

                _role = result.Entity;
            }
Exemplo n.º 11
0
    /// <summary>
    /// Sets the custom role of a character.
    /// </summary>
    /// <param name="guildID">The ID of the guild the user is on.</param>
    /// <param name="userID">The ID of the discord user.</param>
    /// <param name="character">The character.</param>
    /// <param name="characterRole">The role to set.</param>
    /// <param name="ct">The cancellation token in use.</param>
    /// <returns>A modification result which may or may not have succeeded.</returns>
    public async Task <Result> SetCharacterRoleAsync
    (
        Snowflake guildID,
        Snowflake userID,
        Character character,
        CharacterRole characterRole,
        CancellationToken ct = default
    )
    {
        if (character.Role == characterRole)
        {
            return(new UserError("The character already has that role."));
        }

        if (character.IsCurrent)
        {
            if (character.Role is not null)
            {
                var removeRole = await _guildAPI.RemoveGuildMemberRoleAsync
                                 (
                    guildID,
                    userID,
                    character.Role.DiscordID,
                    ct : ct
                                 );

                if (!removeRole.IsSuccess)
                {
                    if (removeRole.Error is not RestResultError <RestError> rre)
                    {
                        return(removeRole);
                    }

                    if (rre.Error.Code is not DiscordError.UnknownRole)
                    {
                        return(removeRole);
                    }

                    // It's probably already removed; that's fine
                }
            }

            var addRole = await _guildAPI.AddGuildMemberRoleAsync(guildID, userID, characterRole.DiscordID, ct : ct);

            if (!addRole.IsSuccess)
            {
                return(addRole);
            }
        }

        character.Role = characterRole;
        await _database.SaveChangesAsync(ct);

        return(Result.FromSuccess());
    }
Exemplo n.º 12
0
 public bool CanPerformRole(CharacterRole role)
 {
     foreach (CharacterRole cRole in Roles)
     {
         if (cRole == role)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 13
0
 public CharacterBehavior(CharacterRole role, string ownName)
 {
     Role                 = role;
     OwnName              = ownName;
     MyAction             = Action.Idle;
     MyDesire             = Desire.Nothing;
     MyAnimation          = AnimationStyle.Idle;
     InebriationLevel     = 0;
     LastDecisionDuration = float.PositiveInfinity;
     MovementSpeed        = 0;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Sets the access conditions for the given character role.
        /// </summary>
        /// <param name="role">The character role.</param>
        /// <param name="access">The access conditions.</param>
        /// <returns>A modification result which may or may not have succeeded.</returns>
        public async Task <ModifyEntityResult> SetCharacterRoleAccessAsync(CharacterRole role, RoleAccess access)
        {
            if (role.Access == access)
            {
                return(ModifyEntityResult.FromError("The role already has those access conditions."));
            }

            role.Access = access;
            await _database.SaveChangesAsync();

            return(ModifyEntityResult.FromSuccess());
        }
Exemplo n.º 15
0
            public override async Task InitializeAsync()
            {
                var guild       = MockHelper.CreateDiscordGuild(0);
                var discordRole = MockHelper.CreateDiscordRole(1, guild);

                var result = await this.Characters.CreateCharacterRoleAsync
                             (
                    discordRole,
                    RoleAccess.Open
                             );

                _role = result.Entity;
            }
Exemplo n.º 16
0
        public List <GameplayEffect> GetStartingEffects(CharacterRole Role)
        {
            switch (Role)
            {
            case CharacterRole.Barbarian: return(Barbarian.StartingEffects);

            case CharacterRole.Assassin: return(Assassin.StartingEffects);

            case CharacterRole.Necromancer: return(Necromanacer.StartingEffects);
            }
            Debug.Assert(false, "Bad role");
            return(new List <GameplayEffect>());
        }
Exemplo n.º 17
0
        public List <AttributeEntry> GetStartingAttributes(CharacterRole Role)
        {
            switch (Role)
            {
            case CharacterRole.Barbarian: return(Barbarian.StartingAttributeSet);

            case CharacterRole.Assassin: return(Assassin.StartingAttributeSet);

            case CharacterRole.Necromancer: return(Necromanacer.StartingAttributeSet);
            }
            Debug.Assert(false, "Bad role");
            return(new List <AttributeEntry>());
        }
Exemplo n.º 18
0
        /// <summary>
        /// Deletes the character role for the given Discord role.
        /// </summary>
        /// <param name="role">The character role.</param>
        /// <param name="ct">The cancellation token in use.</param>
        /// <returns>A deletion result which may or may not have succeeded.</returns>
        public async Task <DeleteEntityResult> DeleteCharacterRoleAsync
        (
            CharacterRole role,
            CancellationToken ct = default
        )
        {
            var currentOwnersWithRole = await _database.Characters.ServerScopedServersideQueryAsync
                                        (
                role.Server,
                q => q
                .Where(c => c.Role == role)
                .Where(c => c.IsCurrent)
                .Select(c => c.Owner)
                .Distinct(),
                ct
                                        );

            _database.CharacterRoles.Remove(role);

            var guild = await _client.GetGuildAsync((ulong)role.Server.DiscordID);

            if (guild is null)
            {
                return(DeleteEntityResult.FromError("Could not retrieve the guild the role was on."));
            }

            foreach (var characterOwner in currentOwnersWithRole)
            {
                var owner = await guild.GetUserAsync((ulong)characterOwner.DiscordID);

                var discordRole = guild.GetRole((ulong)role.DiscordID);

                if (owner is null || discordRole is null)
                {
                    return(DeleteEntityResult.FromError("Failed to get the owner or role."));
                }

                var removeRole = await _discord.RemoveUserRoleAsync(owner, discordRole);

                if (!removeRole.IsSuccess)
                {
                    return(DeleteEntityResult.FromError(removeRole));
                }
            }

            await _database.SaveChangesAsync(ct);

            return(DeleteEntityResult.FromSuccess());
        }
Exemplo n.º 19
0
        /// <summary>
        /// Sets the custom role of a character.
        /// </summary>
        /// <param name="guildUser">The owner of the character.</param>
        /// <param name="character">The character.</param>
        /// <param name="characterRole">The role to set.</param>
        /// <param name="ct">The cancellation token in use.</param>
        /// <returns>A modification result which may or may not have succeeded.</returns>
        public async Task <ModifyEntityResult> SetCharacterRoleAsync
        (
            IGuildUser guildUser,
            Character character,
            CharacterRole characterRole,
            CancellationToken ct = default
        )
        {
            if (character.Role == characterRole)
            {
                return(ModifyEntityResult.FromError("The character already has that role."));
            }

            if (character.IsCurrent)
            {
                if (!(character.Role is null))
                {
                    var oldRole = guildUser.Guild.GetRole((ulong)character.Role.DiscordID);
                    if (!(oldRole is null))
                    {
                        var removeRole = await _discord.RemoveUserRoleAsync(guildUser, oldRole);

                        if (!removeRole.IsSuccess)
                        {
                            return(removeRole);
                        }
                    }
                }

                var newRole = guildUser.Guild.GetRole((ulong)characterRole.DiscordID);
                if (newRole is null)
                {
                    return(ModifyEntityResult.FromError("Failed to get the new role."));
                }

                var addRole = await _discord.AddUserRoleAsync(guildUser, newRole);

                if (!addRole.IsSuccess)
                {
                    return(addRole);
                }
            }

            character.Role = characterRole;
            await _database.SaveChangesAsync(ct);

            return(ModifyEntityResult.FromSuccess());
        }
Exemplo n.º 20
0
 //for the temp object will copy all stats in prefab of that goblin pre set
 public void AddMember(Entity ent)
 {
     this.name            = ent.name;
     this.image           = ent.image;
     this.chanceEncounter = ent.chanceEncounter;
     this.role            = ent.role;
     this.weakness        = ent.weakness;
     this.invulnerable    = ent.invulnerable;
     this.weakness        = ent.weakness;
     this.level           = ent.level;
     this.hitPoints       = ent.hitPoints;
     this.maxHitPoints    = ent.maxHitPoints;
     this.damage          = ent.damage;
     this.magicDamage     = ent.magicDamage;
     this.specialDamage   = ent.specialDamage;
 }
Exemplo n.º 21
0
    /// <summary>
    /// Sets the access conditions for the given character role.
    /// </summary>
    /// <param name="role">The character role.</param>
    /// <param name="access">The access conditions.</param>
    /// <param name="ct">The cancellation token in use.</param>
    /// <returns>A modification result which may or may not have succeeded.</returns>
    public async Task <Result> SetCharacterRoleAccessAsync
    (
        CharacterRole role,
        RoleAccess access,
        CancellationToken ct = default
    )
    {
        if (role.Access == access)
        {
            return(new UserError("The role already has those access conditions."));
        }

        role.Access = access;
        await _database.SaveChangesAsync(ct);

        return(Result.FromSuccess());
    }
Exemplo n.º 22
0
        public static bool IsFromRole(CharacterType type, CharacterRole role)
        {
            if (type == CharacterType.None)
            {
                return(false);
            }
            if (role == CharacterRole.None)
            {
                return(false);
            }

            if (type == CharacterType.PendingWillFill || type == CharacterType.FemaleWillFill)
            {
                return(true);
            }

            return(Roles[role].Contains(type));
        }
Exemplo n.º 23
0
        public static bool IsGoodRole(CharacterRole role)
        {
            switch (role)
            {
            case CharacterRole.Good:
            case CharacterRole.Percival:
            case CharacterRole.Merlin:
                return(true);

            case CharacterRole.Evil:
            case CharacterRole.Assassin:
            case CharacterRole.Morgana:
            case CharacterRole.Mordred:
            case CharacterRole.Oberon:
            default:
                return(false);
            }
        }
            public override async Task InitializeAsync()
            {
                var user = (await this.Users.GetOrRegisterUserAsync(_owner)).Entity;

                _character = new Character((long)_guild.Id, user, CharacterName);

                this.Database.Characters.Update(_character);

                var createRoleResult = await this.Characters.CreateCharacterRoleAsync
                                       (
                    MockHelper.CreateDiscordRole(2, _guild),
                    RoleAccess.Open
                                       );

                _role = createRoleResult.Entity;

                await this.Database.SaveChangesAsync();
            }
    // CTOR

    public tnCharacterData(tnCharacterDataDescriptor i_Descriptor)
    {
        if (i_Descriptor != null)
        {
            m_FirstName = i_Descriptor.firstName;
            m_LastName  = i_Descriptor.lastName;

            m_DisplayName = i_Descriptor.displayName;

            m_Role   = i_Descriptor.role;
            m_Number = i_Descriptor.number;

            m_HasSpecificPrefab  = i_Descriptor.useDifferentPrefab;
            m_PrefabPath         = i_Descriptor.prefabPath;
            m_AnimatorController = i_Descriptor.animatorController;

            m_UIIconFacingRight = i_Descriptor.uiIconFacingRight;
            m_UIIconFacingLeft  = i_Descriptor.uiIconFacingLeft;
        }
    }
Exemplo n.º 26
0
        public async Task <ModifyEntityResult> SetCharacterRoleAsync
        (
            [NotNull] Character character,
            [NotNull] CharacterRole characterRole
        )
        {
            if (character.Role == characterRole)
            {
                return(ModifyEntityResult.FromError
                       (
                           "The character already has that role."
                       ));
            }

            character.Role = characterRole;

            await _database.SaveChangesAsync();

            return(ModifyEntityResult.FromSuccess());
        }
Exemplo n.º 27
0
    /// <summary>
    /// Deletes the character role for the given Discord role.
    /// </summary>
    /// <param name="role">The character role.</param>
    /// <param name="ct">The cancellation token in use.</param>
    /// <returns>A deletion result which may or may not have succeeded.</returns>
    public async Task <Result> DeleteCharacterRoleAsync
    (
        CharacterRole role,
        CancellationToken ct = default
    )
    {
        var currentOwnersWithRole = await _database.Characters.ServersideQueryAsync
                                    (
            q => q
            .Where(c => c.Server == role.Server)
            .Where(c => c.Role == role)
            .Where(c => c.IsCurrent)
            .Select(c => c.Owner)
            .Distinct(),
            ct
                                    );

        _database.CharacterRoles.Remove(role);

        foreach (var characterOwner in currentOwnersWithRole)
        {
            var removeRole = await _guildAPI.RemoveGuildMemberRoleAsync
                             (
                role.Server.DiscordID,
                characterOwner.DiscordID,
                role.DiscordID,
                ct : ct
                             );

            if (!removeRole.IsSuccess)
            {
                return(removeRole);
            }
        }

        await _database.SaveChangesAsync(ct);

        return(Result.FromSuccess());
    }
Exemplo n.º 28
0
        /// <summary>
        /// Deletes the character role for the given Discord role.
        /// </summary>
        /// <param name="role">The character role.</param>
        /// <returns>A deletion result which may or may not have succeeded.</returns>
        public async Task <DeleteEntityResult> DeleteCharacterRoleAsync(CharacterRole role)
        {
            var currentCharactersWithRole = await _characters.GetCharacters(role.Server)
                                            .Where(c => c.Role == role)
                                            .Where(c => c.IsCurrent)
                                            .ToListAsync();

            _database.CharacterRoles.Remove(role);
            await _database.SaveChangesAsync();

            var guild = await _client.GetGuildAsync((ulong)role.Server.DiscordID);

            if (guild is null)
            {
                return(DeleteEntityResult.FromError("Could not retrieve the guild the role was on."));
            }

            foreach (var character in currentCharactersWithRole)
            {
                var owner = await guild.GetUserAsync((ulong)character.Owner.DiscordID);

                var discordRole = guild.GetRole((ulong)role.DiscordID);

                if (owner is null || discordRole is null)
                {
                    return(DeleteEntityResult.FromError("Failed to get the owner or role."));
                }

                var removeRole = await _discord.RemoveUserRoleAsync(owner, discordRole);

                if (!removeRole.IsSuccess)
                {
                    return(DeleteEntityResult.FromError(removeRole));
                }
            }
            return(DeleteEntityResult.FromSuccess());
        }
Exemplo n.º 29
0
 public void SetCharacter(CharacterRole character)
 {
     this.character = character;
 }
Exemplo n.º 30
0
 public void Awake()
 {
     human = (Human)target;
     role = human.MyRole;
 }
Exemplo n.º 31
0
 public bool Applicable(CharacterRole characterMask)
 {
     return((characterMask & applicableMask) != CharacterRole.NA);
 }
 /// <summary>
 /// The order the results will be returned in.
 /// </summary>
 public GraphQueryArgument <CharacterRole> RoleQueryArgument(CharacterRole value)
 {
     return(Role.GetQueryArgumentAndSetValue(value));
 }
Exemplo n.º 33
0
 internal VisualNovelMetadata(UInt32 Id, UInt32 ReleaseId, SpoilerLevel spoilerLevel, CharacterRole characterRole)
 {
     this.Id           = Id;
     this.ReleaseId    = ReleaseId;
     this.SpoilerLevel = spoilerLevel;
     this.Role         = characterRole;
 }
Exemplo n.º 34
0
 public Player(int id, string name)
 {
     this.id         = id;
     this.playerName = name;
     this.character  = CharacterRole.Resistance;
 }
Exemplo n.º 35
0
    public Character(Tile tile, CharacterRole charRole)
    {
        CurrTile = DestTile = nextTile = tile;

        this.CharRole = charRole;
    }