Esempio n. 1
0
 internal void FlushSettings()
 {
     this.mCycleEnded = true;
     using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
     {
         this.GetRoomItemHandler().SaveFurniture(queryreactor, null);
     }
     this.Tags.Clear();
     this.UsersWithRights.Clear();
     this.Bans.Clear();
     this.ActiveTrades.Clear();
     this.LoadedGroups.Clear();
     if (this.GotFreeze())
     {
         this.freeze = new Freeze(this);
     }
     if (this.GotBanzai())
     {
         this.banzai = new BattleBanzai(this);
     }
     if (this.GotSoccer())
     {
         this.soccer = new Soccer(this);
     }
     if (this.gameItemHandler != null)
     {
         this.gameItemHandler = new GameItemHandler(this);
     }
 }
Esempio n. 2
0
        internal void FlushSettings()
        {
            List <ServerMessage> messages = new List <ServerMessage>();

            lock (GetRoomItemHandler().mFloorItems)
            {
                foreach (RoomItem Item in GetRoomItemHandler().mFloorItems.Values)
                {
                    ServerMessage Message = new ServerMessage(94);
                    Message.AppendRawUInt(Item.Id);
                    Message.AppendStringWithBreak("");
                    Message.AppendBoolean(false);
                    messages.Add(Message);
                }
            }


            lock (GetRoomItemHandler().mWallItems)
            {
                foreach (RoomItem Item in GetRoomItemHandler().mWallItems.Values)
                {
                    ServerMessage Message = new ServerMessage(84);
                    Message.AppendRawUInt(Item.Id);
                    Message.AppendStringWithBreak("");
                    Message.AppendBoolean(false);
                    messages.Add(Message);
                }
            }

            SendMessage(messages);


            mCycleEnded = true;
            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                GetRoomItemHandler().SaveFurniture(dbClient);

            Tags.Clear();
            UsersWithRights.Clear();
            Bans.Clear();
            ActiveTrades.Clear();


            if (GotFreeze())
            {
                freeze = new Freeze(this);
            }
            if (GotBanzai())
            {
                banzai = new BattleBanzai(this);
            }
            if (GotSoccer())
            {
                soccer = new Soccer(this);
            }
            if (gameItemHandler != null)
            {
                gameItemHandler = new GameItemHandler(this);
            }
        }
Esempio n. 3
0
 public Soccer GetSoccer()
 {
     if (_soccer == null)
     {
         _soccer = new Soccer(this);
     }
     return(_soccer);
 }
Esempio n. 4
0
 public Soccer GetSoccer()
 {
     if (this.soccer == null)
     {
         this.soccer = new Soccer(this);
     }
     return(this.soccer);
 }
Esempio n. 5
0
 internal Soccer GetSoccer()
 {
     if (soccer == null)
     {
         soccer = new Soccer(this);
     }
     return(soccer);
 }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Hockey hockeyTeam = new Hockey("hockey", "Jack Jacobs", "The Losers", "Finland", 27);
            Soccer newTeam    = new Soccer("soccer", "Jordan Gilmore", "The Bowies", "Red", 20);

            Console.WriteLine(hockeyTeam + "\n");
            Console.WriteLine(newTeam);
            Console.Read(); //keeps console window open
        }
Esempio n. 7
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Soccer soccer = await db.Soccers.FindAsync(id);

            db.Soccers.Remove(soccer);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Opponents,Result,Date,Score")] Soccer soccer)
        {
            if (ModelState.IsValid)
            {
                db.Entry(soccer).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(soccer));
        }
Esempio n. 9
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Opponents,Result,Date,Score")] Soccer soccer)
        {
            if (ModelState.IsValid)
            {
                db.Soccers.Add(soccer);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(soccer));
        }
Esempio n. 10
0
        static void GetSoccer()
        {
            var    soccerList = LoadSoccer();
            Soccer lowest     = null;

            soccerList.ForEach(s => {
                if (lowest == null || s.Difference < lowest.Difference)
                {
                    lowest = s;
                }
            });
            Console.WriteLine($"Team: {lowest.Team}, Difference: {lowest.Difference}");
        }
Esempio n. 11
0
        // GET: Soccers/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Soccer soccer = await db.Soccers.FindAsync(id);

            if (soccer == null)
            {
                return(HttpNotFound());
            }
            return(View(soccer));
        }
        }                              //creazioe property da inserire in un array di tipo Athlete (atleti dentro sacco di atleti)

        public DummyPersistenceLayer() //simulazione creaz. database
        {
            Sport calcio    = new Soccer();
            Sport tennis    = new Tennis();
            Sport pallavolo = new VolleyBall();

            Athlete a1 = new AmateurAthlete("mario", "rossi", 20, Gender.Male);

            a1.Age   = -19;
            a1.Sport = calcio;


            Athlete a2 = new AmateurAthlete("GG01371347019", "Giorgio", "Gori", Gender.Male, DateTime.Now, 25, 1.82, 89, pallavolo);


            ProAthlete pa1 = new ProAthlete("Lebron", "James", 34, Gender.Male, "Nike");

            pa1.Height = 2.03;
            pa1.Weight = 113;
            pa1.Sport  = tennis;

            Athlete pa2 = new ProAthlete("James", "Harden", 30, Gender.Male, "Adidas");



            pa2.Sport = tennis;



            Athlete aa1 = new AmateurAthlete("Giorgia", "Piccolini", 53, Gender.Female);

            aa1.Sport = pallavolo;



            JuniorAthlete ja1 = new JuniorAthlete("Carmelino", "James", 4, Gender.Male, "Pino James");

            ja1.Sport = calcio;


            Athlete ja2 = new JuniorAthlete("Guendalina", "Harden", 13, Gender.Female, "Anna Harden");

            ja2.Sport = tennis;

            AllAthlete = new List <Athlete> {
                a1, a2, pa1, pa2, aa1, ja1, ja2
            };                                                                  //inser. elementi creati sopra
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            //Subclasses referenced from the team dll
            Hockey hockeyTeam = new Hockey("hockey", "Jack Jacobs", "The Losers", "Finland", 27);
            Soccer newTeam    = new Soccer("soccer", "Jordan Gilmore", "The Bowies", "Red", 20);

            //prints subclasses ToString()'s to console
            Console.WriteLine(hockeyTeam);
            Console.WriteLine("The team's budget is: $" + hockeyTeam.TeamFunding());
            Console.WriteLine();
            Console.WriteLine(newTeam);
            Console.WriteLine("The team's budget is: $" + newTeam.TeamFunding());
            //prints interface value

            Console.Read(); //keeps console window open
        }
Esempio n. 14
0
        public async Task <CommandResult> Handle(CreateCompetitionCommand request, CancellationToken cancellationToken)
        {
            //Each new message is found based on it's uniqueness id, that we calculate out of some fields, that considered to be unique.
            //Currently, it's always being replaced with it's new version.
            var teams = request.Teams
                        .Select(x => new Team(x.Name))
                        .ToList();

            var competition = new Soccer(
                request.Name,
                request.Place,
                teams,
                request.StartDate,
                request.UniqueId.ToString(),
                request.LiveUri);

            var documentExisted = await repository.ExistsAsync(competition);

            await repository.UpsertAsync(competition);

            //todo: in real example, should be in transactional manner;
            //all settings for the demo to be working, specified for the simplicity here
            if (!documentExisted)
            {
                await mediator.Publish(
                    new SendLiveSourceNotification
                {
                    ConnectorType        = SourceConnectorType.LifeScores,
                    SourceType           = SourceType.Api,
                    Uri                  = request.LiveUri,
                    When                 = request.StartDate,
                    PollingIntervalInSec = 60,
                    StartTime            = request.StartDate,
                    FinishTime           = request.StartDate.AddMinutes(120), //for POC it should stop after 90 minutes
                    CompetitionUniqueId  = competition.UniqueId,
                    SportType            = SportType.Soccer
                },
                    cancellationToken);
            }

            return(new CommandResult
            {
                Success = true
            });
        }
Esempio n. 15
0
        public async Task <Competition> GetAsync(string id)
        {
            Competition competition    = null;
            var         competitionDto = await competitions.Find(filter => filter.Id.Equals(id)).SingleOrDefaultAsync();

            if (competitionDto != null)
            {
                //here we can use double dispatch to avoid the switch case, but not for POC.
                var teams = competitionDto.Teams
                            .Select(x => new Team(x.Name))
                            .ToList();

                competition = new Soccer(
                    competitionDto.Name,
                    competitionDto.Place,
                    teams,
                    competitionDto.StartDate,
                    competitionDto.Id,
                    competitionDto.LiveUri);
            }

            return(competition);
        }
Esempio n. 16
0
 public Cloud(Room room, Soccer soccer)
 {
     this.room   = room;
     this.soccer = soccer;
 }
Esempio n. 17
0
 public void Add(Soccer soccer)
 {
     Soccers.Add(soccer);
 }
Esempio n. 18
0
 public Push(Room room, Soccer soccer)
 {
     this.room   = room;
     this.soccer = soccer;
 }
Esempio n. 19
0
 public Rebug(Room room, Soccer soccer)
 {
     this.room   = room;
     this.soccer = soccer;
 }
Esempio n. 20
0
 public Soccer GetSoccer()
 {
     return(_soccer ?? (_soccer = new Soccer(this)));
 }
Esempio n. 21
0
        private void Dispose()
        {
            if (!mDisposed)
            {
                try
                {
                    mDisposed   = true;
                    mCycleEnded = true;
                    OtanixEnvironment.GetGame().GetRoomManager().QueueActiveRoomRemove(mRoomData);

                    using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        GetRoomItemHandler().SaveFurniture(dbClient);
                        saveBots();
                    }

                    WorkRoomServerMessageThread();
                    WorkRoomChatServerMessageThread();

                    ClearMute();
                    UsersWithRights.Clear();
                    Bans.Clear();

                    foreach (var item in GetRoomItemHandler().mFloorItems.Values)
                    {
                        item.Destroy();
                    }

                    foreach (var item in GetRoomItemHandler().mWallItems.Values)
                    {
                        item.Destroy();
                    }

                    roomUserManager.Destroy();
                    roomUserManager = null;

                    chatMessageManager.Destroy();
                    chatMessageManager = null;

                    roomItemHandling.Destroy();
                    roomItemHandling = null;

                    if (GetGameManager() != null)
                    {
                        GetGameManager().Destroy();
                        games = null;
                    }

                    if (GotSoccer())
                    {
                        GetSoccer().Destroy();
                        soccer = null;
                    }

                    if (GotWired())
                    {
                        GetWiredHandler().Destroy();
                        wiredHandler = null;
                    }

                    if (GotMusicController())
                    {
                        GetRoomMusicController().Destroy();
                        musicController = null;
                    }

                    if (GetGameMap() != null)
                    {
                        GetGameMap().Destroy();
                        gamemap = null;
                    }
                }
                catch (Exception e)
                {
                    Logging.LogCriticalException("Unload of room " + e);
                }
            }
        }
Esempio n. 22
0
        public void Dispose()
        {
            SendPacket(new CloseConnectionComposer());

            if (!mDisposed)
            {
                isCrashed = false;
                mDisposed = true;

                /* TODO: Needs reviewing */
                try
                {
                    if (ProcessTask != null && ProcessTask.IsCompleted)
                    {
                        ProcessTask.Dispose();
                    }
                }
                catch { }

                if (ActiveTrades.Count > 0)
                {
                    ActiveTrades.Clear();
                }

                TonerData     = null;
                MoodlightData = null;

                if (MutedUsers.Count > 0)
                {
                    MutedUsers.Clear();
                }

                if (Tents.Count > 0)
                {
                    Tents.Clear();
                }

                if (UsersWithRights.Count > 0)
                {
                    UsersWithRights.Clear();
                }

                if (_gameManager != null)
                {
                    _gameManager.Dispose();
                    _gameManager = null;
                }

                if (_freeze != null)
                {
                    _freeze.Dispose();
                    _freeze = null;
                }

                if (_soccer != null)
                {
                    _soccer.Dispose();
                    _soccer = null;
                }

                if (_banzai != null)
                {
                    _banzai.Dispose();
                    _banzai = null;
                }

                if (_gamemap != null)
                {
                    _gamemap.Dispose();
                    _gamemap = null;
                }

                if (_gameItemHandler != null)
                {
                    _gameItemHandler.Dispose();
                    _gameItemHandler = null;
                }

                // Room Data?

                if (teambanzai != null)
                {
                    teambanzai.Dispose();
                    teambanzai = null;
                }

                if (teamfreeze != null)
                {
                    teamfreeze.Dispose();
                    teamfreeze = null;
                }

                if (_roomUserManager != null)
                {
                    _roomUserManager.Dispose();
                    _roomUserManager = null;
                }

                if (_roomItemHandling != null)
                {
                    _roomItemHandling.Dispose();
                    _roomItemHandling = null;
                }

                if (_wordFilterList.Count > 0)
                {
                    _wordFilterList.Clear();
                }

                if (_filterComponent != null)
                {
                    _filterComponent.Cleanup();
                }

                if (_wiredComponent != null)
                {
                    _wiredComponent.Cleanup();
                }

                if (_bansComponent != null)
                {
                    _bansComponent.Cleanup();
                }

                if (_tradingComponent != null)
                {
                    _tradingComponent.Cleanup();
                }
            }
        }