Example #1
0
 public void UpdateWith(UpdateBotStatus u)
 {
     if (u != null)
     {
         if (u.Name != Name)
         {
             throw new Exception(string.Format("Applying update of {0} to user {1}", u.Name, Name));
         }
         if (u.AllyNumber.HasValue)
         {
             AllyNumber = u.AllyNumber.Value;
         }
         if (u.TeamNumber.HasValue)
         {
             TeamNumber = u.TeamNumber.Value;
         }
         if (u.AiLib != null)
         {
             aiLib = u.AiLib;
         }
         if (u.Owner != null)
         {
             owner = u.Owner;
         }
     }
 }
 public void UpdateWith(UpdateBotStatus u)
 {
     if (u != null)
     {
         if (u.Name != Name) throw new Exception(string.Format("Applying update of {0} to user {1}", u.Name, Name));
         if (u.AllyNumber.HasValue) AllyNumber = u.AllyNumber.Value;
         if (u.AiLib != null) aiLib = u.AiLib;
     }
 }
Example #3
0
        public Task AddBot(string name, string aiDll, int?allyNumber = null)
        {
            var u = new UpdateBotStatus();

            if (aiDll != null)
            {
                u.AiLib = aiDll;
            }
            if (name != null)
            {
                u.Name = name;
            }
            if (allyNumber != null)
            {
                u.AllyNumber = allyNumber;
            }
            return(SendCommand(u));
        }
Example #4
0
        public async Task Process(UpdateBotStatus status)
        {
            var bat = MyBattle;

            if (bat != null)
            {
                BotBattleStatus ubs;
                bat.Bots.TryGetValue(status.Name, out ubs);
                if (ubs != null)
                {
                    ubs.UpdateWith(status);
                    BattleBotUpdated(this, ubs);
                }
                else
                {
                    var nubs = new BotBattleStatus(status.Name, status.Owner, status.AiLib);
                    nubs.UpdateWith(status);
                    bat.Bots[status.Name] = nubs;
                    BattleBotAdded(this, nubs);
                }
            }
        }