Exemple #1
0
        /// <summary>
        /// Checks if the opponent is blocking.
        /// Returns: Success, Blocked Damage, Taken Damage
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="defender"></param>
        /// <param name="dmg"></param>
        /// <returns> Success, Blocked Damage, Taken Damage</returns>
        public static Tuple <bool, int, int> CheckForBlock(SocketUser attacker, SocketUser defender, int dmg)
        {
            var config = GlobalUserAccounts.GetUserAccount(defender);
            var choms  = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id);
            var chom1  = choms.Item1;
            var chom2  = choms.Item2;

            int finaldmg2 = 0, finaldmg1 = 0;

            if (chom1.PotionEffects.ContainsKey("Speed"))
            {
                chom2.Effects.Remove(Effect.Blocking);
                ActiveChomusuke.ConvertActiveVariable(attacker.Id, config.OpponentId, chom1, chom2);
                return(new Tuple <bool, int, int>(true, 0, 0));
            }

            if (chom2.Effects.Contains(Effect.Blocking))
            {
                finaldmg1 = dmg * (3 / 4); //blocked dmg
                finaldmg2 = dmg * (1 / 4); //taken dmg
                chom2.Effects.Remove(Effect.Blocking);

                return(new Tuple <bool, int, int>(true, finaldmg1, finaldmg2));
            }

            GlobalUserAccounts.SaveAccounts(config.Id);
            return(new Tuple <bool, int, int>(false, 0, 0)); // use for values
        }
Exemple #2
0
        public static Tuple <bool, int> CheckForDeflect(SocketUser attacker, SocketUser defender, int dmg)
        {
            var config   = GlobalUserAccounts.GetUserAccount(defender);
            var choms    = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id);
            var chom1    = choms.Item1;
            var chom2    = choms.Item2;
            int finaldmg = 0;

            if (chom1.PotionEffects.ContainsKey("Speed"))
            {
                chom2.Effects.Remove(Effect.Deflecting);
                ActiveChomusuke.ConvertActiveVariable(attacker.Id, config.OpponentId, chom1, chom2);
                return(new Tuple <bool, int>(true, 0));
            }

            if (chom2.Effects.Contains(Effect.Deflecting))
            {
                finaldmg = dmg / 2; //damage taken and deflected
                chom2.Effects.Remove(Effect.Deflecting);
                return(new Tuple <bool, int>(true, finaldmg));
            }

            GlobalUserAccounts.SaveAccounts(config.Id);
            return(new Tuple <bool, int>(false, 0));
        }
Exemple #3
0
        public static async Task Reset(ShardedCommandContext context, Core.Entities.Chomusuke chom1,
                                       Core.Entities.Chomusuke chom2)
        {
            var config  = GlobalUserAccounts.GetUserAccount(context.User);
            var player2 = context.Guild.GetUser(config.OpponentId);
            var configg = GlobalUserAccounts.GetUserAccount(player2);

            config.Fighting      = false;
            configg.Fighting     = false;
            chom1.Health         = chom1.HealthCapacity;
            chom2.Health         = chom2.HealthCapacity;
            config.OpponentId    = 0;
            configg.OpponentId   = 0;
            config.OpponentName  = null;
            configg.OpponentName = null;
            config.WhosTurn      = null;
            config.WhoWaits      = null;
            config.PlaceHolder   = null;
            configg.WhosTurn     = null;
            configg.WhoWaits     = null;
            chom1.Effects?.Clear();
            chom2.Effects?.Clear();
            chom1.PotionEffects?.Clear();
            chom2.PotionEffects?.Clear();
            await ActiveChomusuke.ConvertActiveVariable(context.User.Id, config.OpponentId, chom1, chom2);

            GlobalUserAccounts.SaveAccounts(config.Id, configg.Id);
        }