Skip to content

Creating several instances and later access them

Tomas Westerlund

Tomas Westerlund

Asked Jun 24, 2013, 1:16 AM EDT1 answer
Share
LinkedInX
Hi,
this is more of a general question and I would hope that you can give me some best-practice or refer me to a good page with this kind of information.

I'm working on a poker client right now and when the server is being started it should create X tables so that the Lobby (for the user) is not empty so when the program starts on the server it creates 6 tables which can be found in the lobby however how should the user access the right table?

All tables have an unique ID but I'm having problem what is a good approach here.

Thanks in advance,
Tomas

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Tomas Westerlund
    0
    I can show you what I have done so far:
    When the program is being Initialized it runs this method:

    Java
                DataTable allTables = sql.RetrieveAllTables();
    
    
                for (int i = 0; i < allTables.Rows.Count; i++)
                {
                    DataRow row = allTables.Rows[i];
                    int tableID = Convert.ToInt32(row["TableID"]);
    
    
                    Classes.Gameplay.Table temp = new Classes.Gameplay.Table(tableID);
    
    
                    tables.Add(tableID, temp);
                }

    It is far from completed but the idea is that I will always have atleast two tables of each poker form (Texas and Omaha for example) and for each stake (10/20 and 25/50 for example) that will be created when the server (the program) is restarted.

    The tables are being loaded into the lobby and when I double click one table this code is being runned and opens up the table:

    Code
                //Return the selected Row:
                DataRow row = ((DataRowView)listViewLobbyMataAses.SelectedItem).Row;
                //Return the value from the first column (TableID)
                int ID = Convert.ToInt32(row[0]);
    
    
                Classes.Gameplay.Table t;
                if (tables.TryGetValue(ID, out t))
                {
                    t.StartMataAsesTable(2);
                }


    Do you think this is a good approach?

    Best regards,
    Tomas
    0