Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SSHOP  shop   = new SSHOP();
            ATTACK aTTACK = new ATTACK();

            sql.Open();
            int           ID           = Convert.ToInt32(dataGridView1.CurrentCell.RowIndex) + 1;
            string        shopcheck    = "select *from shop where shop_id=" + ID;
            SqlCommand    command_shop = new SqlCommand(shopcheck, sql);
            SqlDataReader reader       = command_shop.ExecuteReader();

            while (reader.Read())
            {
                shop_item = reader.GetString(reader.GetOrdinal("itemname"));
            }
            reader.Close();
            if (shop.losemoney(shop_item) == 1)
            {
                aTTACK.bag_add(shop_item);
                MessageBox.Show("购买成功", "恭喜您");
            }
            else

            {
                MessageBox.Show("您的金钱不够哦");
            }

            sql.Close();
        }
Esempio n. 2
0
        public void useitems(string shop_name)//商城物品的使用
        {
            sql.Open();
            string        use      = "select  * from shop where itemname ='" + shop_name + "'";
            SqlCommand    use_item = new SqlCommand(use, sql);
            SqlDataReader read     = use_item.ExecuteReader();

            while (read.Read())
            {
                all = read.GetString(read.GetOrdinal("function"));
            }
            read.Close();
            string[] s1      = all.Split('_');
            string   s11     = s1[0];
            string   s12     = s1[1];
            PERSON   person1 = new PERSON();

            if (s11 == "hp")
            {
                ATTACK bag = new ATTACK();
                bag.hp_reflash(Convert.ToInt32(s12));
                bag.items_delete(shop_name);
            }
            if (s11 == "wuli")
            {
                ATTACK bag = new ATTACK();
                bag.wuli_add(Convert.ToInt32(s12));
                bag.items_delete(shop_name);
            }
        }
Esempio n. 3
0
        private void button2_Click_3(object sender, EventArgs e)
        {
            ATTACK aTTACK = new ATTACK();

            aTTACK.bag_add("小蛐蛐的腿");
        }
Esempio n. 4
0
        public int attack(string monster_name)//战斗
        {
            MONSTER mONSTER = new MONSTER();
            int     person_hp, person_wuli, monster_wuli, monster_hp;

            person_hp = Tiqu_change_hp();
            if (person_hp > 0)//战斗之前先判断血量
            {
                person_wuli  = Tiqu_person_wuli();
                monster_hp   = mONSTER.Tiqu_monster_hp(monster_name);
                monster_wuli = mONSTER.Tiqu_monster_wuli(monster_name);
                while (monster_hp >= 0 && person_hp >= 0)
                {
                    monster_hp -= person_wuli;
                    person_hp  -= monster_wuli;

                    if (monster_hp <= 0)//战斗胜利
                    {
                        sql.Open();
                        string     attack         = "update person set change_hp= " + person_hp;
                        SqlCommand attack_person  = new SqlCommand(attack, sql);
                        string     experience_add = "update person set Empirical= Empirical +" + mONSTER.Tiqu_monster_experience(monster_name);
                        SqlCommand experience     = new SqlCommand(experience_add, sql);
                        try
                        {
                            attack_person.ExecuteNonQuery();
                            experience.ExecuteNonQuery();
                            PERSON pERSON = new PERSON();
                            pERSON.add_money(monster_name);
                            string equpiment = mONSTER.Tiqu_monster_equipment(monster_name);
                            if (equpiment != null)
                            {
                                ATTACK aTTACK = new ATTACK();
                                aTTACK.bag_add(equpiment);
                            }
                        }
                        catch
                        {
                            MessageBox.Show("执行语句失败");
                        }
                        finally
                        {
                            sql.Close();
                        }
                        break;
                    }
                    else if (person_hp <= 0)
                    {
                        sql.Open();
                        string     attack_lose = "update person set change_hp= 0 ";
                        SqlCommand dead        = new SqlCommand(attack_lose, sql);
                        try
                        {
                            dead.ExecuteNonQuery();
                        }
                        catch
                        {
                            MessageBox.Show("死亡失败");
                        }
                        finally
                        {
                            sql.Close();
                        }


                        return(0);
                    }
                }
                return(1);
            }
            else
            {
                return(0);
            }
        }