0

///TEAM PICKING APP to help Dota 2 drafts///

Objects on form:

  1. heroListBox
  2. team1ListBox
  3. team2ListBox
  4. addTeam1Button
  5. addTeam2Button
  6. labels placed below each team's listbox

I have a class called Hero. Each instance of a Hero has bools and a string for its name. The bools track attributes of that Hero's abilities, for example if he has a ranged attack.

On my MainForm, there's a listbox with all of the available heroes. You select a hero then press one of two buttons: the button to send the object to Team 1's listbox or Team 2's listbox. Below each team's listbox are labels that keep count of that teams' abilities, for example how many Heroes in the team's listbox that have a ranged attack. That team's labels update every time you press that team's button.

I think I'm able to move an object from one list to another. But every time you press one of the two buttons that send, I cannot get the count to work:

public class Hero {
    public string Name;
    public bool IsInitiator;
    public bool IsTank;
    public bool IsNuker;
    public bool IsCarry;
    public bool IsPusher;       
    public bool IsRanged;
    public bool IsGreedy;
    public bool IsAOE;
    public bool IsDisabler;
    public bool IsRat;
    public Hero(string tempName){
        Name = tempName;
        IsInitiator = false;
        IsTank = false;
        IsNuker = false;
        IsCarry = false;
        IsPusher = false;       
        IsRanged = false;
        IsGreedy = false;
        IsAOE = false;
        IsDisabler = false;
        IsRat = false;
    }
    public override string ToString()
    {
        return Name;
    }


}


public partial class MainForm : Form
{
    public int rcounter;
    public int dcounter;
    List<Hero> rHeroes = new List<Hero>();
    List<Hero> dHeroes = new List<Hero>();

    public MainForm()
    {
        InitializeComponent();  

//just one example hero

        Hero Abbadon = new Hero("Abbadon");
        Abbadon.IsCarry=true;
        Abbadon.IsGreedy=true;
        Abbadon.IsTank=true;
        heroList.Items.Add(Abbadon);

        }

//add to team1 ... aka Radiant. Update those label texts!

    void addTeam1ButtonClick(object sender, EventArgs e)
    {
        rcounter++;
        rHeroes.Add(heroList.SelectedItem as Hero);
        team1List.Items.Add(heroList.SelectedItem);
        heroList.Items.Remove(heroList.SelectedItem);

        for (int i = 0; i == rcounter; i++)
        {
            int rangedCounts = 0;
            if (rHeroes[i].IsTank == true){
                rangedCounts++;
            }
            radiantRangedLabel.Text = rangedCounts.ToString();
        }
    }

}
4

1 に答える 1