Exemple #1
0
        public ScorePage()
        {
            InitializeComponent();

            partyDB                    = new DBPartyController();
            dataAccess                 = new DBScoreController();
            BindingContext             = dataAccess = new DBScoreController();
            ScoresListView.ItemsSource = dataAccess.getAllItems();
        }
Exemple #2
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));
        }