public DraftServer(ServerWindow serverWindow, string filename, int packs, int numLandsInPack, int numNonLandsInPack) { this.serverWindow = serverWindow; var landsThenNonlands = ReadCardPool(File.ReadAllText(filename)); serverWindow.PrintLine("Loaded cube: " + cubeName + "."); this.packs = packs; this.numLandsInPack = numLandsInPack; this.numNonLandsInPack = numNonLandsInPack; server = new TcpServer { Port = Util.PORT }; server.OnConnect += OnConnect; server.OnDisconnect += OnDisconnect; server.OnDataAvailable += OnDataAvailable; server.Open(); serverWindow.PrintLine("Fetching card information, this might take a while..."); cards = ReadCardInfo(landsThenNonlands); }
public DraftServer(ServerWindow serverWindow, string setFilename, int packs, int numCommonsInPack, int numUncommonsInPack, int numRaresInPack, float mythicPercentage) { this.serverWindow = serverWindow; ParseText(File.ReadAllText(setFilename)); serverWindow.PrintLine("Loaded set: " + setName + "."); this.packs = packs; this.numCommonsInPack = numCommonsInPack; this.numUncommonsInPack = numUncommonsInPack; this.numRaresInPack = numRaresInPack; this.mythicPercentage = mythicPercentage; server = new TcpServer(); server.Port = 10024; server.OnConnect += OnConnect; server.OnDisconnect += OnDisconnect; server.OnDataAvailable += OnDataAvailable; server.Open(); }
public void PrintServerStartMessage() { // Get public IP address of server. serverWindow.PrintLine("Looking up public IP..."); var ip = GetPublicIp(); serverWindow.PrintLine("Launched server at " + ip + " on port " + server.Port + ". Accepting connections."); }
public bool IsValidSet() { if (commons.Count < numCommonsInPack) { serverWindow.PrintLine("ERROR: Set file must contain at least as many commons as there are per pack. (Contains " + commons.Count + ", needs " + numCommonsInPack + ".)"); return(false); } if (uncommons.Count < numUncommonsInPack) { serverWindow.PrintLine("ERROR: Set file must contain at least as many uncommons as there are per pack. (Contains " + uncommons.Count + ", needs " + numUncommonsInPack + ".)"); return(false); } if (rares.Count < numRaresInPack) { serverWindow.PrintLine("ERROR: Set file must contain at least as many rares as there are per pack. (Contains " + rares.Count + ", needs " + numRaresInPack + ".)"); return(false); } if (mythicRares.Count == 0 && mythicPercentage > 0) { serverWindow.PrintLine("ERROR: Set file contains no mythic rares."); return(false); } return(true); }