public static Player getPlayerByChannel(MyIp channel) { Team teamOne = Server.mainTable.Teams[0]; Team teamTwo = Server.mainTable.Teams[1]; for (int i = 0; i < teamOne.Players1.Length; i += 1) { if (teamOne.Players1[i] != null && teamOne.Players1[i].Channel == channel) { return(teamOne.Players1[i]); } } for (int i = 0; i < teamTwo.Players1.Length; i += 1) { if (teamTwo.Players1[i] != null && teamTwo.Players1[i].Channel == channel) { return(teamTwo.Players1[i]); } } for (int i = 0; i < Server.playerQueue.Count; i += 1) { Player waitingPlayer = Server.playerQueue[i]; if (waitingPlayer.Channel == channel) { return(waitingPlayer); } } return(null); }
public bool isThePlayerCanPlay(MyIp player) { if (this.getPlayerMapPostion(player) == this.playerTurn) { return(true); } else { return(false); } }
public static MyIp getIpPortFromString(string str) { var newIp = new MyIp(); var serverIP = str.Split(':').First(); var serverPort = str.Split(':').Last(); newIp.Ip = serverIP; newIp.Port = serverPort; return(newIp); }
public static int getQueueIndex(MyIp channel) { for (int i = 0; i < Server.playerQueue.Count; i += 1) { Player temp = Server.playerQueue[i]; if (temp.Channel == channel) { return(i); } } return(-1); }
public Team getTeamOfPlayer(MyIp channel) { if (Server.mainTable.Teams[0].Players1[0].Channel == channel || Server.mainTable.Teams[0].Players1[1].Channel == channel) { return(Server.mainTable.Teams[0]); } else if (Server.mainTable.Teams[1].Players1[0].Channel == channel || Server.mainTable.Teams[1].Players1[1].Channel == channel) { return(Server.mainTable.Teams[1]); } else { return(null); } }
public int getPlayerMapPostion(MyIp playerChan) { if (Server.mainTable.Teams[0].Players1[0].Channel == playerChan) { return(0); } else if (Server.mainTable.Teams[0].Players1[1].Channel == playerChan) { return(2); } else if (Server.mainTable.Teams[1].Players1[0].Channel == playerChan) { return(1); } else if (Server.mainTable.Teams[1].Players1[1].Channel == playerChan) { return(3); } else { return(-1); } }
public static void writeMessage(MyIp client, string message) { NetworkComms.SendObject("Message", client.Ip, int.Parse(client.Port), message); }