//adds a world number to a skill set private void AddWorldToSkill(string skill, GeobieWorld world) { switch (skill) { case "agil": if (!CheckIfWorldIsUsed(world)) { skill1.Add(world); } break; case "farm": if (!CheckIfWorldIsUsed(world)) { skill2.Add(world); } break; case "hunt": if (!CheckIfWorldIsUsed(world)) { skill3.Add(world); } break; } }
//adds a world the the list with the user who entered it public string AddWorld(string username, int world, string skill) { if (world > 0 && world <= 140) { //set up user to compare to the list GeobieUser u = new GeobieUser(username); GeobieWorld w = new GeobieWorld(world, username); if (!CheckIfWorldIsUsed(w)) { if (!w.IsFreeWorld) { string output = ""; //output switch (skill.ToLower()) { case "a": AddScoutToUSer(u); AddWorldToSkill("agil", w); output = u.Username + " added as a scout."; break; case "f": AddScoutToUSer(u); AddWorldToSkill("farm", w); output = u.Username + " added as a scout."; break; case "w": AddScoutToUSer(u); AddWorldToSkill("hunt", w); output = u.Username + " added as a scout."; break; default: output = "Incorrect skills."; break; } LastUpdated = DateTime.Now; return(output); } else { return("That world is not availble."); } } else { return("World is already registered."); } } else { return("Invalid world."); } }
//removes a world from the list public string RemoveWorld(int world) { GeobieWorld w = new GeobieWorld(world); string output = "World " + world + " removed."; if (skill1.Contains(w)) { for (int i = 0; i < skill1.Count; ++i) { if (w.Equals(skill1[i])) { GeobieUser u = new GeobieUser(skill1[i].ScoutName); if (users.Contains(u)) { RemoveScoutFromUser(u.Username); } } } skill1.Remove(w); } else if (skill2.Contains(w)) { for (int i = 0; i < skill2.Count; ++i) { if (w.Equals(skill2[i])) { GeobieUser u = new GeobieUser(skill2[i].ScoutName); if (users.Contains(u)) { RemoveScoutFromUser(u.Username); } } } skill2.Remove(w); } else if (skill3.Contains(w)) { for (int i = 0; i < skill3.Count; ++i) { if (w.Equals(skill3[i])) { GeobieUser u = new GeobieUser(skill3[i].ScoutName); if (users.Contains(u)) { RemoveScoutFromUser(u.Username); } } } skill3.Remove(w); } else { output = "World not found."; } return(output); }
//marks world as dead public string MarkAsDead(int worldNum) { GeobieWorld w = new GeobieWorld(worldNum); string output = "World not found."; if (skill1.Contains(w)) { for (int i = 0; i < skill1.Count; ++i) { if (skill1[i].WorldNum == worldNum) { skill1[i].IsDead = true; output = worldNum.ToString() + " has been marked as dead."; } } } else if (skill2.Contains(w)) { for (int i = 0; i < skill2.Count; ++i) { if (skill2[i].WorldNum == worldNum) { skill2[i].IsDead = true; output = worldNum.ToString() + " has been marked as dead."; } } } else if (skill3.Contains(w)) { for (int i = 0; i < skill3.Count; ++i) { if (skill3[i].WorldNum == worldNum) { skill3[i].IsDead = true; output = worldNum.ToString() + " has been marked as dead."; } } } return(output); }
//returns false if world is not used, true if used private bool CheckIfWorldIsUsed(GeobieWorld w) { bool found = false; for (int i = 0; i < skill1.Count; ++i) { if (skill1[i].Equals(w)) { found = true; break; } } if (!found) { for (int i = 0; i < skill2.Count; ++i) { if (skill2[i].Equals(w)) { found = true; break; } } } if (!found) { for (int i = 0; i < skill3.Count; ++i) { if (skill3[i].Equals(w)) { found = true; break; } } } return(found); }