예제 #1
0
        public void Sellitem(int itemid)
        {
            PlayerRepo repo   = new PlayerRepo(new PlayerQuery());
            GameRepo   g_repo = new GameRepo(new GameQuery());


            if (repo.PlayerEquipment(CurrentPlayer.Id).Contains(itemid))
            {
                if (g_repo.ItemAmount(CurrentPlayer.Id, itemid) > 1)
                {
                    g_repo.Sellitem(1, CurrentPlayer.Id, itemid);
                    SetPlayer(CurrentPlayer.Id);
                    Gold      = true;
                    Isequiped = false;
                }
                else
                {
                    Isequiped = true;
                }
            }
            else
            {
                g_repo.Sellitem(1, CurrentPlayer.Id, itemid);
                SetPlayer(CurrentPlayer.Id);
                Gold      = true;
                Isequiped = false;
            }
        }
예제 #2
0
        public void Endturn()
        {
            if (CurrentPlayer.Health <= 0)
            {
                GameText.AddText("You Died");
                Dead = true;
            }
            else
            {
                PlayerRepo repo   = new PlayerRepo(new PlayerQuery());
                GameRepo   g_repo = new GameRepo(new GameQuery());
                CurrentPlayer.Mana   += CurrentPlayer.ManaRegen;
                CurrentPlayer.Health += CurrentPlayer.HealthRegen;
                repo.UpdatePlayer(CurrentPlayer);
                CurrentPlayer              = repo.GetPlayer(CurrentPlayer.Id);
                CurrentPlayer.UsedMagic    = repo.EquipedMagic(CurrentPlayer.Id);
                CurrentPlayer.CurrentMagic = repo.PlayerMagic(CurrentPlayer.Id);
                if (CurrentEnemy != null)
                {
                    if (CurrentEnemy.Health <= 0)
                    {
                        GameText.AddText(CurrentPlayer.Name + " Defeated " + CurrentEnemy.Name + " And gained " +
                                         CurrentEnemy.ExperienceDrop + " experience");

                        List <int> items = new List <int>();
                        Item       item  = g_repo.GetItem(CurrentPlayer.Level);

                        GameText.AddText(CurrentEnemy.Name + " Dropped a " + item.Name);

                        items.Add(item.Id);
                        items.Add(200);
                        g_repo.SetItem(items, CurrentPlayer.Id);

                        int enemyspawn = g_repo.EnemyDefeated(CurrentEnemy.Id, CurrentPlayer.Id);
                        if (enemyspawn != 0 && new Random().Next(1, 100) > 80)
                        {
                            CurrentEnemy = g_repo.EnemybyId(enemyspawn);
                            GameText.AddText("A " + CurrentEnemy.Name + "Jumps at you!");
                        }
                        else
                        {
                            CurrentEnemy = null;
                        }
                    }
                }
            }
        }
예제 #3
0
        public void Nextroom()
        {
            Trader = false;
            GameRepo repo = new GameRepo(new GameQuery());

            if (CurrentEnemy == null)
            {
                CurrentRoom = null;
                int roomlevel = new Random().Next(1, CurrentPlayer.Level);
                CurrentRoom = repo.Nextroom(roomlevel);

                if (CurrentRoom.Id == 0)
                {
                    while (CurrentRoom.Id == 0)
                    {
                        roomlevel--;
                        CurrentRoom = repo.Nextroom(roomlevel);
                    }
                }
                GameText.AddText(CurrentPlayer.Name + " entered a " + CurrentRoom.Name);
                if (CurrentRoom.Random <= CurrentRoom.EnemyChance && CurrentRoom.Random >= CurrentRoom.TraderChance &&
                    CurrentRoom.Random >= CurrentRoom.EventChance)
                {
                    CurrentEnemy = repo.Enemy(roomlevel);
                    GameText.AddText("a " + CurrentEnemy.Name + " appeared in the " + CurrentRoom.Name);
                }
                if (CurrentRoom.Random >= CurrentRoom.EnemyChance && CurrentRoom.Random <= CurrentRoom.TraderChance &&
                    CurrentRoom.Random >= CurrentRoom.EventChance)
                {
                    GameText.AddText("You meet a trader while traveling");
                    Trader = true;
                }
            }
            else
            {
                GameText.AddText("You cannot leave while a enemy is still alive");
            }
        }