Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            mySquad  = new ClassSquad("TestNewSquad", "KaiLiu", CaptainSpec.Forest, true, CaptainSpec.Water, HeroSpec.Curses);
            NPCSquad = new ClassSquad();

            listBox1.Items.Add("Add a squad " + mySquad.name);
            listBox1.Items.Add("Add a squad " + NPCSquad.name);

            store = new ClassGameStore();
            listBox1.Items.Add("Add a gamestore have " + store.soldierList.Count.ToString() + " soldiers and " + store.stashList.Count.ToString() + " items.");

            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", count of roster: " + mySquad.rosterList.Count.ToString());
            mySquad.BuyRosterMember(store, 5);
            listBox1.Items.Add("Buy a member to roster");

            mySquad.BuyRosterMember(store, 5);
            listBox1.Items.Add("Buy a member to roster");

            mySquad.BuyRosterMember(store, 5);
            listBox1.Items.Add("Buy a member to roster");

            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have roster:  " + mySquad.rosterList.Count.ToString());

            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());
            mySquad.BuyStashItem(store, 5);
            listBox1.Items.Add("Buy an item to stash");
            mySquad.BuyStashItem(store, 5);
            listBox1.Items.Add("Buy an item to stash");
            mySquad.BuyStashItem(store, 5);
            listBox1.Items.Add("Buy an item to stash");
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());

            mySquad.AddItemToCaptain(1);
            listBox1.Items.Add("Add an item to Captain, now the captain have items:" + (mySquad.captain.equipList.Count + mySquad.captain.weaponList.Count).ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());

            mySquad.AddItemToCaptain(0);
            listBox1.Items.Add("Add an item to Captain, now captain have items: " + (mySquad.captain.equipList.Count + mySquad.captain.weaponList.Count).ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());

            mySquad.AddSquadMember(0);
            listBox1.Items.Add("Add an item to squad, now have members:" + mySquad.memberList.Count.ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have roster:  " + mySquad.rosterList.Count.ToString());

            mySquad.AddSquadMember(0);
            listBox1.Items.Add("Add an item to squad, now have members:" + mySquad.memberList.Count.ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have roster:  " + mySquad.rosterList.Count.ToString());
        }
Beispiel #2
0
        public int BuyRosterMember(ClassGameStore store, int idx)
        {
            try
            {
                if (idx >= store.soldierList.Count)
                {
                    throw new Exception("Not valid soldier!");
                }
                if (credit > store.soldierList[idx].stats.cost)
                {
                    rosterList.Add(store.soldierList[idx]);
                    credit = credit - store.soldierList[idx].stats.cost;
                    store.SellSoldier(idx);

                    return(1);
                }
                throw new Exception("No enough credit to buy this soldier!");
            }
            catch (Exception ex)
            {
                lastErr = ex.Message;
                return(0);
            }
        }
Beispiel #3
0
        public int BuyStashItem(ClassGameStore store, int idx)
        {
            try
            {
                if (idx >= store.stashList.Count)
                {
                    throw new Exception("Not valid item!");
                }
                if (credit > store.stashList[idx].price)
                {
                    stashList.Add(store.stashList[idx]);
                    credit = credit - store.stashList[idx].price;
                    store.SellItem(idx);

                    return(1);
                }
                throw new Exception("No enough credit to buy this item!");
            }
            catch (Exception ex)
            {
                lastErr = ex.Message;
                return(0);
            }
        }