Пример #1
0
        public int DeleteItem(PartyScore item)
        {
            var id = item.Id;

            if (id != 0)
            {
                lock (collisionLock)
                {
                    database.Delete <PartyScore>(id);
                }
            }
            this.Items.Remove(item);
            return(id);
        }
Пример #2
0
 public int SaveItem(PartyScore item)
 {
     lock (collisionLock)
     {
         if (item.Id != 0)
         {
             database.Update(item);
             return(item.Id);
         }
         else
         {
             database.Insert(item);
             return(item.Id);
         }
     }
 }
Пример #3
0
        //Takes care of the logic for pushing the scores to the DB
        //Then goes to the end-of-game score page
        async void GoToScoreAndPushToDB(List <Character> c)
        {
            //Initialize DBs
            DBPartyController partyDB = new DBPartyController();
            DBScoreController scoreDB = new DBScoreController();

            //Push general party score (battles won + overall levels)
            int scoretotal = battles;

            foreach (Character myC in c)
            {
                scoretotal += myC.Level;
            }
            Score scoreToPush = new Score {
                Points = scoretotal
            };
            int scoreID = scoreDB.SaveItem(scoreToPush);

            //Associate specific character scores with the party score and push to partyDB
            foreach (Character myC in c)
            {
                PartyScore charScore = new PartyScore
                {
                    PartyId   = scoreID,
                    Name      = myC.Name,
                    Image     = myC.Image,
                    Str       = myC.Str,
                    Def       = myC.Def,
                    Dex       = myC.Dex,
                    Health    = myC.MaxHealth,
                    Battles   = battles,
                    Levels    = myC.Level,
                    ExpPoints = myC.ExpPoints
                };
                partyDB.SaveItem(charScore);
            }

            //Exit to end-of-game page
            await Navigation.PushAsync(new EndGamePage(c, battles));
        }