Exemplo n.º 1
0
        public Dictionary<Guid, bool> CreateMatchId(string numOfRounds)
        {
            try
            {
                using (RockPaperScissorsContainer entities = new RockPaperScissorsContainer())
                {
                    tblMatch tblMatch = new tblMatch();
                    tblMatch.MatchId = Guid.NewGuid();
                    tblMatch.MatchType = numOfRounds;
                    entities.tblMatches.Add(tblMatch);
                    entities.SaveChanges();

                    Dictionary<Guid, bool> Outcome = new Dictionary<Guid, bool>();
                    Outcome.Add(tblMatch.MatchId, true);
                    return Outcome;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public void SaveMove(string Choice, Guid MatchId, string Player, int currentRound)
        {
            try
            {
                using (RockPaperScissorsContainer entities = new RockPaperScissorsContainer())
                {
                    int OpponentId = entities.tblPlayerTypes
                        .Where(p => p.PlayerType == Player)
                        .FirstOrDefault()
                        .PlayerTypeId;

                    tblTurn tblTurn = new tblTurn();
                    tblTurn.TurnId = Guid.NewGuid();
                    tblTurn.MatchId = MatchId;
                    tblTurn.Choice = Choice;
                    tblTurn.PlayerTypeId = OpponentId;
                    tblTurn.TurnNumber = currentRound;
                    entities.tblTurns.Add(tblTurn);
                    entities.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }