Ejemplo n.º 1
0
        public string DropItems()
        {
            CharacterRepository repo = new CharacterRepository();
            string itemsDropped      = "You Dropped:";
            Random rand = new Random();

            //defeated
            if (this.HP == 0)
            {
                foreach (Item item in this.Items)
                {
                    repo.RemoveCharacterItem(item);
                    repo.Save();
                }

                itemsDropped = "You lost all of your items!";
                Items.Clear();
            }
            else if (Items.Count > 0)
            {
                int numItems = rand.Next(1, Items.Count) / 2;
                for (int n = 0; n < numItems; n++)
                {
                    int itemToDrop = rand.Next(1, Items.Count);
                    itemsDropped += "..." + Items[itemToDrop].Name;
                    repo.RemoveCharacterItem(Items[itemToDrop]);
                    Items.RemoveAt(itemToDrop);
                    repo.Save();
                }
            }
            SaveProgress();
            return(itemsDropped);
        }
Ejemplo n.º 2
0
        private void SaveProgress()
        {
            CharacterRepository repo = new CharacterRepository();

            repo.UpdateCharacter(this);
            repo.Save();
        }
Ejemplo n.º 3
0
 private void btnCreatePlayer_Click(object sender, EventArgs e)
 {
     gamerRepo.AddCharacter(txtNewPlayerName.Text);
     gamerRepo.Save();
     PopulatePlayers();
     cbPlayer.SelectedIndex  = cbPlayer.Items.Count - 1;
     pnlCreatePlayer.Visible = false;
 }
Ejemplo n.º 4
0
        public void PlunderDefeatedEnemy(Enemy enemy)
        {
            CharacterRepository repo = new CharacterRepository();

            GainXP(enemy.XP);

            foreach (Item item in enemy.Items)
            {
                item.CharacterId = this.CharacterId;
                repo.AddCharacterItem(item);
                repo.Save();
            }
            Items.AddRange(enemy.Items);
            SaveProgress();
        }
Ejemplo n.º 5
0
        public MessagePacket UseItemOnEnemy(int itemIndex, Enemy enemy)
        {
            CharacterRepository repo = new CharacterRepository();
            string strMessage        = "";
            int    nAttackStrength;

            if (enemy.Weakness == this.Items[itemIndex].Name)
            {
                strMessage      = "You discovered " + enemy.Name + "'s weakness!!";
                nAttackStrength = enemy.HP;
                enemy.HP        = enemy.HP - nAttackStrength;
            }
            else
            {
                strMessage      = "Using " + this.Items[itemIndex].Name + " had no effect";
                nAttackStrength = 0;
            }

            repo.RemoveCharacterItem(this.Items[itemIndex]);
            this.Items.RemoveAt(itemIndex);
            repo.Save();

            return(new MessagePacket(strMessage, this.AttackImage, nAttackStrength));
        }