private void updateProfile(GameClient c, string profile) { if (Program.CUR_PHASE == Program.Phase.FULL) { if (c.isLoggedIn()) { if (DBConnection.updateProfile(c.getUserName(), profile) > 0) { c.sendMessage(Message.PROFILE_UPDATED); } } else { c.sendMessage(Message.LOGIN_FAIL); } } }
private void getProfile(GameClient c, string user) { if (Program.CUR_PHASE == Program.Phase.FULL) { if (c.isLoggedIn()) { string[] profile = DBConnection.getProfile(user); if (profile != null) { c.sendMessage(Message.USER_PROFILE.ToString() + " " + profile[0] + " " + profile[1] + " " + profile[2] + " " + profile[3]); } } else { c.sendMessage(Message.LOGIN_FAIL); } } }
private void createTable(GameClient client) { if (client.isLoggedIn()) { Random r = new Random(); while (true) { int tid = r.Next(1001, 5000); bool exists = false; if (tables.Count == 0) { tables.Add(tid, new GameTable(tid)); alertNewTable(tid); joinTable(client, tid); return; } else { foreach (int i in tables.Keys) { if (i == tid) { exists = true; break; } } if (!exists) { tables.Add(tid, new GameTable(tid)); alertNewTable(tid); joinTable(client, tid); return; } } } } else { client.sendMessage(Message.LOGIN_FAIL); } }
//verify the client can join the table - see if tid has open seat private void joinTable(GameClient c, int tid) { if (c.isLoggedIn()) { if (tables.Count > 0) { foreach (int i in tables.Keys) { if (i == tid) { GameTable t = tables[i]; if (t.joinTable(c)) { putOnTable(c, tid); if (!t.hasOpenSeat()) { t.createGame(); } } else { //we couldnt join the table. It must be full. c.sendMessage(Message.TBL_FULL.ToString()); } return; } } //else we iterated over all the tables, and couldnt find the id. c.sendMessage(Message.TBL_NOT_EXIST.ToString()); } else { c.sendMessage(Message.TBL_NOT_EXIST.ToString()); } } else { c.sendMessage(Message.LOGIN_FAIL); } }
//verify the client can join the table - see if tid has open seat private void joinTable(GameClient c, int tid) { if (c.isLoggedIn()) { if (tables.Count > 0) { foreach (int i in tables.Keys) { if (i == tid) { GameTable t = tables[i]; if (t.joinTable(c)) { putOnTable(c, tid); if (!t.hasOpenSeat()) { t.createGame(); } } else { //we couldnt join the table. It must be full. c.sendMessage(Message.TBL_FULL.ToString()); } return; } } //else we iterated over all the tables, and couldnt find the id. c.sendMessage(Message.TBL_NOT_EXIST.ToString()); } else c.sendMessage(Message.TBL_NOT_EXIST.ToString()); } else c.sendMessage(Message.LOGIN_FAIL); }
private void createTable(GameClient client) { if (client.isLoggedIn()) { Random r = new Random(); while (true) { int tid = r.Next(1001, 5000); bool exists = false; if (tables.Count == 0) { tables.Add(tid, new GameTable(tid)); alertNewTable(tid); joinTable(client, tid); return; } else { foreach (int i in tables.Keys) { if (i == tid) { exists = true; break; } } if (!exists) { tables.Add(tid, new GameTable(tid)); alertNewTable(tid); joinTable(client, tid); return; } } } } else client.sendMessage(Message.LOGIN_FAIL); }