Exemple #1
0
        // I.method
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

            switch (animalCode)
            {
            case 0:
                newAnimal = new Kangaroo();
                break;

            case 1:
                newAnimal = new Dingo();
                break;

            case 2:
                newAnimal = new Crocodile();
                break;

            case 3:
                newAnimal = new Koala();
                break;
            }

            return(newAnimal);
        }
Exemple #2
0
        //private Dictionary<ulong, Reply> _memcache;

        public ReplyManager(Koala bot, Logger logger = null) : base(bot, logger)
        {
            ReplyTimeout = TimeSpan.FromDays(1);

            //_memcache = new Dictionary<ulong, Reply>(16);

            Bot.Discord.MessageUpdated += HandleCommandsAsync;
            Bot.Discord.MessageDeleted += HandleMessageDelete;
        }
Exemple #3
0
        public void KoalaLengthInInches()
        {
            Koala koala = new Koala();

            decimal expected = koala.LengthInInches;
            decimal input    = 30;

            //Assert
            Assert.Equal(expected, input);
        }
Exemple #4
0
        public void GetKoalaWeight()
        {
            Koala koala = new Koala();

            //act
            int input    = 30;
            int expected = koala.GetWeight();

            //assert
            Assert.Equal(expected, input);
        }
 public void removeTrainee(Koala k)
 {
     foreach (object[] ob in trainees)
     {
         Koala ko = (Koala)ob[0];
         if (ko.Equals(k))
         {
             trainees.Remove(ob);
             break;
         }
     }
 }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Zoo");


            //create new animal array
            Animals[] animals = new Animals[6];
            Puffin    puffin  = new Puffin()
            {
                IsInZoo = true, Name = "Puff Diddy"
            };
            ScarletIbis scarletIbis = new ScarletIbis()
            {
                IsInZoo = true, Name = "Q-T Pie"
            };
            Seahorse seahorse = new Seahorse()
            {
                IsInZoo = true, Name = "Sven"
            };
            Stingray stingray = new Stingray()
            {
                IsInZoo = true, Name = "Spotty"
            };
            Koala koala = new Koala()
            {
                IsInZoo = true, Name = "George"
            };
            SnowLeopard snowLeopard = new SnowLeopard();

            //Animal Array Contains 6 animals

            //Bird
            animals[0] = puffin;
            animals[1] = scarletIbis;

            // Fish
            animals[2] = seahorse;
            animals[3] = stingray;


            // Mammals
            animals[4] = koala;
            animals[5] = snowLeopard;


            //for loop to display animals
            foreach (var t in animals)
            {
                t.DisplayCard();
            }
        }
Exemple #7
0
        public BoostEmojiManager(Koala bot, Logger logger = null) : base(bot, logger)
        {
            Discord.GuildMemberRemoved += async(args) =>
            {
                await DeleteEmojiAsync(args.Member);
            };

            Discord.GuildMemberUpdated += async(args) =>
            {
                if (!args.Member.PremiumSince.HasValue)
                {
                    await DeleteEmojiAsync(args.Member);
                }
            };
        }
Exemple #8
0
    public static void removeKoalaJob(Koala k)
    {
        bool b = false;

        object[] o = new object[2];
        foreach (object[] ob in koalaToJob)
        {
            if (((Koala)ob[0]).Equals(k))
            {
                b = true;
                o = ob;
            }
        }
        if (b)
        {
            koalaToJob.Remove(o);
        }
    }
Exemple #9
0
    public static void addKoalaJob(TrainingFacility fac, Koala k)
    {
        bool b = true;

        foreach (object[] ob in koalaToJob)
        {
            if (((Koala)ob[0]).Equals(k))
            {
                b = false;
            }
        }
        if (b)
        {
            object[] ob = new object[2];
            ob[0] = k;
            ob[1] = fac;
            koalaToJob.Add(ob);
        }
    }
    public void addTrainee(Koala k, Skill s, int daysToTrain)
    {
        bool b = true;

        foreach (object[] ob in trainees)
        {
            Koala ko = (Koala)ob[0];
            if (ko.Equals(k))
            {
                b = false;
            }
        }
        if (b)
        {
            object[] sl = new object[4];
            sl[0] = k;
            sl[1] = 0;
            sl[2] = s;
            sl[3] = daysToTrain;
            trainees.Add(sl);
        }
    }
    public void incrementDayTrain()
    {
        List <object[]> toRemove    = new List <object[]>();
        List <object[]> toIncrement = new List <object[]>();

        foreach (object[] ob in trainees)
        {
            Koala k = (Koala)ob[0];
            if (k.isAlive())
            {
                if (((int)ob[1]) + 1 >= (int)ob[3])
                {
                    Skill s = (Skill)ob[2];
                    k.setSkill(s);
                    EventLogger.addLog(((Koala)ob[0]).getName() + " has finished training to be a " + s.ToString());
                    toRemove.Add(ob);
                }
                else
                {
                    toIncrement.Add(ob);
                }
            }
            else
            {
                toRemove.Add(ob);
            }
        }
        foreach (object[] ob in toRemove)
        {
            trainees.Remove(ob);
        }
        foreach (object[] ob in toIncrement)
        {
            trainees.Remove(ob);
            ob[1] = ((int)ob[1]) + 1;
            trainees.Add(ob);
        }
    }
Exemple #12
0
        public PermissionManager(Koala bot, Logger logger = null) : base(bot, logger)
        {
            _guildEngines = new Dictionary <ulong, Engine>();

            Bot.Discord.GuildAvailable += (args) =>
            {
                Logger.Log("Loading Guild {0}", args.Guild);
                var gm = new Engine(new RedisStore(Redis, Namespace.Join(Namespace.RootNamespace, args.Guild.Id.ToString(), "perms")));
                _guildEngines[args.Guild.Id] = gm;
                return(Task.CompletedTask);
            };

            Bot.Discord.GuildUnavailable += (args) =>
            {
                Logger.Log("Clearing Guild {0}", args.Guild);
                _guildEngines.Remove(args.Guild.Id);
                return(Task.CompletedTask);
            };

            /*
             * Bot.Discord.GuildMemberRemoved += async (args) =>
             * {
             *  Logger.Log("Deleting Member {0}", args.Member);
             *  var manager = GetEngine(args.Guild);
             *  var group = await manager.GetMemberGroupAsync(args.Member);
             *  await group.DeleteAsync();
             * };
             */

            Bot.Discord.GuildRoleDeleted += async(args) =>
            {
                Logger.Log("Deleting Role {0}", args.Role);
                var group = await GetRoleGroupAsync(args.Guild, args.Role);

                await group.DeleteAsync();
            };
        }
Exemple #13
0
 public ReactRoleManager(Koala bot, Logger logger = null) : base(bot, logger)
 {
     /*
      * Discord.MessageDeleted += async (args) =>
      * {
      *  //Remove the reactions that we stored.
      *  await RemoveAllReactionRoleAsync(args.Message);
      * };
      *
      * Discord.MessagesBulkDeleted += async (args) =>
      * {
      *  //Bulk deletes
      *  foreach (var m in args.Messages)
      *      await RemoveAllReactionRoleAsync(m);
      * };
      *
      * Discord.MessageReactionAdded += async (args) =>
      * {
      *  //Award the reaction
      *  var r = await GetReactionRoleAsync(args.Message, args.Emoji);
      *  if (r != null)
      *  {
      *      var gm = await args.Channel.Guild.GetMemberAsync(args.User);
      *      await gm.GrantRoleAsync(r, "Reaction Role");
      *  }
      * };
      *
      * Discord.MessageReactionRemoved += async (args) =>
      * {
      *  //Remove the role
      *  var r = await GetReactionRoleAsync(args.Message, args.Emoji);
      *  var gm = await args.Channel.Guild.GetMemberAsync(args.User);
      *  await gm.RevokeRoleAsync(r, "Reaction Role");
      * };
      */
 }
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

            switch (animalCode)
            {
                case 0:
                    newAnimal = new Crocodile();
                    break;
                case 1:
                    newAnimal = new Koala();
                    break;
                case 2:
                    newAnimal = new Kangaroo();
                    break;
                case 3:
                    newAnimal = new Kookaburra();
                    break;
                case 4:
                    newAnimal = new Funnelweb();
                    break;
            }
            return newAnimal;
        }
Exemple #15
0
        public MessageCounter(Koala bot, double syncTimeMillis)
        {
            this.Bot      = bot;
            this.SyncRate = syncTimeMillis;

            _userTallies = new Dictionary <ulong, GuildTracking>();
            _semaphore   = new SemaphoreSlim(1, 1);
            _syncTimer   = new System.Timers.Timer(syncTimeMillis)
            {
                AutoReset = true
            };
            _syncTimer.Elapsed += async(sender, args) => await SyncChanges();

            _syncTimer.Start();

            bot.Discord.MessageCreated += async(args) =>
            {
                if (args.Author.IsBot)
                {
                    return;
                }
                await RecordMessage(args.Message);
            };
        }
 public void addEngineer(Koala k)
 {
     this.engineers.Add(k);
 }
Exemple #17
0
 public AccountModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-SW-ACC", bot.Logger);
 }
 public void addTrainer(Koala k)
 {
     trainers.Add(k);
 }
Exemple #19
0
 public StarwatchModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-SW", bot.Logger);
 }
Exemple #20
0
 public FunModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-FUN", bot.Logger);
 }
Exemple #21
0
 public RoleplayModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-RP", bot.Logger);
 }
Exemple #22
0
 /// <summary>
 /// Gets the probably reply to this command.
 /// </summary>
 /// <param name="koala"></param>
 /// <returns></returns>
 public Task <Reply> GetReplyAsync(Koala koala = null)
 {
     koala = koala ?? Koala.Bot;
     return(koala.ReplyManager.GetReplyAsync(GuildId, MessageId));
 }
Exemple #23
0
    //For time related stuffies, use FixedUpdate
    void Start()
    {
        terrain  = GameObject.FindGameObjectWithTag("terrain");
        RAND_Day = Random.Range(2, 6);
        events.Add(Events.DUST_STORM);
        events.Add(Events.EARTHQUAKE);
        events.Add(Events.METEOR);
        events.Add(Events.SOLAR_FLARE);
        timeScale      = PlayerPrefs.GetInt("TimeScale");
        Time.timeScale = .1f;
        DirectoryInfo d         = new DirectoryInfo(@Application.dataPath);
        IFormatter    formatter = new BinaryFormatter();

        FileInfo[] pdFiles = d.Parent.GetFiles("Assetspd.bin");
        foreach (FileInfo f in pdFiles)
        {
            Stream stream = new FileStream(f.Name,
                                           FileMode.Open,
                                           FileAccess.Read,
                                           FileShare.Read);
            pd = (PlayerData)formatter.Deserialize(stream);
            stream.Close();
            days    = pd.getDayCount();
            years   = pd.getYearCount();
            minutes = pd.getMinuteCount();
            Debug.Log(pd.getFoodSupply());
            Debug.Log(pd.getWaterSupply());
        }

        if (pd == null)
        {
            pd = new PlayerData(1500, 1500, 1000, 500);
            FileInfo[] allBinFiles = d.Parent.GetFiles("*.bin");
            foreach (FileInfo f in allBinFiles)
            {
                f.Delete();
            }
            for (int i = 0; i < 10; i++)
            {
                System.Random rnd = new System.Random();
                koalas.Add(new Koala(NameDictionary.firstNames[rnd.Next(NameDictionary.firstNames.Length)] + " " + NameDictionary.lastNames[rnd.Next(NameDictionary.lastNames.Length)],
                                     0, rnd.Next(2) + 1, rnd.Next(2) + 1, rnd.Next(2) + 1, Storage.days, Random.Range(1, 3)));
            }
            Debug.Log("New game");
        }
        else
        {
            FileInfo[] tbFiles = d.Parent.GetFiles("*tb.bin");
            foreach (FileInfo f in tbFiles)
            {
                Stream stream = new FileStream(f.Name,
                                               FileMode.Open,
                                               FileAccess.Read,
                                               FileShare.Read);
                Facility fac = (Facility)formatter.Deserialize(stream);
                Storage.allTB.Add(fac);
                fac.create();
                stream.Close();
                Debug.Log(f.Name);
            }

            FileInfo[] tfFiles = d.Parent.GetFiles("*tf.bin");
            foreach (FileInfo f in tfFiles)
            {
                Stream stream = new FileStream(f.Name,
                                               FileMode.Open,
                                               FileAccess.Read,
                                               FileShare.Read);
                TrainingFacility tf = (TrainingFacility)formatter.Deserialize(stream);
                tf.create();
                allTF.Add(tf);
                stream.Close();
            }

            FileInfo[] files = d.Parent.GetFiles("*koala.bin");
            foreach (FileInfo f in files)
            {
                Stream stream = new FileStream(f.Name,
                                               FileMode.Open,
                                               FileAccess.Read,
                                               FileShare.Read);
                Koala ko = (Koala)formatter.Deserialize(stream);
                koalas.Add(ko);
                stream.Close();
            }
        }
        FileInfo[] fe = d.Parent.GetFiles("*.bin");
        foreach (FileInfo f in fe)
        {
            f.Delete();
        }
    }
Exemple #24
0
 public ModerationModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-MOD", bot.Logger);
 }
Exemple #25
0
 public ReactRoleModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-ROLE", bot.Logger);
 }
 public void removeTrainer(Koala k)
 {
     trainers.Remove(k);
 }
 public ConfigurationModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-CONFIG", bot.Logger);
 }
Exemple #28
0
 public WorldModule(Koala bot)
 {
     this.Bot    = bot;
     this.Logger = new Logger("CMD-SW-PROC", bot.Logger);
 }
 public void removeKoala(Koala k)
 {
     this.koalas.Remove(k);
 }
 public void addKoala(Koala k)
 {
     this.koalas.Add(k);
 }
Exemple #31
0
 public Manager(Koala bot, Logger logger = null)
 {
     Bot    = bot;
     Logger = logger ?? new Logger(GetType().Name);
 }