Exemple #1
0
        public async Task <bool> DodoBorn(string deviceID, Dodo dodo)
        {
            var filter = Builders <Player> .Filter.Eq(p => p.DeviceID, deviceID);

            Player player = _playerCollection.Find(filter).FirstAsync().Result;

            player.Dodos.Add(dodo);
            Player checkedPlayer = achievementManager.CheckSpecial(player, dodo);

            if (!player.Equals(checkedPlayer))
            {
                ServerUpdatePlayerDodoList(player, checkedPlayer);
                return(await Task.FromResult <bool>(false));
            }
            else
            {
                ServerUpdatePlayerDodoList(player, checkedPlayer);
                return(await Task.FromResult <bool>(true));



                //  .Set(x => x.Name, player.Name)
            }
            //return Task.FromResult<bool>(player.Dodos.Count != 0);
            //return Task.FromResult<bool>(achievementManager.CheckSpecial(player, dodo, this));
        }
Exemple #2
0
        public async Task <Dodo[]> GetFamilyTree(string deviceID, Dodo dodo)
        {
            var filter = Builders <Player> .Filter.Eq(p => p.DeviceID, deviceID);

            Player      player    = _playerCollection.Find(filter).FirstAsync().Result;
            List <Dodo> famTree   = new List <Dodo>();
            List <Dodo> tempList  = new List <Dodo>();
            List <Dodo> tempList2 = new List <Dodo>();

            famTree.Add(dodo.Father);
            famTree.Add(dodo.Mother);
            tempList2 = famTree;
            int counter = 0;

            while (counter < 5)
            {
                foreach (Dodo d in tempList2)
                {
                    if (d.Father == null || d.Mother == null)
                    {
                        counter = 5;
                        break;
                    }
                    tempList.Add(d.Father);
                    tempList.Add(d.Mother);
                }
                tempList2 = tempList;
                famTree.AddRange(tempList);
                tempList.Clear();
                counter++;
            }
            return(await Task.FromResult <Dodo[]>(famTree.ToArray()));
        }
 public Task <Dodo[]> GetFamilyTree(string deviceID, Dodo dodo)
 {
     throw new NotImplementedException();
 }
 public Task <bool> DodoBorn(string deviceID, Dodo dodo)
 {
     throw new NotImplementedException();
 }
Exemple #5
0
        // TODO
        //MongonRepo needs a function to unlock achievement
        public Player CheckSpecial(Player player, Dodo dodo)
        {
            Player newPlayer = new Player()
            {
                DeviceID             = player.DeviceID,
                CreationTime         = player.CreationTime,
                IsBanned             = player.IsBanned,
                Name                 = player.Name,
                Gender               = player.Gender,
                SkinType             = player.SkinType,
                HairColor            = player.HairColor,
                ShirtColor           = player.ShirtColor,
                TrousersColor        = player.TrousersColor,
                Achievements         = player.Achievements,
                Dodos                = player.Dodos,
                UncommonCount        = player.UncommonCount,
                RareCount            = player.RareCount,
                LegendaryCount       = player.LegendaryCount,
                PassedLevels         = player.PassedLevels,
                SpecialDodosUnlocked = player.SpecialDodosUnlocked
            };

            foreach (ServerDodos d in _specialDodos)
            {
                if (d.Colors.SequenceEqual(dodo.Colors))
                {
                    if (newPlayer.SpecialDodosUnlocked.Contains(d.SpecialID))
                    {
                        break;
                    }
                    else
                    {
                        newPlayer.SpecialDodosUnlocked.Add(d.SpecialID);
                        if (d.SpecialType == 0)
                        {
                            newPlayer.UncommonCount++;
                            if (newPlayer.UncommonCount == 1)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.FirstUncommon,
                                    Name = "First uncommon"
                                });
                                break;
                            }
                            else if (newPlayer.UncommonCount > _uncommonCount / 2f)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.HalfUncommon,
                                    Name = "Half uncommon"
                                });
                                break;
                            }
                            else if (newPlayer.UncommonCount == _uncommonCount)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.AllUncommon,
                                    Name = "All uncommon"
                                });
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else if (d.SpecialType == 1)
                        {
                            newPlayer.RareCount++;
                            if (newPlayer.RareCount == 1)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.FirstRare,
                                    Name = "First rare"
                                });
                                break;
                            }
                            else if (newPlayer.RareCount > _rareCount / 2f)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.HalfRare,
                                    Name = "Half rare"
                                });
                                break;
                            }
                            else if (newPlayer.RareCount == _rareCount)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.AllRare,
                                    Name = "All rare"
                                });
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else if (d.SpecialType == 2)
                        {
                            newPlayer.LegendaryCount++;
                            if (newPlayer.LegendaryCount == 1)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.FirstLegendary,
                                    Name = "First legendary"
                                });
                                break;
                            }
                            else if (newPlayer.LegendaryCount > _legendaryCount / 2f)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.HalfLegendary,
                                    Name = "Half legendary"
                                });
                                break;
                            }
                            else if (newPlayer.LegendaryCount == _legendaryCount)
                            {
                                newPlayer.Achievements.Add(new Achievement()
                                {
                                    Id   = 100 + (int)Achievements.AllLegendary,
                                    Name = "All legendary"
                                });
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return(newPlayer);
        }